#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 () |
StatusCode | initialize () |
StatusCode | execute () |
StatusCode | finalize () |
Protected Member Functions | |
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 | |
IMdcGeomSvc * | geosvc |
IDedxCorrecSvc * | exsvc |
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 |
Private Attributes | |
vector< float > | m_runNOVector |
TH1F ** | m_rungain |
TH1F * | m_hist |
Definition at line 9 of file DedxCalibRunByRun.h.
DedxCalibRunByRun::DedxCalibRunByRun | ( | const std::string & | name, | |
ISvcLocator * | pSvcLocator | |||
) |
DedxCalibRunByRun::~DedxCalibRunByRun | ( | ) | [inline] |
void DedxCalibRunByRun::AnalyseHists | ( | ) | [virtual] |
Implements DedxCalib.
Definition at line 90 of file DedxCalibRunByRun.cxx.
References genRecEmupikp::i, Bes_Common::INFO, m_hist, m_rungain, msgSvc(), and runNo.
00091 { 00092 MsgStream log(msgSvc(), name()); 00093 log<<MSG::INFO<<"DedxCalibRunByRun::AnalyseHists()"<<endreq; 00094 00095 m_hist->Fit("gaus", "Q" ); 00096 for(int i=0; i<runNo; i++) 00097 { 00098 m_rungain[i]->Fit("gaus", "Q" ); 00099 } 00100 }
void DedxCalibRunByRun::BookHists | ( | ) | [virtual] |
Implements DedxCalib.
Definition at line 19 of file DedxCalibRunByRun.cxx.
References genRecEmupikp::i, Bes_Common::INFO, m_hist, DedxCalib::m_recFileVector, m_rungain, MaxHistValue1, MinHistValue1, msgSvc(), NumHistBins, DedxCalib::ReadRecFileList(), and runNo.
00020 { 00021 MsgStream log(msgSvc(), name()); 00022 log<<MSG::INFO<<"DedxCalibRunByRun::BookHists()"<<endreq; 00023 00024 ReadRecFileList(); 00025 runNo = m_recFileVector.size(); 00026 00027 m_hist = new TH1F("dEdx_allRun","dEdx_allRun",NumHistBins,MinHistValue1,MaxHistValue1); 00028 m_hist->GetXaxis()->SetTitle("dE/dx"); 00029 m_hist->GetYaxis()->SetTitle("entries"); 00030 m_rungain = new TH1F*[runNo]; 00031 stringstream hlabel; 00032 for(int i=0; i<runNo; i++) 00033 { 00034 hlabel.str(""); 00035 hlabel<<"dEdx_Run_"<<i; 00036 m_rungain[i] = new TH1F(hlabel.str().c_str(), hlabel.str().c_str(),NumHistBins,MinHistValue1,MaxHistValue1); 00037 } 00038 }
double DedxCalib::cal_dedx | ( | float | truncate, | |
std::vector< double > | phlist | |||
) | [protected, inherited] |
Definition at line 127 of file DedxCalib.cxx.
References genRecEmupikp::i.
00128 { 00129 sort(phlist.begin(),phlist.end()); 00130 int smpl = (int)(phlist.size()*(truncate+0.05)); 00131 int min_cut = 0; 00132 double qSum = 0; 00133 unsigned i = 0; 00134 for(vector<double>::iterator ql= phlist.begin();ql!=phlist.end();ql++) 00135 { 00136 i++; 00137 if(i<= smpl && i>=min_cut ) qSum += (*ql); 00138 } 00139 double trunc=-99; 00140 int usedhit = smpl-min_cut+1; 00141 if(usedhit>0) trunc=qSum/usedhit; 00142 00143 return trunc; 00144 }
double DedxCalib::cal_dedx_bitrunc | ( | float | truncate, | |
std::vector< double > | phlist | |||
) | [protected, inherited] |
Definition at line 108 of file DedxCalib.cxx.
References genRecEmupikp::i.
Referenced by DedxCalibLayerGain::AnalyseHists(), FillHists(), DedxCalibMomentum::FillHists(), and DedxCalibCostheta::FillHists().
00109 { 00110 sort(phlist.begin(),phlist.end()); 00111 int smpl = (int)(phlist.size()*(truncate+0.05)); 00112 int min_cut = (int)( phlist.size()*0.05 + 0.5 ); 00113 double qSum = 0; 00114 unsigned i = 0; 00115 for(vector<double>::iterator ql= phlist.begin();ql!=phlist.end();ql++) 00116 { 00117 i++; 00118 if(i<= smpl && i>=min_cut ) qSum += (*ql); 00119 } 00120 double trunc=-99; 00121 int usedhit = smpl-min_cut+1; 00122 if(usedhit>0) trunc=qSum/usedhit; 00123 00124 return trunc; 00125 }
StatusCode DedxCalib::execute | ( | ) | [inherited] |
Definition at line 56 of file DedxCalib.cxx.
References DedxCalib::AnalyseHists(), DedxCalib::FillHists(), DedxCalib::genNtuple(), Bes_Common::INFO, msgSvc(), and DedxCalib::WriteHists().
00057 { 00058 MsgStream log(msgSvc(), name()); 00059 log << MSG::INFO << "DedxCalib execute()" << endreq; 00060 00061 genNtuple(); 00062 FillHists(); 00063 AnalyseHists(); 00064 WriteHists(); 00065 00066 return StatusCode::SUCCESS; 00067 }
void DedxCalibRunByRun::FillHists | ( | ) | [virtual] |
Implements DedxCalib.
Definition at line 40 of file DedxCalibRunByRun.cxx.
References DedxCalib::cal_dedx_bitrunc(), DedxCalib::exsvc, genRecEmupikp::i, Bes_Common::INFO, ganga-rec::j, m_hist, DedxCalib::m_recFileVector, m_rungain, m_runNOVector, msgSvc(), runNo, IDedxCorrecSvc::StandardHitCorrec(), IDedxCorrecSvc::StandardTrackCorrec(), deljobs::string, and DedxCalib::truncate.
00041 { 00042 MsgStream log(msgSvc(), name()); 00043 log<<MSG::INFO<<"DedxCalibRunByRun::FillHists()"<<endreq; 00044 00045 TFile* f; 00046 TTree* n103; 00047 string runlist; 00048 00049 int ndedxhit=0; 00050 double dEdx[100]={0},pathlength[100]={0},wid[100]={0},layid[100]={0},dd_in[100]={0},eangle[100]={0},zhit[100]={0}; 00051 double dedx=0; 00052 float runNO=0,runFlag=0,costheta=0,tes=0; 00053 vector<double> phlist; 00054 for(int i=0; i<runNo; i++) 00055 { 00056 runlist = m_recFileVector[i]; 00057 f = new TFile(runlist.c_str()); 00058 n103 = (TTree*)f->Get("n103"); 00059 n103-> SetBranchAddress("ndedxhit", &ndedxhit); 00060 n103-> SetBranchAddress("dEdx_hit",dEdx); 00061 n103-> SetBranchAddress("pathlength_hit",pathlength); 00062 n103-> SetBranchAddress("wid_hit",wid); 00063 n103-> SetBranchAddress("layid_hit",layid); 00064 n103-> SetBranchAddress("dd_in_hit",dd_in); 00065 n103-> SetBranchAddress("eangle_hit",eangle); 00066 n103-> SetBranchAddress("zhit_hit",zhit); 00067 n103-> SetBranchAddress("runNO",&runNO); 00068 n103-> SetBranchAddress("runFlag",&runFlag); 00069 n103-> SetBranchAddress("costheta",&costheta); 00070 n103-> SetBranchAddress("t0",&tes); 00071 for(int j=0;j<n103->GetEntries();j++) 00072 { 00073 phlist.clear(); 00074 n103->GetEntry(j); 00075 for(int k=0;k<ndedxhit;k++) 00076 { 00077 dEdx[k] = exsvc->StandardHitCorrec(0,runFlag,2,runNO,pathlength[k],wid[k],layid[k],dEdx[k],dd_in[k],eangle[k],costheta); 00078 phlist.push_back(dEdx[k]); 00079 } 00080 dedx = cal_dedx_bitrunc(truncate, phlist); 00081 dedx = exsvc->StandardTrackCorrec(0, runFlag, 2, runNO, dedx, costheta, tes); 00082 m_rungain[i]->Fill(dedx); 00083 m_hist->Fill(dedx); 00084 } 00085 cout<<"runNO = "<<runNO<<endl; 00086 m_runNOVector.push_back(runNO); 00087 } 00088 }
StatusCode DedxCalib::finalize | ( | ) | [inherited] |
Definition at line 69 of file DedxCalib.cxx.
References Bes_Common::INFO, and msgSvc().
00070 { 00071 MsgStream log(msgSvc(), name()); 00072 log << MSG::INFO << "DedxCalib finalize()" << endreq; 00073 00074 return StatusCode::SUCCESS; 00075 }
void DedxCalibRunByRun::genNtuple | ( | ) | [inline, virtual] |
void DedxCalib::getCurvePar | ( | ) | [protected, inherited] |
Definition at line 146 of file DedxCalib.cxx.
References DedxCalib::Curve_Para, genRecEmupikp::i, DedxCalib::m_curvefile, Sigma, DedxCalib::Sigma_Para, and DedxCalib::vFlag.
Referenced by DedxCalib::initialize().
00148 { 00149 if(m_curvefile=="no rootfile") 00150 { 00151 cout<<"no curve file! can not calculate chi!!! "<<endl; 00152 return; 00153 } 00154 00155 double Curve[100]; 00156 double Sigma[100]; 00157 int CurveSize,SigmaSize; 00158 TFile* f = new TFile(m_curvefile.c_str()); 00159 TTree *curve = (TTree*) f->Get("curve"); 00160 TTree *sigma = (TTree*) f->Get("sigma"); 00161 curve->SetBranchAddress("CurveSize",&CurveSize); 00162 curve->SetBranchAddress("curve",Curve); 00163 sigma->SetBranchAddress("SigmaSize",&SigmaSize); 00164 sigma->SetBranchAddress("sigma",Sigma); 00165 curve->GetEntry(0); 00166 sigma->GetEntry(0); 00167 00168 for(int i=0; i<CurveSize; i++) // get the dedx curve parameters 00169 { 00170 cout<<Curve[i]<<endl; 00171 if(i==0) vFlag[0] = (int) Curve[i]; //first element is dedx curve version 00172 else Curve_Para.push_back(Curve[i]); //dedx curve parameters 00173 } 00174 for(int i=0; i<SigmaSize; i++) 00175 { 00176 cout<<Sigma[i]<<endl; 00177 if(i==0) vFlag[1] = (int) Sigma[i]; //dedx sigma version: 2: psip; 3:jpsi 00178 else Sigma_Para.push_back(Sigma[i]); //dedx sigma parameters 00179 } 00180 //if(runflag>0) vFlag[2]=0; 00181 //else vFlag[2]=1; 00182 }
StatusCode DedxCalib::initialize | ( | ) | [inherited] |
Definition at line 24 of file DedxCalib.cxx.
References DedxCalib::BookHists(), calibUtil::ERROR, DedxCalib::exsvc, DedxCalib::geosvc, DedxCalib::getCurvePar(), Bes_Common::INFO, DedxCalib::initializing(), DedxCalib::m_calibflag, msgSvc(), and IDedxCorrecSvc::set_flag().
00025 { 00026 MsgStream log(msgSvc(), name()); 00027 log << MSG::INFO << "DedxCalib initialze()" << endreq; 00028 00029 StatusCode gesc = service("MdcGeomSvc", geosvc); 00030 if (gesc == StatusCode::SUCCESS) 00031 { 00032 log << MSG::INFO <<"MdcGeomSvc is running"<<endreq; 00033 } 00034 else 00035 { 00036 log << MSG::ERROR <<"MdcGeomSvc is failed"<<endreq; 00037 return StatusCode::SUCCESS; 00038 } 00039 00040 StatusCode scex = service("DedxCorrecSvc", exsvc); 00041 if (scex == StatusCode::SUCCESS) { 00042 log << MSG::INFO <<"Hi, DedxCorrectSvc is running"<<endl; 00043 } else { 00044 log << MSG::ERROR <<"DedxCorrectSvc is failed"<<endl; 00045 return StatusCode::SUCCESS; 00046 } 00047 exsvc->set_flag( m_calibflag ); 00048 00049 initializing(); 00050 BookHists(); 00051 getCurvePar(); 00052 00053 return StatusCode::SUCCESS; 00054 }
void DedxCalibRunByRun::initializing | ( | ) | [inline, virtual] |
void DedxCalib::ReadRecFileList | ( | ) | [protected, inherited] |
Definition at line 89 of file DedxCalib.cxx.
References Bes_Common::INFO, DedxCalib::m_recFileList, DedxCalib::m_recFileVector, msgSvc(), and deljobs::string.
Referenced by DedxCalibWireGain::BookHists(), BookHists(), DedxCalibMomentum::BookHists(), DedxCalibLayerGain::BookHists(), DedxCalibEAng::BookHists(), DedxCalibDocaEAng::BookHists(), and DedxCalibCostheta::BookHists().
00090 { 00091 00092 MsgStream log(msgSvc(), name()); 00093 log<<MSG::INFO<<"DedxCalib::ReadRecFileList()"<<endreq; 00094 00095 ifstream filea(m_recFileList.c_str(),ifstream::in); 00096 cout<<m_recFileList.c_str()<<endl; 00097 00098 string runlist; 00099 filea>>runlist; 00100 do 00101 { 00102 m_recFileVector.push_back(runlist); 00103 cout<<runlist.c_str()<<endl; 00104 filea>>runlist; 00105 }while(filea); 00106 }
void DedxCalib::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 | |||
) | [protected, inherited] |
Definition at line 184 of file DedxCalib.cxx.
References DedxCalib::Curve_Para, dedx_pid_exp(), dedx_pid_exp_old(), DedxCalib::m_chi_ex, DedxCalib::m_dedx_exp, DedxCalib::m_ex_sigma, DedxCalib::m_pid_prob, DedxCalib::Sigma_Para, and DedxCalib::vFlag.
Referenced by DedxCalibMomentum::FillHists(), and DedxCalibCostheta::FillHists().
00185 { 00186 //landau: 1:landau distribution; 0:gaus distribution 00187 //pl_rp: 1.5, not know what 00188 //getCurvePar(runflag); 00189 if(runflag>0) vFlag[2]=0; 00190 else vFlag[2]=1; 00191 00192 //some old data with old methods 00193 if(runflag ==1 || runflag ==2 ) 00194 dedx_pid_exp_old( landau, runflag, (float)dEdx, (int)dedxhit_use, 00195 (float)ptrk, (float)theta, (float)t0,(float)pl_rp, 00196 m_dedx_exp, m_ex_sigma, m_pid_prob, m_chi_ex); 00197 //for 2009 psip data and after 00198 else 00199 dedx_pid_exp( vflag, (float)dEdx, trkalg,(int)dedxhit_use, 00200 (float)ptrk, (float)theta, (float)t0,(float)pl_rp, 00201 m_dedx_exp, m_ex_sigma, m_pid_prob, m_chi_ex, Curve_Para, Sigma_Para); 00202 }
void DedxCalibRunByRun::WriteHists | ( | ) | [virtual] |
Implements DedxCalib.
Definition at line 102 of file DedxCalibRunByRun.cxx.
References genRecEmupikp::i, Bes_Common::INFO, m_hist, DedxCalib::m_rootfile, m_rungain, m_runNOVector, msgSvc(), NormalMean, runNo, and check_raw_filter::runno.
00103 { 00104 MsgStream log(msgSvc(), name()); 00105 log<<MSG::INFO<<"DedxCalibRunByRun::WriteHists()"<<endreq; 00106 00107 TFile* f = new TFile(m_rootfile.c_str(), "recreate"); 00108 00109 Double_t gainpar=0, resolpar=0; 00110 gainpar = m_hist -> GetFunction("gaus") -> GetParameter(1); 00111 resolpar = m_hist -> GetFunction("gaus") -> GetParameter(2); 00112 00113 TTree* gain = new TTree("gaincalib", "gaincalib"); 00114 gain -> Branch("gain", &gainpar, "gain[1]/D"); 00115 gain->Fill(); 00116 TTree* resol = new TTree("resolcalib", "resolcalib"); 00117 resol -> Branch("resol", &resolpar, "resol[1]/D"); 00118 resol->Fill(); 00119 00120 Int_t runno=0; 00121 Double_t runmean=0, rungain=0, runresol=0; 00122 TTree* runbyrun = new TTree("runcalib", "runcalib"); 00123 runbyrun -> Branch("runno", &runno, "runno/I"); 00124 runbyrun -> Branch("runmean", &runmean, "runmean/D"); 00125 runbyrun -> Branch("rungain", &rungain, "rungain/D"); 00126 runbyrun -> Branch("runresol", &runresol, "runresol/D"); 00127 for(int i=0; i<runNo; i++) 00128 { 00129 runno = m_runNOVector[i]; 00130 runmean = m_rungain[i] -> GetFunction("gaus") -> GetParameter(1); 00131 runresol = m_rungain[i] -> GetFunction("gaus") -> GetParameter(2); 00132 rungain = runmean/NormalMean; 00133 cout<<"i = "<<i<<" runno = "<<runno <<" @ runmean = "<<runmean<<" @ rungain = "<<rungain<<" @ runresol = "<<runresol<<endl; 00134 runbyrun -> Fill(); 00135 } 00136 00137 m_hist->Write(); 00138 for(int i=0; i<runNo; i++) m_rungain[i]->Write(); 00139 gain->Write(); 00140 resol -> Write(); 00141 runbyrun -> Write(); 00142 00143 delete m_hist; 00144 for(int i=0; i<runNo; i++) delete m_rungain[i]; 00145 delete gain; 00146 delete resol; 00147 delete runbyrun; 00148 f->Close(); 00149 }
vector<double> DedxCalib::Curve_Para [protected, inherited] |
Definition at line 39 of file DedxCalib.h.
Referenced by DedxCalib::getCurvePar(), and DedxCalib::set_dEdx().
IDedxCorrecSvc* DedxCalib::exsvc [protected, inherited] |
Definition at line 30 of file DedxCalib.h.
Referenced by DedxCalibWireGain::FillHists(), FillHists(), DedxCalibMomentum::FillHists(), DedxCalibLayerGain::FillHists(), DedxCalibEAng::FillHists(), DedxCalibDocaEAng::FillHists(), DedxCalibCostheta::FillHists(), and DedxCalib::initialize().
IMdcGeomSvc* DedxCalib::geosvc [protected, inherited] |
Definition at line 29 of file DedxCalib.h.
Referenced by DedxCalibEvent::genNtuple(), and DedxCalib::initialize().
int DedxCalib::m_calibflag [protected, inherited] |
Definition at line 51 of file DedxCalib.h.
Referenced by DedxCalib::DedxCalib(), and DedxCalib::initialize().
double DedxCalib::m_chi_ex[5] [protected, inherited] |
Definition at line 46 of file DedxCalib.h.
Referenced by DedxCalibMomentum::FillHists(), DedxCalibCostheta::FillHists(), and DedxCalib::set_dEdx().
std::string DedxCalib::m_curvefile [protected, inherited] |
Definition at line 56 of file DedxCalib.h.
Referenced by DedxCalib::DedxCalib(), and DedxCalib::getCurvePar().
double DedxCalib::m_dedx_exp[5] [protected, inherited] |
std::string DedxCalib::m_eventType [protected, inherited] |
Definition at line 53 of file DedxCalib.h.
Referenced by DedxCalib::DedxCalib(), and DedxCalibEvent::genNtuple().
double DedxCalib::m_ex_sigma[5] [protected, inherited] |
TH1F* DedxCalibRunByRun::m_hist [private] |
Definition at line 24 of file DedxCalibRunByRun.h.
Referenced by AnalyseHists(), BookHists(), FillHists(), and WriteHists().
int DedxCalib::m_phShapeFlag [protected, inherited] |
Definition at line 52 of file DedxCalib.h.
Referenced by DedxCalibWireGain::AnalyseHists(), DedxCalibLayerGain::AnalyseHists(), DedxCalibEAng::AnalyseHists(), DedxCalibDocaEAng::AnalyseHists(), DedxCalib::DedxCalib(), DedxCalibWireGain::WriteHists(), DedxCalibLayerGain::WriteHists(), DedxCalibEAng::WriteHists(), and DedxCalibDocaEAng::WriteHists().
double DedxCalib::m_pid_prob[5] [protected, inherited] |
std::string DedxCalib::m_recFileList [protected, inherited] |
Definition at line 54 of file DedxCalib.h.
Referenced by DedxCalib::DedxCalib(), and DedxCalib::ReadRecFileList().
vector<string> DedxCalib::m_recFileVector [protected, inherited] |
Definition at line 48 of file DedxCalib.h.
Referenced by BookHists(), DedxCalibWireGain::FillHists(), FillHists(), DedxCalibMomentum::FillHists(), DedxCalibLayerGain::FillHists(), DedxCalibEAng::FillHists(), DedxCalibDocaEAng::FillHists(), DedxCalibCostheta::FillHists(), and DedxCalib::ReadRecFileList().
std::string DedxCalib::m_rootfile [protected, inherited] |
Definition at line 55 of file DedxCalib.h.
Referenced by DedxCalib::DedxCalib(), DedxCalibWireGain::WriteHists(), WriteHists(), DedxCalibMomentum::WriteHists(), DedxCalibLayerGain::WriteHists(), DedxCalibEAng::WriteHists(), DedxCalibDocaEAng::WriteHists(), and DedxCalibCostheta::WriteHists().
TH1F** DedxCalibRunByRun::m_rungain [private] |
Definition at line 23 of file DedxCalibRunByRun.h.
Referenced by AnalyseHists(), BookHists(), FillHists(), and WriteHists().
vector<float> DedxCalibRunByRun::m_runNOVector [private] |
int DedxCalib::ParticleFlag [protected, inherited] |
Definition at line 50 of file DedxCalib.h.
Referenced by DedxCalib::DedxCalib(), DedxCalibMomentum::FillHists(), DedxCalibCostheta::FillHists(), and DedxCalibEvent::genNtuple().
vector<double> DedxCalib::Sigma_Para [protected, inherited] |
Definition at line 40 of file DedxCalib.h.
Referenced by DedxCalib::getCurvePar(), and DedxCalib::set_dEdx().
float DedxCalib::truncate [protected, inherited] |
Definition at line 33 of file DedxCalib.h.
Referenced by DedxCalibLayerGain::AnalyseHists(), DedxCalib::DedxCalib(), FillHists(), DedxCalibMomentum::FillHists(), and DedxCalibCostheta::FillHists().
int DedxCalib::vFlag[3] [protected, inherited] |
Definition at line 41 of file DedxCalib.h.
Referenced by DedxCalibMomentum::FillHists(), DedxCalibCostheta::FillHists(), DedxCalib::getCurvePar(), and DedxCalib::set_dEdx().