BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
DedxCalibRunByRun Class Reference

#include <DedxCalibRunByRun.h>

+ Inheritance diagram for DedxCalibRunByRun:

Public Member Functions

 DedxCalibRunByRun (const std::string &name, ISvcLocator *pSvcLocator)
 
 ~DedxCalibRunByRun ()
 
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 ()
 

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 9 of file DedxCalibRunByRun.h.

Constructor & Destructor Documentation

◆ DedxCalibRunByRun()

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

Definition at line 16 of file DedxCalibRunByRun.cxx.

16: DedxCalib(name, pSvcLocator){}
DedxCalib(const std::string &name, ISvcLocator *pSvcLocator)
Definition DedxCalib.cxx:12

◆ ~DedxCalibRunByRun()

DedxCalibRunByRun::~DedxCalibRunByRun ( )
inline

Definition at line 13 of file DedxCalibRunByRun.h.

13{};

Member Function Documentation

◆ AnalyseHists()

void DedxCalibRunByRun::AnalyseHists ( )
virtual

Implements DedxCalib.

Definition at line 122 of file DedxCalibRunByRun.cxx.

123{
124 MsgStream log(msgSvc(), name());
125 log<<MSG::INFO<<"DedxCalibRunByRun::AnalyseHists()"<<endreq;
126
127 m_hist->Fit("gaus", "Q" );
128 for(int i=0; i<runNo; i++)
129 {
130 for(int j=0; j<NumEvtBlocksInRun; j++)
131 {
132 m_rungain[i*NumEvtBlocksInRun+j]->Fit("gaus", "Q" );
133 }
134 }
135}
int runNo
Definition DQA_TO_DB.cxx:12
#define NumEvtBlocksInRun
IMessageSvc * msgSvc()

◆ BookHists()

void DedxCalibRunByRun::BookHists ( )
virtual

Implements DedxCalib.

Definition at line 19 of file DedxCalibRunByRun.cxx.

20{
21 MsgStream log(msgSvc(), name());
22 log<<MSG::INFO<<"DedxCalibRunByRun::BookHists()"<<endreq;
23
25 runNo = m_recFileVector.size();
26
27 m_hist = new TH1F("dEdx_allRun","dEdx_allRun",NumHistBins,MinHistValue1,MaxHistValue1);
28 m_hist->GetXaxis()->SetTitle("dE/dx");
29 m_hist->GetYaxis()->SetTitle("entries");
30 m_rungain = new TH1F*[runNo*NumEvtBlocksInRun];
31 stringstream hlabel;
32 for(int i=0; i<runNo; i++)
33 {
34 for(int j=0; j<NumEvtBlocksInRun; j++){
35 hlabel.str("");
36 hlabel<<"dEdx_Run_"<<i << "_sub_" << j ;
37 m_rungain[i*NumEvtBlocksInRun+j] = new TH1F(hlabel.str().c_str(), hlabel.str().c_str(),NumHistBins,MinHistValue1,MaxHistValue1);
38 }
39 }
40}
#define MinHistValue1
#define MaxHistValue1
#define NumHistBins
void ReadRecFileList()
Definition DedxCalib.cxx:89
vector< string > m_recFileVector
Definition DedxCalib.h:48

◆ FillHists()

void DedxCalibRunByRun::FillHists ( )
virtual

Implements DedxCalib.

Definition at line 42 of file DedxCalibRunByRun.cxx.

43{
44 MsgStream log(msgSvc(), name());
45 log<<MSG::INFO<<"DedxCalibRunByRun::FillHists()"<<endreq;
46
47 TFile* f;
48 TTree* n103;
49 string runlist;
50
51 int ndedxhit=0;
52 double dEdx[100]={0},pathlength[100]={0},wid[100]={0},layid[100]={0},dd_in[100]={0},eangle[100]={0},zhit[100]={0};
53 double dedx=0;
54 float runNO=0, evtNO=0, runFlag=0,costheta=0,tes=0;
55 vector<double> phlist;
56 for(int i=0; i<runNo; i++)
57 {
58 runlist = m_recFileVector[i];
59 f = new TFile(runlist.c_str());
60 n103 = (TTree*)f->Get("n103");
61 n103-> SetBranchAddress("ndedxhit", &ndedxhit);
62 n103-> SetBranchAddress("dEdx_hit",dEdx);
63 n103-> SetBranchAddress("pathlength_hit",pathlength);
64 n103-> SetBranchAddress("wid_hit",wid);
65 n103-> SetBranchAddress("layid_hit",layid);
66 n103-> SetBranchAddress("dd_in_hit",dd_in);
67 n103-> SetBranchAddress("eangle_hit",eangle);
68 n103-> SetBranchAddress("zhit_hit",zhit);
69 n103-> SetBranchAddress("runNO",&runNO);
70 n103-> SetBranchAddress("evtNO",&evtNO);
71 n103-> SetBranchAddress("runFlag",&runFlag);
72 n103-> SetBranchAddress("costheta",&costheta);
73 n103-> SetBranchAddress("t0",&tes);
74 int m(0); // count for events in a block
75 int index(0);
76 float evtfrom(0);
77 struct runevt m_runevt;
78 for(int j=0;j<n103->GetEntries();j++)
79 {
80 phlist.clear();
81 n103->GetEntry(j);
82 for(int k=0;k<ndedxhit;k++)
83 {
84 dEdx[k] = exsvc->StandardHitCorrec(0,runFlag,2,runNO, evtNO, pathlength[k],wid[k],layid[k],dEdx[k],dd_in[k],eangle[k],costheta);
85 phlist.push_back(dEdx[k]);
86 }
87 dedx = cal_dedx_bitrunc(truncate, phlist);
88 dedx = exsvc->StandardTrackCorrec(0, runFlag, 2, runNO, evtNO, dedx, costheta, tes);
89 m_rungain[i*NumEvtBlocksInRun+index]->Fill(dedx);
90 m_hist->Fill(dedx);
91 m++;
92 if(m==NumEvtInBlocks)
93 {
94 m_runevt.runno = runNO;
95 m_runevt.evtfrom = evtfrom;
96 m_runevt.evtto = evtNO;
97 m_runevt.global_index = i*NumEvtBlocksInRun+index;
98 m_runevt.local_index = index;
99 m_evtNOVector.push_back(m_runevt);
100 evtfrom = evtNO +1;
101 index ++;
102 m = 0;
103 }
104 if(index==NumEvtBlocksInRun){
105 log<<MSG::FATAL<<"DedxCalibRunByRun: Too many events in a run!!!"<<endreq;
106 break;
107 }
108 }
109 if(index) m_evtNOVector.pop_back();
110 else{
111 m_runevt.runno = runNO;
112 m_runevt.evtfrom = 0;
113 m_runevt.global_index = i*NumEvtBlocksInRun;
114 m_runevt.local_index = 0;
115 }
116 m_runevt.evtto = MaxNumEvt;
117 m_evtNOVector.push_back(m_runevt);
118 cout<<"runNO = "<< m_runevt.runno << endl;
119 }
120}
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
data SetBranchAddress("time",&time)
#define NumEvtInBlocks
#define MaxNumEvt
IDedxCorrecSvc * exsvc
Definition DedxCalib.h:30
double cal_dedx_bitrunc(float truncate, std::vector< double > phlist)
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
float costheta

