#include <DedxCalibEntra.h>
Inheritance diagram for DedxCalibEntra:
Public Member Functions | |
void | AnalyseHists () |
void | AnalyseHists () |
void | BookHists () |
void | BookHists () |
void | checkSelections () |
void | checkSelections () |
DedxCalibEntra (const std::string &name, ISvcLocator *pSvcLocator) | |
DedxCalibEntra (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 | |
TObjArray * | m_caliblist |
TObjArray * | m_caliblist |
vector< TH1F * > | m_hist |
vector< TH1F * > | m_hist |
vector< TH1F * > | m_histcalib |
vector< TH1F * > | m_histcalib |
TObjArray * | m_list |
TObjArray * | m_list |
TRandom * | m_rand |
TRandom * | m_rand |
|
00027 : DedxCalib(name, pSvcLocator) 00028 { 00029 log<<MSG::INFO<<"DedxCalibEntra::DedxCalibEntra( )..."<<endreq; 00030 }
|
|
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00240 { 00241 log<<MSG::INFO<<"DedxCalibEntra::AnalyseHists( )..."<<endreq; 00242 00243 TF1* func; 00244 if(m_phshape_flag==0) { 00245 func = new TF1("mylan",mylan,1000,4000,4); 00246 func->SetParameters(10000.0,2010.1,300,-1.0); 00247 } else if(m_phshape_flag==1) { 00248 func = new TF1("landaun",landaun,1000,4000,3); 00249 func->SetParameters(2000.0,300.0); 00250 } else if(m_phshape_flag==2) { 00251 func = new TF1("land",Landau,1000,4000,2); 00252 func->SetParameters(2010.1,300); 00253 } else if(m_phshape_flag==3) { 00254 func = new TF1("vavi",Vavilov,1000,4000,2); 00255 func->SetParameters(3.1,0.4); 00256 } else if(m_phshape_flag==4) { 00257 func = new TF1("asym",AsymGauss,1000,4000,4); 00258 func->SetParameters(10000.0,2000.0,300.0,100.); 00259 } 00260 00261 func->SetLineWidth(2.1); 00262 func->SetLineColor(2); 00263 Double_t entry, mean, rms; 00264 Double_t binmax; 00265 Double_t lp[3]; 00266 for(int hid=0; hid<43*NumBinSinEAngle; hid++){ 00267 entry = m_hist[hid]->GetEntries(); 00268 mean = m_hist[hid]->GetMean(); 00269 rms = m_hist[hid]->GetRMS(); 00270 binmax = m_hist[hid]->GetMaximumBin(); 00271 lp[1] = m_hist[hid]->GetBinCenter(binmax); 00272 lp[2] = 200; 00273 lp[0] = (m_hist[hid]->GetBinContent(binmax)+m_hist[hid]->GetBinContent(binmax-1)+m_hist[hid]->GetBinContent(binmax+1))/3; 00274 00275 if(m_phshape_flag==0) { 00276 func->SetParameters(entry, mean, rms, -0.8); 00277 } else if(m_phshape_flag==1) { 00278 // func->SetParameters(entry, 0.7*mean, rms ); 00279 func->SetParameters(lp[0], lp[1], lp[2] ); 00280 } else if(m_phshape_flag==2) { 00281 func->SetParameters(0.7*mean, rms ); 00282 } else if(m_phshape_flag==3) { 00283 func->SetParameters(0.05, 0.6); 00284 } else if(m_phshape_flag==4) { 00285 func->SetParameters(entry, mean, rms, 1.0 ); 00286 } 00287 m_hist[hid]->Fit(func, "Q" ); 00288 } 00289 00290 double fitmean[NumBinSinEAngle], mean0; 00291 if(m_phshape_flag==0) { 00292 mean0 = m_hist[SinEAngleStandard] -> GetFunction("mylan") -> GetParameter(1); 00293 } else if(m_phshape_flag==1) { 00294 mean0 = m_hist[SinEAngleStandard] -> GetFunction("landaun") -> GetParameter(1); 00295 } else if(m_phshape_flag==2) { 00296 mean0 = m_hist[SinEAngleStandard] -> GetFunction("land") -> GetParameter(1); 00297 } else if(m_phshape_flag==3) { 00298 mean0 = m_hist[SinEAngleStandard] -> GetFunction("vavi") -> GetParameter(1); 00299 } else if(m_phshape_flag==4) { 00300 mean0 = m_hist[SinEAngleStandard] -> GetFunction("asym") -> GetParameter(1); 00301 } 00302 00303 for(int lay=0; lay<43; lay++) { 00304 for(int bin=0; bin<NumBinSinEAngle; bin++) { 00305 int hid=lay*NumBinSinEAngle+bin; 00306 if(m_phshape_flag==0) { 00307 fitmean[bin] = m_hist[hid] -> GetFunction("mylan") -> GetParameter(1); 00308 } else if(m_phshape_flag==1) { 00309 fitmean[bin] = m_hist[hid] -> GetFunction("landaun") -> GetParameter(1); 00310 } else if(m_phshape_flag==2) { 00311 fitmean[bin] = m_hist[hid] -> GetFunction("land") -> GetParameter(1); 00312 } else if(m_phshape_flag==3) { 00313 fitmean[bin] = m_hist[hid] -> GetFunction("vavi") -> GetParameter(1); 00314 } else if(m_phshape_flag==4) { 00315 fitmean[bin] = m_hist[hid] -> GetFunction("asym") -> GetParameter(1); 00316 } 00317 00318 if(mean0) { 00319 fitmean[bin] = fitmean[bin]/mean0; 00320 } else { 00321 fitmean[bin] = fitmean[bin]/2000.0; 00322 } 00323 m_histcalib[lay]->Fill(SinEAngle_step*bin+SinEAngle_step/2+SinEAngleMin,fitmean[bin]); 00324 } 00325 } 00326 00327 TF1* parfunc; 00328 parfunc = new TF1("cheby3",ChebyP3,0.0,15.0,4); 00329 parfunc->SetParameters(10.0,1.0,3.1,0.4); 00330 parfunc->SetLineWidth(2.1); 00331 parfunc->SetLineColor(2); 00332 for(int lay=0; lay<43; lay++) { 00333 if(m_par_flag==0) m_histcalib[lay]->Fit(parfunc,"Q"); 00334 if(m_par_flag==1) m_histcalib[lay]->Fit("pol3","Q"); 00335 } 00336 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00095 { 00096 log<<MSG::INFO<<"DedxCalibEntra::BookHists( )..."<<endreq; 00097 log<<MSG::DEBUG<<" bookhist...1" <<endreq; 00098 m_list = new TObjArray(0); 00099 m_caliblist = new TObjArray(0); 00100 log<<MSG::DEBUG<<" bookhist...2" <<endreq; 00101 m_rand = new TRandom(); 00102 std::string hlabel; 00103 log<<MSG::DEBUG<<" bookhist...3" <<endreq; 00104 00105 00106 for(int jj=0; jj<43; jj++) { 00107 for(int mm=0; mm<NumBinSinEAngle; mm++) { 00108 std::ostringstream strout; 00109 strout << "Gain_Layer_" << jj <<"_Entra_"<<mm; 00110 hlabel = strout.str(); 00111 TH1F *entra = new TH1F(hlabel.c_str(), hlabel.c_str(), NumHistBins,MinHistValue,MaxHistValue); 00112 // wireg->Print("base"); 00113 entra->GetXaxis()->SetTitle("dE/dx(eV/1.5cm)"); 00114 entra->GetYaxis()->SetTitle("entries/(40eV/1.5cm)"); 00115 m_hist.push_back(entra); 00116 m_list -> Add(entra); 00117 } 00118 std::ostringstream strout2; 00119 strout2 << "Entra_Layer_" << jj ; 00120 hlabel = strout2.str(); 00121 TH1F *calib = new TH1F(hlabel.c_str(), hlabel.c_str(), NumBinSinEAngle, SinEAngleMin, SinEAngleMax); 00122 // wireg->Print("base"); 00123 calib->GetXaxis()->SetTitle("entrance angle(rad)"); 00124 calib->GetYaxis()->SetTitle("normalized dE/dx"); 00125 m_histcalib.push_back(calib); 00126 m_caliblist -> Add(calib); 00127 } 00128 log<<MSG::DEBUG<<" m_hist size..." <<m_hist.size()<<endreq; 00129 }
|
|
|
|
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. 00132 { 00133 log<<MSG::INFO<<"DedxCalibEntra::FillHists( )..."<<endreq; 00134 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader"); 00135 if (!eventHeader) { 00136 log << MSG::FATAL << "Could not find Event Header" << endreq; 00137 return; 00138 } 00139 int event = eventHeader->eventNumber(); 00140 int runNO = eventHeader->runNumber(); 00141 int typFlag; //data type flag: 0:MC data, 1: 2150, 2:2200 00142 if(runNO<0) typFlag =0; 00143 else if(runNO>=0 && runNO<5459) typFlag =1; 00144 else if(runNO>=5459 && runNO<8093) typFlag =2; 00145 else if(runNO>=8093 && runNO<9815) typFlag =3; 00146 else if(runNO>=9815 ) typFlag =4; 00147 00148 double tes; 00149 int esTimeflag = -1; 00150 SmartDataPtr<RecEsTimeCol> estimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol"); 00151 if( ! estimeCol) { 00152 log << MSG::WARNING << "Could not find EvTimeCol" << endreq; 00153 }else{ 00154 RecEsTimeCol::iterator iter_evt = estimeCol->begin(); 00155 for(; iter_evt!=estimeCol->end(); iter_evt++){ 00156 tes = (*iter_evt)->getTest(); 00157 esTimeflag = (*iter_evt)->getStat(); 00158 } 00159 } 00160 if(typFlag ==2) {if( tes>1000 ) return;} 00161 else if(typFlag ==3 ){if (tes>700 ) return;} 00162 else if(typFlag ==4 ){if (tes>1400 ) return;} 00163 00164 Identifier mdcid; 00165 SmartDataPtr<RecMdcTrackCol> trkCol(eventSvc(),"/Event/Recon/RecMdcTrackCol"); 00166 if (!trkCol) { 00167 log << MSG::WARNING << "Could not find RecMdcTrackCol" << endreq; 00168 return; 00169 } 00170 int lr, layid, hid,localwid; 00171 double adc_raw, tdc_raw, costhe, zhit, ddl, ddr, dd, ph, sinenta, pathlength, sintheta, rphi_path; 00172 double m_driftd, driftd, eangle, driftdist; 00173 log << MSG::INFO << "Begin to check RecMdcTrackCol"<<endreq; 00174 RecMdcTrackCol::iterator iter_trk = trkCol->begin(); 00175 for( ; iter_trk != trkCol->end(); iter_trk++) { 00176 HepVector a = (*iter_trk)->helix(); 00177 HepSymMatrix tkErrM = (*iter_trk)->err(); 00178 double m_d0E = tkErrM[0][0]; 00179 double m_phi0E = tkErrM[1][1]; 00180 double m_cpaE = tkErrM[2][2]; 00181 double m_z0E = tkErrM[3][3]; 00182 00183 HepPoint3D IP(0,0,0); 00184 Dedx_Helix exhel(IP, a); 00185 float m_Pt = 1.0/fabs( a(3) ); 00186 float m_P = m_Pt*sqrt(1 + a(5)*a(5)); 00187 //if(m_P>1.95||m_P<1.8) continue; 00188 00189 log << MSG::DEBUG << "hitList of this track:" << endreq; 00190 HitRefVec gothits = (*iter_trk)->getVecHits(); 00191 HitRefVec::iterator it_gothit = gothits.begin(); 00192 if(gothits.size()<20) StatusCode::SUCCESS; 00193 for( ; it_gothit != gothits.end(); it_gothit++) { 00194 mdcid = (*it_gothit)->getMdcId(); 00195 layid = MdcID::layer(mdcid); 00196 localwid = MdcID::wire(mdcid); 00197 adc_raw = (*it_gothit)->getAdc(); 00198 //adc_raw = (*it_gothit)->getAdc()*1000000; 00199 tdc_raw = (*it_gothit)->getTdc(); 00200 zhit = (*it_gothit)->getZhit(); 00201 sinenta = sin((*it_gothit)->getEntra()); 00202 costhe = cos(M_PI_2-atan(a[4])); 00203 sintheta = sin(M_PI_2-atan(a[4])); 00204 eangle = (*it_gothit)->getEntra(); 00205 eangle = eangle/M_PI; 00206 lr = (*it_gothit)->getFlagLR(); 00207 if(lr == 0 || lr == 2) driftdist = (*it_gothit)->getDriftDistLeft(); 00208 if(lr == 1 ) driftdist = (*it_gothit)->getDriftDistRight(); 00209 driftd = abs(driftdist); 00210 dd = (*it_gothit)->getDoca(); 00211 if(lr == 0 || lr == 2 ) dd = -abs(dd); 00212 if(lr == 1 ) dd = abs(dd); 00213 int ntpFlag = 1; 00214 ph = exsvc->StandardCorrec(typFlag, ntpFlag, runNO, exhel, mdcid, adc_raw, dd, sinenta, zhit, costhe ); 00215 pathlength = exsvc->PathL(ntpFlag, exhel, layid, localwid, zhit); 00216 00217 //ph = exsvc->StandardCorrec( exhel, mdcid, adc_raw, dd, sinenta, zhit, costhe ); 00218 //pathlength = exsvc->PathL(exhel, layid, localwid, zhit); 00219 // pathlength = exsvc->PathLCosmic(exhel, layid, localwid, zhit,m_z0E); 00220 rphi_path = pathlength * sintheta; 00221 if(layid <8) 00222 {if(adc_raw<MinADCValuecut || adc_raw>MaxADCValuecut || rphi_path>RPhi_PathMaxCut || rphi_path<Iner_RPhi_PathMinCut || driftd>Iner_DriftDistCut) continue;} 00223 else if(layid >= 8) 00224 {if(adc_raw<MinADCValuecut || adc_raw>MaxADCValuecut || rphi_path>RPhi_PathMaxCut || rphi_path<Out_RPhi_PathMinCut || driftd>Out_DriftDistCut) continue;} 00225 00226 if(fabs(eangle)>SinEAngleMax || fabs(eangle)<SinEAngleMin) continue; 00227 for(int kk=0; kk<NumBinSinEAngle; kk++) { 00228 if((eangle>(SinEAngleMin+SinEAngle_step*kk))&&(eangle<(SinEAngleMin+SinEAngle_step*(kk+1)))) { 00229 hid=layid*NumBinSinEAngle+kk; 00230 //cout<<"sinenta = "<<sinenta<<" hid = "<<hid<<endl; 00231 } 00232 } 00233 m_hist[hid]->Fill(ph); 00234 } 00235 } 00236 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00340 { 00341 log<<MSG::INFO<<"DedxCalibEntra::FillHistsFromTree( )..."<<endreq; 00342 }
|
|
|
|
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<<"DedxCalibEntra::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. 00345 { 00346 log<<MSG::INFO<<"DedxCalibEntra::WriteCalibdEdxParameters( )..."<<endreq; 00347 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00042 { 00043 log<<MSG::INFO<<"DedxCalibEntra::WriteHists( )..."<<endreq; 00044 double mean[4][43]; 00045 for(int lay=0; lay<43; lay++) { 00046 if(m_par_flag==0) { 00047 mean[0][lay] = m_histcalib[lay] -> GetFunction("cheby3") -> GetParameter(0); 00048 mean[1][lay] = m_histcalib[lay] -> GetFunction("cheby3") -> GetParameter(1); 00049 mean[2][lay] = m_histcalib[lay] -> GetFunction("cheby3") -> GetParameter(2); 00050 mean[3][lay] = m_histcalib[lay] -> GetFunction("cheby3") -> GetParameter(3); 00051 } 00052 if(m_par_flag==1) { 00053 mean[0][lay] = m_histcalib[lay] -> GetFunction("pol3") -> GetParameter(0); 00054 mean[1][lay] = m_histcalib[lay] -> GetFunction("pol3") -> GetParameter(1); 00055 mean[2][lay] = m_histcalib[lay] -> GetFunction("pol3") -> GetParameter(2); 00056 mean[3][lay] = m_histcalib[lay] -> GetFunction("pol3") -> GetParameter(3); 00057 } 00058 } 00059 00060 if(m_rootfile=="no rootfile") 00061 { 00062 log << MSG::ERROR<<"no sepcified calibration file path of wiregcalib "<<endreq; 00063 //return StatusCode::FAILURE; 00064 return; 00065 } 00066 //std::cout<<"m_rootfile = "<<m_rootfile<<endl; 00067 std::string rootpath_entrance = m_rootfile; 00068 std::string hlabel_rootpath_entrance; 00069 std::ostringstream strout; 00070 strout << rootpath_entrance <<"/entracalib.root"; 00071 hlabel_rootpath_entrance = strout.str(); 00072 std::cout<<"string eangle : "<<hlabel_rootpath_entrance.c_str()<<endl; 00073 00074 TFile fhist(hlabel_rootpath_entrance.c_str(), "recreate"); 00075 TTree* entra = new TTree("entracalib", "entracalib"); 00076 entra -> Branch("entra0", &mean[0], "entra[43]/D"); 00077 entra -> Branch("entra1", &mean[1], "entra[43]/D"); 00078 entra -> Branch("entra2", &mean[2], "entra[43]/D"); 00079 entra -> Branch("entra3", &mean[3], "entra[43]/D"); 00080 entra -> Fill(); 00081 00082 entra -> Write(); 00083 m_list -> Write(); 00084 m_caliblist -> Write(); 00085 fhist.Close(); 00086 for(int i=0; i<43*NumBinSinEAngle; i++) delete m_hist[i]; 00087 for(int i=0; i<43; i++) delete m_histcalib[i]; 00088 delete m_list; 00089 delete m_caliblist; 00090 //delete entra; 00091 delete m_rand; 00092 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|