54 MsgStream log(
msgSvc(), name());
55 log<<MSG::INFO<<
"DedxCalibDocaEAng::FillHists()"<<endreq;
58 TTree* n103, *t_test(0);
61 double doca_test(0), eang_test(0);
63 double dEdx[100]={0},pathlength[100]={0},wid[100]={0},layid[100]={0},dd_in[100]={0},eangle[100]={0},zhit[100]={0};
66 if(m_debug){ f_test =
new TFile(
"doca_eangle_test.root",
"recreate");
67 t_test =
new TTree(
"inftest",
"information for test doca eangle calibration");
68 t_test->Branch(
"idoca", &m_idoca_test,
"idoca/I");
69 t_test->Branch(
"ieang", &m_ieang_test,
"ieang/I");
70 t_test->Branch(
"doca", &doca_test,
"doca/D");
71 t_test->Branch(
"eang", &eang_test,
"eang/D");
76 cout<<
"runlist: "<<runlist.c_str()<<endl;
77 f =
new TFile(runlist.c_str());
78 n103 = (TTree*)
f->Get(
"n103");
79 if(
f==0){ cout <<
"the file is empty" << endl;
continue;}
80 if(n103==0){ cout <<
"the tree is empty" << endl;
continue;}
99 vector<double> m_phlist_test(0);
100 for(
int j=0;j<n103->GetEntries();j++){
102 if(
ptrk>pMax ||
ptrk<pMin)
continue;
103 if(tes>1400)
continue;
118 for(
int k=0;k<ndedxhit;k++){
120 dd_in[k] = dd_in[k]/doca_norm[int(layid[k])];
121 if(eangle[k] >0.25) eangle[k] = eangle[k] -0.5;
122 else if(eangle[k] <-0.25) eangle[k] = eangle[k] +0.5;
125 if(layid[k] <4)
continue;
132 for(
int i =0; i<14; i++)
134 if(eangle[k] < Eangle_value_cut[i] || eangle[k] >= Eangle_value_cut[i+1])
continue;
135 else if(eangle[k] >= Eangle_value_cut[i] && eangle[k] < Eangle_value_cut[i+1])
137 for(
int m =0; m<i; m++)
139 iEAng += Eangle_cut_bin[m];
141 double eangle_bin_cut_step = (Eangle_value_cut[i+1] - Eangle_value_cut[i])/Eangle_cut_bin[i];
142 int temp_bin = int((eangle[k]-Eangle_value_cut[i])/eangle_bin_cut_step);
146 if(m_debug && (iDoca==m_idoca_test) && (iEAng==m_ieang_test)){
147 doca_test = dd_in[k];
148 eang_test = eangle[k];
150 cout <<
"dedx before cor: " << dEdx[k]*1.5/pathlength[k] << endl;
152 dEdx[k] =
exsvc->
StandardHitCorrec(0,runFlag,2,runNO,evtNO,pathlength[k],wid[k],layid[k],dEdx[k],(dd_in[k])*(doca_norm[
int(layid[k])]),eangle[k],
costheta);
154 m_docaeangle[iDoca][iEAng]->Fill(dEdx[k]);
155 if(m_debug && (iDoca==m_idoca_test) && (iEAng==m_ieang_test)){
156 cout <<
"dedx after cor: " << dEdx[k] << endl << endl;
161 f->Close();
f = 0; n103 = 0;
163 if(m_debug){ f_test->cd(); t_test->Write(); f_test->Close(); }
168 MsgStream log(
msgSvc(), name());
169 log<<MSG::INFO<<
"DedxCalibDocaEAng::AnalyseHists()"<<endreq;
172 Double_t entry=0,mean=0,rms=0;
175 gStyle->SetOptFit(1111);
180 entry = m_docaeangle[id][ip]->GetEntries();
181 if(entry<10)
continue;
182 mean = m_docaeangle[id][ip]->GetMean();
183 rms = m_docaeangle[id][ip]->GetRMS();
184 binmax = m_docaeangle[id][ip]->GetMaximumBin();
185 lp[1] = m_docaeangle[id][ip]->GetBinCenter(binmax);
187 lp[0] = (m_docaeangle[id][ip]->GetBinContent(binmax)+m_docaeangle[
id][ip]->GetBinContent(binmax-1)+m_docaeangle[
id][ip]->GetBinContent(binmax+1))/3;
191 func =
new TF1(
"mylan",
mylan,10,3000,4);
192 func->SetParameters(entry, mean, rms, -0.8);
193 func->SetParLimits(0, 0, entry);
194 func->SetParLimits(1, 0, mean);
195 func->SetParLimits(2, 10, rms);
196 func->SetParLimits(3, -1, 0);
197 func->SetParameters(entry/36., mean-200, rms/2.3, -0.5);
201 func =
new TF1(
"landaun",
landaun,10,3000,3);
202 func->SetParameters(lp[0], lp[1], lp[2] );
206 func =
new TF1(
"Landau",
Landau,10,3000,2);
207 func->SetParameters(0.7*mean, rms );
211 func =
new TF1(
"Vavilov",
Vavilov,10,3000,2);
212 func->SetParameters(0.05, 0.6);
216 func =
new TF1(
"AsymGauss",
AsymGauss,10,3000,4);
217 func->SetParameters(entry, mean, rms, 1.0 );
219 func->SetLineWidth(2.1);
220 func->SetLineColor(2);
222 m_docaeangle[id][ip]->Fit(func,
"rq");
229 MsgStream log(
msgSvc(), name());
230 log<<MSG::INFO<<
"DedxCalibDocaEAng::WriteHists()"<<endreq;
233 double Out_entryNo[totalNo]={0},Out_mean[totalNo]={0},Out_sigma[totalNo]={0},Out_fitmean[totalNo]={0},Out_fitmeanerr[totalNo]={0},Out_fitsigma[totalNo]={0},Out_gain[totalNo]={0};
234 double Iner_entryNo[totalNo]={0},Iner_mean[totalNo]={0},Iner_sigma[totalNo]={0},Iner_fitmean[totalNo]={0},Iner_fitmeanerr[totalNo]={0},Iner_fitsigma[totalNo]={0},Iner_gain[totalNo]={0};
235 double Id_doca[totalNo]={0},Ip_eangle[totalNo]={0},doca[totalNo]={0},eangle[totalNo]={0},chisq[totalNo]={0};
237 double Norm(0),
count(0);
248 if(ip>=iE && ip<iE+Eangle_cut_bin[i])
break;
249 iE=iE+Eangle_cut_bin[i];
252 eangle[
id*
NumSlicesEAng+ip] = Eangle_value_cut[i] + (ip-iE+0.5)*(Eangle_value_cut[i+1]-Eangle_value_cut[i])/Eangle_cut_bin[i];
255 Out_entryNo[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetEntries();
256 Out_mean[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetMean();
257 Out_sigma[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetRMS();
263 Out_fitmean[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"mylan")->GetParameter(1);
264 Out_fitmeanerr[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"mylan")->GetParError(1);
265 Out_fitsigma[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"mylan")->GetParameter(2);
267 chisq[
id*
NumSlicesEAng+ip] = (m_docaeangle[id][ip]->GetFunction(
"mylan")-> GetChisquare())/(m_docaeangle[id][ip]->GetFunction(
"mylan")-> GetNDF());
271 Out_fitmean[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"landaun")->GetParameter(1);
272 Out_fitmeanerr[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"landaun")->GetParError(1);
273 Out_fitsigma[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"landaun")->GetParameter(2);
274 chisq[
id*
NumSlicesEAng+ip] = (m_docaeangle[id][ip]->GetFunction(
"landaun")-> GetChisquare())/(m_docaeangle[id][ip]->GetFunction(
"landaun")-> GetNDF());
278 Out_fitmean[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"Landau")->GetParameter(1);
279 Out_fitmeanerr[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"Landau")->GetParError(1);
280 Out_fitsigma[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"Landau")->GetParameter(2);
281 chisq[
id*
NumSlicesEAng+ip] = (m_docaeangle[id][ip]->GetFunction(
"Landau")-> GetChisquare())/(m_docaeangle[id][ip]->GetFunction(
"Landau")-> GetNDF());
285 Out_fitmean[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"Vavilov")->GetParameter(1);
286 Out_fitmeanerr[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"Vavilov")->GetParError(1);
287 Out_fitsigma[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"Vavilov")->GetParameter(2);
288 chisq[
id*
NumSlicesEAng+ip] = (m_docaeangle[id][ip]->GetFunction(
"Vavilov")-> GetChisquare())/(m_docaeangle[id][ip]->GetFunction(
"Vavilov")-> GetNDF());
292 Out_fitmean[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"AsymGauss")->GetParameter(1);
293 Out_fitmeanerr[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"AsymGauss")->GetParError(1);
294 Out_fitsigma[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"AsymGauss")->GetParameter(2);
295 chisq[
id*
NumSlicesEAng+ip] = (m_docaeangle[id][ip]->GetFunction(
"AsymGauss")-> GetChisquare())/(m_docaeangle[id][ip]->GetFunction(
"AsymGauss")-> GetNDF());
298 m_DocaEAngAverdE -> SetBinContent(
id+1, ip+1, Out_fitmean[
id*
NumSlicesEAng+ip]);
306 cout<<
"count= "<<
count<<
" average value of doca eangle bins: "<<Norm<<endl;
307 for(Int_t i=0;i<totalNo;i++)
309 if(Out_entryNo[i]>10 && Out_fitmean[i]>0 && Out_fitsigma[i]>0) Out_gain[i]=Out_fitmean[i]/Norm;
310 else Out_gain[i] = 0;
313 log<<MSG::INFO<<
"begin generating root file!!! "<<endreq;
314 TFile*
f =
new TFile(
m_rootfile.c_str(),
"recreate");
319 m_docaeangle[id][ip]->Write();
322 m_DocaEAngAverdE->Write();
324 TTree* ddgcalib =
new TTree(
"ddgcalib",
"ddgcalib");
325 ddgcalib ->
Branch(
"Out_hits", Out_entryNo,
"Out_entryNo[1600]/D");
326 ddgcalib ->
Branch(
"Out_mean", Out_mean,
"Out_mean[1600]/D");
327 ddgcalib ->
Branch(
"Out_sigma", Out_sigma,
"Out_sigma[1600]/D");
328 ddgcalib ->
Branch(
"Out_fitmean", Out_fitmean,
"Out_fitmean[1600]/D");
329 ddgcalib ->
Branch(
"Out_fitmeanerr", Out_fitmeanerr,
"Out_fitmeanerr[1600]/D");
330 ddgcalib ->
Branch(
"Out_chi", Out_fitsigma,
"Out_fitsigma[1600]/D");
331 ddgcalib ->
Branch(
"Out_gain", Out_gain,
"Out_gain[1600]/D");
332 ddgcalib ->
Branch(
"Iner_hits", Iner_entryNo,
"Iner_entryNo[1600]/D");
333 ddgcalib ->
Branch(
"Iner_mean", Iner_mean,
"Iner_mean[1600]/D");
334 ddgcalib ->
Branch(
"Iner_sigma", Iner_sigma,
"Iner_sigma[1600]/D");
335 ddgcalib ->
Branch(
"Iner_fitmean", Iner_fitmean,
"Iner_fitmean[1600]/D");
336 ddgcalib ->
Branch(
"Iner_fitmeanerr", Iner_fitmeanerr,
"Iner_fitmeanerr[1600]/D");
337 ddgcalib ->
Branch(
"Iner_chi", Iner_fitsigma,
"Iner_fitsigma[1600]/D");
338 ddgcalib ->
Branch(
"Iner_gain", Iner_gain,
"Iner_gain[1600]/D");
339 ddgcalib ->
Branch(
"Id_doca", Id_doca,
"Id_doca[1600]/D");
340 ddgcalib ->
Branch(
"Ip_eangle", Ip_eangle,
"Ip_eangle[1600]/D");
341 ddgcalib ->
Branch(
"chisq", chisq,
"chisq[1600]/D");
342 ddgcalib ->
Branch(
"doca", doca,
"doca[1600]/D");
343 ddgcalib ->
Branch(
"eangle", eangle,
"eangle[1600]/D");
348 TCanvas c1(
"c1",
"canvas", 500, 400);
354 m_docaeangle[id][ip]->Draw();
364 delete m_docaeangle[id][ip];
367 delete m_DocaEAngAverdE;
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