1#include "GaudiKernel/MsgStream.h"
12#include "DedxCalibAlg/DedxCalibCostheta.h"
21 declareProperty(
"Debug", m_debug=
false);
22 declareProperty(
"Ave", m_ave=
true);
23 declareProperty(
"DebugMin", m_debug_min=2);
24 declareProperty(
"DebugMax", m_debug_max=2);
25 declareProperty(
"PMin", pMin=0.2);
26 declareProperty(
"PMax", pMax=2.3);
31 MsgStream log(
msgSvc(), name());
32 log<<MSG::INFO<<
"DedxCalibCostheta::BookHists()"<<endreq;
46 hlabel<<
"dEdx_costheta"<<i;
49 hlabel<<
"pos_dEdx_costheta"<<i;
52 hlabel<<
"neg_dEdx_costheta"<<i;
55 hlabel<<
"chi_costheta"<<i;
58 hlabel<<
"pos_chi_costheta"<<i;
61 hlabel<<
"neg_chi_costheta"<<i;
65 hlabel<<
"dEdxVsCostheta";
67 m_dEdxVsCostheta->GetXaxis()->SetTitle(
"cos#theta");
68 m_dEdxVsCostheta->GetYaxis()->SetTitle(
"dE/dx");
70 hlabel<<
"pos_dEdxVsCostheta";
72 m_pos_dEdxVsCostheta->GetXaxis()->SetTitle(
"cos#theta");
73 m_pos_dEdxVsCostheta->GetYaxis()->SetTitle(
"dE/dx");
75 hlabel<<
"neg_dEdxVsCostheta";
77 m_neg_dEdxVsCostheta->GetXaxis()->SetTitle(
"cos#theta");
78 m_neg_dEdxVsCostheta->GetYaxis()->SetTitle(
"dE/dx");
86 MsgStream log(
msgSvc(), name());
87 log<<MSG::INFO<<
"DedxCalibCostheta::FillHists()"<<endreq;
94 double dEdx[100]={0},pathlength[100]={0},wid[100]={0},layid[100]={0},dd_in[100]={0},eangle[100]={0},zhit[100]={0};
98 vector<double> phlist;
102 int m_current_trks(0);
104 f =
new TFile(runlist.c_str());
105 n103 = (TTree*)
f->Get(
"n103");
124 for(
int j=0;j<n103->GetEntries();j++)
127 if(m_current_trks>
Size)
break;
131 if(tes>1400)
continue;
132 if(
ptrk>pMax ||
ptrk<pMin)
continue;
133 for(
int k=0;k<ndedxhit;k++)
135 dEdx[k] =
exsvc->
StandardHitCorrec(0,runFlag,2,runNO,evtNO,pathlength[k],wid[k],layid[k],dEdx[k],dd_in[k],eangle[k],
costheta);
136 phlist.push_back(dEdx[k]);
140 double pre_dedx = dedx;
141 if(m_debug && iCos>=m_debug_min && iCos<=m_debug_max)
142 cout <<
"before cor, dedx " << pre_dedx <<
" with cos(theta) " <<
costheta << endl;
144 if(m_debug && iCos>=m_debug_min && iCos<=m_debug_max)
145 cout <<
"after cor, dedx " << dedx <<
" with gain " << pre_dedx/dedx << endl;
146 m_costheta[iCos]->Fill(dedx);
147 if(
charge>0) m_pos_costheta[iCos]->Fill(dedx);
148 if(
charge<0) m_neg_costheta[iCos]->Fill(dedx);
153 m_chi[iCos]->Fill(chi);
154 if(
charge>0) m_pos_chi[iCos]->Fill(chi);
155 if(
charge<0) m_neg_chi[iCos]->Fill(chi);
157 Vec_dedx.push_back(dedx);
165 MsgStream log(
msgSvc(), name());
166 log<<MSG::INFO<<
"DedxCalibCostheta::AnalyseHists()"<<endreq;
168 gStyle->SetOptFit(1111);
171 if(m_debug) cout <<
"num of bin " << i << endl;
172 if(m_costheta[i]->GetEntries()>100) m_costheta[i]->Fit(
"gaus",
"Q" );
173 if(m_pos_costheta[i]->GetEntries()>100) m_pos_costheta[i]->Fit(
"gaus",
"Q" );
174 if(m_neg_costheta[i]->GetEntries()>100) m_neg_costheta[i]->Fit(
"gaus",
"Q" );
175 if(m_chi[i]->GetEntries()>100) m_chi[i]->Fit(
"gaus",
"Q" );
176 if(m_pos_chi[i]->GetEntries()>100) m_pos_chi[i]->Fit(
"gaus",
"Q" );
177 if(m_neg_chi[i]->GetEntries()>100) m_neg_chi[i]->Fit(
"gaus",
"Q" );
183 MsgStream log(
msgSvc(), name());
184 log<<MSG::INFO<<
"DedxCalibCostheta::WriteHists()"<<endreq;
198 chientryNo[i] = m_chi[i]->GetEntries();
199 if(m_debug) cout <<
"get results at " << i <<
" bin with chi entries " << chientryNo[i] << endl;
200 if(m_chi[i]->GetFunction(
"gaus"))
202 chimean[i] = m_chi[i]->GetFunction(
"gaus")->GetParameter(1);
203 chimeanerr[i] = m_chi[i]->GetFunction(
"gaus")->GetParError(1);
204 chisigma[i] = m_chi[i]->GetFunction(
"gaus")->GetParameter(2);
205 chisq[i] = (m_chi[i]->GetFunction(
"gaus")->GetChisquare())/(m_chi[i]->GetFunction(
"gaus")->GetNDF());
207 pos_chientryNo[i] = m_pos_chi[i]->GetEntries();
208 if(m_debug) cout <<
"get results at " << i <<
" bin with pos_chi entries " << pos_chientryNo[i] << endl;
209 if(m_pos_chi[i]->GetFunction(
"gaus"))
211 pos_chimean[i] = m_pos_chi[i]->GetFunction(
"gaus")->GetParameter(1);
212 pos_chimeanerr[i] = m_pos_chi[i]->GetFunction(
"gaus")->GetParError(1);
213 pos_chisigma[i] = m_pos_chi[i]->GetFunction(
"gaus")->GetParameter(2);
214 pos_chisq[i] = (m_pos_chi[i]->GetFunction(
"gaus")->GetChisquare())/(m_pos_chi[i]->GetFunction(
"gaus")->GetNDF());
216 neg_chientryNo[i] = m_neg_chi[i]->GetEntries();
217 if(m_debug) cout <<
"get results at " << i <<
" bin with neg_chi entries " << neg_chientryNo[i] << endl;
218 if(m_neg_chi[i]->GetFunction(
"gaus"))
220 neg_chimean[i] = m_neg_chi[i]->GetFunction(
"gaus")->GetParameter(1);
221 neg_chimeanerr[i] = m_neg_chi[i]->GetFunction(
"gaus")->GetParError(1);
222 neg_chisigma[i] = m_neg_chi[i]->GetFunction(
"gaus")->GetParameter(2);
223 neg_chisq[i] = (m_neg_chi[i]->GetFunction(
"gaus")->GetChisquare())/(m_neg_chi[i]->GetFunction(
"gaus")->GetNDF());
226 fitentryNo[i] = m_costheta[i]->GetEntries();
227 if(m_debug) cout <<
"get results at " << i <<
" bin with fit entries " << fitentryNo[i] << endl;
228 if(m_costheta[i]->GetFunction(
"gaus"))
230 fitmean[i] = m_costheta[i]->GetFunction(
"gaus")->GetParameter(1);
231 fitmeanerr[i] = m_costheta[i]->GetFunction(
"gaus")->GetParError(1);
232 fitsigma[i] = m_costheta[i]->GetFunction(
"gaus")->GetParameter(2);
234 fitchisq[i] = (m_costheta[i]->GetFunction(
"gaus")->GetChisquare())/(m_costheta[i]->GetFunction(
"gaus")->GetNDF());
236 pos_fitentryNo[i] = m_pos_costheta[i]->GetEntries();
237 if(m_debug) cout <<
"get results at " << i <<
" bin with pos_fit entries " << pos_fitentryNo[i] << endl;
238 if(m_pos_costheta[i]->GetFunction(
"gaus"))
240 pos_fitmean[i] = m_pos_costheta[i]->GetFunction(
"gaus")->GetParameter(1);
241 pos_fitmeanerr[i] = m_pos_costheta[i]->GetFunction(
"gaus")->GetParError(1);
242 pos_fitsigma[i] = m_pos_costheta[i]->GetFunction(
"gaus")->GetParameter(2);
244 pos_fitchisq[i] = (m_pos_costheta[i]->GetFunction(
"gaus")->GetChisquare())/(m_pos_costheta[i]->GetFunction(
"gaus")->GetNDF());
246 neg_fitentryNo[i] = m_neg_costheta[i]->GetEntries();
247 if(m_debug) cout <<
"get results at " << i <<
" bin with neg_fit entries " << neg_fitentryNo[i] << endl;
248 if(m_neg_costheta[i]->GetFunction(
"gaus"))
250 neg_fitmean[i] = m_neg_costheta[i]->GetFunction(
"gaus")->GetParameter(1);
251 neg_fitmeanerr[i] = m_neg_costheta[i]->GetFunction(
"gaus")->GetParError(1);
252 neg_fitsigma[i] = m_neg_costheta[i]->GetFunction(
"gaus")->GetParameter(2);
254 neg_fitchisq[i] = (m_neg_costheta[i]->GetFunction(
"gaus")->GetChisquare())/(m_neg_costheta[i]->GetFunction(
"gaus")->GetNDF());
258 fitmean[i] = (pos_fitmean[i] + neg_fitmean[i])/2;
259 fitmeanerr[i] = sqrt(pow(pos_fitmeanerr[i],2) + pow(neg_fitmeanerr[i],2));
260 fitsigma[i] = sqrt(pow(pos_fitsigma[i],2) + pow(neg_fitsigma[i],2));
262 fitchisq[i] = (pos_fitchisq[i] + neg_fitchisq[i])/2;
265 if(fitentryNo[i]>100) m_dEdxVsCostheta -> SetBinContent(i+1,fitmean[i]);
266 if(pos_fitentryNo[i]>100) m_pos_dEdxVsCostheta -> SetBinContent(i+1,pos_fitmean[i]);
267 if(neg_fitentryNo[i]>100) m_neg_dEdxVsCostheta -> SetBinContent(i+1,neg_fitmean[i]);
270 double dedx1[
Size] = {0};
271 double costheta1[
Size] = {0};
272 cout <<
"Vec_dedx.size() = " << Vec_dedx.size() << endl;
273 for(
unsigned int i=0;i<
Size && i< Vec_dedx.size();i++)
275 dedx1[i] = Vec_dedx[i];
276 costheta1[i] = Vec_costheta[i];
280 log<<MSG::INFO<<
"begin generating root file!!! "<<endreq;
281 TFile*
f =
new TFile(
m_rootfile.c_str(),
"RECREATE");
285 m_pos_chi[i]->Write();
286 m_neg_chi[i]->Write();
287 m_costheta[i]->Write();
288 m_pos_costheta[i]->Write();
289 m_neg_costheta[i]->Write();
291 m_dEdxVsCostheta->Write();
292 m_pos_dEdxVsCostheta->Write();
293 m_neg_dEdxVsCostheta->Write();
295 TTree *costhetacalib =
new TTree(
"costhetacalib",
"costhetacalib");
296 costhetacalib ->
Branch(
"chientryNo",chientryNo,
"chientryNo[80]/D");
297 costhetacalib ->
Branch(
"chimean",chimean,
"chimean[80]/D");
298 costhetacalib ->
Branch(
"chimeanerr",chimeanerr,
"chimeanerr[80]/D");
299 costhetacalib ->
Branch(
"chisigma",chisigma,
"chisigma[80]/D");
300 costhetacalib ->
Branch(
"chisq",chisq,
"chisq[80]/D");
301 costhetacalib ->
Branch(
"pos_chientryNo",pos_chientryNo,
"pos_chientryNo[80]/D");
302 costhetacalib ->
Branch(
"pos_chimean",pos_chimean,
"pos_chimean[80]/D");
303 costhetacalib ->
Branch(
"pos_chimeanerr",pos_chimeanerr,
"pos_chimeanerr[80]/D");
304 costhetacalib ->
Branch(
"pos_chisigma",pos_chisigma,
"pos_chisigma[80]/D");
305 costhetacalib ->
Branch(
"pos_chisq",pos_chisq,
"pos_chisq[80]/D");
306 costhetacalib ->
Branch(
"neg_chientryNo",neg_chientryNo,
"neg_chientryNo[80]/D");
307 costhetacalib ->
Branch(
"neg_chimean",neg_chimean,
"neg_chimean[80]/D");
308 costhetacalib ->
Branch(
"neg_chimeanerr",neg_chimeanerr,
"neg_chimeanerr[80]/D");
309 costhetacalib ->
Branch(
"neg_chisigma",neg_chisigma,
"neg_chisigma[80]/D");
310 costhetacalib ->
Branch(
"neg_chisq",neg_chisq,
"neg_chisq[80]/D");
311 costhetacalib ->
Branch(
"fitentryNo", fitentryNo,
"fitentryNo[80]/D");
312 costhetacalib ->
Branch(
"fitmean", fitmean,
"fitmean[80]/D");
313 costhetacalib ->
Branch(
"fitmeanerr", fitmeanerr,
"fitmeanerr[80]/D");
314 costhetacalib ->
Branch(
"fitsigma", fitsigma,
"fitsigma[80]/D");
315 costhetacalib ->
Branch(
"costheta", gain,
"gain[80]/D");
316 costhetacalib ->
Branch(
"fitchisq", fitchisq,
"fitchisq[80]/D");
317 costhetacalib ->
Branch(
"pos_fitentryNo", pos_fitentryNo,
"pos_fitentryNo[80]/D");
318 costhetacalib ->
Branch(
"pos_fitmean", pos_fitmean,
"pos_fitmean[80]/D");
319 costhetacalib ->
Branch(
"pos_fitmeanerr", pos_fitmeanerr,
"pos_fitmeanerr[80]/D");
320 costhetacalib ->
Branch(
"pos_fitsigma", pos_fitsigma,
"pos_fitsigma[80]/D");
321 costhetacalib ->
Branch(
"pos_gain", pos_gain,
"pos_gain[80]/D");
322 costhetacalib ->
Branch(
"pos_fitchisq", pos_fitchisq,
"pos_fitchisq[80]/D");
323 costhetacalib ->
Branch(
"neg_fitentryNo", neg_fitentryNo,
"neg_fitentryNo[80]/D");
324 costhetacalib ->
Branch(
"neg_fitmean", neg_fitmean,
"neg_fitmean[80]/D");
325 costhetacalib ->
Branch(
"neg_fitmeanerr", neg_fitmeanerr,
"neg_fitmeanerr[80]/D");
326 costhetacalib ->
Branch(
"neg_fitsigma", neg_fitsigma,
"neg_fitsigma[80]/D");
327 costhetacalib ->
Branch(
"neg_gain", neg_gain,
"neg_gain[80]/D");
328 costhetacalib ->
Branch(
"neg_fitchisq", neg_fitchisq,
"neg_fitchisq[80]/D");
329 costhetacalib ->
Branch(
"cosBin", cosBin,
"cosBin[80]/D");
330 costhetacalib ->
Branch(
"costheta1",costheta1,
"costheta1[700000]/D");
331 costhetacalib ->
Branch(
"dedx1",dedx1,
"dedx1[700000]/D");
332 costhetacalib ->
Fill();
333 costhetacalib ->
Write();
335 TCanvas c1(
"c1",
"canvas", 500, 400);
337 costhetacalib ->
Draw(
"dedx1:costheta1",
"dedx1>200 && dedx1<1000");
339 m_dEdxVsCostheta->Draw();
341 m_pos_dEdxVsCostheta->Draw();
343 m_neg_dEdxVsCostheta->Draw();
352 m_pos_chi[i]->Draw();
357 m_neg_chi[i]->Draw();
362 m_costheta[i]->Draw();
367 m_pos_costheta[i]->Draw();
372 m_neg_costheta[i]->Draw();
383 delete m_costheta[i];
384 delete m_pos_costheta[i];
385 delete m_neg_costheta[i];
387 delete m_dEdxVsCostheta;
388 delete m_pos_dEdxVsCostheta;
389 delete m_neg_dEdxVsCostheta;
curve Branch("CurveSize",&CurveSize,"CurveSize/I")
data SetBranchAddress("time",&time)
const double StepCostheta
DedxCalibCostheta(const std::string &name, ISvcLocator *pSvcLocator)
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)
vector< string > m_recFileVector
double cal_dedx_bitrunc(float truncate, std::vector< double > phlist)
virtual double StandardHitCorrec(int calib_rec_Flag, int runFlag, int ntpFlag, int runNO, int evtNO, double pathl, int wid, int layid, double adc, double dd, double eangle, double costheta) const =0
virtual double StandardTrackCorrec(int calib_rec_Flag, int typFlag, int ntpFlag, int runNO, int evtNO, double ex, double costheta, double t0) const =0
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")