BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
DedxCalibMomentum Class Reference

#include <DedxCalibMomentum.h>

+ Inheritance diagram for DedxCalibMomentum:

Public Member Functions

 DedxCalibMomentum (const std::string &name, ISvcLocator *pSvcLocator)
 
 ~DedxCalibMomentum ()
 
void initializing ()
 
void BookHists ()
 
void genNtuple ()
 
void FillHists ()
 
void AnalyseHists ()
 
void WriteHists ()
 
- Public Member Functions inherited from DedxCalib
 DedxCalib (const std::string &name, ISvcLocator *pSvcLocator)
 
 ~DedxCalib ()
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
virtual void genNtuple ()=0
 
virtual void initializing ()=0
 
virtual void BookHists ()=0
 
virtual void FillHists ()=0
 
virtual void AnalyseHists ()=0
 
virtual void WriteHists ()=0
 

Additional Inherited Members

- Protected Member Functions inherited from DedxCalib
double cal_dedx_bitrunc (float truncate, std::vector< double > phlist)
 
double cal_dedx (float truncate, std::vector< double > phlist)
 
void getCurvePar ()
 
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)
 
void ReadRecFileList ()
 
- Protected Attributes inherited from DedxCalib
IMdcGeomSvcgeosvc
 
IDedxCorrecSvcexsvc
 
float truncate
 
vector< double > Curve_Para
 
vector< double > Sigma_Para
 
int vFlag [3]
 
double m_dedx_exp [5]
 
double m_ex_sigma [5]
 
double m_pid_prob [5]
 
double m_chi_ex [5]
 
vector< string > m_recFileVector
 
int ParticleFlag
 
int m_calibflag
 
int m_phShapeFlag
 
std::string m_eventType
 
std::string m_recFileList
 
std::string m_rootfile
 
std::string m_curvefile
 

Detailed Description

Definition at line 12 of file DedxCalibMomentum.h.

Constructor & Destructor Documentation

◆ DedxCalibMomentum()

DedxCalibMomentum::DedxCalibMomentum ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 26 of file DedxCalibMomentum.cxx.

26 : DedxCalib(name, pSvcLocator){
27 declareProperty("PMin", pMin=0.2);
28 declareProperty("PMax", pMax=1.0);
29}

◆ ~DedxCalibMomentum()

DedxCalibMomentum::~DedxCalibMomentum ( )
inline

Definition at line 16 of file DedxCalibMomentum.h.

16{};

Member Function Documentation

◆ AnalyseHists()

void DedxCalibMomentum::AnalyseHists ( )
virtual

Implements DedxCalib.

Definition at line 148 of file DedxCalibMomentum.cxx.

149{
150 MsgStream log(msgSvc(), name());
151 log<<MSG::INFO<<"DedxCalibMomentum::AnalyseHists()"<<endreq;
152
153 gStyle->SetOptFit(1111);
154 for(int i=0; i<nbins; i++)
155 {
156 m_dedx[i]->Fit("gaus", "Q" );
157 m_pos_dedx[i]->Fit("gaus", "Q" );
158 m_neg_dedx[i]->Fit("gaus", "Q" );
159 m_chi[i]->Fit("gaus", "Q" );
160 m_pos_chi[i]->Fit("gaus", "Q" );
161 m_neg_chi[i]->Fit("gaus", "Q" );
162 }
163}
const int nbins
IMessageSvc * msgSvc()

◆ BookHists()

void DedxCalibMomentum::BookHists ( )
virtual

Implements DedxCalib.

Definition at line 31 of file DedxCalibMomentum.cxx.

