#include <DedxCalibRunByRun.h>
Inheritance diagram for DedxCalibRunByRun:
Public Member Functions | |
void | AnalyseHists () |
void | AnalyseHists () |
void | BookHists () |
void | BookHists () |
void | checkSelections () |
void | checkSelections () |
DedxCalibRunByRun (const std::string &name, ISvcLocator *pSvcLocator) | |
DedxCalibRunByRun (const std::string &name, ISvcLocator *pSvcLocator) | |
virtual StatusCode | execute () |
virtual StatusCode | execute () |
void | FillHists () |
void | FillHists () |
void | FillHistsFromTree () |
void | FillHistsFromTree () |
void | FillTestHists () |
void | FillTestHists () |
void | FillTree () |
void | FillTree () |
virtual StatusCode | finalize () |
virtual StatusCode | finalize () |
virtual Float_t | GetChargeOffCorr (Int_t il, Int_t iw, Float_t ChargeIn, Float_t path, Float_t doca, Float_t EAngle, Float_t dipAngle, Float_t z) |
virtual Float_t | GetChargeOffCorr (Int_t il, Int_t iw, Float_t ChargeIn, Float_t path, Float_t doca, Float_t EAngle, Float_t dipAngle, Float_t z) |
Float_t | GetChargeOnCorr (Int_t il, Int_t iw, Float_t ChargeIn, Float_t path, Float_t doca, Float_t EAngle, Float_t dipAngle, Float_t z) |
Float_t | GetChargeOnCorr (Int_t il, Int_t iw, Float_t ChargeIn, Float_t path, Float_t doca, Float_t EAngle, Float_t dipAngle, Float_t z) |
virtual StatusCode | initialize () |
virtual StatusCode | initialize () |
void | ReadBetheBlochParameters () |
void | ReadBetheBlochParameters () |
void | ReadCalibdEdxParameters () |
void | ReadCalibdEdxParameters () |
void | WriteCalibdEdxParameters () |
void | WriteCalibdEdxParameters () |
void | WriteHists () |
void | WriteHists () |
Protected Attributes | |
int | calib_flag |
bool | ddgflag |
IDedxCorrecSvc * | exsvc |
IDedxCorrecSvc * | exsvc |
IMdcGeomSvc * | geosvc |
IMdcGeomSvc * | geosvc |
bool | ggsflag |
bool | layergflag |
MsgStream | log |
std::string | m_constrootfile |
int | m_correc_flag |
std::string | m_inputfile |
int | m_par_flag |
int | m_phshape_flag |
std::string | m_rootfile |
bool | wiregflag |
bool | zdepflag |
Private Attributes | |
TH1F * | m_hist |
TH1F * | m_hist |
TObjArray * | m_list |
TObjArray * | m_list |
TRandom * | m_rand |
TRandom * | m_rand |
vector< TH1F * > | m_run_hist |
vector< TH1F * > | m_run_hist |
|
00029 : DedxCalib(name, pSvcLocator) 00030 { 00031 log<<MSG::INFO<<"DedxCalibRunByRun::DedxCalibRunByRun( )..."<<endreq; 00032 }
|
|
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00176 { 00177 log<<MSG::INFO<<"DedxCalibRunByRun::AnalyseHists( )..."<<endreq; 00178 int status=m_hist->Fit("gaus", "Q" ); 00179 RUN_NUM[Run_N] = RunNO2_run; 00180 cout<<"m_hist Fit status: "<<status<<endl; 00181 00182 for(int i=0; i<Run_N+1; i++){ 00183 status=m_run_hist[i]->Fit("gaus", "Q" ); 00184 cout<<"Run "<<RUN_NUM[i]<<" Fit status: "<<status<<endl; 00185 } 00186 00187 cout<<"Run Number == "<<Run_N+1<<endl; 00188 00189 00190 if(m_rootfile=="no rootfile") 00191 { 00192 log << MSG::ERROR<<"no sepcified calibration file path of runbyruncalib "<<endreq; 00193 return; 00194 } 00195 00196 std::string rootpath_run = m_rootfile; 00197 std::string hlabel_rootpath_run; 00198 std::ostringstream strout; 00199 strout << rootpath_run; 00200 hlabel_rootpath_run = strout.str(); 00201 std::cout<<"string run : "<<hlabel_rootpath_run.c_str()<<endl; 00202 00203 TFile fhist(hlabel_rootpath_run.c_str(), "recreate"); 00204 00205 Double_t gainpar, resolpar; 00206 gainpar = m_hist -> GetFunction("gaus") -> GetParameter(1); 00207 resolpar = m_hist -> GetFunction("gaus") -> GetParameter(2); 00208 00209 TTree* gain_all = new TTree("gaincalib", "gaincalib"); 00210 gain_all -> Branch("gain", &gainpar, "gain/D"); 00211 gain_all->Fill(); 00212 TTree* resol_all = new TTree("resolcalib", "resolcalib"); 00213 resol_all -> Branch("resol", &resolpar, "resol/D"); 00214 resol_all->Fill(); 00215 00216 m_hist -> Write(); 00217 gain_all ->Write(); 00218 resol_all ->Write(); 00219 m_list ->Write(); 00220 00221 fhist.Close(); 00222 00223 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00102 {// cout<<"DedxCalibRunByRun::BookHists"<<endl; 00103 log<<MSG::INFO<<"DedxCalibRunByRun::BookHists( )..."<<endreq; 00104 log<<MSG::DEBUG<<" bookhist...1" <<endreq; 00105 m_list = new TObjArray(0); 00106 log<<MSG::DEBUG<<" bookhist...2" <<endreq; 00107 m_rand = new TRandom(); 00108 std::string hlabel; 00109 log<<MSG::DEBUG<<" bookhist...3" <<endreq; 00110 00111 std::ostringstream strout; 00112 strout << "dEdx_Run_"; 00113 hlabel = strout.str(); 00114 m_hist = new TH1F(hlabel.c_str(), hlabel.c_str(), 300,400,1000); 00115 //m_hist = new TH1F(hlabel.c_str(), hlabel.c_str(), 300,350,750); 00116 m_hist->GetXaxis()->SetTitle("dE/dx(eV/1.5cm)"); 00117 m_hist->GetYaxis()->SetTitle("entries/(40eV/1.5cm)"); 00118 00119 for(int i=0; i<100; i++){ 00120 std::string hlabel_1; 00121 std::ostringstream strout; 00122 strout << "dEdx_Run_" <<i; 00123 hlabel_1 = strout.str(); 00124 //std::cout<<"string : "<<hlabel_1.c_str()<<endl; 00125 //TH1F *rung = new TH1F(hlabel_1.c_str(), hlabel_1.c_str(), 300, 400, 1000); 00126 TH1F *rung = new TH1F(hlabel_1.c_str(), hlabel_1.c_str(), 300, 300, 950); 00127 m_run_hist.push_back(rung); 00128 m_list -> Add(rung); 00129 } 00130 }
|
|
|
|
00121 { 00122 log<<MSG::INFO<<"DedxCalib::checkSelections()...."<<endreq; 00123 }
|
|
|
|
00075 { 00076 00077 this->FillTree(); 00078 00079 this->FillHists(); 00080 return StatusCode::SUCCESS; 00081 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00133 { 00134 //cout<<" DedxCalibRunByRun::FillHists"<<endl; 00135 log<<MSG::INFO<<"DedxCalibRunByRun::FillHists( )..."<<endreq; 00136 00137 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader"); 00138 if (!eventHeader) { 00139 log << MSG::FATAL << "Could not find Event Header" << endreq; 00140 return; 00141 } 00142 int event = eventHeader->eventNumber() ; 00143 int run = eventHeader->runNumber(); 00144 //cout<<"run event NO : "<<event<<" run run NO : "<<run<<endl; 00145 log << MSG::INFO << "now begin the event " << event << endreq; 00146 RunNO2_run= run; 00147 if(RunNO1_run==0) RunNO1_run=run; 00148 if(RunNO2_run != RunNO1_run){ 00149 RUN_NUM[Run_N] = RunNO1_run; 00150 Run_N++; 00151 cout<<"RunNO2 = "<<RunNO2_run <<" RunNO1 = "<<RunNO1_run<<" Run_N = "<<Run_N<<endl; 00152 } 00153 RunNO1_run = run; 00154 // retrieve MdcDedxCol reconstructed 00155 SmartDataPtr<RecMdcDedxCol> newexCol(eventSvc(),"/Event/Recon/RecMdcDedxCol"); 00156 if (!newexCol) { 00157 log << MSG::WARNING << "Could not find RecMdcDedxCol" << endreq; 00158 return; 00159 } 00160 log << MSG::INFO << "Begin to retrieve RecMdcDedxCol"<<endreq; 00161 double dedx; 00162 RecMdcDedxCol::iterator it_dedx = newexCol->begin(); 00163 for( ; it_dedx != newexCol->end(); it_dedx++) { 00164 dedx = (*it_dedx)->probPH(); 00165 log << MSG::DEBUG << "retrieved MDC dE/dx:" 00166 << " measured dEdx: " << dedx << endreq; 00167 //cout<<"track id : "<<(*it_dedx)->trackId()<<" measured dEdx: "<<(*it_dedx)->probPH()<<endl; 00168 m_hist->Fill(dedx); 00169 m_run_hist[Run_N] ->Fill(dedx); 00170 } 00171 00172 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00227 { 00228 log<<MSG::INFO<<"DedxCalibRunByRun::FillHistsFromTree( )..."<<endreq; 00229 }
|
|
|
|
00117 { 00118 log<<MSG::INFO<<"DedxCalib::FillTestHists()...."<<endreq; 00119 }
|
|
|
|
00105 { 00106 log<<MSG::INFO<<"DedxCalib::FillTree()...."<<endreq; 00107 }
|
|
|
|
00084 { 00085 00086 log << MSG::INFO << "DedxCalib finalize() ..." << endreq; 00087 this->AnalyseHists(); 00088 00089 this->WriteCalibdEdxParameters(); 00090 this->WriteHists(); 00091 00092 this->FillTestHists(); 00093 00094 00095 00096 return StatusCode::SUCCESS; 00097 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00037 { 00038 log<<MSG::INFO<<"DedxCalibRunByRun::GetChargeOffCorr( )..."<<endreq; 00039 return 1.0; 00040 }
|
|
|
|
00127 { 00128 00129 }
|
|
|
|
00035 { 00036 log << MSG::INFO << "DedxCalib initialze() ..." << endreq; 00037 /*StatusCode scint = Service::initialize(); 00038 if( scint.isFailure() ) return scint; 00039 IIncidentSvc* incsvc; 00040 scint = service("IncidentSvc", incsvc); 00041 int priority = 100; 00042 if( sc.isSuccess() ){ 00043 incsvc -> addListener(this, "BeginEvent", priority); 00044 //incsvc -> addListener(this, "NewRun", priority); 00045 }*/ 00046 00047 StatusCode sc = service("MdcGeomSvc", geosvc); 00048 if (sc == StatusCode::SUCCESS) { 00049 log << MSG::INFO <<"MdcGeomSvc is running"<<endl; 00050 } else { 00051 log << MSG::ERROR <<"MdcGeomSvc is failed"<<endl; 00052 return StatusCode::SUCCESS; 00053 } 00054 00055 StatusCode scex = service("DedxCorrecSvc", exsvc); 00056 if (scex == StatusCode::SUCCESS) { 00057 log << MSG::INFO <<"Hi, DedxCorrectSvc is running"<<endl; 00058 } else { 00059 log << MSG::ERROR <<"DedxCorrectSvc is failed"<<endl; 00060 return StatusCode::SUCCESS; 00061 } 00062 00063 exsvc->set_flag( calib_flag ); 00064 this->checkSelections(); 00065 log << MSG::INFO <<"DedxCalib: read correction parameters"<<endreq; 00066 this->ReadCalibdEdxParameters(); 00067 this->FillHistsFromTree(); 00068 00069 this->BookHists(); 00070 00071 return StatusCode::SUCCESS; 00072 }
|
|
|
|
|
|
|
|
00109 { 00110 log<<MSG::INFO<<"DedxCalib::ReadCalibdEdxParameters()...."<<endreq; 00111 }
|
|
Reimplemented from DedxCalib. |
|
Reimplemented from DedxCalib. 00232 { 00233 log<<MSG::INFO<<"DedxCalibRunByRun::WriteCalibdEdxParameters( )..."<<endreq; 00234 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00044 { 00045 00046 log<<MSG::INFO<<"DedxCalibRunByRun::WriteHists( )..."<<endreq; 00047 00048 Int_t runno; 00049 Double_t runmean, rungain, runresol; 00050 TTree* runbyrun = new TTree("runcalib", "runcalib"); 00051 runbyrun -> Branch("runno", &runno, "runno/I"); 00052 runbyrun -> Branch("runmean", &runmean, "runmean/D"); 00053 runbyrun -> Branch("rungain", &rungain, "rungain/D"); 00054 runbyrun -> Branch("runresol", &runresol, "runresol/D"); 00055 00056 for(int i=0; i<Run_N+1; i++){ 00057 runno = RUN_NUM[i]; 00058 m_run_hist[i]->Fit("gaus", "Q" ); 00059 runmean = m_run_hist[i] -> GetFunction("gaus") -> GetParameter(1); 00060 runresol = m_run_hist[i] -> GetFunction("gaus") -> GetParameter(2); 00061 rungain = runmean/NormalMean; 00062 cout<<"i = "<<i<<" runno = "<<runno <<" @ runmean = "<<runmean<<" @ rungain = "<<rungain<<" @ runresol = "<<runresol<<endl; 00063 runbyrun -> Fill(); 00064 } 00065 00066 Double_t gainpar, resolpar; 00067 gainpar = m_hist -> GetFunction("gaus") -> GetParameter(1); 00068 resolpar = m_hist -> GetFunction("gaus") -> GetParameter(2); 00069 00070 delete m_hist; 00071 for(int i=0; i<100; i++) delete m_run_hist[i]; 00072 delete m_list; 00073 delete m_rand; 00074 00075 TTree* gain = new TTree("gaincalib", "gaincalib"); 00076 gain -> Branch("gain", &gainpar, "gain[1]/D"); 00077 gain->Fill(); 00078 TTree* resol = new TTree("resolcalib", "resolcalib"); 00079 resol -> Branch("resol", &resolpar, "resol[1]/D"); 00080 resol->Fill(); 00081 00082 std::string rootpath_dedxconst = m_constrootfile; 00083 std::string hlabel_rootpath_dedxconst; 00084 std::ostringstream strout1; 00085 strout1 << rootpath_dedxconst; 00086 hlabel_rootpath_dedxconst = strout1.str(); 00087 std::cout<<"string const : "<<hlabel_rootpath_dedxconst.c_str()<<endl; 00088 TFile fdedx(hlabel_rootpath_dedxconst.c_str(), "recreate"); 00089 gain->Write(); 00090 resol->Write(); 00091 runbyrun ->Write(); 00092 00093 00094 delete runbyrun; 00095 delete gain; 00096 delete resol; 00097 00098 fdedx.Close(); 00099 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|