32 MsgStream log(
msgSvc(), name() );
33 log << MSG::INFO <<
"DedxCalibCostheta::BookHists()" << endmsg;
47 hlabel <<
"dEdx_costheta" << i;
48 m_costheta[i] =
new TH1F( hlabel.str().c_str(), hlabel.str().c_str(),
NumHistBins,
51 hlabel <<
"pos_dEdx_costheta" << i;
52 m_pos_costheta[i] =
new TH1F( hlabel.str().c_str(), hlabel.str().c_str(),
NumHistBins,
55 hlabel <<
"neg_dEdx_costheta" << i;
56 m_neg_costheta[i] =
new TH1F( hlabel.str().c_str(), hlabel.str().c_str(),
NumHistBins,
59 hlabel <<
"chi_costheta" << i;
63 hlabel <<
"pos_chi_costheta" << i;
64 m_pos_chi[i] =
new TH1F( hlabel.str().c_str(), hlabel.str().c_str(),
NumHistBins,
67 hlabel <<
"neg_chi_costheta" << i;
68 m_neg_chi[i] =
new TH1F( hlabel.str().c_str(), hlabel.str().c_str(),
NumHistBins,
72 hlabel <<
"dEdxVsCostheta";
73 m_dEdxVsCostheta =
new TH1F( hlabel.str().c_str(),
"dEdx vs costheta",
NumBinCostheta,
75 m_dEdxVsCostheta->GetXaxis()->SetTitle(
"cos#theta" );
76 m_dEdxVsCostheta->GetYaxis()->SetTitle(
"dE/dx" );
78 hlabel <<
"pos_dEdxVsCostheta";
79 m_pos_dEdxVsCostheta =
new TH1F( hlabel.str().c_str(),
"positron dEdx vs costheta",
81 m_pos_dEdxVsCostheta->GetXaxis()->SetTitle(
"cos#theta" );
82 m_pos_dEdxVsCostheta->GetYaxis()->SetTitle(
"dE/dx" );
84 hlabel <<
"neg_dEdxVsCostheta";
85 m_neg_dEdxVsCostheta =
new TH1F( hlabel.str().c_str(),
"electron dEdx vs costheta",
87 m_neg_dEdxVsCostheta->GetXaxis()->SetTitle(
"cos#theta" );
88 m_neg_dEdxVsCostheta->GetYaxis()->SetTitle(
"dE/dx" );
95 MsgStream log(
msgSvc(), name() );
96 log << MSG::INFO <<
"DedxCalibCostheta::FillHists()" << endmsg;
103 double dEdx[100] = { 0 }, pathlength[100] = { 0 }, wid[100] = { 0 }, layid[100] = { 0 },
104 dd_in[100] = { 0 }, eangle[100] = { 0 }, zhit[100] = { 0 };
106 float runNO = 0, evtNO = 0, runFlag = 0, costheta = 0, tes = 0, charge = 0, recalg = 0,
107 ptrk = 0, chidedx = 0;
109 vector<double> phlist;
113 int m_current_trks( 0 );
115 f =
new TFile( runlist.c_str() );
116 n103 = (TTree*)
f->Get(
"n103" );
117 n103->SetBranchAddress(
"ndedxhit", &ndedxhit );
118 n103->SetBranchAddress(
"dEdx_hit", dEdx );
119 n103->SetBranchAddress(
"pathlength_hit", pathlength );
120 n103->SetBranchAddress(
"wid_hit", wid );
121 n103->SetBranchAddress(
"layid_hit", layid );
122 n103->SetBranchAddress(
"dd_in_hit", dd_in );
123 n103->SetBranchAddress(
"eangle_hit", eangle );
124 n103->SetBranchAddress(
"zhit_hit", zhit );
125 n103->SetBranchAddress(
"runNO", &runNO );
126 n103->SetBranchAddress(
"evtNO", &evtNO );
127 n103->SetBranchAddress(
"runFlag", &runFlag );
128 n103->SetBranchAddress(
"costheta", &costheta );
129 n103->SetBranchAddress(
"t0", &tes );
130 n103->SetBranchAddress(
"charge", &charge );
131 n103->SetBranchAddress(
"recalg", &recalg );
132 n103->SetBranchAddress(
"ndedxhit", &ndedxhit );
133 n103->SetBranchAddress(
"ptrk", &ptrk );
134 n103->SetBranchAddress(
"chidedx_e", &chidedx );
135 for (
int j = 0; j < n103->GetEntries(); j++ )
138 if ( m_current_trks >
Size )
break;
142 if ( tes > 1400 )
continue;
143 if ( ptrk > pMax || ptrk < pMin )
continue;
144 for (
int k = 0; k < ndedxhit; k++ )
146 dEdx[k] =
exsvc->StandardHitCorrec( 0, runFlag, 2, runNO, evtNO, pathlength[k], wid[k],
147 layid[k], dEdx[k], dd_in[k], eangle[k], costheta );
148 phlist.push_back( dEdx[k] );
152 double pre_dedx = dedx;
153 if ( m_debug && iCos >= m_debug_min && iCos <= m_debug_max )
154 cout <<
"before cor, dedx " << pre_dedx <<
" with cos(theta) " << costheta << endl;
155 dedx =
exsvc->StandardTrackCorrec( 0, runFlag, 2, runNO, evtNO, dedx, costheta, tes );
156 if ( m_debug && iCos >= m_debug_min && iCos <= m_debug_max )
157 cout <<
"after cor, dedx " << dedx <<
" with gain " << pre_dedx / dedx << endl;
158 m_costheta[iCos]->Fill( dedx );
159 if ( charge > 0 ) m_pos_costheta[iCos]->Fill( dedx );
160 if ( charge < 0 ) m_neg_costheta[iCos]->Fill( dedx );
163 set_dEdx( 1, dedx, recalg, runFlag, usedhit, ptrk, acos( costheta ), 1.5,
vFlag, tes );
165 m_chi[iCos]->Fill( chi );
166 if ( charge > 0 ) m_pos_chi[iCos]->Fill( chi );
167 if ( charge < 0 ) m_neg_chi[iCos]->Fill( chi );
169 Vec_dedx.push_back( dedx );
170 Vec_costheta.push_back( costheta );
193 MsgStream log(
msgSvc(), name() );
194 log << MSG::INFO <<
"DedxCalibCostheta::WriteHists()" << endmsg;
220 chientryNo[i] = m_chi[i]->GetEntries();
222 cout <<
"get results at " << i <<
" bin with chi entries " << chientryNo[i] << endl;
223 if ( m_chi[i]->GetFunction(
"gaus" ) )
225 chimean[i] = m_chi[i]->GetFunction(
"gaus" )->GetParameter( 1 );
226 chimeanerr[i] = m_chi[i]->GetFunction(
"gaus" )->GetParError( 1 );
227 chisigma[i] = m_chi[i]->GetFunction(
"gaus" )->GetParameter( 2 );
228 chisq[i] = ( m_chi[i]->GetFunction(
"gaus" )->GetChisquare() ) /
229 ( m_chi[i]->GetFunction(
"gaus" )->GetNDF() );
231 pos_chientryNo[i] = m_pos_chi[i]->GetEntries();
233 cout <<
"get results at " << i <<
" bin with pos_chi entries " << pos_chientryNo[i]
235 if ( m_pos_chi[i]->GetFunction(
"gaus" ) )
237 pos_chimean[i] = m_pos_chi[i]->GetFunction(
"gaus" )->GetParameter( 1 );
238 pos_chimeanerr[i] = m_pos_chi[i]->GetFunction(
"gaus" )->GetParError( 1 );
239 pos_chisigma[i] = m_pos_chi[i]->GetFunction(
"gaus" )->GetParameter( 2 );
240 pos_chisq[i] = ( m_pos_chi[i]->GetFunction(
"gaus" )->GetChisquare() ) /
241 ( m_pos_chi[i]->GetFunction(
"gaus" )->GetNDF() );
243 neg_chientryNo[i] = m_neg_chi[i]->GetEntries();
245 cout <<
"get results at " << i <<
" bin with neg_chi entries " << neg_chientryNo[i]
247 if ( m_neg_chi[i]->GetFunction(
"gaus" ) )
249 neg_chimean[i] = m_neg_chi[i]->GetFunction(
"gaus" )->GetParameter( 1 );
250 neg_chimeanerr[i] = m_neg_chi[i]->GetFunction(
"gaus" )->GetParError( 1 );
251 neg_chisigma[i] = m_neg_chi[i]->GetFunction(
"gaus" )->GetParameter( 2 );
252 neg_chisq[i] = ( m_neg_chi[i]->GetFunction(
"gaus" )->GetChisquare() ) /
253 ( m_neg_chi[i]->GetFunction(
"gaus" )->GetNDF() );
256 fitentryNo[i] = m_costheta[i]->GetEntries();
258 cout <<
"get results at " << i <<
" bin with fit entries " << fitentryNo[i] << endl;
259 if ( m_costheta[i]->GetFunction(
"gaus" ) )
261 fitmean[i] = m_costheta[i]->GetFunction(
"gaus" )->GetParameter( 1 );
262 fitmeanerr[i] = m_costheta[i]->GetFunction(
"gaus" )->GetParError( 1 );
263 fitsigma[i] = m_costheta[i]->GetFunction(
"gaus" )->GetParameter( 2 );
265 fitchisq[i] = ( m_costheta[i]->GetFunction(
"gaus" )->GetChisquare() ) /
266 ( m_costheta[i]->GetFunction(
"gaus" )->GetNDF() );
268 pos_fitentryNo[i] = m_pos_costheta[i]->GetEntries();
270 cout <<
"get results at " << i <<
" bin with pos_fit entries " << pos_fitentryNo[i]
272 if ( m_pos_costheta[i]->GetFunction(
"gaus" ) )
274 pos_fitmean[i] = m_pos_costheta[i]->GetFunction(
"gaus" )->GetParameter( 1 );
275 pos_fitmeanerr[i] = m_pos_costheta[i]->GetFunction(
"gaus" )->GetParError( 1 );
276 pos_fitsigma[i] = m_pos_costheta[i]->GetFunction(
"gaus" )->GetParameter( 2 );
278 pos_fitchisq[i] = ( m_pos_costheta[i]->GetFunction(
"gaus" )->GetChisquare() ) /
279 ( m_pos_costheta[i]->GetFunction(
"gaus" )->GetNDF() );
281 neg_fitentryNo[i] = m_neg_costheta[i]->GetEntries();
283 cout <<
"get results at " << i <<
" bin with neg_fit entries " << neg_fitentryNo[i]
285 if ( m_neg_costheta[i]->GetFunction(
"gaus" ) )
287 neg_fitmean[i] = m_neg_costheta[i]->GetFunction(
"gaus" )->GetParameter( 1 );
288 neg_fitmeanerr[i] = m_neg_costheta[i]->GetFunction(
"gaus" )->GetParError( 1 );
289 neg_fitsigma[i] = m_neg_costheta[i]->GetFunction(
"gaus" )->GetParameter( 2 );
291 neg_fitchisq[i] = ( m_neg_costheta[i]->GetFunction(
"gaus" )->GetChisquare() ) /
292 ( m_neg_costheta[i]->GetFunction(
"gaus" )->GetNDF() );
297 fitmean[i] = ( pos_fitmean[i] + neg_fitmean[i] ) / 2;
298 fitmeanerr[i] = sqrt( pow( pos_fitmeanerr[i], 2 ) + pow( neg_fitmeanerr[i], 2 ) );
299 fitsigma[i] = sqrt( pow( pos_fitsigma[i], 2 ) + pow( neg_fitsigma[i], 2 ) );
301 fitchisq[i] = ( pos_fitchisq[i] + neg_fitchisq[i] ) / 2;
304 if ( fitentryNo[i] > 100 ) m_dEdxVsCostheta->SetBinContent( i + 1, fitmean[i] );
305 if ( pos_fitentryNo[i] > 100 )
306 m_pos_dEdxVsCostheta->SetBinContent( i + 1, pos_fitmean[i] );
307 if ( neg_fitentryNo[i] > 100 )
308 m_neg_dEdxVsCostheta->SetBinContent( i + 1, neg_fitmean[i] );
311 double dedx1[
Size] = { 0 };
312 double costheta1[
Size] = { 0 };
313 cout <<
"Vec_dedx.size() = " << Vec_dedx.size() << endl;
314 for (
unsigned int i = 0; i <
Size && i < Vec_dedx.size(); i++ )
316 dedx1[i] = Vec_dedx[i];
317 costheta1[i] = Vec_costheta[i];
321 log << MSG::INFO <<
"begin generating root file!!! " << endmsg;
322 TFile*
f =
new TFile(
m_rootfile.c_str(),
"RECREATE" );
326 m_pos_chi[i]->Write();
327 m_neg_chi[i]->Write();
328 m_costheta[i]->Write();
329 m_pos_costheta[i]->Write();
330 m_neg_costheta[i]->Write();
332 m_dEdxVsCostheta->Write();
333 m_pos_dEdxVsCostheta->Write();
334 m_neg_dEdxVsCostheta->Write();
336 TTree* costhetacalib =
new TTree(
"costhetacalib",
"costhetacalib" );
337 costhetacalib->Branch(
"chientryNo", chientryNo,
"chientryNo[80]/D" );
338 costhetacalib->Branch(
"chimean", chimean,
"chimean[80]/D" );
339 costhetacalib->Branch(
"chimeanerr", chimeanerr,
"chimeanerr[80]/D" );
340 costhetacalib->Branch(
"chisigma", chisigma,
"chisigma[80]/D" );
341 costhetacalib->Branch(
"chisq", chisq,
"chisq[80]/D" );
342 costhetacalib->Branch(
"pos_chientryNo", pos_chientryNo,
"pos_chientryNo[80]/D" );
343 costhetacalib->Branch(
"pos_chimean", pos_chimean,
"pos_chimean[80]/D" );
344 costhetacalib->Branch(
"pos_chimeanerr", pos_chimeanerr,
"pos_chimeanerr[80]/D" );
345 costhetacalib->Branch(
"pos_chisigma", pos_chisigma,
"pos_chisigma[80]/D" );
346 costhetacalib->Branch(
"pos_chisq", pos_chisq,
"pos_chisq[80]/D" );
347 costhetacalib->Branch(
"neg_chientryNo", neg_chientryNo,
"neg_chientryNo[80]/D" );
348 costhetacalib->Branch(
"neg_chimean", neg_chimean,
"neg_chimean[80]/D" );
349 costhetacalib->Branch(
"neg_chimeanerr", neg_chimeanerr,
"neg_chimeanerr[80]/D" );
350 costhetacalib->Branch(
"neg_chisigma", neg_chisigma,
"neg_chisigma[80]/D" );
351 costhetacalib->Branch(
"neg_chisq", neg_chisq,
"neg_chisq[80]/D" );
352 costhetacalib->Branch(
"fitentryNo", fitentryNo,
"fitentryNo[80]/D" );
353 costhetacalib->Branch(
"fitmean", fitmean,
"fitmean[80]/D" );
354 costhetacalib->Branch(
"fitmeanerr", fitmeanerr,
"fitmeanerr[80]/D" );
355 costhetacalib->Branch(
"fitsigma", fitsigma,
"fitsigma[80]/D" );
356 costhetacalib->Branch(
"costheta", gain,
"gain[80]/D" );
357 costhetacalib->Branch(
"fitchisq", fitchisq,
"fitchisq[80]/D" );
358 costhetacalib->Branch(
"pos_fitentryNo", pos_fitentryNo,
"pos_fitentryNo[80]/D" );
359 costhetacalib->Branch(
"pos_fitmean", pos_fitmean,
"pos_fitmean[80]/D" );
360 costhetacalib->Branch(
"pos_fitmeanerr", pos_fitmeanerr,
"pos_fitmeanerr[80]/D" );
361 costhetacalib->Branch(
"pos_fitsigma", pos_fitsigma,
"pos_fitsigma[80]/D" );
362 costhetacalib->Branch(
"pos_gain", pos_gain,
"pos_gain[80]/D" );
363 costhetacalib->Branch(
"pos_fitchisq", pos_fitchisq,
"pos_fitchisq[80]/D" );
364 costhetacalib->Branch(
"neg_fitentryNo", neg_fitentryNo,
"neg_fitentryNo[80]/D" );
365 costhetacalib->Branch(
"neg_fitmean", neg_fitmean,
"neg_fitmean[80]/D" );
366 costhetacalib->Branch(
"neg_fitmeanerr", neg_fitmeanerr,
"neg_fitmeanerr[80]/D" );
367 costhetacalib->Branch(
"neg_fitsigma", neg_fitsigma,
"neg_fitsigma[80]/D" );
368 costhetacalib->Branch(
"neg_gain", neg_gain,
"neg_gain[80]/D" );
369 costhetacalib->Branch(
"neg_fitchisq", neg_fitchisq,
"neg_fitchisq[80]/D" );
370 costhetacalib->Branch(
"cosBin", cosBin,
"cosBin[80]/D" );
371 costhetacalib->Branch(
"costheta1", costheta1,
"costheta1[700000]/D" );
372 costhetacalib->Branch(
"dedx1", dedx1,
"dedx1[700000]/D" );
373 costhetacalib->Fill();
374 costhetacalib->Write();
376 TCanvas c1(
"c1",
"canvas", 500, 400 );
378 costhetacalib->Draw(
"dedx1:costheta1",
"dedx1>200 && dedx1<1000" );
380 m_dEdxVsCostheta->Draw();
382 m_pos_dEdxVsCostheta->Draw();
384 m_neg_dEdxVsCostheta->Draw();
393 m_pos_chi[i]->Draw();
398 m_neg_chi[i]->Draw();
403 m_costheta[i]->Draw();
408 m_pos_costheta[i]->Draw();
413 m_neg_costheta[i]->Draw();
424 delete m_costheta[i];
425 delete m_pos_costheta[i];
426 delete m_neg_costheta[i];
428 delete m_dEdxVsCostheta;
429 delete m_pos_dEdxVsCostheta;
430 delete m_neg_dEdxVsCostheta;