32{
33 MsgStream log(msgSvc(), name());
34 log<<MSG::INFO<<"DedxCalibMomentum::BookHists()"<<endreq;
35 bin_step = (pMax-pMin)/nbins;
37
38 m_chi = new TH1F*[nbins];
39 m_pos_chi = new TH1F*[nbins];
40 m_neg_chi = new TH1F*[nbins];
41 m_dedx = new TH1F*[nbins];
42 m_pos_dedx = new TH1F*[nbins];
43 m_neg_dedx = new TH1F*[nbins];
44 m_hits = new TH1F*[nbins];
45
46 stringstream hlabel;
47 for(int i=0;i<nbins;i++)
48 {
49 hlabel.str("");
50 hlabel<<"chi"<<i;
51 m_chi[i] = new TH1F(hlabel.str().c_str(), hlabel.str().c_str(), nbins, chihist_min, chihist_max);
52 hlabel.str("");
53 hlabel<<"pos_chi"<<i;
54 m_pos_chi[i] = new TH1F(hlabel.str().c_str(), hlabel.str().c_str(), nbins, chihist_min, chihist_max);
55 hlabel.str("");
56 hlabel<<"neg_chi"<<i;
57 m_neg_chi[i] = new TH1F(hlabel.str().c_str(), hlabel.str().c_str(), nbins, chihist_min, chihist_max);
58 hlabel.str("");
59 hlabel<<"dedx"<<i;
60 m_dedx[i] = new TH1F(hlabel.str().c_str(), hlabel.str().c_str(), nbins, dedxhist_min, dedxhist_max);
61 hlabel.str("");
62 hlabel<<"pos_dedx"<<i;
63 m_pos_dedx[i] = new TH1F(hlabel.str().c_str(), hlabel.str().c_str(), nbins, dedxhist_min, dedxhist_max);
64 hlabel.str("");
65 hlabel<<"neg_dedx"<<i;
66 m_neg_dedx[i] = new TH1F(hlabel.str().c_str(), hlabel.str().c_str(), nbins, dedxhist_min, dedxhist_max);
67 hlabel.str("");
68 hlabel<<"hits"<<i;
69 m_hits[i] = new TH1F(hlabel.str().c_str(), hlabel.str().c_str(), nbins, hits_min, hits_max);
70 }
71
72 Vec_dedx.clear();
73 Vec_ptrk.clear();
74}
const double chihist_min
const double dedxhist_max
const double hits_max
const double chihist_max
const double dedxhist_min
const double hits_min
void ReadRecFileList()
Definition: DedxCalib.cxx:89

◆ FillHists()

void DedxCalibMomentum::FillHists ( )
virtual

Implements DedxCalib.

Definition at line 76 of file DedxCalibMomentum.cxx.

