#include <DedxCalibWireGain.h>
Inheritance diagram for DedxCalibWireGain:
Public Member Functions | |
void | AnalyseHists () |
void | AnalyseHists () |
void | BookHists () |
void | BookHists () |
void | checkSelections () |
void | checkSelections () |
DedxCalibWireGain (const std::string &name, ISvcLocator *pSvcLocator) | |
DedxCalibWireGain (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 | |
vector< TH1F * > | m_hist |
vector< TH1F * > | m_hist |
TRandom * | m_rand |
TRandom * | m_rand |
TObjArray * | m_wireglist |
TObjArray * | m_wireglist |
|
00026 : DedxCalib(name, pSvcLocator) 00027 { 00028 log<<MSG::INFO<<"DedxCalibWireGain::DedxCalibWireGain( )..."<<endreq; 00029 }
|
|
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00225 { 00226 log<<MSG::INFO<<"DedxCalibWireGain::AnalyseHists( )..."<<endreq; 00227 00228 TF1* func; 00229 00230 if(m_phshape_flag==0) { 00231 func = new TF1("mylan",mylan,1000,4000,4); 00232 func->SetParameters(10000.0,2010.1,300,-1.0); 00233 } else if(m_phshape_flag==1) { 00234 func = new TF1("landaun",landaun,1000,4000,3); 00235 func->SetParameters(2000.0,300.0); 00236 } else if(m_phshape_flag==2) { 00237 func = new TF1("land",Landau,1000,4000,2); 00238 func->SetParameters(2010.1,300); 00239 } else if(m_phshape_flag==3) { 00240 func = new TF1("vavi",Vavilov,1000,4000,2); 00241 func->SetParameters(3.1,0.4); 00242 } else if(m_phshape_flag==4) { 00243 func = new TF1("asym",AsymGauss,1000,4000,4); 00244 func->SetParameters(10000.0,2000.0,300.0,100.); 00245 } 00246 00247 func->SetLineWidth(2.1); 00248 func->SetLineColor(2); 00249 Double_t entry, mean, rms; 00250 Double_t binmax; 00251 Double_t lp[3]; 00252 for(int wire=0; wire<6796; wire++){ 00253 entry = m_hist[wire]->GetEntries(); 00254 mean = m_hist[wire]->GetMean(); 00255 rms = m_hist[wire]->GetRMS(); 00256 binmax = m_hist[wire]->GetMaximumBin(); 00257 lp[1] = m_hist[wire]->GetBinCenter(binmax); 00258 lp[2] = 200; 00259 lp[0] = (m_hist[wire]->GetBinContent(binmax)+m_hist[wire]->GetBinContent(binmax-1)+m_hist[wire]->GetBinContent(binmax+1))/3; 00260 00261 if(m_phshape_flag==0) { 00262 func->SetParameters(entry, mean, rms, -0.9); 00263 // func->SetParLimits(2,0,300); 00264 } else if(m_phshape_flag==1) { 00265 // func->SetParameters(entry, 0.7*mean, rms ); 00266 func->SetParameters(lp[0], lp[1], lp[2] ); 00267 } else if(m_phshape_flag==2) { 00268 func->SetParameters(0.7*mean, rms ); 00269 } else if(m_phshape_flag==3) { 00270 func->SetParameters(0.05, 0.6); 00271 } else if(m_phshape_flag==4) { 00272 func->SetParameters(entry, mean, rms, 1.0 ); 00273 } 00274 00275 m_hist[wire]->Fit(func, "Q" ); 00276 } 00277 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00142 { 00143 log<<MSG::INFO<<"DedxCalibWireGain::BookHists( )..."<<endreq; 00144 log<<MSG::DEBUG<<" bookhist...1" <<endreq; 00145 m_wireglist = new TObjArray(0); 00146 log<<MSG::DEBUG<<" bookhist...2" <<endreq; 00147 m_rand = new TRandom(); 00148 std::string hlabel; 00149 log<<MSG::DEBUG<<" bookhist...3" <<endreq; 00150 00151 for(int jj=0; jj<6796; jj++) { 00152 std::ostringstream strout; 00153 strout << "Wire_Gain_" << jj; 00154 hlabel = strout.str(); 00155 TH1F *wireg = new TH1F(hlabel.c_str(), hlabel.c_str(), NumHistBins,MinHistValue,MaxHistValue); 00156 // wireg->Print("base"); 00157 wireg->GetXaxis()->SetTitle("dEdx(eV/1.5cm)"); 00158 wireg->GetYaxis()->SetTitle("entries/(40eV/1.5cm)"); 00159 m_hist.push_back(wireg); 00160 m_wireglist -> Add(wireg); 00161 } 00162 TH1F *wirenormal = new TH1F("Normal_wire_dedx", "Normal_wire_dedx", NumHistBins,MinHistValue,MaxHistValue); 00163 //m_hist.push_back(wirenormal); 00164 log<<MSG::DEBUG<<" m_hist size..." <<m_hist.size()<<endreq; 00165 }
|
|
|
|
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. 00168 { 00169 log<<MSG::INFO<<"DedxCalibWireGain::FillHists( )..."<<endreq; 00170 00171 int lr, layid, hid, localwid, w0id, wid;; 00172 double adc_raw, tdc_raw, costhe, ddl, ddr, dd, ph, pathlength, sintheta, rphi_path; 00173 double m_driftd, driftd, zhit, zhit_pol, eangle, theta, costhe_pol; 00174 00175 std::string rootpath_input = m_inputfile; 00176 std::string hlabel_rootpath_input; 00177 std::ostringstream strout; 00178 strout << rootpath_input; 00179 hlabel_rootpath_input = strout.str(); 00180 std::cout<<"string wire : "<<hlabel_rootpath_input.c_str()<<endl; 00181 00182 //TFile fhist(hlabel_rootpath_input.c_str()); 00183 TFile *fhist = new TFile(hlabel_rootpath_input.c_str()); 00184 double exraw, phraw, adc, dedx; 00185 float ptrk1, driftdist, path_rphi, sinenta, doca; 00186 float t01, layer, wire; 00187 //int ltype, EAng_bin, iDoca, iEAng, layid, hid, lr, localwid; 00188 TTree *Mdc_dedx = (TTree *)fhist->Get("n102"); 00189 Mdc_dedx->SetBranchAddress("exraw", &dedx); 00190 Mdc_dedx->SetBranchAddress("adc_raw", &adc); 00191 Mdc_dedx->SetBranchAddress("ptrk1", &ptrk1); 00192 Mdc_dedx->SetBranchAddress("path_rphi", &path_rphi); 00193 Mdc_dedx->SetBranchAddress("driftdist",&driftdist); 00194 Mdc_dedx->SetBranchAddress("doca",&doca); 00195 Mdc_dedx->SetBranchAddress("sinenta",&sinenta); 00196 Mdc_dedx->SetBranchAddress("layer",&layer); 00197 Mdc_dedx->SetBranchAddress("wire",&wire); 00198 Mdc_dedx->SetBranchAddress("t01",&t01); 00199 cout<<"entries : "<<Mdc_dedx->GetEntries()<<endl; 00200 for(int i = 0; i <Mdc_dedx->GetEntries(); i++){ 00201 Mdc_dedx->GetEntry(i); 00202 //cout<<"i : "<<i<<" t0: "<<t01<<" dd : "<<doca<<" eangle : "<<sinenta<<endl; 00203 //add the to cut and ptrk cut 00204 if (t01>1400 || ptrk1 <1.7 || ptrk1>2.0){continue;} 00205 eangle = sinenta; 00206 dd = doca; 00207 driftd = abs(driftdist); 00208 layid = layer; 00209 dd = dd/doca_norm[layid]; 00210 adc_raw = adc; 00211 rphi_path = path_rphi; 00212 ph = dedx; 00213 wid = wire; 00214 if(layid <8) 00215 {if(adc_raw<MinADCValuecut || adc_raw>MaxADCValuecut || rphi_path>RPhi_PathMaxCut || rphi_path<Iner_RPhi_PathMinCut || driftd>Iner_DriftDistCut) continue;} 00216 else if(layid >= 8) 00217 {if(adc_raw<MinADCValuecut || adc_raw>MaxADCValuecut || rphi_path>RPhi_PathMaxCut || rphi_path<Out_RPhi_PathMinCut || driftd>Out_DriftDistCut) continue;} 00218 m_hist[wid]->Fill(ph); 00219 } 00220 00221 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00280 { 00281 log<<MSG::INFO<<"DedxCalibWireGain::FillHistsFromTree( )..."<<endreq; 00282 }
|
|
|
|
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. 00034 { 00035 log<<MSG::INFO<<"DedxCalibWireGain::GetChargeOffCorr( )..."<<endreq; 00036 return 1.0; 00037 }
|
|
|
|
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. 00285 { 00286 log<<MSG::INFO<<"DedxCalibWireGain::WriteCalibdEdxParameters( )..."<<endreq; 00287 }
|
|
Implements DedxCalib. |
|
Implements DedxCalib. 00040 { 00041 log<<MSG::INFO<<"DedxCalibWireGain::WriteHists( )..."<<endreq; 00042 // double mean[6796],mean0; 00043 double wiregmean[6796],wiregmean0,wiregain[6796],wiregchisq[6796],meanwire[6796],rmswire[6796],sigmawire[6796]; 00044 int layerNO; 00045 double wirentries[6796],wireNO[6796]; 00046 00047 if(m_phshape_flag==0) { 00048 wiregmean0 = m_hist[4546] -> GetFunction("mylan") -> GetParameter(1); 00049 } else if(m_phshape_flag==1) { 00050 wiregmean0 = m_hist[4546] -> GetFunction("landaun") -> GetParameter(1); 00051 } else if(m_phshape_flag==2) { 00052 wiregmean0 = m_hist[4546] -> GetFunction("land") -> GetParameter(1); 00053 } else if(m_phshape_flag==3) { 00054 wiregmean0 = m_hist[4546] -> GetFunction("vavi") -> GetParameter(1); 00055 } else if(m_phshape_flag==4) { 00056 wiregmean0 = m_hist[4546] -> GetFunction("asym") -> GetParameter(1); 00057 } 00058 00059 for(int wire=0; wire<6796; wire++) { 00060 wirentries[wire] = m_hist[wire]->GetEntries(); 00061 meanwire[wire] = m_hist[wire]->GetMean(); 00062 rmswire[wire] = m_hist[wire]->GetRMS(); 00063 if(m_phshape_flag==0) { 00064 // mean[wire] = m_hist[wire]->GetMean(); 00065 wiregmean[wire] = m_hist[wire] -> GetFunction("mylan") -> GetParameter(1); 00066 wiregchisq[wire] = m_hist[wire] -> GetFunction("mylan") -> GetParameter(2); 00067 sigmawire[wire] = m_hist[wire] -> GetFunction("mylan") -> GetParError(1); 00068 } else if(m_phshape_flag==1) { 00069 wiregmean[wire] = m_hist[wire] -> GetFunction("landaun") -> GetParameter(1); 00070 wiregchisq[wire] = m_hist[wire] -> GetFunction("landaun") -> GetParameter(2); 00071 sigmawire[wire] = m_hist[wire] -> GetFunction("landaun") -> GetParError(1); 00072 } else if(m_phshape_flag==2) { 00073 wiregmean[wire] = m_hist[wire] -> GetFunction("land") -> GetParameter(1); 00074 } else if(m_phshape_flag==3) { 00075 wiregmean[wire] = m_hist[wire] -> GetFunction("vavi") -> GetParameter(1); 00076 } else if(m_phshape_flag==4) { 00077 wiregmean[wire] = m_hist[wire] -> GetFunction("asym") -> GetParameter(1); 00078 } 00079 /*if(wiregmean0) { 00080 wiregain[wire] = wiregmean[wire]/wiregmean0; 00081 } else { 00082 wiregain[wire] = wiregmean[wire]/NormalMean; 00083 }*/ 00084 //wiregain[wire] = wiregmean[wire]/NormalMean; 00085 cout <<"mean["<<wire<<"] : "<<m_hist[wire]->GetMean() 00086 <<" fitted mean: "<<wiregmean[wire]<<endl; 00087 } 00088 00089 double total_mean = 0; 00090 int wire_normal_N =0; 00091 for(int j=188; j<6796; j++){ 00092 //int wireNO_temp = Normal_wire[j]; 00093 if(wiregmean[j]>0&&sigmawire[j]<10&&sigmawire[j]>0&&wiregchisq[j]>0&&wiregchisq[j]<200&&wirentries[j]>1500) 00094 { 00095 total_mean += wiregmean[j]; 00096 wire_normal_N++; 00097 } 00098 } 00099 double Normal_mean = total_mean/wire_normal_N; 00100 cout<<"Normal_mean : "<<Normal_mean<<endl; 00101 for(int wire=0; wire<6796; wire++) { 00102 wiregain[wire] = wiregmean[wire]/Normal_mean; 00103 cout<<"wiregain [ "<<wire<<" ] : "<<wiregain[wire]<<endl; 00104 } 00105 00106 if(m_rootfile=="no rootfile") 00107 { 00108 log << MSG::ERROR<<"no sepcified calibration file path of wiregcalib "<<endreq; 00109 //return StatusCode::FAILURE; 00110 return; 00111 } 00112 //std::cout<<"m_rootfile = "<<m_rootfile<<endl; 00113 std::string rootpath_wire = m_rootfile; 00114 std::string hlabel_rootpath_wire; 00115 std::ostringstream strout; 00116 strout << rootpath_wire; 00117 hlabel_rootpath_wire = strout.str(); 00118 std::cout<<"string wire : "<<hlabel_rootpath_wire.c_str()<<endl; 00119 00120 TFile fhist(hlabel_rootpath_wire.c_str(), "recreate"); 00121 00122 TTree* wireg = new TTree("wiregcalib", "wiregcalib"); 00123 wireg -> Branch("wireg", &wiregain, "wireg[6796]/D"); 00124 wireg -> Branch("wirentries", &wirentries, "wirentries[6796]/D"); 00125 wireg -> Branch("meanwire", &meanwire, "meanwire[6796]/D"); 00126 wireg -> Branch("rmswire", &rmswire, "rmswire[6796]/D"); 00127 wireg -> Branch("wiregchisq", &wiregchisq, "wiregchisq[6796]/D"); 00128 wireg -> Branch("wiregmean", &wiregmean, "wiregmean[6796]/D"); 00129 wireg -> Fill(); 00130 00131 wireg -> Write(); 00132 m_wireglist -> Write(); 00133 00134 fhist.Close(); 00135 for(int i=0; i<6796; i++) delete m_hist[i]; 00136 delete m_wireglist; 00137 // delete wireg; 00138 delete m_rand; 00139 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|