◆ genNtuple()

void DedxCalibRunByRun::genNtuple ( )
inlinevirtual

Implements DedxCalib.

Definition at line 16 of file DedxCalibRunByRun.h.

16{}

◆ initializing()

void DedxCalibRunByRun::initializing ( )
inlinevirtual

Implements DedxCalib.

Definition at line 14 of file DedxCalibRunByRun.h.

14{}

◆ WriteHists()

void DedxCalibRunByRun::WriteHists ( )
virtual

Implements DedxCalib.

Definition at line 137 of file DedxCalibRunByRun.cxx.

138{
139 MsgStream log(msgSvc(), name());
140 log<<MSG::INFO<<"DedxCalibRunByRun::WriteHists()"<<endreq;
141
142 TFile* f = new TFile(m_rootfile.c_str(), "recreate");
143
144 Double_t gainpar=0, resolpar=0;
145 gainpar = m_hist -> GetFunction("gaus") -> GetParameter(1);
146 resolpar = m_hist -> GetFunction("gaus") -> GetParameter(2);
147
148 TTree* gain = new TTree("gaincalib", "gaincalib");
149 gain -> Branch("gain", &gainpar, "gain[1]/D");
150 gain->Fill();
151 TTree* resol = new TTree("resolcalib", "resolcalib");
152 resol -> Branch("resol", &resolpar, "resol[1]/D");
153 resol->Fill();
154
155 Int_t runno(0), evtfrom(0), evtto(0), index(0), global_index(0);
156 Double_t runmean=0, rungain=0, runresol=0;
157 TTree* runbyrun = new TTree("runcalib", "runcalib");
158 runbyrun -> Branch("runno", &runno, "runno/I");
159 runbyrun -> Branch("index", &index, "index/I");
160 runbyrun -> Branch("evtfrom", &evtfrom, "evtfrom/I");
161 runbyrun -> Branch("evtto", &evtto, "evtto/I");
162 runbyrun -> Branch("runmean", &runmean, "runmean/D");
163 runbyrun -> Branch("rungain", &rungain, "rungain/D");
164 runbyrun -> Branch("runresol", &runresol, "runresol/D");
165 vector<struct runevt>::iterator p;
166 p = m_evtNOVector.begin();
167 while(p != m_evtNOVector.end())
168 {
169 runno = (*p).runno;
170 evtfrom = (*p).evtfrom;
171 evtto = (*p).evtto;
172 index = (*p).local_index;
173 global_index = (*p).global_index;
174 runmean = m_rungain[global_index] -> GetFunction("gaus") -> GetParameter(1);
175 runresol = m_rungain[global_index] -> GetFunction("gaus") -> GetParameter(2);
176 rungain = runmean/NormalMean;
177 cout<<" runno = "<< runno << " @ evtfrom = " << evtfrom << " @ evtto " << evtto << " @ index " << index << " @ runmean = "<<runmean<<" @ rungain = "<<rungain<<" @ runresol = "<<runresol<<endl;
178 runbyrun -> Fill();
179 m_rungain[global_index]->Write();
180 p++;
181 }
182
183 m_hist->Write();
184 gain->Write();
185 resol -> Write();
186 runbyrun -> Write();
187
188 delete m_hist;
189 for(int i=0; i<runNo; i++)
190 {
191 for(int j=0; j<NumEvtBlocksInRun; j++) delete m_rungain[i*NumEvtBlocksInRun+j];
192 }
193 delete gain;
194 delete resol;
195 delete runbyrun;
196 f->Close();
197}
curve Branch("CurveSize",&CurveSize,"CurveSize/I")
curve Fill()
curve Write()
#define NormalMean
std::string m_rootfile
Definition DedxCalib.h:55

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