25 MsgStream log(
msgSvc(), name() );
26 log << MSG::INFO <<
"DedxCalibTzero::BookHists()" << endmsg;
40 hlabel <<
"dEdx_tzero" << i;
41 m_tzero[i] =
new TH1F( hlabel.str().c_str(), hlabel.str().c_str(),
NumHistBins,
44 hlabel <<
"pos_dEdx_tzero" << i;
45 m_pos_tzero[i] =
new TH1F( hlabel.str().c_str(), hlabel.str().c_str(),
NumHistBins,
48 hlabel <<
"neg_dEdx_tzero" << i;
49 m_neg_tzero[i] =
new TH1F( hlabel.str().c_str(), hlabel.str().c_str(),
NumHistBins,
52 hlabel <<
"chi_tzero" << i;
56 hlabel <<
"pos_chi_tzero" << i;
57 m_pos_chi[i] =
new TH1F( hlabel.str().c_str(), hlabel.str().c_str(),
NumHistBins,
60 hlabel <<
"neg_chi_tzero" << i;
61 m_neg_chi[i] =
new TH1F( hlabel.str().c_str(), hlabel.str().c_str(),
NumHistBins,
65 hlabel <<
"dEdxVsTzero";
68 m_dEdxVsTzero->GetXaxis()->SetTitle(
"t0" );
69 m_dEdxVsTzero->GetYaxis()->SetTitle(
"dE/dx" );
71 hlabel <<
"pos_dEdxVsTzero";
72 m_pos_dEdxVsTzero =
new TH2F( hlabel.str().c_str(),
"positron dEdx vs t0",
NumBinTzero,
74 m_pos_dEdxVsTzero->GetXaxis()->SetTitle(
"pos t0" );
75 m_pos_dEdxVsTzero->GetYaxis()->SetTitle(
"dE/dx" );
77 hlabel <<
"neg_dEdxVsTzero";
78 m_neg_dEdxVsTzero =
new TH2F( hlabel.str().c_str(),
"electron dEdx vs tzero",
NumBinTzero,
80 m_neg_dEdxVsTzero->GetXaxis()->SetTitle(
"neg t0" );
81 m_neg_dEdxVsTzero->GetYaxis()->SetTitle(
"dE/dx" );
88 MsgStream log(
msgSvc(), name() );
89 log << MSG::INFO <<
"DedxCalibTzero::FillHists()" << endmsg;
96 double dEdx[100] = { 0 }, pathlength[100] = { 0 }, wid[100] = { 0 }, layid[100] = { 0 },
97 dd_in[100] = { 0 }, eangle[100] = { 0 }, zhit[100] = { 0 },
100 float runNO = 0, evtNO = 0, runFlag = 0, costheta = 0, tes = 0, charge = 0, recalg = 0,
101 ptrk = 0, chidedx = 0;
105 tzero_bin_low[i] = ( i == 0 ) ? 0 : ( tzero_bin_value[i - 1] + tzero_bin_value[i] ) / 2;
108 : ( tzero_bin_value[i] + tzero_bin_value[i + 1] ) / 2;
110 vector<double> phlist;
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++ )
141 for (
int k = 0; k < ndedxhit; k++ )
143 dEdx[k] =
exsvc->StandardHitCorrec( 0, runFlag, 2, runNO, evtNO, pathlength[k], wid[k],
144 layid[k], dEdx[k], dd_in[k], eangle[k], costheta );
145 phlist.push_back( dEdx[k] );
150 if ( tes > tzero_bin_low[iTes] && tes <= tzero_bin_high[iTes] )
break;
151 if ( m_debug && i < 10 && j < 100 )
152 cout <<
"t0 " << tes <<
" iTes " << iTes <<
" dedx " << dedx << endl;
154 dedx =
exsvc->StandardTrackCorrec( 0, runFlag, 2, runNO, evtNO, dedx, costheta, tes );
157 m_tzero[iTes]->Fill( dedx );
158 m_dEdxVsTzero->Fill( tes, dedx );
161 m_pos_tzero[iTes]->Fill( dedx );
162 m_pos_dEdxVsTzero->Fill( tes, dedx );
166 m_neg_tzero[iTes]->Fill( dedx );
167 m_neg_dEdxVsTzero->Fill( tes, dedx );
171 set_dEdx( 1, dedx, recalg, runFlag, usedhit, ptrk, acos( costheta ), 1.5,
vFlag, tes );
174 m_chi[iTes]->Fill( chi );
175 if ( charge > 0 ) m_pos_chi[iTes]->Fill( chi );
176 if ( charge < 0 ) m_neg_chi[iTes]->Fill( chi );
178 Vec_dedx.push_back( dedx );
179 Vec_tzero.push_back( tes );
202 MsgStream log(
msgSvc(), name() );
203 log << MSG::INFO <<
"DedxCalibTzero::WriteHists()" << endmsg;
217 double avegain( 550. );
221 t0[i] = tzero_bin_value[i];
222 fitentryNo[i] = m_tzero[i]->Integral();
223 if ( m_debug ) cout <<
"num of bin " << i <<
" with events " << fitentryNo[i] << endl;
224 if ( fitentryNo[i] <=
numcut )
continue;
226 cout <<
"get results at " << i <<
" bin with fit entries " << fitentryNo[i] << endl;
227 if ( m_tzero[i]->GetFunction(
"gaus" ) )
229 fitmean[i] = m_tzero[i]->GetFunction(
"gaus" )->GetParameter( 1 );
230 fitmeanerr[i] = m_tzero[i]->GetFunction(
"gaus" )->GetParError( 1 );
231 fitsigma[i] = m_tzero[i]->GetFunction(
"gaus" )->GetParameter( 2 );
232 gain[i] = fitmean[i] / avegain;
234 fitchisq[i] = ( m_tzero[i]->GetFunction(
"gaus" )->GetChisquare() ) /
235 ( m_tzero[i]->GetFunction(
"gaus" )->GetNDF() );
237 pos_fitentryNo[i] = m_pos_tzero[i]->Integral();
238 if ( pos_fitentryNo[i] <=
numcut )
continue;
240 cout <<
"get results at " << i <<
" bin with pos_fit entries " << pos_fitentryNo[i]
242 if ( m_pos_tzero[i]->GetFunction(
"gaus" ) )
244 pos_fitmean[i] = m_pos_tzero[i]->GetFunction(
"gaus" )->GetParameter( 1 );
245 pos_fitmeanerr[i] = m_pos_tzero[i]->GetFunction(
"gaus" )->GetParError( 1 );
246 pos_fitsigma[i] = m_pos_tzero[i]->GetFunction(
"gaus" )->GetParameter( 2 );
247 pos_gain[i] = pos_fitmean[i] / avegain;
248 pos_fitchisq[i] = ( m_pos_tzero[i]->GetFunction(
"gaus" )->GetChisquare() ) /
249 ( m_pos_tzero[i]->GetFunction(
"gaus" )->GetNDF() );
251 neg_fitentryNo[i] = m_neg_tzero[i]->Integral();
252 if ( neg_fitentryNo[i] <=
numcut )
continue;
254 cout <<
"get results at " << i <<
" bin with neg_fit entries " << neg_fitentryNo[i]
256 if ( m_neg_tzero[i]->GetFunction(
"gaus" ) )
258 neg_fitmean[i] = m_neg_tzero[i]->GetFunction(
"gaus" )->GetParameter( 1 );
259 neg_fitmeanerr[i] = m_neg_tzero[i]->GetFunction(
"gaus" )->GetParError( 1 );
260 neg_fitsigma[i] = m_neg_tzero[i]->GetFunction(
"gaus" )->GetParameter( 2 );
261 neg_gain[i] = neg_fitmean[i] / avegain;
262 neg_fitchisq[i] = ( m_neg_tzero[i]->GetFunction(
"gaus" )->GetChisquare() ) /
263 ( m_neg_tzero[i]->GetFunction(
"gaus" )->GetNDF() );
267 log << MSG::INFO <<
"begin generating root file!!! " << endmsg;
268 TFile*
f =
new TFile(
m_rootfile.c_str(),
"RECREATE" );
272 m_pos_chi[i]->Write();
273 m_neg_chi[i]->Write();
275 m_pos_tzero[i]->Write();
276 m_neg_tzero[i]->Write();
278 m_dEdxVsTzero->Write();
279 m_pos_dEdxVsTzero->Write();
280 m_neg_dEdxVsTzero->Write();
282 TTree* tzerocalib =
new TTree(
"gaincalib",
"gaincalib" );
283 tzerocalib->Branch(
"gain", &avegain,
"gain/D" );
284 tzerocalib->Branch(
"t0", t0,
"t0[35]/D" );
285 tzerocalib->Branch(
"dedx", gain,
"dedx[35]/D" );
286 tzerocalib->Branch(
"fakededx", fakegain,
"fakededx[35]/D" );
287 tzerocalib->Branch(
"fitmean", fitmean,
"fitmean[35]/D" );
288 tzerocalib->Branch(
"fitmeanerr", fitmeanerr,
"fitmeanerr[35]/D" );
289 tzerocalib->Branch(
"fitsigma", fitsigma,
"fitsigma[35]/D" );
290 tzerocalib->Branch(
"fitchisq", fitchisq,
"fitchisq[35]/D" );
294 TCanvas c1(
"c1",
"canvas", 500, 400 );
296 tzerocalib->Draw(
"dedx:t0" );
300 m_dEdxVsTzero->Draw();
302 m_pos_dEdxVsTzero->Draw();
304 m_neg_dEdxVsTzero->Draw();
313 m_pos_tzero[i]->Draw();
318 m_neg_tzero[i]->Draw();
322 if ( m_debug ) cout <<
"before delete" << endl;
329 delete m_pos_tzero[i];
330 delete m_neg_tzero[i];
332 delete m_dEdxVsTzero;
333 delete m_pos_dEdxVsTzero;
334 delete m_neg_dEdxVsTzero;
void set_dEdx(int landau, float dEdx, int trkalg, int runflag, int dedxhit_use, float ptrk, float theta, float pl_rp, int vflag[3], double t0)