1#include "GaudiKernel/MsgStream.h"
13#include "DedxCalibAlg/DedxCalibDocaEAng.h"
21 declareProperty(
"Debug", m_debug=
false);
22 declareProperty(
"Idoca", m_idoca_test=1);
23 declareProperty(
"Ieang", m_ieang_test=1);
28 MsgStream log(
msgSvc(), name());
29 log<<MSG::INFO<<
"DedxCalibDocaEAng::BookHists()"<<endreq;
41 hlabel<<
"dEdx_doca"<<i<<
"_eang"<<j;
46 hlabel<<
"dEdxVsDocaEAng";
52 MsgStream log(
msgSvc(), name());
53 log<<MSG::INFO<<
"DedxCalibDocaEAng::FillHists()"<<endreq;
56 TTree* n103, *t_test(0);
59 double doca_test(0), eang_test(0);
61 double dEdx[100]={0},pathlength[100]={0},wid[100]={0},layid[100]={0},dd_in[100]={0},eangle[100]={0},zhit[100]={0};
62 float runNO=0,runFlag=0,costheta=0,tes=0,charge=0,recalg=0,ptrk=0,chidedx=0;
64 if(m_debug){ f_test =
new TFile(
"doca_eangle_test.root",
"recreate");
65 t_test =
new TTree(
"inftest",
"information for test doca eangle calibration");
66 t_test->Branch(
"idoca", &m_idoca_test,
"idoca/I");
67 t_test->Branch(
"ieang", &m_ieang_test,
"ieang/I");
68 t_test->Branch(
"doca", &doca_test,
"doca/D");
69 t_test->Branch(
"eang", &eang_test,
"eang/D");
74 cout<<
"runlist: "<<runlist.c_str()<<endl;
75 f =
new TFile(runlist.c_str());
77 n103 = (TTree*)f->Get(
"n103");
94 for(
int j=0;j<n103->GetEntries();j++){
97 if(tes>1400)
continue;
98 for(
int k=0;k<ndedxhit;k++){
99 dd_in[k] = dd_in[k]/doca_norm[int(layid[k])];
100 if(eangle[k] >0.25) eangle[k] = eangle[k] -0.5;
101 else if(eangle[k] <-0.25) eangle[k] = eangle[k] +0.5;
111 for(
int i =0; i<14; i++)
113 if(eangle[k] < Eangle_value_cut[i] || eangle[k] >= Eangle_value_cut[i+1])
continue;
114 else if(eangle[k] >= Eangle_value_cut[i] && eangle[k] < Eangle_value_cut[i+1])
116 for(
int m =0; m<i; m++)
118 iEAng += Eangle_cut_bin[m];
120 double eangle_bin_cut_step = (Eangle_value_cut[i+1] - Eangle_value_cut[i])/Eangle_cut_bin[i];
121 int temp_bin = int((eangle[k]-Eangle_value_cut[i])/eangle_bin_cut_step);
125 if(m_debug && (iDoca==m_idoca_test) && (iEAng==m_ieang_test)){
126 doca_test = dd_in[k];
127 eang_test = eangle[k];
129 cout <<
"dedx before cor: " << dEdx[k]*1.5/pathlength[k] << endl;
131 dEdx[k] =
exsvc->
StandardHitCorrec(0,runFlag,2,runNO,pathlength[k],wid[k],layid[k],dEdx[k],(dd_in[k])*(doca_norm[
int(layid[k])]),eangle[k],costheta);
133 m_docaeangle[iDoca][iEAng]->Fill(dEdx[k]);
134 if(m_debug && (iDoca==m_idoca_test) && (iEAng==m_ieang_test)){
135 cout <<
"dedx after cor: " << dEdx[k] << endl << endl;
141 if(m_debug){ f_test->cd(); t_test->Write(); f_test->Close(); }
146 MsgStream log(
msgSvc(), name());
147 log<<MSG::INFO<<
"DedxCalibDocaEAng::AnalyseHists()"<<endreq;
150 Double_t entry=0,mean=0,rms=0;
153 gStyle->SetOptFit(1111);
158 entry = m_docaeangle[id][ip]->GetEntries();
159 if(entry<10)
continue;
160 mean = m_docaeangle[id][ip]->GetMean();
161 rms = m_docaeangle[id][ip]->GetRMS();
162 binmax = m_docaeangle[id][ip]->GetMaximumBin();
163 lp[1] = m_docaeangle[id][ip]->GetBinCenter(binmax);
165 lp[0] = (m_docaeangle[id][ip]->GetBinContent(binmax)+m_docaeangle[id][ip]->GetBinContent(binmax-1)+m_docaeangle[id][ip]->GetBinContent(binmax+1))/3;
169 func =
new TF1(
"mylan",
mylan,10,3000,4);
170 func->SetParameters(entry, mean, rms, -0.8);
171 func->SetParLimits(0, 0, entry);
172 func->SetParLimits(1, 0, mean);
173 func->SetParLimits(2, 10, rms);
174 func->SetParLimits(3, -1, 0);
175 func->SetParameters(entry/36., mean-200, rms/2.3, -0.5);
179 func =
new TF1(
"landaun",
landaun,10,3000,3);
180 func->SetParameters(lp[0], lp[1], lp[2] );
184 func =
new TF1(
"Landau",
Landau,10,3000,2);
185 func->SetParameters(0.7*mean, rms );
189 func =
new TF1(
"Vavilov",
Vavilov,10,3000,2);
190 func->SetParameters(0.05, 0.6);
194 func =
new TF1(
"AsymGauss",
AsymGauss,10,3000,4);
195 func->SetParameters(entry, mean, rms, 1.0 );
197 func->SetLineWidth(2.1);
198 func->SetLineColor(2);
200 m_docaeangle[id][ip]->Fit(func,
"r");
207 MsgStream log(
msgSvc(), name());
208 log<<MSG::INFO<<
"DedxCalibDocaEAng::WriteHists()"<<endreq;
211 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};
212 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};
213 double Id_doca[totalNo]={0},Ip_eangle[totalNo]={0},doca[totalNo]={0},eangle[totalNo]={0},chisq[totalNo]={0};
215 double Norm(0),
count(0);
226 if(ip>=iE && ip<iE+Eangle_cut_bin[i])
break;
227 iE=iE+Eangle_cut_bin[i];
230 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];
233 Out_entryNo[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetEntries();
234 Out_mean[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetMean();
235 Out_sigma[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetRMS();
241 Out_fitmean[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"mylan")->GetParameter(1);
242 Out_fitmeanerr[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"mylan")->GetParError(1);
243 Out_fitsigma[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"mylan")->GetParameter(2);
245 chisq[
id*
NumSlicesEAng+ip] = (m_docaeangle[id][ip]->GetFunction(
"mylan")-> GetChisquare())/(m_docaeangle[
id][ip]->GetFunction(
"mylan")-> GetNDF());
249 Out_fitmean[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"landaun")->GetParameter(1);
250 Out_fitmeanerr[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"landaun")->GetParError(1);
251 Out_fitsigma[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"landaun")->GetParameter(2);
252 chisq[
id*
NumSlicesEAng+ip] = (m_docaeangle[id][ip]->GetFunction(
"landaun")-> GetChisquare())/(m_docaeangle[
id][ip]->GetFunction(
"landaun")-> GetNDF());
256 Out_fitmean[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"Landau")->GetParameter(1);
257 Out_fitmeanerr[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"Landau")->GetParError(1);
258 Out_fitsigma[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"Landau")->GetParameter(2);
259 chisq[
id*
NumSlicesEAng+ip] = (m_docaeangle[id][ip]->GetFunction(
"Landau")-> GetChisquare())/(m_docaeangle[
id][ip]->GetFunction(
"Landau")-> GetNDF());
263 Out_fitmean[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"Vavilov")->GetParameter(1);
264 Out_fitmeanerr[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"Vavilov")->GetParError(1);
265 Out_fitsigma[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"Vavilov")->GetParameter(2);
266 chisq[
id*
NumSlicesEAng+ip] = (m_docaeangle[id][ip]->GetFunction(
"Vavilov")-> GetChisquare())/(m_docaeangle[
id][ip]->GetFunction(
"Vavilov")-> GetNDF());
270 Out_fitmean[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"AsymGauss")->GetParameter(1);
271 Out_fitmeanerr[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"AsymGauss")->GetParError(1);
272 Out_fitsigma[
id*
NumSlicesEAng+ip] = m_docaeangle[id][ip]->GetFunction(
"AsymGauss")->GetParameter(2);
273 chisq[
id*
NumSlicesEAng+ip] = (m_docaeangle[id][ip]->GetFunction(
"AsymGauss")-> GetChisquare())/(m_docaeangle[
id][ip]->GetFunction(
"AsymGauss")-> GetNDF());
276 m_DocaEAngAverdE -> SetBinContent(
id+1, ip+1, Out_fitmean[
id*
NumSlicesEAng+ip]);
284 cout<<
"count= "<<
count<<
" average value of doca eangle bins: "<<Norm<<endl;
285 for(Int_t i=0;i<totalNo;i++)
287 if(Out_entryNo[i]>10 && Out_fitmean[i]>0 && Out_fitsigma[i]>0) Out_gain[i]=Out_fitmean[i]/Norm;
288 else Out_gain[i] = 0;
291 log<<MSG::INFO<<
"begin generating root file!!! "<<endreq;
292 TFile* f =
new TFile(
m_rootfile.c_str(),
"recreate");
297 m_docaeangle[id][ip]->Write();
300 m_DocaEAngAverdE->Write();
302 TTree* ddgcalib =
new TTree(
"ddgcalib",
"ddgcalib");
303 ddgcalib -> Branch(
"Out_hits", Out_entryNo,
"Out_entryNo[1600]/D");
304 ddgcalib -> Branch(
"Out_mean", Out_mean,
"Out_mean[1600]/D");
305 ddgcalib -> Branch(
"Out_sigma", Out_sigma,
"Out_sigma[1600]/D");
306 ddgcalib -> Branch(
"Out_fitmean", Out_fitmean,
"Out_fitmean[1600]/D");
307 ddgcalib -> Branch(
"Out_fitmeanerr", Out_fitmeanerr,
"Out_fitmeanerr[1600]/D");
308 ddgcalib -> Branch(
"Out_chi", Out_fitsigma,
"Out_fitsigma[1600]/D");
309 ddgcalib -> Branch(
"Out_gain", Out_gain,
"Out_gain[1600]/D");
310 ddgcalib -> Branch(
"Iner_hits", Iner_entryNo,
"Iner_entryNo[1600]/D");
311 ddgcalib -> Branch(
"Iner_mean", Iner_mean,
"Iner_mean[1600]/D");
312 ddgcalib -> Branch(
"Iner_sigma", Iner_sigma,
"Iner_sigma[1600]/D");
313 ddgcalib -> Branch(
"Iner_fitmean", Iner_fitmean,
"Iner_fitmean[1600]/D");
314 ddgcalib -> Branch(
"Iner_fitmeanerr", Iner_fitmeanerr,
"Iner_fitmeanerr[1600]/D");
315 ddgcalib -> Branch(
"Iner_chi", Iner_fitsigma,
"Iner_fitsigma[1600]/D");
316 ddgcalib -> Branch(
"Iner_gain", Iner_gain,
"Iner_gain[1600]/D");
317 ddgcalib -> Branch(
"Id_doca", Id_doca,
"Id_doca[1600]/D");
318 ddgcalib -> Branch(
"Ip_eangle", Ip_eangle,
"Ip_eangle[1600]/D");
319 ddgcalib -> Branch(
"chisq", chisq,
"chisq[1600]/D");
320 ddgcalib -> Branch(
"doca", doca,
"doca[1600]/D");
321 ddgcalib -> Branch(
"eangle", eangle,
"eangle[1600]/D");
326 TCanvas c1(
"c1",
"canvas", 500, 400);
332 m_docaeangle[id][ip]->Draw();
342 delete m_docaeangle[id][ip];
345 delete m_DocaEAngAverdE;
data SetBranchAddress("time",&time)
DOUBLE_PRECISION count[2]
double Landau(double *x, double *par)
double Vavilov(double *x, double *par)
double landaun(double *x, double *par)
double AsymGauss(double *x, double *par)
double mylan(double *x, double *par)
DedxCalibDocaEAng(const std::string &name, ISvcLocator *pSvcLocator)
vector< string > m_recFileVector
virtual double StandardHitCorrec(int calib_rec_Flag, int runFlag, int ntpFlag, int runNO, 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, double ex, double costheta, double t0) const =0