#include <DedxCalibCostheta.h>
Inheritance diagram for DedxCalibCostheta:
Public Member Functions | |
void | AnalyseHists () |
void | AnalyseHists () |
void | BookHists () |
void | BookHists () |
void | checkSelections () |
void | checkSelections () |
DedxCalibCostheta (const std::string &name, ISvcLocator *pSvcLocator) | |
DedxCalibCostheta (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 () |
Public Attributes | |
TObjArray * | m_caliblist |
TObjArray * | m_caliblist |
vector< TH1F * > | m_hist_e |
vector< TH1F * > | m_hist_e |
vector< TH1F * > | m_hist_p |
vector< TH1F * > | m_hist_p |
vector< TH1F * > | m_histcalib |
vector< TH1F * > | m_histcalib |
TRandom * | m_rand |
TRandom * | m_rand |
TObjArray * | m_spacelist |
TObjArray * | m_spacelist |
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 |
|
00028 : DedxCalib(name, pSvcLocator) 00029 { 00030 log<<MSG::INFO<<"DedxCalibCostheta::DedxCalibCostheta( )..."<<endreq; 00031 }
|
|
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00237 { 00238 log<<MSG::INFO<<"DedxCalibCostheta::AnalyseHists( )..."<<endreq; 00239 00240 double fitmean=0; 00241 double fiterr=0; 00242 double fitmean2=0; 00243 double fiterr2=0; 00244 00245 00246 for(int bin=0; bin<NumBinCostheta; bin++) { 00247 m_hist_e[bin]->Fit("gaus", "Q" ); 00248 fitmean = m_hist_e[bin] -> GetFunction("gaus") -> GetParameter(1); 00249 fiterr = m_hist_e[bin] -> GetFunction("gaus") -> GetParError(1); 00250 fitmean = fitmean/NormalMean; 00251 fiterr = fiterr/NormalMean; 00252 cout<<"electron bin : "<<bin<<" gain : "<<fitmean<<" error : "<<fiterr<<" entries"<<m_hist_e[bin]->GetEntries()<<endl; 00253 if(m_hist_e[bin]->GetEntries()>0 && fiterr<0.5*fitmean){ 00254 m_histcalib[0]->SetBinContent(bin+1,fitmean); 00255 m_histcalib[0]->SetBinError(bin+1,fiterr); 00256 } 00257 else{ 00258 m_histcalib[0]->SetBinContent(bin+1,0.00); 00259 m_histcalib[0]->SetBinError(bin+1,0.05); 00260 } 00261 00262 00263 m_hist_p[bin]->Fit("gaus", "Q" ); 00264 fitmean2 = m_hist_p[bin] -> GetFunction("gaus") -> GetParameter(1); 00265 fiterr2 = m_hist_p[bin] -> GetFunction("gaus") -> GetParError(1); 00266 fitmean2 = fitmean2/NormalMean; 00267 fiterr2 = fiterr2/NormalMean; 00268 if(m_hist_p[bin]->GetEntries()>0 && fiterr2<0.5*fitmean2){ 00269 m_histcalib[1]->SetBinContent(bin+1,fitmean2); 00270 m_histcalib[1]->SetBinError(bin+1,fiterr2); 00271 } 00272 else{ 00273 m_histcalib[1]->SetBinContent(bin+1,0.00); 00274 m_histcalib[1]->SetBinError(bin+1,0.05); 00275 } 00276 cout<<"positron bin : "<<bin<<" gain : "<<fitmean2<<" error : "<<fiterr2<<endl; 00277 00278 if(fitmean>0 && fitmean2>0){ 00279 m_histcalib[2]->SetBinContent(bin+1,0.5*m_histcalib[0]->GetBinContent(bin+1)+0.5*m_histcalib[1]->GetBinContent(bin+1)); 00280 m_histcalib[2]->SetBinError(bin+1,0.5*m_histcalib[0]->GetBinError(bin+1)+0.5*m_histcalib[1]->GetBinError(bin+1)); 00281 cout<<"costheta bin : "<<bin<<" gain : "<<0.5*m_histcalib[0]->GetBinContent(bin+1)+0.5*m_histcalib[1]->GetBinContent(bin+1)<<endl; 00282 } 00283 else{ 00284 m_histcalib[2]->SetBinContent(bin+1,0.0); 00285 m_histcalib[2]->SetBinError(bin+1,0.05); 00286 cout<<"costheta bin : "<<bin<<" gain : "<<0.5*m_histcalib[0]->GetBinContent(bin+1)+0.5*m_histcalib[1]->GetBinContent(bin+1)<<endl; 00287 } 00288 } 00289 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00117 { 00118 log<<MSG::INFO<<"DedxCalibCostheta::BookHists( )..."<<endreq; 00119 log<<MSG::DEBUG<<" bookhist...1" <<endreq; 00120 m_spacelist = new TObjArray(0); 00121 m_caliblist = new TObjArray(0); 00122 log<<MSG::DEBUG<<" bookhist...2" <<endreq; 00123 m_rand = new TRandom(); 00124 std::string hlabel; 00125 log<<MSG::DEBUG<<" bookhist...3" <<endreq; 00126 00127 for(int mm=0; mm<NumBinCostheta; mm++) { 00128 std::ostringstream strout; 00129 strout << "Electron Dedx_Vs" <<"_Costheta_"<<mm; 00130 hlabel = strout.str(); 00131 TH1F *space_e = new TH1F(hlabel.c_str(), hlabel.c_str(), NumHistBins,300,1000); 00132 // wireg->Print("base"); 00133 space_e->GetXaxis()->SetTitle("dE/dx(eV/1.5cm)"); 00134 space_e->GetYaxis()->SetTitle("entries/(40eV/1.5cm)"); 00135 00136 std::ostringstream strout1; 00137 strout1 << "Positron Dedx_Vs" <<"_Costheta_"<<mm; 00138 hlabel = strout1.str(); 00139 TH1F *space_p = new TH1F(hlabel.c_str(), hlabel.c_str(), NumHistBins,300,1000); 00140 // wireg->Print("base"); 00141 space_p->GetXaxis()->SetTitle("dE/dx(eV/1.5cm)"); 00142 space_p->GetYaxis()->SetTitle("entries/(40eV/1.5cm)"); 00143 00144 m_hist_e.push_back(space_e); 00145 m_hist_p.push_back(space_p); 00146 m_spacelist -> Add(space_e); 00147 m_spacelist -> Add(space_p); 00148 } 00149 00150 std::ostringstream strout2; 00151 strout2 << "Costheta_Effect_electron"; 00152 hlabel = strout2.str(); 00153 TH1F *calib_e = new TH1F(hlabel.c_str(), hlabel.c_str(), NumBinCostheta, CosthetaMin, CosthetaMax); 00154 // wireg->Print("base"); 00155 calib_e->GetXaxis()->SetTitle("cos#theta"); 00156 calib_e->GetYaxis()->SetTitle("normalized dE/dx"); 00157 00158 std::ostringstream strout3; 00159 strout3 << "Costheta_Effect_positron"; 00160 hlabel = strout3.str(); 00161 TH1F *calib_p = new TH1F(hlabel.c_str(), hlabel.c_str(), NumBinCostheta, CosthetaMin, CosthetaMax); 00162 // wireg->Print("base"); 00163 calib_p->GetXaxis()->SetTitle("cos#theta"); 00164 calib_p->GetYaxis()->SetTitle("normalized dE/dx"); 00165 00166 std::ostringstream strout4; 00167 strout4 << "Costheta_Effect"; 00168 hlabel = strout4.str(); 00169 TH1F *calib = new TH1F(hlabel.c_str(), hlabel.c_str(), NumBinCostheta, CosthetaMin, CosthetaMax); 00170 // wireg->Print("base"); 00171 calib->GetXaxis()->SetTitle("cos#theta"); 00172 calib->GetYaxis()->SetTitle("normalized dE/dx"); 00173 00174 m_histcalib.push_back(calib_e); 00175 m_histcalib.push_back(calib_p); 00176 m_histcalib.push_back(calib); 00177 m_caliblist -> Add(calib_e); 00178 m_caliblist -> Add(calib_p); 00179 m_caliblist -> Add(calib); 00180 00181 00182 }
|
|
|
|
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. 00185 { 00186 log<<MSG::INFO<<"DedxCalibCostheta::FillHists( )..."<<endreq; 00187 00188 int layid, hid, localwid, lr, w0id, wid; 00189 double adc_raw, costhe, zhit, driftdist, dd, ph, sinenta, dipan, pathlength, sintheta, eangle,rphi_path; 00190 double m_driftd, driftd; 00191 double m_P, logp; 00192 00193 std::string rootpath_input = m_inputfile; 00194 std::string hlabel_rootpath_input; 00195 std::ostringstream strout; 00196 strout << rootpath_input; 00197 hlabel_rootpath_input = strout.str(); 00198 std::cout<<"string doca : "<<hlabel_rootpath_input.c_str()<<endl; 00199 00200 TFile *f_costheta = new TFile(hlabel_rootpath_input.c_str()); 00201 float dEdx_meas, ptrk, charge, costheta, t0,nhit; 00202 TTree *Mdc_dedx = (TTree *)f_costheta->Get("n103"); 00203 Mdc_dedx->SetBranchAddress("dEdx_meas",&dEdx_meas); 00204 Mdc_dedx->SetBranchAddress("ptrk",&ptrk); 00205 Mdc_dedx->SetBranchAddress("charge",&charge); 00206 Mdc_dedx->SetBranchAddress("costheta",&costheta); 00207 Mdc_dedx->SetBranchAddress("nhit",&nhit); 00208 Mdc_dedx->SetBranchAddress("t0",&t0); 00209 cout<<"entries : "<<Mdc_dedx->GetEntries()<<endl; 00210 for(int i = 0; i <Mdc_dedx->GetEntries(); i++){ 00211 Mdc_dedx->GetEntry(i); 00212 // if(t0>1400) continue; 00213 if (nhit<20) continue; 00214 if (t0>700 || ptrk <1.78 || ptrk>1.88){continue;} 00215 costhe = costheta; 00216 00217 if(abs(costhe)>= CosthetaMax) continue; 00218 hid=0; 00219 //cout<<"bin step is"<<bin_step<<endl; 00220 for(int kk=0; kk<NumBinCostheta; kk++) { 00221 if((costhe>=CosthetaMin+bin_step*kk)&&(costhe<CosthetaMin+bin_step*(kk+1))) { 00222 hid=kk; 00223 } 00224 } 00225 //cout<<"costhe : "<<costhe<<" hid : "<<hid<<" bitrunc: "<<bitrunc<<" charge: "<<charge<<endl; 00226 00227 if(charge<0) m_hist_e[hid]->Fill(dEdx_meas); 00228 else if( charge>0) m_hist_p[hid]->Fill(dEdx_meas); 00229 /*if((*iter_trk)->charge()<0) 00230 m_hist_e[hid]->Fill(m_dEdx); 00231 else if( (*iter_trk)->charge()>0) 00232 m_hist_p[hid]->Fill(m_dEdx);*/ 00233 } 00234 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00293 { 00294 log<<MSG::INFO<<"DedxCalibCostheta::FillHistsFromTree( )..."<<endreq; 00295 }
|
|
|
|
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. 00035 { 00036 log<<MSG::INFO<<"DedxCalibCostheta::GetChargeOffCorr( )..."<<endreq; 00037 return 1.0; 00038 }
|
|
|
|
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. 00298 { 00299 log<<MSG::INFO<<"DedxCalibCostheta::WriteCalibdEdxParameters( )..."<<endreq; 00300 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00041 { 00042 log<<MSG::INFO<<"DedxCalibDipAngle::WriteHists( )..."<<endreq; 00043 00044 /* 00045 TTree tree("costhetacalib","costhetacalib"); 00046 double tmp[2]; 00047 tree.Branch("costheta",&tmp,"slope/D:intersect/D"); 00048 //tree.Branch("costheta",&tmp,"tree[2]/D"); 00049 00050 for(int i=1;i<NumBinCostheta;i++){ 00051 double x1= m_histcalib[0]->GetBinCenter(i); 00052 double y1= m_histcalib[0]->GetBinContent(i); 00053 00054 double x2= m_histcalib[0]->GetBinCenter(i+1); 00055 double y2= m_histcalib[0]->GetBinContent(i+1); 00056 00057 double k=(y2-y1)/(x2-x1); 00058 double b=(y1*x2-y2*x1)/(x2-x1); 00059 tmp[0]=k; 00060 tmp[1]=b; 00061 00062 tree.Fill(); 00063 } 00064 */ 00065 00066 TTree tree("costhetacalib","costhetacalib"); 00067 double tmp[1]; 00068 tree.Branch("costheta",&tmp,"cosbin/D"); 00069 /*for(int i=1;i<=NumBinCostheta;i++){ 00070 tmp[0]=m_histcalib[2]->GetBinContent(i); 00071 cout<<"i : "<<i<<tmp[0]<<endl; 00072 tree.Fill(); 00073 }*/ 00074 00075 for(int i=0;i<NumBinCostheta+1;i++){ 00076 tmp[0]=m_histcalib[2]->GetBinContent(i); 00077 cout<<"i : "<<i<<" gain : "<<tmp[0]<<endl; 00078 tree.Fill(); 00079 } 00080 00081 00082 if(m_rootfile=="no rootfile") 00083 { 00084 log << MSG::ERROR<<"no sepcified calibration file path of costheta calib "<<endreq; 00085 //return StatusCode::FAILURE; 00086 return; 00087 } 00088 00089 std::string rootpath_costhe = m_rootfile; 00090 std::string hlabel_rootpath_costhe; 00091 std::ostringstream strout; 00092 strout << rootpath_costhe; 00093 hlabel_rootpath_costhe = strout.str(); 00094 std::cout<<"string wire : "<<hlabel_rootpath_costhe.c_str()<<endl; 00095 00096 //TFile fhist("/home/bes/xcao/besd26/Calib/Calib_650/Calibconst_check/costhetacalib2.root", "recreate"); 00097 TFile fhist(hlabel_rootpath_costhe.c_str(), "recreate"); 00098 tree.Write(); 00099 m_spacelist -> Write(); 00100 m_caliblist -> Write(); 00101 fhist.Close(); 00102 00103 00104 for(int i=0; i<NumBinCostheta; i++) delete m_hist_e[i]; 00105 for(int i=0; i<NumBinCostheta; i++) delete m_hist_p[i]; 00106 for(int i=0; i<3; i++) delete m_histcalib[i]; 00107 delete m_spacelist; 00108 delete m_caliblist; 00109 //delete spcharge; 00110 delete m_rand; 00111 00112 00113 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|