#include <TwoGamma.h>
Public Member Functions | |
TwoGamma (const std::string &name, ISvcLocator *pSvcLocator) | |
StatusCode | initialize () |
StatusCode | execute () |
StatusCode | finalize () |
Private Attributes | |
double | m_max1 |
double | m_max2 |
double | m_costheta |
double | m_dphi1 |
double | m_dphi2 |
double | m_eff |
double | m_sec |
int | m_event |
double | m_ecms |
double | m_pass [10] |
int | Ndata1 |
int | Ndata2 |
int | m_runNo |
NTuple::Tuple * | m_tuple1 |
NTuple::Item< double > | m_ngood |
NTuple::Item< double > | m_nchrg |
NTuple::Item< long > | m_run |
NTuple::Item< long > | m_rec |
NTuple::Item< long > | m_time |
NTuple::Item< double > | m_e1 |
NTuple::Item< double > | m_e2 |
NTuple::Item< double > | m_e |
NTuple::Item< double > | m_costheta1 |
NTuple::Item< double > | m_costheta2 |
NTuple::Item< double > | m_dltphi |
NTuple::Item< double > | m_dltphi_1 |
NTuple::Item< double > | m_dlttheta |
NTuple::Item< double > | m_phi1 |
NTuple::Item< double > | m_phi2 |
NTuple::Item< double > | m_e1_lab |
NTuple::Item< double > | m_e2_lab |
NTuple::Item< double > | m_e_lab |
NTuple::Item< double > | m_costheta1_lab |
NTuple::Item< double > | m_costheta2_lab |
NTuple::Item< double > | m_dltphi_lab |
NTuple::Item< double > | m_dlttheta_lab |
NTuple::Item< double > | m_phi1_lab |
NTuple::Item< double > | m_phi2_lab |
NTuple::Item< double > | m_xBoost |
NTuple::Item< double > | m_yBoost |
NTuple::Item< double > | m_zBoost |
Definition at line 7 of file TwoGamma.h.
TwoGamma::TwoGamma | ( | const std::string & | name, | |
ISvcLocator * | pSvcLocator | |||
) |
Definition at line 46 of file TwoGamma.cxx.
References genRecEmupikp::i, m_costheta, m_dphi1, m_dphi2, m_ecms, m_eff, m_event, m_max1, m_max2, m_pass, m_runNo, m_sec, Ndata1, and Ndata2.
00046 : 00047 Algorithm(name, pSvcLocator) 00048 { 00049 // m_tuple1 = 0; 00050 for(int i = 0; i < 10; i++) 00051 { 00052 m_pass[i] = 0; 00053 } 00054 m_event = 0; 00055 00056 Ndata1 = 0; 00057 Ndata2 = 0; 00058 m_runNo = 0; 00059 00060 //Declare the properties 00061 declareProperty("CmsEnergy", m_ecms = 3.686); 00062 00063 declareProperty("max1", m_max1 = 1.2); 00064 declareProperty("max2", m_max2 = 0.8); 00065 declareProperty("costheta", m_costheta = 0.8); 00066 declareProperty("dphi1", m_dphi1 = 2.5); 00067 declareProperty("dphi2", m_dphi2 = 5); 00068 declareProperty("eff", m_eff = 0.07); 00069 declareProperty("sec", m_sec = 184.1); 00070 }
StatusCode TwoGamma::execute | ( | ) |
Definition at line 135 of file TwoGamma.cxx.
References cos(), DstEmcShower::energy(), EventModel::EvtRec::EvtRecEvent, EventModel::EvtRec::EvtRecTrackCol, genRecEmupikp::i, Bes_Common::INFO, m_costheta, m_costheta1, m_costheta1_lab, m_costheta2, m_costheta2_lab, m_dltphi, m_dltphi_lab, m_dlttheta, m_dlttheta_lab, m_dphi1, m_dphi2, m_e, m_e1, m_e1_lab, m_e2, m_e2_lab, m_e_lab, m_ecms, m_event, m_max1, m_max2, m_pass, m_phi1, m_phi1_lab, m_phi2, m_phi2_lab, m_rec, m_run, m_runNo, m_time, m_tuple1, m_xBoost, m_yBoost, m_zBoost, msgSvc(), Ndata1, Ndata2, pai, DstEmcShower::phi(), Phi(), phi1, phi2, runNo, sin(), DstEmcShower::theta(), theta1, and theta2.
00136 { 00137 StatusCode sc=StatusCode::SUCCESS; 00138 m_event++; 00139 00140 MsgStream log(msgSvc(),name()); 00141 log<<MSG::INFO<<"in execute()"<<endreq; 00142 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader"); 00143 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(),EventModel::EvtRec::EvtRecEvent); 00144 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol(eventSvc(),EventModel::EvtRec::EvtRecTrackCol); 00145 00146 m_run = eventHeader->runNumber(); 00147 m_rec = eventHeader->eventNumber(); 00148 int runNo = m_run; 00149 int event = m_rec; 00150 int time = eventHeader->time(); 00151 if(m_event > 1 && runNo != m_runNo) return sc; 00152 m_runNo = runNo; 00153 m_time = time; 00154 00155 if(m_rec%1000==0)cout<<"Run "<<m_run<<" Event "<<m_rec<<endl; 00156 00157 HepLorentzVector p4psip(0.011*m_ecms, 0.0, 0.005, m_ecms); 00158 double psipBeta = (p4psip.vect()).mag()/(p4psip.e()); 00159 00160 m_pass[0]+=1; 00161 00162 int NCharge = evtRecEvent->totalCharged(); 00163 if(NCharge != 0)return sc; 00164 00165 m_pass[1]+=1; 00166 00167 double Emax1=0.0; 00168 double Emax2=0.0; 00169 int Imax[2]; 00170 00171 if(((evtRecEvent->totalTracks() - evtRecEvent->totalCharged() )<2) || ((evtRecEvent->totalTracks() - evtRecEvent->totalCharged() )>15)) return sc; 00172 m_pass[2]+=1; 00173 00174 HepLorentzVector p4Gam_1; 00175 HepLorentzVector p4Gam_2; 00176 00177 for(int i=evtRecEvent->totalCharged(); i<evtRecEvent->totalTracks(); i++) 00178 { 00179 EvtRecTrackIterator itTrk=evtRecTrkCol->begin() + i; 00180 if(!(*itTrk)->isEmcShowerValid()) continue; 00181 RecEmcShower *emcTrk = (*itTrk)->emcShower(); 00182 00183 HepLorentzVector p4Gam; 00184 double Phi = emcTrk->phi(); 00185 double Theta = emcTrk->theta(); 00186 double Ener=emcTrk->energy(); 00187 00188 p4Gam.setPx(Ener * sin(Theta) * cos(Phi)); 00189 p4Gam.setPy(Ener * sin(Theta) * sin(Phi)); 00190 p4Gam.setPz(Ener * cos(Theta)); 00191 p4Gam.setE(Ener); 00192 p4Gam.boost(-0.011, 0 ,-0.005 * 1.0 / 3.686); 00193 00194 if(Ener>Emax2) 00195 { 00196 Emax2=Ener; 00197 Imax[1]=i; 00198 p4Gam_2 = p4Gam; 00199 } 00200 if(Ener>Emax1) 00201 { 00202 Emax2=Emax1; 00203 p4Gam_2 = p4Gam_1; 00204 Imax[1]=Imax[0]; 00205 Emax1=Ener; 00206 p4Gam_1 = p4Gam; 00207 Imax[0]=i; 00208 } 00209 } 00210 m_e1_lab = Emax1; 00211 m_e2_lab = Emax2; 00212 m_e_lab = Emax1 + Emax2; 00213 log << MSG::INFO << "Emax1 = " << Emax1 <<"Emax2= "<<Emax2<< endreq; 00214 if(Emax1 < m_max1 || Emax2 < m_max2) return sc; 00215 m_pass[3]+=1; 00216 00217 //P4 in Lab 00218 double emcphi[2],emctht[2]; 00219 for(int i = 0;i < 2; i++) 00220 { 00221 if(i>=evtRecTrkCol->size()) break; 00222 EvtRecTrackIterator itTrk=evtRecTrkCol->begin() + Imax[i]; 00223 if(!(*itTrk)->isEmcShowerValid()) continue; 00224 RecEmcShower *emcTrk = (*itTrk)->emcShower(); 00225 emcphi[i]=emcTrk->phi(); 00226 emctht[i]=emcTrk->theta(); 00227 } 00228 double dltphi_lab = (fabs(emcphi[0] - emcphi[1]) - pai) * 180.0 / pai; 00229 double dlttheta_lab = (fabs(emctht[0] + emctht[1]) - pai) * 180.0 / pai; 00230 m_costheta1_lab = cos(emctht[0]); 00231 m_costheta2_lab = cos(emctht[1]); 00232 m_phi1_lab = emcphi[0] * 180.0 / pai; 00233 m_phi2_lab = emcphi[1] * 180.0 / pai; 00234 m_dlttheta_lab = dlttheta_lab; 00235 m_dltphi_lab = dltphi_lab; 00236 00237 if(fabs(m_costheta1_lab) > m_costheta || fabs(m_costheta2_lab) > m_costheta) return sc; 00238 m_pass[4]+=1; 00239 //P4 in Lab 00240 00241 //P4 in Cms 00242 double px1 = p4Gam_1.px(); 00243 double py1 = p4Gam_1.py(); 00244 double pz1 = p4Gam_1.pz(); 00245 double pxy1 = sqrt(px1 * px1 + py1 * py1); 00246 double e1 = p4Gam_1.e(); 00247 00248 double px2 = p4Gam_2.px(); 00249 double py2 = p4Gam_2.py(); 00250 double pz2 = p4Gam_2.pz(); 00251 double pxy2 = sqrt(px2 * px2 + py2 * py2); 00252 double e2 = p4Gam_2.e(); 00253 00254 00255 double phi1 = 0; 00256 double phi2 = 0; 00257 if(atan(py1 * 1.0 / px1) > 0){ 00258 if(px1 > 0)phi1 = atan(py1 * 1.0 / px1); 00259 else phi1 = -(pai - atan(py1 * 1.0 / px1)); 00260 } 00261 else{ 00262 if(px1 > 0)phi1 = atan(py1 * 1.0 / px1); 00263 else phi1 = pai + atan(py1 * 1.0 / px1); 00264 } 00265 00266 if(atan(py2 * 1.0 / px2) > 0){ 00267 if(px2 > 0)phi2 = atan(py2 * 1.0 / px2); 00268 else phi2 = -(pai - atan(py2 * 1.0 / px2)); 00269 } 00270 else{ 00271 if(px2 > 0)phi2 = atan(py2 * 1.0 / px2); 00272 else phi2 = pai + atan(py2 * 1.0 / px2); 00273 } 00274 00275 double dltphi = (fabs(phi1 - phi2) - pai) * 180.0 / pai; 00276 00277 double theta1 = 0; 00278 double theta2 = 0; 00279 00280 if(pz1 > 0) theta1 = atan(pxy1 * 1.0 / pz1); 00281 else theta1 = (pai + atan(pxy1 * 1.0 / pz1)); 00282 00283 if(pz2 > 0) theta2 = atan(pxy2 * 1.0 / pz2); 00284 else theta2 = (pai + atan(pxy2 * 1.0 / pz2)); 00285 00286 double dlttheta = (theta1 + theta2 - pai) * 180.0 / pai; 00287 00288 double xBoost = p4Gam_1.px() + p4Gam_2.px(); 00289 double yBoost = p4Gam_1.py() + p4Gam_2.py(); 00290 double zBoost = p4Gam_1.pz() + p4Gam_2.pz(); 00291 m_xBoost = xBoost; 00292 m_yBoost = yBoost; 00293 m_zBoost = zBoost; 00294 00295 m_costheta1 = cos(theta1); 00296 m_costheta2 = cos(theta2); 00297 m_phi1 = phi1 * 180.0 / pai; 00298 m_phi2 = phi2 * 180.0 / pai; 00299 m_dlttheta = dlttheta; 00300 m_dltphi = dltphi; 00301 m_e1 = e1; 00302 m_e2 = e2; 00303 m_e = e1 + e2; 00304 //P4 in Cms 00305 00306 if(fabs(m_dltphi) < m_dphi1) Ndata1++; 00307 if(fabs(m_dltphi) > m_dphi1 && fabs(m_dltphi) < m_dphi2) Ndata2++; 00308 00309 00310 m_tuple1->write(); 00311 // runNo = 0; 00312 00313 return StatusCode::SUCCESS; 00314 }
StatusCode TwoGamma::finalize | ( | ) |
Definition at line 317 of file TwoGamma.cxx.
References m_costheta, m_eff, m_max1, m_max2, m_pass, m_runNo, m_sec, msgSvc(), Ndata1, and Ndata2.
00318 { 00319 char head[100]; 00320 char foot[100] = ".txt"; 00321 sprintf(head,"OffLineLum_%04d",m_runNo); 00322 strcat(head,foot); 00323 ofstream fout(head,ios::out); 00324 fout<<"==============================================="<<endl; 00325 fout<<"DESIGNED For OffLine Luminosity BY 2Gam Events"<<endl<<endl; 00326 fout<<"MANY THANKS to Prof. C.Z Yuan & Z.Y Wang"<<endl<<endl; 00327 fout<<" 2009/05"<<endl; 00328 // fout<<" Charmonium Group"<<endl; 00329 fout<<"==============================================="<<endl<<endl<<endl; 00330 00331 double lum = (Ndata1 - Ndata2) * 1.0 / (m_eff * m_sec); 00332 fout<<" Table List "<<endl<<endl; 00333 fout<<"-----------------------------------------------"<<endl; 00334 fout<<"Firstly Energy Gamma "<<m_max1<<" Gev"<<endl; 00335 fout<<"Secondly Energy Gamma "<<m_max2<<" Gev"<<endl; 00336 fout<<"Solid Angle Acceptance "<<m_costheta<<endl; 00337 fout<<"QED XSection "<<m_sec<<" NB"<<endl; 00338 fout<<"Monte Carto Efficiency "<<m_eff * 100<<"%"<<endl<<endl; 00339 fout<<"runNo Luminosity "<<endl<<endl; 00340 fout<<m_runNo<<" "<<lum<<" nb^(-1)"<<endl; 00341 fout<<"-----------------------------------------------"<<endl; 00342 fout.close(); 00343 00344 MsgStream log(msgSvc(), name()); 00345 cout<< "in finalize()" <<endl; 00346 cout<< "all events " <<m_pass[0]<<endl; 00347 cout<< "NCharged==0 " <<m_pass[1]<<endl; 00348 cout<< "Number of Gam " <<m_pass[2]<<endl; 00349 cout<< "N events " <<m_pass[3]<<endl; 00350 cout<< "N events 0.8 " <<m_pass[4]<<endl; 00351 return StatusCode::SUCCESS; 00352 }
StatusCode TwoGamma::initialize | ( | ) |
Definition at line 73 of file TwoGamma.cxx.
References calibUtil::ERROR, Bes_Common::INFO, m_costheta1, m_costheta1_lab, m_costheta2, m_costheta2_lab, m_dltphi, m_dltphi_1, m_dltphi_lab, m_dlttheta, m_dlttheta_lab, m_e, m_e1, m_e1_lab, m_e2, m_e2_lab, m_e_lab, m_nchrg, m_ngood, m_phi1, m_phi1_lab, m_phi2, m_phi2_lab, m_rec, m_run, m_runNo, m_time, m_tuple1, m_xBoost, m_yBoost, m_zBoost, msgSvc(), Ndata1, Ndata2, and ntupleSvc().
00074 { 00075 MsgStream log(msgSvc(), name()); 00076 00077 log << MSG::INFO << "in initialize()" << endmsg; 00078 00079 StatusCode status; 00080 00081 NTuplePtr nt1(ntupleSvc(), "FILE1/DiGam"); 00082 if ( nt1 ) m_tuple1 = nt1; 00083 else 00084 { 00085 m_tuple1 = ntupleSvc()->book ("FILE1/DiGam", CLID_ColumnWiseTuple, "DiGam N-Tuple signal"); 00086 if ( m_tuple1 ) 00087 { 00088 status = m_tuple1->addItem ("run", m_run ); 00089 status = m_tuple1->addItem ("rec", m_rec ); 00090 status = m_tuple1->addItem ("time", m_time ); 00091 00092 status = m_tuple1->addItem ("ngood", m_ngood); 00093 status = m_tuple1->addItem ("nchrg", m_nchrg); 00094 00095 status = m_tuple1->addItem ("Cms_e1", m_e1); 00096 status = m_tuple1->addItem ("Cms_e2", m_e2); 00097 status = m_tuple1->addItem ("Cms_e", m_e); 00098 status = m_tuple1->addItem ("Cms_costheta1", m_costheta1); 00099 status = m_tuple1->addItem ("Cms_costheta2", m_costheta2); 00100 status = m_tuple1->addItem ("Cms_dltphi", m_dltphi); 00101 status = m_tuple1->addItem ("Cms_dltphi_1", m_dltphi_1); 00102 status = m_tuple1->addItem ("Cms_dlttheta", m_dlttheta); 00103 status = m_tuple1->addItem ("Cms_phi1", m_phi1); 00104 status = m_tuple1->addItem ("Cms_phi2", m_phi2); 00105 00106 status = m_tuple1->addItem ("Lab_e1", m_e1_lab); 00107 status = m_tuple1->addItem ("Lab_e2", m_e2_lab); 00108 status = m_tuple1->addItem ("Lab_e", m_e_lab); 00109 status = m_tuple1->addItem ("Lab_costheta1", m_costheta1_lab); 00110 status = m_tuple1->addItem ("Lab_costheta2", m_costheta2_lab); 00111 status = m_tuple1->addItem ("Lab_dltphi", m_dltphi_lab); 00112 status = m_tuple1->addItem ("Lab_dlttheta", m_dlttheta_lab); 00113 status = m_tuple1->addItem ("Lab_phi1", m_phi1_lab); 00114 status = m_tuple1->addItem ("Lab_phi2", m_phi2_lab); 00115 00116 status = m_tuple1->addItem ("xBoost", m_xBoost); 00117 status = m_tuple1->addItem ("yBoost", m_yBoost); 00118 status = m_tuple1->addItem ("zBoost", m_zBoost); 00119 } 00120 else 00121 { 00122 log << MSG::ERROR << "Cannot book N-tuple1:"<<long(m_tuple1)<<endmsg; 00123 return StatusCode::FAILURE; 00124 } 00125 } 00126 Ndata1 = 0; 00127 Ndata2 = 0; 00128 m_runNo = 0; 00129 00130 log << MSG::INFO << "successfully return from initialize()" <<endmsg; 00131 return StatusCode::SUCCESS; 00132 }
double TwoGamma::m_costheta [private] |
NTuple::Item<double> TwoGamma::m_costheta1 [private] |
NTuple::Item<double> TwoGamma::m_costheta1_lab [private] |
NTuple::Item<double> TwoGamma::m_costheta2 [private] |
NTuple::Item<double> TwoGamma::m_costheta2_lab [private] |
NTuple::Item<double> TwoGamma::m_dltphi [private] |
NTuple::Item<double> TwoGamma::m_dltphi_1 [private] |
NTuple::Item<double> TwoGamma::m_dltphi_lab [private] |
NTuple::Item<double> TwoGamma::m_dlttheta [private] |
NTuple::Item<double> TwoGamma::m_dlttheta_lab [private] |
double TwoGamma::m_dphi1 [private] |
double TwoGamma::m_dphi2 [private] |
NTuple::Item<double> TwoGamma::m_e [private] |
NTuple::Item<double> TwoGamma::m_e1 [private] |
NTuple::Item<double> TwoGamma::m_e1_lab [private] |
NTuple::Item<double> TwoGamma::m_e2 [private] |
NTuple::Item<double> TwoGamma::m_e2_lab [private] |
NTuple::Item<double> TwoGamma::m_e_lab [private] |
double TwoGamma::m_ecms [private] |
double TwoGamma::m_eff [private] |
int TwoGamma::m_event [private] |
double TwoGamma::m_max1 [private] |
double TwoGamma::m_max2 [private] |
NTuple::Item<double> TwoGamma::m_nchrg [private] |
NTuple::Item<double> TwoGamma::m_ngood [private] |
double TwoGamma::m_pass[10] [private] |
NTuple::Item<double> TwoGamma::m_phi1 [private] |
NTuple::Item<double> TwoGamma::m_phi1_lab [private] |
NTuple::Item<double> TwoGamma::m_phi2 [private] |
NTuple::Item<double> TwoGamma::m_phi2_lab [private] |
NTuple::Item<long> TwoGamma::m_rec [private] |
NTuple::Item<long> TwoGamma::m_run [private] |
int TwoGamma::m_runNo [private] |
Definition at line 34 of file TwoGamma.h.
Referenced by execute(), finalize(), initialize(), and TwoGamma().
double TwoGamma::m_sec [private] |
NTuple::Item<long> TwoGamma::m_time [private] |
NTuple::Tuple* TwoGamma::m_tuple1 [private] |
NTuple::Item<double> TwoGamma::m_xBoost [private] |
NTuple::Item<double> TwoGamma::m_yBoost [private] |
NTuple::Item<double> TwoGamma::m_zBoost [private] |
int TwoGamma::Ndata1 [private] |
Definition at line 32 of file TwoGamma.h.
Referenced by execute(), finalize(), initialize(), and TwoGamma().
int TwoGamma::Ndata2 [private] |
Definition at line 33 of file TwoGamma.h.
Referenced by execute(), finalize(), initialize(), and TwoGamma().