45 MsgStream log(
msgSvc(), name() );
46 log << MSG::INFO <<
"DedxCalibRunByRun::FillHists()" << endmsg;
53 double dEdx[100] = { 0 }, pathlength[100] = { 0 }, wid[100] = { 0 }, layid[100] = { 0 },
54 dd_in[100] = { 0 }, eangle[100] = { 0 }, zhit[100] = { 0 };
56 float runNO = 0, evtNO = 0, runFlag = 0, costheta = 0, tes = 0;
57 vector<double> phlist;
58 for (
int i = 0; i <
runNo; i++ )
61 f =
new TFile( runlist.c_str() );
62 n103 = (TTree*)
f->Get(
"n103" );
63 n103->SetBranchAddress(
"ndedxhit", &ndedxhit );
64 n103->SetBranchAddress(
"dEdx_hit", dEdx );
65 n103->SetBranchAddress(
"pathlength_hit", pathlength );
66 n103->SetBranchAddress(
"wid_hit", wid );
67 n103->SetBranchAddress(
"layid_hit", layid );
68 n103->SetBranchAddress(
"dd_in_hit", dd_in );
69 n103->SetBranchAddress(
"eangle_hit", eangle );
70 n103->SetBranchAddress(
"zhit_hit", zhit );
71 n103->SetBranchAddress(
"runNO", &runNO );
72 n103->SetBranchAddress(
"evtNO", &evtNO );
73 n103->SetBranchAddress(
"runFlag", &runFlag );
74 n103->SetBranchAddress(
"costheta", &costheta );
75 n103->SetBranchAddress(
"t0", &tes );
79 struct runevt m_runevt;
80 for (
int j = 0; j < n103->GetEntries(); j++ )
84 for (
int k = 0; k < ndedxhit; k++ )
86 dEdx[k] =
exsvc->StandardHitCorrec( 0, runFlag, 2, runNO, evtNO, pathlength[k], wid[k],
87 layid[k], dEdx[k], dd_in[k], eangle[k], costheta );
88 phlist.push_back( dEdx[k] );
91 dedx =
exsvc->StandardTrackCorrec( 0, runFlag, 2, runNO, evtNO, dedx, costheta, tes );
97 m_runevt.runno = runNO;
98 m_runevt.evtfrom = evtfrom;
99 m_runevt.evtto = evtNO;
101 m_runevt.local_index = index;
102 m_evtNOVector.push_back( m_runevt );
109 log << MSG::FATAL <<
"DedxCalibRunByRun: Too many events in a run!!!" << endmsg;
113 if ( index ) m_evtNOVector.pop_back();
116 m_runevt.runno = runNO;
117 m_runevt.evtfrom = 0;
119 m_runevt.local_index = 0;
122 m_evtNOVector.push_back( m_runevt );
123 cout <<
"runNO = " << m_runevt.runno << endl;
140 MsgStream log(
msgSvc(), name() );
141 log << MSG::INFO <<
"DedxCalibRunByRun::WriteHists()" << endmsg;
143 TFile*
f =
new TFile(
m_rootfile.c_str(),
"recreate" );
145 Double_t gainpar = 0, resolpar = 0;
146 gainpar = m_hist->GetFunction(
"gaus" )->GetParameter( 1 );
147 resolpar = m_hist->GetFunction(
"gaus" )->GetParameter( 2 );
149 TTree* gain =
new TTree(
"gaincalib",
"gaincalib" );
150 gain->Branch(
"gain", &gainpar,
"gain[1]/D" );
152 TTree* resol =
new TTree(
"resolcalib",
"resolcalib" );
153 resol->Branch(
"resol", &resolpar,
"resol[1]/D" );
156 Int_t runno( 0 ), evtfrom( 0 ), evtto( 0 ), index( 0 ), global_index( 0 );
157 Double_t runmean = 0, rungain = 0, runresol = 0;
158 TTree* runbyrun =
new TTree(
"runcalib",
"runcalib" );
159 runbyrun->Branch(
"runno", &runno,
"runno/I" );
160 runbyrun->Branch(
"index", &index,
"index/I" );
161 runbyrun->Branch(
"evtfrom", &evtfrom,
"evtfrom/I" );
162 runbyrun->Branch(
"evtto", &evtto,
"evtto/I" );
163 runbyrun->Branch(
"runmean", &runmean,
"runmean/D" );
164 runbyrun->Branch(
"rungain", &rungain,
"rungain/D" );
165 runbyrun->Branch(
"runresol", &runresol,
"runresol/D" );
166 vector<struct runevt>::iterator p;
167 p = m_evtNOVector.begin();
168 while ( p != m_evtNOVector.end() )
170 runno = ( *p ).runno;
171 evtfrom = ( *p ).evtfrom;
172 evtto = ( *p ).evtto;
173 index = ( *p ).local_index;
174 global_index = ( *p ).global_index;
175 runmean = m_rungain[global_index]->GetFunction(
"gaus" )->GetParameter( 1 );
176 runresol = m_rungain[global_index]->GetFunction(
"gaus" )->GetParameter( 2 );
178 cout <<
" runno = " << runno <<
" @ evtfrom = " << evtfrom <<
" @ evtto " << evtto
179 <<
" @ index " << index <<
" @ runmean = " << runmean
180 <<
" @ rungain = " << rungain <<
" @ runresol = " << runresol << endl;
182 m_rungain[global_index]->Write();
192 for (
int i = 0; i <
runNo; i++ )