#include <DedxCalibSpaCharge.h>
Inheritance diagram for DedxCalibSpaCharge:
Public Member Functions | |
void | AnalyseHists () |
void | AnalyseHists () |
void | BookHists () |
void | BookHists () |
void | checkSelections () |
void | checkSelections () |
DedxCalibSpaCharge (const std::string &name, ISvcLocator *pSvcLocator) | |
DedxCalibSpaCharge (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 |
vector< TH1F * > | m_hist |
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 |
|
00026 : DedxCalib(name, pSvcLocator) 00027 { 00028 log<<MSG::INFO<<"DedxCalibSpaCharge::DedxCalibSpaCharge( )..."<<endreq; 00029 }
|
|
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00211 { 00212 log<<MSG::INFO<<"DedxCalibSpaCharge::AnalyseHists( )..."<<endreq; 00213 00214 double fitmean[NumBinSpaceCharge]; 00215 for(int bin=0; bin<NumBinSpaceCharge; bin++) { 00216 m_hist[bin]->Fit("gaus", "Q" ); 00217 fitmean[bin] = m_hist[bin] -> GetFunction("gaus") -> GetParameter(1); 00218 fitmean[bin] = fitmean[bin]/NormalMean; 00219 //if(fitmean[bin]>1.12) fitmean[bin] =1; 00220 m_histcalib[0]->Fill(Space_step*bin+SpacethetaMin+Space_step/2,fitmean[bin]); 00221 } 00222 00223 TF1* parfunc; 00224 parfunc = new TF1("cheby3",ChebyP3,0.0,15.0,4); 00225 parfunc->SetParameters(10.0,1.0,3.1,0.4); 00226 parfunc->SetLineWidth(2.1); 00227 parfunc->SetLineColor(2); 00228 00229 TF1* spacefunc; 00230 spacefunc = new TF1("spacharge",SpaceChargeFunction,0.0,15.0,3); 00231 spacefunc->SetParameters(1.2,0.0001,0.01); 00232 spacefunc->SetLineWidth(2.1); 00233 spacefunc->SetLineColor(2); 00234 00235 if(m_par_flag==2) m_histcalib[0]->Fit(spacefunc,"Q"); 00236 if(m_par_flag==0) m_histcalib[0]->Fit(parfunc,"Q"); 00237 if(m_par_flag==1) m_histcalib[0]->Fit("pol3","Q"); 00238 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00081 { 00082 log<<MSG::INFO<<"DedxCalibSpaCharge::BookHists( )..."<<endreq; 00083 log<<MSG::DEBUG<<" bookhist...1" <<endreq; 00084 m_spacelist = new TObjArray(0); 00085 m_caliblist = new TObjArray(0); 00086 log<<MSG::DEBUG<<" bookhist...2" <<endreq; 00087 m_rand = new TRandom(); 00088 std::string hlabel; 00089 log<<MSG::DEBUG<<" bookhist...3" <<endreq; 00090 00091 for(int mm=0; mm<NumBinSpaceCharge; mm++) { 00092 std::ostringstream strout; 00093 strout << "Dedx_Vs" <<"_Costheta_"<<mm; 00094 hlabel = strout.str(); 00095 TH1F *space = new TH1F(hlabel.c_str(), hlabel.c_str(), NumHistBins,MinHistValue,MaxHistValue); 00096 // wireg->Print("base"); 00097 space->GetXaxis()->SetTitle("dE/dx(eV/1.5cm)"); 00098 space->GetYaxis()->SetTitle("entries/(40eV/1.5cm)"); 00099 m_hist.push_back(space); 00100 m_spacelist -> Add(space); 00101 } 00102 std::ostringstream strout2; 00103 strout2 << "SpaceCharge_Effect"; 00104 hlabel = strout2.str(); 00105 TH1F *calib = new TH1F(hlabel.c_str(), hlabel.c_str(), NumBinSpaceCharge, SpacethetaMin, SpacethetaMax); 00106 // wireg->Print("base"); 00107 calib->GetXaxis()->SetTitle("cos#theta"); 00108 calib->GetYaxis()->SetTitle("normalized dE/dx"); 00109 m_histcalib.push_back(calib); 00110 m_caliblist -> Add(calib); 00111 }
|
|
|
|
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. 00114 { 00115 log<<MSG::INFO<<"DedxCalibSpaCharge::FillHists( )..."<<endreq; 00116 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader"); 00117 if (!eventHeader) { 00118 log << MSG::FATAL << "Could not find Event Header" << endreq; 00119 return; 00120 } 00121 int event = eventHeader->eventNumber(); 00122 int runNO = eventHeader->runNumber(); 00123 int typFlag; //data type flag: 0:MC data, 1: 2150, 2:2200 00124 if(runNO<0) typFlag =0; 00125 else if(runNO>=0 && runNO<5459) typFlag =1; 00126 else if(runNO>=5459 && runNO<8093) typFlag =2; 00127 else if(runNO>=8093) typFlag =3; 00128 00129 Identifier mdcid; 00130 SmartDataPtr<RecMdcTrackCol> trkCol(eventSvc(),"/Event/Recon/RecMdcTrackCol"); 00131 if (!trkCol) { 00132 log << MSG::WARNING << "Could not find RecMdcTrackCol" << endreq; 00133 return; 00134 } 00135 int layid, hid, localwid, lr; 00136 double adc_raw, costhe, zhit, driftdist, dd, ph, sinenta, dipan, pathlength, sintheta, rphi_path; 00137 double m_driftd, driftd; 00138 double m_P, logp; 00139 log << MSG::INFO << "Begin to check RecMdcTrackCol"<<endreq; 00140 RecMdcTrackCol::iterator iter_trk = trkCol->begin(); 00141 for( ; iter_trk != trkCol->end(); iter_trk++) { 00142 HepVector a = (*iter_trk)->helix(); 00143 HepSymMatrix tkErrM = (*iter_trk)->err(); 00144 double m_d0E = tkErrM[0][0]; 00145 double m_phi0E = tkErrM[1][1]; 00146 double m_cpaE = tkErrM[2][2]; 00147 double m_z0E = tkErrM[3][3]; 00148 00149 vector<double> phlist; 00150 HepPoint3D IP(0,0,0); 00151 Dedx_Helix exhel(IP, a); 00152 //QvsDipAngP->Reset(); 00153 log << MSG::DEBUG << "hitList of this track:" << endreq; 00154 HitRefVec gothits = (*iter_trk)->getVecHits(); 00155 HitRefVec::iterator it_gothit = gothits.begin(); 00156 00157 //double m_Pt = 1.0/fabs(a[2]); 00158 //m_P = m_Pt*sqrt(1 + (a[4]*a[4])); 00159 float m_Pt = 1.0/fabs( a(3) ); 00160 m_P = m_Pt*sqrt(1 + a(5)*a(5)); 00161 if(m_P>1.95||m_P<1.8) continue; 00162 for( ; it_gothit != gothits.end(); it_gothit++) { 00163 mdcid = (*it_gothit)->getMdcId(); 00164 layid = MdcID::layer(mdcid); 00165 localwid = MdcID::wire(mdcid); 00166 adc_raw = (*it_gothit)->getAdc()*1000000; 00167 zhit = (*it_gothit)->getZhit(); 00168 lr = (*it_gothit)->getFlagLR(); 00169 if(lr == 0 || lr == 2) m_driftd = (*it_gothit)->getDriftDistLeft(); 00170 if(lr == 1 ) m_driftd = (*it_gothit)->getDriftDistRight(); 00171 driftd = abs(m_driftd); 00172 dd = fabs((*it_gothit)->getDoca()); 00173 sinenta = sin((*it_gothit)->getEntra()); 00174 costhe = cos(M_PI_2-atan(a[4])); 00175 sintheta = sin(M_PI_2-atan(a[4])); 00176 int ntpFlag = 1; 00177 ph = exsvc->StandardCorrec(typFlag,ntpFlag, runNO, exhel, mdcid, adc_raw, dd, sinenta, zhit, costhe ); 00178 pathlength = exsvc->PathL(ntpFlag, exhel, layid, localwid, zhit); 00179 rphi_path = pathlength * sintheta; 00180 if(layid <8) continue; 00181 // {if(adc_raw<MinADCValuecut || adc_raw>MaxADCValuecut || rphi_path>RPhi_PathMaxCut || rphi_path<Iner_RPhi_PathMinCut || driftd>Iner_DriftDistCut) continue;} 00182 else if(layid >= 8) 00183 {if(adc_raw<MinADCValuecut || adc_raw>MaxADCValuecut || rphi_path>RPhi_PathMaxCut || rphi_path<Out_RPhi_PathMinCut || driftd>Out_DriftDistCut) continue;} 00184 if( ph>0 ) phlist.push_back(ph); 00185 } 00186 sort(phlist.begin(),phlist.end()); 00187 int nsampl = (int)( phlist.size()*Truncate ); 00188 int smpl = (int)(phlist.size()*(Truncate+0.05)); 00189 int min_cut = (int)( phlist.size()*0.05 + 0.5 ); 00190 double qSum = 0; 00191 unsigned i = 0; 00192 for(vector<double>::iterator ql= phlist.begin();ql!=phlist.end();ql++){ 00193 i++; 00194 if(i<= smpl && i>=min_cut ) qSum += (*ql); 00195 } 00196 float trunc=qSum/(smpl-min_cut+1); 00197 double m_dEdx = trunc; 00198 00199 if(abs(costhe)> SpacethetaMax) continue; 00200 for(int kk=0; kk<NumBinSpaceCharge; kk++) { 00201 if((costhe>=SpacethetaMin+Space_step*kk)&&(costhe<SpacethetaMax+Space_step*(kk+1))) { 00202 hid=kk; 00203 } 00204 } 00205 m_hist[hid]->Fill(m_dEdx); 00206 phlist.clear(); 00207 } 00208 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00242 { 00243 log<<MSG::INFO<<"DedxCalibSpaCharge::FillHistsFromTree( )..."<<endreq; 00244 }
|
|
|
|
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. 00033 { 00034 log<<MSG::INFO<<"DedxCalibSpaCharge::GetChargeOffCorr( )..."<<endreq; 00035 return 1.0; 00036 }
|
|
|
|
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. 00247 { 00248 log<<MSG::INFO<<"DedxCalibSpaCharge::WriteCalibdEdxParameters( )..."<<endreq; 00249 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00039 { 00040 log<<MSG::INFO<<"DedxCalibDipAngle::WriteHists( )..."<<endreq; 00041 double mean[4], spacemean[3]; 00042 if(m_par_flag==0) { 00043 mean[0] = m_histcalib[0] -> GetFunction("cheby3") -> GetParameter(0); 00044 mean[1] = m_histcalib[0] -> GetFunction("cheby3") -> GetParameter(1); 00045 mean[2] = m_histcalib[0] -> GetFunction("cheby3") -> GetParameter(2); 00046 mean[3] = m_histcalib[0] -> GetFunction("cheby3") -> GetParameter(3); 00047 } 00048 if(m_par_flag==1) { 00049 mean[0] = m_histcalib[0] -> GetFunction("pol3") -> GetParameter(0); 00050 mean[1] = m_histcalib[0] -> GetFunction("pol3") -> GetParameter(1); 00051 mean[2] = m_histcalib[0] -> GetFunction("pol3") -> GetParameter(2); 00052 mean[3] = m_histcalib[0] -> GetFunction("pol3") -> GetParameter(3); 00053 } 00054 if(m_par_flag==2) { 00055 spacemean[0] = m_histcalib[0] -> GetFunction("spacharge") -> GetParameter(0); 00056 spacemean[1] = m_histcalib[0] -> GetFunction("spacharge") -> GetParameter(1); 00057 spacemean[2] = m_histcalib[0] -> GetFunction("spacharge") -> GetParameter(2); 00058 } 00059 00060 TFile fhist("/ihepbatch/besd09/xcao/calibconst_temp/dug_root/spacecalib.root", "recreate"); 00061 TTree* spcharge= new TTree("spchargecalib", "spchargecalib"); 00062 spcharge -> Branch("spcharge", &spacemean, "spcharge[3]/D"); 00063 spcharge -> Fill(); 00064 00065 spcharge-> Write(); 00066 m_spacelist -> Write(); 00067 m_caliblist -> Write(); 00068 fhist.Close(); 00069 for(int i=0; i<NumBinSpaceCharge; i++) delete m_hist[i]; 00070 for(int i=0; i<1; i++) delete m_histcalib[i]; 00071 delete m_spacelist; 00072 delete m_caliblist; 00073 delete spcharge; 00074 delete m_rand; 00075 00076 00077 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|