1#include "GaudiKernel/MsgStream.h"
10#include "DedxCalibAlg/DedxCalibRunByRun.h"
21 MsgStream log(
msgSvc(), name());
22 log<<MSG::INFO<<
"DedxCalibRunByRun::BookHists()"<<endreq;
28 m_hist->GetXaxis()->SetTitle(
"dE/dx");
29 m_hist->GetYaxis()->SetTitle(
"entries");
32 for(
int i=0; i<
runNo; i++)
36 hlabel<<
"dEdx_Run_"<<i <<
"_sub_" << j ;
44 MsgStream log(
msgSvc(), name());
45 log<<MSG::INFO<<
"DedxCalibRunByRun::FillHists()"<<endreq;
52 double dEdx[100]={0},pathlength[100]={0},wid[100]={0},layid[100]={0},dd_in[100]={0},eangle[100]={0},zhit[100]={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++)
59 f =
new TFile(runlist.c_str());
60 n103 = (TTree*)
f->Get(
"n103");
77 struct runevt m_runevt;
78 for(
int j=0;j<n103->GetEntries();j++)
82 for(
int k=0;k<ndedxhit;k++)
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]);
94 m_runevt.runno = runNO;
95 m_runevt.evtfrom = evtfrom;
96 m_runevt.evtto = evtNO;
98 m_runevt.local_index = index;
99 m_evtNOVector.push_back(m_runevt);
105 log<<MSG::FATAL<<
"DedxCalibRunByRun: Too many events in a run!!!"<<endreq;
109 if(index) m_evtNOVector.pop_back();
111 m_runevt.runno = runNO;
112 m_runevt.evtfrom = 0;
114 m_runevt.local_index = 0;
117 m_evtNOVector.push_back(m_runevt);
118 cout<<
"runNO = "<< m_runevt.runno << endl;
124 MsgStream log(
msgSvc(), name());
125 log<<MSG::INFO<<
"DedxCalibRunByRun::AnalyseHists()"<<endreq;
127 m_hist->Fit(
"gaus",
"Q" );
128 for(
int i=0; i<
runNo; i++)
139 MsgStream log(
msgSvc(), name());
140 log<<MSG::INFO<<
"DedxCalibRunByRun::WriteHists()"<<endreq;
142 TFile*
f =
new TFile(
m_rootfile.c_str(),
"recreate");
144 Double_t gainpar=0, resolpar=0;
145 gainpar = m_hist -> GetFunction(
"gaus") -> GetParameter(1);
146 resolpar = m_hist -> GetFunction(
"gaus") -> GetParameter(2);
148 TTree* gain =
new TTree(
"gaincalib",
"gaincalib");
149 gain ->
Branch(
"gain", &gainpar,
"gain[1]/D");
151 TTree* resol =
new TTree(
"resolcalib",
"resolcalib");
152 resol ->
Branch(
"resol", &resolpar,
"resol[1]/D");
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())
170 evtfrom = (*p).evtfrom;
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);
177 cout<<
" runno = "<< runno <<
" @ evtfrom = " << evtfrom <<
" @ evtto " << evtto <<
" @ index " << index <<
" @ runmean = "<<runmean<<
" @ rungain = "<<rungain<<
" @ runresol = "<<runresol<<endl;
179 m_rungain[global_index]->Write();
189 for(
int i=0; i<
runNo; i++)
curve Branch("CurveSize",&CurveSize,"CurveSize/I")
data SetBranchAddress("time",&time)
#define NumEvtBlocksInRun
DedxCalibRunByRun(const std::string &name, ISvcLocator *pSvcLocator)
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")