42 MsgStream log(
msgSvc(), name() );
43 log << MSG::INFO <<
"DedxCalibWireGain::FillHists()" << endmsg;
48 float runNO = 0, evtNO = 0, runFlag = 0, pathlength = 0, wid = 0, layid = 0, dd_in = 0,
49 driftdist = 0, eangle = 0, zhit = 0, costheta = 0, tes = 0, ptrk = 0;
54 cout <<
"runlist: " << runlist.c_str() << endl;
57 f =
new TFile( runlist.c_str() );
58 n102 = (TTree*)
f->Get(
"n102" );
59 n102->SetBranchAddress(
"adc_raw", &dedx );
60 n102->SetBranchAddress(
"path_rphi", &pathlength );
61 n102->SetBranchAddress(
"wire", &wid );
62 n102->SetBranchAddress(
"layer", &layid );
63 n102->SetBranchAddress(
"doca_in", &dd_in );
64 n102->SetBranchAddress(
"driftdist", &driftdist );
65 n102->SetBranchAddress(
"eangle", &eangle );
66 n102->SetBranchAddress(
"zhit", &zhit );
67 n102->SetBranchAddress(
"runNO", &runNO );
68 n102->SetBranchAddress(
"evtNO", &evtNO );
69 n102->SetBranchAddress(
"runFlag", &runFlag );
70 n102->SetBranchAddress(
"costheta1", &costheta );
71 n102->SetBranchAddress(
"t01", &tes );
72 n102->SetBranchAddress(
"ptrk1", &ptrk );
74 cout <<
"entries in this file " << n102->GetEntries() << endl;
76 for (
int j = 0; j < n102->GetEntries(); j++ )
79 if ( tes > 1400 )
continue;
80 if ( ptrk > pMax || ptrk < pMin )
continue;
93 dedx =
exsvc->StandardHitCorrec( 0, runFlag, 2, runNO, evtNO, pathlength, wid, layid,
94 dedx, dd_in, eangle, costheta );
95 dedx =
exsvc->StandardTrackCorrec( 0, runFlag, 2, runNO, evtNO, dedx, costheta, tes );
96 m_wiregain[(int)wid]->Fill( dedx );
103 MsgStream log(
msgSvc(), name() );
104 log << MSG::INFO <<
"DedxCalibWireGain::AnalyseHists()" << endmsg;
106 TF1* func =
new TF1();
107 Double_t entry = 0, mean = 0, rms = 0;
109 Double_t lp[3] = { 0 };
110 gStyle->SetOptFit( 1111 );
111 for (
int wire = 0; wire <
wireNo; wire++ )
113 entry = m_wiregain[wire]->Integral();
114 if ( entry < 10 )
continue;
115 mean = m_wiregain[wire]->GetMean();
116 rms = m_wiregain[wire]->GetRMS();
117 binmax = m_wiregain[wire]->GetMaximumBin();
118 lp[1] = m_wiregain[wire]->GetBinCenter( binmax );
120 lp[0] = ( m_wiregain[wire]->GetBinContent( binmax ) +
121 m_wiregain[wire]->GetBinContent( binmax - 1 ) +
122 m_wiregain[wire]->GetBinContent( binmax + 1 ) ) /
127 func =
new TF1(
"mylan",
mylan, 10, 3000, 4 );
128 func->SetParameters( entry, mean, rms, -0.8 );
129 func->SetParLimits( 0, 0, entry );
130 func->SetParLimits( 1, 0, mean );
131 func->SetParLimits( 2, 10, rms );
132 func->SetParLimits( 3, -3, 3 );
136 func =
new TF1(
"landaun",
landaun, 10, 3000, 3 );
137 func->SetParameters( lp[0], lp[1], lp[2] );
141 func =
new TF1(
"Landau",
Landau, 10, 3000, 2 );
142 func->SetParameters( 0.7 * mean, rms );
146 func =
new TF1(
"Vavilov",
Vavilov, 10, 3000, 2 );
147 func->SetParameters( 0.05, 0.6 );
151 func =
new TF1(
"AsymGauss",
AsymGauss, 10, 3000, 4 );
152 func->SetParameters( entry, mean, rms, 1.0 );
154 func->SetLineWidth( 2.1 );
155 func->SetLineColor( 2 );
157 m_wiregain[wire]->Fit( func,
"rq",
"", mean - rms, mean + rms / 2 );
162 MsgStream log(
msgSvc(), name() );
163 log << MSG::INFO <<
"DedxCalibWireGain::WriteHists()" << endmsg;
169 for (
int i = 0; i <
wireNo; i++ )
171 entryNo[i] = m_wiregain[i]->Integral();
172 mean[i] = m_wiregain[i]->GetMean();
173 sigma[i] = m_wiregain[i]->GetRMS();
174 proper[i] = m_wiregain[i]->GetBinCenter( m_wiregain[i]->GetMaximumBin() );
175 if ( entryNo[i] < 10 )
continue;
179 fitmean[i] = m_wiregain[i]->GetFunction(
"mylan" )->GetParameter( 1 );
180 fitmeanerr[i] = m_wiregain[i]->GetFunction(
"mylan" )->GetParError( 1 );
181 fitsigma[i] = m_wiregain[i]->GetFunction(
"mylan" )->GetParameter( 2 );
182 chisq[i] = ( m_wiregain[i]->GetFunction(
"mylan" )->GetChisquare() ) /
183 ( m_wiregain[i]->GetFunction(
"mylan" )->GetNDF() );
187 fitmean[i] = m_wiregain[i]->GetFunction(
"landaun" )->GetParameter( 1 );
188 fitmeanerr[i] = m_wiregain[i]->GetFunction(
"landaun" )->GetParError( 1 );
189 fitsigma[i] = m_wiregain[i]->GetFunction(
"landaun" )->GetParameter( 2 );
190 chisq[i] = ( m_wiregain[i]->GetFunction(
"landaun" )->GetChisquare() ) /
191 ( m_wiregain[i]->GetFunction(
"landaun" )->GetNDF() );
195 fitmean[i] = m_wiregain[i]->GetFunction(
"Landau" )->GetParameter( 1 );
196 fitmeanerr[i] = m_wiregain[i]->GetFunction(
"Landau" )->GetParError( 1 );
197 fitsigma[i] = m_wiregain[i]->GetFunction(
"Landau" )->GetParameter( 2 );
198 chisq[i] = ( m_wiregain[i]->GetFunction(
"Landau" )->GetChisquare() ) /
199 ( m_wiregain[i]->GetFunction(
"Landau" )->GetNDF() );
203 fitmean[i] = m_wiregain[i]->GetFunction(
"Vavilov" )->GetParameter( 1 );
204 fitmeanerr[i] = m_wiregain[i]->GetFunction(
"Vavilov" )->GetParError( 1 );
205 fitsigma[i] = m_wiregain[i]->GetFunction(
"Vavilov" )->GetParameter( 2 );
206 chisq[i] = ( m_wiregain[i]->GetFunction(
"Vavilov" )->GetChisquare() ) /
207 ( m_wiregain[i]->GetFunction(
"Vavilov" )->GetNDF() );
211 fitmean[i] = m_wiregain[i]->GetFunction(
"AsymGauss" )->GetParameter( 1 );
212 fitmeanerr[i] = m_wiregain[i]->GetFunction(
"AsymGauss" )->GetParError( 1 );
213 fitsigma[i] = m_wiregain[i]->GetFunction(
"AsymGauss" )->GetParameter( 2 );
214 chisq[i] = ( m_wiregain[i]->GetFunction(
"AsymGauss" )->GetChisquare() ) /
215 ( m_wiregain[i]->GetFunction(
"AsymGauss" )->GetNDF() );
221 double Norm = 0,
count = 0;
222 for (
int i = 188; i <
wireNo; i++ )
224 if ( fitmean[i] > 0 && fitmeanerr[i] > 0 && fitmeanerr[i] < 10 && fitsigma[i] > 0 &&
225 fitsigma[i] < 200 && entryNo[i] > 1500 )
232 cout <<
"count= " <<
count <<
" average value of good wire: " << Norm << endl;
236 for (
int i = 0; i <
wireNo; i++ )
238 wireg[i] = fitmean[i] / Norm;
242 log << MSG::INFO <<
"begin generating root file!!! " << endmsg;
243 TFile*
f =
new TFile(
m_rootfile.c_str(),
"recreate" );
244 for (
int i = 0; i <
wireNo; i++ ) m_wiregain[i]->Write();
246 TTree* wiregcalib =
new TTree(
"wiregcalib",
"wiregcalib" );
247 wiregcalib->Branch(
"wireg", wireg,
"wireg[6796]/D" );
248 wiregcalib->Branch(
"wire", wire,
"wire[6796]/D" );
249 wiregcalib->Branch(
"entryNo", entryNo,
"entryNo[6796]/D" );
250 wiregcalib->Branch(
"proper", proper,
"proper[6796]/D" );
251 wiregcalib->Branch(
"mean", mean,
"mean[6796]/D" );
252 wiregcalib->Branch(
"sigma", sigma,
"sigma[6796]/D" );
253 wiregcalib->Branch(
"fitmean", fitmean,
"fitmean[6796]/D" );
254 wiregcalib->Branch(
"fitmeanerr", fitmeanerr,
"fitmeanerr[6796]/D" );
255 wiregcalib->Branch(
"fitsigma", fitsigma,
"fitsigma[6796]/D" );
256 wiregcalib->Branch(
"chisq", chisq,
"chisq[6796]/D" );
262 TCanvas c1(
"c1",
"canvas", 500, 400 );
264 for (
int i = 0; i <
wireNo; i++ )
266 m_wiregain[i]->Draw();
271 for (
int i = 0; i <
wireNo; i++ )
delete m_wiregain[i];