77{
78 MsgStream log(msgSvc(), name());
79 log<<MSG::INFO<<"DedxCalibMomentum::FillHists()"<<endreq;
80
81 TFile* f;
82 TTree* n103;
83 string runlist;
84
85 int ndedxhit=0;
86 double dEdx[100]={0},pathlength[100]={0},wid[100]={0},layid[100]={0},dd_in[100]={0},eangle[100]={0},zhit[100]={0};
87 double dedx=0;
88 float runNO=0,evtNO=0,runFlag=0,costheta=0,tes=0,charge=0,recalg=0,ptrk=0,chidedx=0;
89 int usedhit=0;
90 vector<double> phlist;
91 cout<<"m_recFileVector.size()= "<<m_recFileVector.size()<<endl;
92 for(int i=0; i<m_recFileVector.size(); i++)
93 {
94 runlist = m_recFileVector[i];
95 f = new TFile(runlist.c_str());
96 n103 = (TTree*)f->Get("n103");
97 n103-> SetBranchAddress("ndedxhit", &ndedxhit);
98 n103-> SetBranchAddress("dEdx_hit",dEdx);
99 n103-> SetBranchAddress("pathlength_hit",pathlength);
100 n103-> SetBranchAddress("wid_hit",wid);
101 n103-> SetBranchAddress("layid_hit",layid);
102 n103-> SetBranchAddress("dd_in_hit",dd_in);
103 n103-> SetBranchAddress("eangle_hit",eangle);
104 n103-> SetBranchAddress("zhit_hit",zhit);
105 n103-> SetBranchAddress("runNO",&runNO);
106 n103-> SetBranchAddress("evtNO",&evtNO);
107 n103-> SetBranchAddress("runFlag",&runFlag);
108 n103-> SetBranchAddress("costheta",&costheta);
109 n103-> SetBranchAddress("t0",&tes);
110 n103-> SetBranchAddress("charge",&charge);
111 n103-> SetBranchAddress("recalg",&recalg);
112 n103-> SetBranchAddress("ndedxhit",&ndedxhit);
113 n103-> SetBranchAddress("ptrk",&ptrk);
114 n103-> SetBranchAddress("chidedx_e",&chidedx);
115 for(int j=0;j<n103->GetEntries();j++)
116 {
117 phlist.clear();
118 n103->GetEntry(j);
119 if(ptrk>pMax || ptrk<pMin) continue;
120 if(tes>1400) continue;
121 for(int k=0;k<ndedxhit;k++)
122 {
123 dEdx[k] = exsvc->StandardHitCorrec(0,runFlag,2,runNO,evtNO,pathlength[k],wid[k],layid[k],dEdx[k],dd_in[k],eangle[k],costheta);
124 phlist.push_back(dEdx[k]);
125 }
126 dedx = cal_dedx_bitrunc(truncate, phlist);
127 dedx = exsvc->StandardTrackCorrec(0, runFlag, 2, runNO, evtNO, dedx, costheta, tes);
128 int ipBin = (Int_t)floor((ptrk-pMin)/bin_step);
129 m_dedx[ipBin]->Fill(dedx);
130 if(charge>0) m_pos_dedx[ipBin]->Fill(dedx);
131 if(charge<0) m_neg_dedx[ipBin]->Fill(dedx);
132
133 usedhit = ndedxhit*truncate;
134 set_dEdx(1,dedx,recalg,runFlag,usedhit,ptrk,acos(costheta),1.5,vFlag,tes);
135 double chi = m_chi_ex[ParticleFlag];
136 //cout<<"chidedx= "<<chidedx<<" particleType= "<<ParticleFlag<<" new chi= "<<chi<<endl;
137 m_chi[ipBin]->Fill(chi);
138 if(charge>0) m_pos_chi[ipBin]->Fill(chi);
139 if(charge<0) m_neg_chi[ipBin]->Fill(chi);
140 m_hits[ipBin]->Fill(usedhit);
141
142 Vec_dedx.push_back(dedx);
143 Vec_ptrk.push_back(ptrk);
144 }
145 }
146}
double m_chi_ex[5]
Definition: DedxCalib.h:46
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)
Definition: DedxCalib.cxx:184
int ParticleFlag
Definition: DedxCalib.h:50
int vFlag[3]
Definition: DedxCalib.h:41
IDedxCorrecSvc * exsvc
Definition: DedxCalib.h:30
double cal_dedx_bitrunc(float truncate, std::vector< double > phlist)
Definition: DedxCalib.cxx:108
vector< string > m_recFileVector
Definition: DedxCalib.h:48
float truncate
Definition: DedxCalib.h:33
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")
curve SetBranchAddress("CurveSize",&CurveSize)
float costheta
float charge
float ptrk

◆ genNtuple()

void DedxCalibMomentum::genNtuple ( )
inlinevirtual

Implements DedxCalib.

Definition at line 19 of file DedxCalibMomentum.h.

19{}

◆ initializing()

void DedxCalibMomentum::initializing ( )
inlinevirtual

Implements DedxCalib.

Definition at line 17 of file DedxCalibMomentum.h.

17{}

◆ WriteHists()

void DedxCalibMomentum::WriteHists ( )
virtual

Implements DedxCalib.

Definition at line 165 of file DedxCalibMomentum.cxx.

166{
167 MsgStream log(msgSvc(), name());
168 log<<MSG::INFO<<"DedxCalibMomentum::WriteHists()"<< endreq;
169
170 double chientryNo[nbins]={0},chimean[nbins]={0},chimeanerr[nbins]={0},chisigma[nbins]={0},chisq[nbins]={0};
171 double pos_chientryNo[nbins]={0},pos_chimean[nbins]={0},pos_chimeanerr[nbins]={0},pos_chisigma[nbins]={0},pos_chisq[nbins]={0};
172 double neg_chientryNo[nbins]={0},neg_chimean[nbins]={0},neg_chimeanerr[nbins]={0},neg_chisigma[nbins]={0},neg_chisq[nbins]={0};
173 double fitentryNo[nbins]={0},fitmean[nbins]={0},fitmeanerr[nbins]={0},fitsigma[nbins]={0},fitchisq[nbins]={0};
174 double pos_fitentryNo[nbins]={0},pos_fitmean[nbins]={0},pos_fitmeanerr[nbins]={0},pos_fitsigma[nbins]={0},pos_fitchisq[nbins]={0};
175 double neg_fitentryNo[nbins]={0},neg_fitmean[nbins]={0},neg_fitmeanerr[nbins]={0},neg_fitsigma[nbins]={0},neg_fitchisq[nbins]={0};
176 double hits_mean[nbins]={0},hits_sigma[nbins]={0};
177 double pBin[nbins]={0};
178
179 for(int i=0;i<nbins;i++)
180 {
181 pBin[i] = (i+0.5)*bin_step + pMin;
182
183 chientryNo[i] = m_chi[i]->Integral();
184 if(chientryNo[i]>100)
185 {
186 chimean[i] = m_chi[i]->GetFunction("gaus")->GetParameter(1);
187 chimeanerr[i] = m_chi[i]->GetFunction("gaus")->GetParError(1);
188 chisigma[i] = m_chi[i]->GetFunction("gaus")->GetParameter(2);
189 chisq[i] = (m_chi[i]->GetFunction("gaus")->GetChisquare())/(m_chi[i]->GetFunction("gaus")->GetNDF());
190 }
191 pos_chientryNo[i] = m_pos_chi[i]->Integral();
192 if(pos_chientryNo[i]>100)
193 {
194 pos_chimean[i] = m_pos_chi[i]->GetFunction("gaus")->GetParameter(1);
195 pos_chimeanerr[i] = m_pos_chi[i]->GetFunction("gaus")->GetParError(1);
196 pos_chisigma[i] = m_pos_chi[i]->GetFunction("gaus")->GetParameter(2);
197 pos_chisq[i] = (m_pos_chi[i]->GetFunction("gaus")->GetChisquare())/(m_pos_chi[i]->GetFunction("gaus")->GetNDF());
198 }
199 neg_chientryNo[i] = m_neg_chi[i]->Integral();
200 if(neg_chientryNo[i]>100)
201 {
202 neg_chimean[i] = m_neg_chi[i]->GetFunction("gaus")->GetParameter(1);
203 neg_chimeanerr[i] = m_neg_chi[i]->GetFunction("gaus")->GetParError(1);
204 neg_chisigma[i] = m_neg_chi[i]->GetFunction("gaus")->GetParameter(2);
205 neg_chisq[i] = (m_neg_chi[i]->GetFunction("gaus")->GetChisquare())/(m_neg_chi[i]->GetFunction("gaus")->GetNDF());
206 }
207
208 fitentryNo[i] = m_dedx[i]->Integral();
209 if(fitentryNo[i]>100)
210 {
211 fitmean[i] = m_dedx[i]->GetFunction("gaus")->GetParameter(1);
212 fitmeanerr[i] = m_dedx[i]->GetFunction("gaus")->GetParError(1);
213 fitsigma[i] = m_dedx[i]->GetFunction("gaus")->GetParameter(2);
214 fitchisq[i] = (m_dedx[i]->GetFunction("gaus")->GetChisquare())/(m_dedx[i]->GetFunction("gaus")->GetNDF());
215 }
216 pos_fitentryNo[i] = m_pos_dedx[i]->Integral();
217 if(pos_fitentryNo[i]>100)
218 {
219 pos_fitmean[i] = m_pos_dedx[i]->GetFunction("gaus")->GetParameter(1);
220 pos_fitmeanerr[i] = m_pos_dedx[i]->GetFunction("gaus")->GetParError(1);
221 pos_fitsigma[i] = m_pos_dedx[i]->GetFunction("gaus")->GetParameter(2);
222 pos_fitchisq[i] = (m_pos_dedx[i]->GetFunction("gaus")->GetChisquare())/(m_pos_dedx[i]->GetFunction("gaus")->GetNDF());
223 }
224 neg_fitentryNo[i] = m_neg_dedx[i]->Integral();
225 if(neg_fitentryNo[i]>100)
226 {
227 neg_fitmean[i] = m_neg_dedx[i]->GetFunction("gaus")->GetParameter(1);
228 neg_fitmeanerr[i] = m_neg_dedx[i]->GetFunction("gaus")->GetParError(1);
229 neg_fitsigma[i] = m_neg_dedx[i]->GetFunction("gaus")->GetParameter(2);
230 neg_fitchisq[i] = (m_neg_dedx[i]->GetFunction("gaus")->GetChisquare())/(m_neg_dedx[i]->GetFunction("gaus")->GetNDF());
231 }
232
233 hits_mean[i] = m_hits[i]->GetMean();
234 hits_sigma[i] = m_hits[i]->GetRMS();
235 }
236
237 double dedx1[Size] = {0};
238 double ptrk1[Size] = {0};
239 cout << "Vec_dedx.size() = " << Vec_dedx.size() << endl;
240 for(int i=0;i<Size && i< Vec_dedx.size();i++)
241 {
242 dedx1[i] = Vec_dedx[i];
243 ptrk1[i] = Vec_ptrk[i];
244 //cout<<"i= "<<i<<"dedx= "<<dedx1[i]<<" ptrk= "<<ptrk1[i]<<endl;
245 }
246
247 log<<MSG::INFO<<"begin generating root file!!! "<<endreq;
248 TFile* f = new TFile(m_rootfile.c_str(), "RECREATE");
249 for(int i=0;i<nbins;i++)
250 {
251 m_chi[i]->Write();
252 m_pos_chi[i]->Write();
253 m_neg_chi[i]->Write();
254 m_dedx[i]->Write();
255 m_pos_dedx[i]->Write();
256 m_neg_dedx[i]->Write();
257 m_hits[i]->Write();
258 }
259
260 TTree* momInfor = new TTree("momInfor","momInfor");
261 momInfor->Branch("chientryNo",chientryNo,"chientryNo[50]/D");
262 momInfor->Branch("chimean",chimean,"chimean[50]/D");
263 momInfor->Branch("chimeanerr",chimeanerr,"chimeanerr[50]/D");
264 momInfor->Branch("chisigma",chisigma,"chisigma[50]/D");
265 momInfor->Branch("chisq",chisq,"chisq[50]/D");
266 momInfor->Branch("pos_chientryNo",pos_chientryNo,"pos_chientryNo[50]/D");
267 momInfor->Branch("pos_chimean",pos_chimean,"pos_chimean[50]/D");
268 momInfor->Branch("pos_chimeanerr",pos_chimeanerr,"pos_chimeanerr[50]/D");
269 momInfor->Branch("pos_chisigma",pos_chisigma,"pos_chisigma[50]/D");
270 momInfor->Branch("pos_chisq",pos_chisq,"pos_chisq[50]/D");
271 momInfor->Branch("neg_chientryNo",neg_chientryNo,"neg_chientryNo[50]/D");
272 momInfor->Branch("neg_chimean",neg_chimean,"neg_chimean[50]/D");
273 momInfor->Branch("neg_chimeanerr",neg_chimeanerr,"neg_chimeanerr[50]/D");
274 momInfor->Branch("neg_chisigma",neg_chisigma,"neg_chisigma[50]/D");
275 momInfor->Branch("neg_chisq",neg_chisq,"neg_chisq[50]/D");
276 momInfor->Branch("fitentryNo",fitentryNo,"fitentryNo[50]/D");
277 momInfor->Branch("fitmean",fitmean,"fitmean[50]/D");
278 momInfor->Branch("fitmeanerr",fitmeanerr,"fitmeanerr[50]/D");
279 momInfor->Branch("fitsigma",fitsigma,"fitsigma[50]/D");
280 momInfor->Branch("fitchisq",fitchisq,"fitchisq[50]/D");
281 momInfor->Branch("pos_fitentryNo",pos_fitentryNo,"pos_fitentryNo[50]/D");
282 momInfor->Branch("pos_fitmean",pos_fitmean,"pos_fitmean[50]/D");
283 momInfor->Branch("pos_fitmeanerr",pos_fitmeanerr,"pos_fitmeanerr[50]/D");
284 momInfor->Branch("pos_fitsigma",pos_fitsigma,"pos_fitsigma[50]/D");
285 momInfor->Branch("pos_fitchisq",pos_fitchisq,"pos_fitchisq[50]/D");
286 momInfor->Branch("neg_fitentryNo",neg_fitentryNo,"neg_fitentryNo[50]/D");
287 momInfor->Branch("neg_fitmean",neg_fitmean,"neg_fitmean[50]/D");
288 momInfor->Branch("neg_fitmeanerr",neg_fitmeanerr,"neg_fitmeanerr[50]/D");
289 momInfor->Branch("neg_fitsigma",neg_fitsigma,"neg_fitsigma[50]/D");
290 momInfor->Branch("neg_fitchisq",neg_fitchisq,"neg_fitchisq[50]/D");
291 momInfor->Branch("hits_mean",hits_mean,"hits_mean[50]/D");
292 momInfor->Branch("hits_sigma",hits_sigma,"hits_sigma[50]/D");
293 momInfor->Branch("pBin",pBin,"pBin[50]/D");
294 momInfor-> Branch("ptrk1",ptrk1,"ptrk1[700000]/D");
295 momInfor-> Branch("dedx1",dedx1,"dedx1[700000]/D");
296 momInfor->Fill();
297 momInfor->Write();
298
299 TCanvas c1("c1", "canvas", 500, 400);
300 c1.Print((m_rootfile+".ps[").c_str());
301 momInfor -> Draw("dedx1:ptrk1","dedx1>200 && dedx1<1200");
302 c1.Print((m_rootfile+".ps").c_str());
303 for(Int_t i=0;i<nbins;i++)
304 {
305 m_chi[i]->Draw();
306 c1.Print((m_rootfile+".ps").c_str());
307 }
308 for(Int_t i=0;i<nbins;i++)
309 {
310 m_pos_chi[i]->Draw();
311 c1.Print((m_rootfile+".ps").c_str());
312 }
313 for(Int_t i=0;i<nbins;i++)
314 {
315 m_neg_chi[i]->Draw();
316 c1.Print((m_rootfile+".ps").c_str());
317 }
318 for(Int_t i=0;i<nbins;i++)
319 {
320 m_dedx[i]->Draw();
321 c1.Print((m_rootfile+".ps").c_str());
322 }
323 for(Int_t i=0;i<nbins;i++)
324 {
325 m_pos_dedx[i]->Draw();
326 c1.Print((m_rootfile+".ps").c_str());
327 }
328 for(Int_t i=0;i<nbins;i++)
329 {
330 m_neg_dedx[i]->Draw();
331 c1.Print((m_rootfile+".ps").c_str());
332 }
333 c1.Print((m_rootfile+".ps]").c_str());
334 f->Close();
335
336 for(int i=0;i<nbins;i++)
337 {
338 delete m_chi[i];
339 delete m_pos_chi[i];
340 delete m_neg_chi[i];
341 delete m_dedx[i];
342 delete m_pos_dedx[i];
343 delete m_neg_dedx[i];
344 delete m_hits[i];
345 }
346}
curve Branch("CurveSize",&CurveSize,"CurveSize/I")
#define Size
std::string m_rootfile
Definition: DedxCalib.h:55
legend Draw()
char * c_str(Index i)
Definition: EvtCyclic3.cc:252

The documentation for this class was generated from the following files: