Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

PrintMcInfo Class Reference

#include <PrintMcInfo.h>

List of all members.

Public Member Functions

StatusCode beginRun ()
StatusCode beginRun ()
StatusCode endRun ()
StatusCode endRun ()
StatusCode execute ()
StatusCode execute ()
StatusCode finalize ()
StatusCode finalize ()
StatusCode initialize ()
StatusCode initialize ()
void mkmap ()
void mkmap ()
void printHit (ofstream &, Event::MdcMcHitCol &, Event::TofMcHitCol &, Event::EmcMcHitCol &, Event::MucMcHitCol &, int &)
void printHit (ofstream &, Event::MdcMcHitCol &, Event::TofMcHitCol &, Event::EmcMcHitCol &, Event::MucMcHitCol &, int &)
 PrintMcInfo (const std::string &name, ISvcLocator *pSvcLocator)
 PrintMcInfo (const std::string &name, ISvcLocator *pSvcLocator)
void printPartInf (ofstream &, Event::McParticle *, int &, int)
void printPartInf (ofstream &, Event::McParticle *, int &, int)
void printTitle (ofstream &os, int &)
void printTitle (ofstream &os, int &)
void printTree (ofstream &, Event::McParticle *, int &, int)
void printTree (ofstream &, Event::McParticle *, int &, int)
 ~PrintMcInfo ()
 ~PrintMcInfo ()

Private Attributes

string daughters
string m_FileName
bool m_firstTime
int m_OutputLevel
int m_pid
int m_trkIndex
map< int, string > map_pid
map< int, string > map_pid


Constructor & Destructor Documentation

PrintMcInfo::PrintMcInfo const std::string &  name,
ISvcLocator *  pSvcLocator
 

00024                                                                        :Algorithm(name,pSvcLocator)
00025 {
00026 
00027         declareProperty("PrintLevel", m_OutputLevel=0);
00028         declareProperty("FileName", m_FileName );
00029 }

PrintMcInfo::~PrintMcInfo  ) 
 

00030 {  }

PrintMcInfo::PrintMcInfo const std::string &  name,
ISvcLocator *  pSvcLocator
 

PrintMcInfo::~PrintMcInfo  ) 
 


Member Function Documentation

StatusCode PrintMcInfo::beginRun  ) 
 

StatusCode PrintMcInfo::beginRun  ) 
 

00042                                 {
00043         MsgStream log(msgSvc(), name());
00044         log<<MSG::INFO<<"PrintMcInfo::beginRun()"<<endreq;
00045         //add your code here
00046         return StatusCode::SUCCESS;
00047 
00048 }

StatusCode PrintMcInfo::endRun  ) 
 

StatusCode PrintMcInfo::endRun  ) 
 

00111                               {
00112         MsgStream log(msgSvc(), name());
00113         log<<MSG::INFO<<"PrintMcInfo::endRun()"<<endreq;
00114         return StatusCode::SUCCESS;
00115 
00116 }

StatusCode PrintMcInfo::execute  ) 
 

StatusCode PrintMcInfo::execute  ) 
 

00054                                {
00055         MsgStream log(msgSvc(), name());
00056         log<<MSG::INFO<<"PrintMcInfo::execute()"<<endreq;
00057 
00058         ofstream os(m_FileName.c_str(),ios::app);       
00059 
00060         SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
00061         int runNo=eventHeader->runNumber();
00062         int event=eventHeader->eventNumber();
00063         os<<"run number:"<<runNo<<endl
00064                 <<"event number:"<<event<<endl;
00065 
00066         SmartDataPtr<Event::McParticleCol> mcPartCol(eventSvc(), "/Event/MC/McParticleCol");
00067         if (runNo < 0) 
00068         {
00069                 if(!mcPartCol)
00070                 {
00071                         log << MSG::ERROR << "Could not retrieve McParticelCol" << endreq;
00072                         return StatusCode::FAILURE;
00073                 }
00074 
00075                 Event::McParticleCol::iterator iter_mc = mcPartCol->begin();
00076                 for (;iter_mc !=mcPartCol->end();iter_mc++)
00077                 {
00078                         bool primary = (*iter_mc)->primaryParticle();
00079                         bool gamma = ((*iter_mc)->particleProperty())==22?true:false;
00080                         if(primary&&(!gamma))
00081                         {       
00082                                 Event::McParticle* pMcPart = (*iter_mc);
00083                                 PrintMcInfo::printTree(os,pMcPart,m_OutputLevel,0);
00084                                 if(m_OutputLevel==1)
00085                                 {       
00086                                         os<<"\n- - - - - - - - - - - - - - - - - - - - - - - - - - - -- - -- - -\n"<<endl;
00087                                         PrintMcInfo::printTitle(os,m_OutputLevel);
00088                                         PrintMcInfo::printPartInf(os,pMcPart,m_OutputLevel,0);
00089                                 }
00090                                 if(m_OutputLevel==2)
00091                                 {       
00092                                         os<<"\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"<<endl;
00093                                         m_OutputLevel -= 1;
00094                                         PrintMcInfo::printTitle(os,m_OutputLevel);
00095                                         PrintMcInfo::printPartInf(os,pMcPart,m_OutputLevel,0);
00096                                         os<<"\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"<<endl;
00097                                         m_OutputLevel += 1;
00098                                         PrintMcInfo::printPartInf(os,pMcPart,m_OutputLevel,0);
00099                                 }
00100                                 os<<endl<<"\n*****************************************************\n"<<endl;
00101                         }                       
00102                 }
00103 
00104         }//end of if(runNo < 0)
00105         return StatusCode::SUCCESS;
00106 }

StatusCode PrintMcInfo::finalize  ) 
 

StatusCode PrintMcInfo::finalize  ) 
 

00117                                 {
00118         MsgStream log(msgSvc(), name());
00119         log<<MSG::INFO<<"PrintMcInfo::finalize()"<<endreq;
00120         return StatusCode::SUCCESS;
00121 
00122 }

StatusCode PrintMcInfo::initialize  ) 
 

StatusCode PrintMcInfo::initialize  ) 
 

00032                                   {
00033         //make a map for tanslating the PDG code to its name 
00034         PrintMcInfo::mkmap();
00035 
00036         MsgStream log(msgSvc(), name());
00037         log<<MSG::INFO<<"PrintMcInfo::initialize()"<<endreq;
00038 
00039         StatusCode status;
00040         return StatusCode::SUCCESS;
00041 }

void PrintMcInfo::mkmap  ) 
 

void PrintMcInfo::mkmap  ) 
 

00005 {
00006         string str,str1,str2,str3,str4;
00007         int id;
00008         
00009         char* pdt_path=getenv("BESEVTGENROOT");
00010         if(0 == pdt_path)
00011                 std::cerr<<"ERROR : Can't get env $BESEVTGENROOT"<<std::endl;
00012         std::string pdtname=std::string(pdt_path) + "/share/pdt.table";
00013         ifstream fin(pdtname.c_str());
00014         
00015         while(getline(fin,str))
00016         {
00017                 fin>>str;
00018                 if(str == "add")
00019                 {
00020                         fin>>str1>>str2>>str3>>str4;
00021                         id = atoi(str4.c_str());
00022                         map_pid.insert(map<int, string>::value_type(id,str3));
00023                 }
00024         }
00025 }

void PrintMcInfo::printHit ofstream ,
Event::MdcMcHitCol ,
Event::TofMcHitCol ,
Event::EmcMcHitCol ,
Event::MucMcHitCol ,
int & 
 

void PrintMcInfo::printHit ofstream ,
Event::MdcMcHitCol ,
Event::TofMcHitCol ,
Event::EmcMcHitCol ,
Event::MucMcHitCol ,
int & 
 

00169 {
00170         os<< '\t' <<setw(40)<<"MdcHit"
00171                   <<setw(25)<<"TofHit"
00172                   <<setw(17)<<"EmcHit"
00173                   <<"MucHit"<<endl;
00174         os<< '\t' <<"(layer wire drift_d(mm) DeDx(MeV/m))"<<"  "<<"(B/EC layer phi_module)"<<"  "<<"(B/EC theta phi)"<<"  "<<"(B/EC segment layer strip)"<<endl;
00175         Event::MdcMcHitCol::const_iterator it_mdc = mdcCol.begin();
00176         Event::TofMcHitCol::const_iterator it_tof = tofCol.begin();
00177         Event::EmcMcHitCol::const_iterator it_emc = emcCol.begin();
00178         Event::MucMcHitCol::const_iterator it_muc = mucCol.begin();
00179         vector<Event::MdcMcHitCol::const_iterator> vmdc;
00180         vector<Event::TofMcHitCol::const_iterator> vtof;
00181         vector<Event::EmcMcHitCol::const_iterator> vemc;
00182         vector<Event::MucMcHitCol::const_iterator> vmuc;
00183         if(mdcCol.size() != 0)
00184         {       
00185                 for(;it_mdc != mdcCol.end();it_mdc++)
00186                 {       
00187                         int trkIndexmdc = (*it_mdc)->getTrackIndex();
00188                         if(trkIndexmdc == trk_Idx)   
00189                         {  
00190                                 vmdc.push_back(it_mdc);
00191                         }
00192                 }
00193         }
00194         if(tofCol.size() != 0)
00195         {
00196                 for(;it_tof != tofCol.end();it_tof++)
00197                 {       
00198                         int trkIndextof = (*it_tof)->getTrackIndex();
00199                         if(trkIndextof==trk_Idx)      vtof.push_back(it_tof);
00200                 }
00201         }
00202 
00203         if(emcCol.size() != 0)
00204         {
00205                 for(;it_emc != emcCol.end();it_emc++)
00206                 {
00207                         int trkIndexemc = (*it_emc)->getTrackIndex();
00208                         if(trkIndexemc==trk_Idx)      vemc.push_back(it_emc);
00209                 }
00210         }
00211 
00212         if(mucCol.size() != 0)
00213         {
00214                 for(;it_muc != mucCol.end();it_muc++)
00215                 {
00216                         int trkIndexmuc = (*it_muc)->getTrackIndex();
00217                         if(trkIndexmuc==trk_Idx)      vmuc.push_back(it_muc);
00218                 }
00219         }
00220 
00221 
00222         for(int i=0;;i++)
00223         {       
00224                 bool bmdc=(i>vmdc.size())?true:false;
00225                 bool btof=(i>vtof.size())?true:false;
00226                 bool bemc=(i>vemc.size())?true:false;
00227                 bool bmuc=(i>vmuc.size())?true:false;   
00228                 if((i>=vmdc.size())&&(i>=vtof.size())&&(i>=vemc.size())&&(i>=vmuc.size())) break;
00229                 os<< '\t' ;
00230                 if(vmdc.size()>0)
00231                 {
00232                         if(i<vmdc.size())
00233                         {
00234                                 const Identifier ident_mdc = (*vmdc[i])->identify();
00235                                 os<<setw(4)<<MdcID::layer(ident_mdc);
00236                                 os<<setw(6)<<MdcID::wire(ident_mdc);
00237                                 os<<setw(10)<<(*vmdc[i])->getDriftDistance();
00238                                 os<<setw(21)<<(*vmdc[i])->getDepositEnergy();
00239                         }else{for (int m = 0; m < 16; m++)  os<<" ";}
00240                 }else{for (int m = 0; m < 16; m++)  os<<" ";}
00241 
00242 
00243                 if(vtof.size()>0)
00244                 {
00245                         if(i<vtof.size())
00246                         {
00247                                 const Identifier ident_tof =(*vtof[i])->identify();
00248                                 if(TofID::barrel_ec(ident_tof)==1){os<<"B  "<<"  ";}
00249                                 if(TofID::barrel_ec(ident_tof)==0){os<<"E_E"<<"  ";}
00250                                 if(TofID::barrel_ec(ident_tof)==2){os<<"W_E"<<"  ";}
00251                                 os<<setw(3)<<TofID::layer(ident_tof);
00252                                 os<<setw(17)<<TofID::phi_module(ident_tof);
00253                         }else{for (int m = 0; m < 25; m++)  os<<" ";}
00254                 }else{for (int m = 0; m < 25; m++)  os<<" ";}
00255 
00256 
00257                 if(vemc.size()>0)
00258                 {
00259                         if(i<vemc.size())
00260                         {
00261                                 const Identifier ident_emc = (*vemc[i])->identify();
00262                                 if(EmcID::barrel_ec(ident_emc)==1){os<<"B  "<<"  ";}
00263                                 if(EmcID::barrel_ec(ident_emc)==0){os<<"E_E"<<"  ";}
00264                                 if(EmcID::barrel_ec(ident_emc)==2){os<<"W_E"<<"  ";}
00265                                 os<<setw(5)<<EmcID::theta_module(ident_emc);
00266                                 os<<setw(9)<<EmcID::phi_module(ident_emc);
00267                         }else{for (int m = 0; m < 19; m++)  os<<" ";}
00268                 }else{for (int m = 0; m < 19; m++)  os<<" ";}
00269 
00270                 if(vmuc.size()>0)
00271                 {
00272                         if(i<vmuc.size())
00273                         {
00274                                 const Identifier ident_muc = (*vmuc[i])->identify();
00275                                 if(MucID::barrel_ec(ident_muc)==1){os<<"B  "<<"  ";}
00276                                 if(MucID::barrel_ec(ident_muc)==0){os<<"E_E"<<"  ";}
00277                                 if(MucID::barrel_ec(ident_muc)==2){os<<"W_E"<<"  ";}
00278                                 os<<setw(3)<<MucID::segment(ident_muc);
00279                                 os<<setw(3)<<MucID::layer(ident_muc);
00280                                 os<<setw(4)<<MucID::strip(ident_muc);
00281                                 os<<endl;
00282                         }else{ os<<endl;}
00283                 }else{os<<endl;}
00284 
00285 
00286                 i++;
00287         }
00288         vmdc.clear();
00289         vtof.clear();
00290         vemc.clear();
00291         vmuc.clear();
00292 
00293 }

void PrintMcInfo::printPartInf ofstream ,
Event::McParticle ,
int &  ,
int 
 

void PrintMcInfo::printPartInf ofstream ,
Event::McParticle ,
int &  ,
int 
 

00101 {
00102         bool decay = (pMc->daughterList()).size()==0?false:true;
00103         if(decay)
00104         {
00105                 SmartDataPtr<Event::MdcMcHitCol> mdcMcHitCol(eventSvc(), "/Event/MC/MdcMcHitCol");
00106                 SmartDataPtr<Event::TofMcHitCol> tofMcHitCol(eventSvc(), "/Event/MC/TofMcHitCol");
00107                 SmartDataPtr<Event::EmcMcHitCol> emcMcHitCol(eventSvc(), "/Event/MC/EmcMcHitCol");
00108                 SmartDataPtr<Event::MucMcHitCol> mucMcHitCol(eventSvc(), "/Event/MC/MucMcHitCol");
00109 
00110                 SmartRefVector<Event::McParticle>::const_iterator begin = (pMc->daughterList()).begin();
00111                 SmartRefVector<Event::McParticle>::const_iterator end = (pMc->daughterList()).end();
00112                 SmartRefVector<Event::McParticle>::const_iterator it;
00113                 for(it = begin;it != end;it++)
00114                 {       
00115                         m_trkIndex = (*it)->trackIndex();
00116                         map<int,string>::iterator iter;
00117                         iter = map_pid.find((*it)->particleProperty());
00118                         if(iter!=map_pid.end())
00119                         {       
00120                                 daughters = iter->second;
00121                                 if(m_OutputLevel == 1)
00122                                 {       
00123                                         os.setf(ios::left);
00124                                         os<<"["<<m_trkIndex<<"]"<<setw(20)<<daughters<<endl;
00125 
00126                                         HepLorentzVector p4 = (*it)->initialFourMomentum();
00127                                         os<<"  "<<"["<<setw(12)<<p4.vect().cosTheta()<<setw(12)<<p4.vect().phi()<<"]  ";
00128                                         os<<"["<<setw(12)<<p4.x()<<setw(12)<<p4.y()
00129                                                 <<setw(12)<<p4.z()<<" "<<setw(10)<<p4.t()<<"]  ";
00130 
00131                                         //os<<"["<<setw(4)<<(*it)->vertexIndex0();
00132                                         HepLorentzVector ipst = (*it)->initialPosition();
00133                                         os<<"["<<setw(12)<<ipst.x();
00134                                         os<<setw(12)<<ipst.y();
00135                                         os<<setw(10)<<ipst.z()<<"]  ";
00136                                         //os<<setw(8)<<ipst.t()<<"]  ";                                 
00137 
00138                                         //os<<"["<<setw(4)<<(*it)->vertexIndex1();
00139                                         HepLorentzVector fpst = (*it)->finalPosition();
00140                                         os<<"["<<setw(12)<<fpst.x();
00141                                         os<<setw(12)<<fpst.y();
00142                                         os<<setw(10)<<fpst.z()<<"]  ";
00143                                         //os<<setw(8)<<fpst.t()<<"]";
00144                                 }
00145                                 if(m_OutputLevel==2)
00146                                 {       
00147                                         os.setf(ios::left);
00148                                         os<<"["<<m_trkIndex<<"]"<<setw(12)<<daughters<<endl;
00149 
00150                                         int trkIdx = (*it)->trackIndex();
00151                                         PrintMcInfo::printHit(os,mdcMcHitCol,tofMcHitCol,emcMcHitCol,mucMcHitCol,trkIdx);
00152                                 }
00153                                 os<<endl;
00154                         }
00155                         else cout<<"can not find the daughter particle in pdt_table"<<endl;
00156                 }
00157                 daughters.erase();
00158 
00159                 for(it = begin;it != end;it++)
00160                 {
00161                         SmartRef<Event::McParticle> pdMc = (*it);
00162                         printPartInf(os,pdMc,m_OutputLevel,tab+1);
00163                 }
00164         }
00165 }

void PrintMcInfo::printTitle ofstream os,
int & 
 

void PrintMcInfo::printTitle ofstream os,
int & 
 

00028 {
00029         if(m_OutputLevel==1)
00030         {
00031                 os<<'\n'<<"    "<<setw(27)<<"cosTeta  phi"<<setw(50)<<"P4 : momentum Energy"
00032                         <<setw(15)<<" "<<setw(40)<<"initialPosition"
00033                         <<setw(15)<<"finalPosition"<<endl;
00034                 for (int m = 0; m < 5; m++) {os<< '\t';}
00035                 os<<"Px, Py, Pz , E (Gev)";
00036                 for (int m = 0; m < 5; m++) {os<< '\t';}
00037                 os<<"x(cm) y(cm) z(cm)";
00038                 for (int m = 0; m < 3; m++) {os<< '\t';}
00039                 os  <<"x(cm) y(cm) z(cm)"<<endl;
00040         }
00041         /*      if(m_OutputLevel==2)  
00042                 {
00043                 os<<'\t'<<"MdcHit"<<'\t'<<'\t'<<"TofHit"<<'\t'<<'\t'<<'\t'<<"EmcHit"<<'\t'<<'\t'<<'\t'<<"MucHit"
00044                 <<endl;
00045                 os<<'\t'<<"(layer wire)"<<"  "<<"(b/ec layer phi_module)"<<"  "<<"(b/ec theta phi)"<<"  "<<"(b/ec segment layer strip)"<<endl;
00046                 }
00047          */
00048 }

void PrintMcInfo::printTree ofstream ,
Event::McParticle ,
int &  ,
int 
 

void PrintMcInfo::printTree ofstream ,
Event::McParticle ,
int &  ,
int 
 

00054 {         
00055         bool decay = (pmcp->daughterList()).size()==0?false:true;
00056         if(decay)
00057         {
00058                 for (int m = 0; m < tab; m++) {os<< '\t';}
00059 
00060                 m_pid = (*pmcp).particleProperty();
00061                 m_trkIndex = (*pmcp).trackIndex();
00062                 map<int,string>::iterator iterPar;
00063                 iterPar = map_pid.find(m_pid);
00064                 if (iterPar!=map_pid.end())
00065                         os<<iterPar->second<<"["<<m_trkIndex<<"]"<<" "<<"->";
00066 
00067                 //loop: to get the daughters of the decayed particle
00068                 SmartRefVector<Event::McParticle>::const_iterator begin = (pmcp->daughterList()).begin();
00069                 SmartRefVector<Event::McParticle>::const_iterator end = (pmcp->daughterList()).end();
00070                 SmartRefVector<Event::McParticle>::const_iterator it;
00071                 for(it = begin;it != end;it++)
00072                 {      
00073                         m_trkIndex = (*it)->trackIndex();
00074                         map<int,string>::iterator iter;
00075                         iter = map_pid.find((*it)->particleProperty());
00076                         if(iter!=map_pid.end())
00077                         {               
00078                                 daughters = iter->second;
00079                                 m_trkIndex = (*it)->trackIndex();
00080                                 os.setf(ios::left);
00081                                 os<<daughters<<"["<<m_trkIndex<<"]"<<" ";
00082                                 daughters.erase();
00083                         }
00084                         else
00085                                 cout<<"can not find the daughter particle in pdt_table"<<endl;
00086                 }
00087                 os<<endl;
00088 
00089                 for(it = begin;it != end;it++)
00090                 {       
00091                         SmartRef<Event::McParticle> pdMc = (*it);
00092                         printTree(os,pdMc,m_OutputLevel,tab+1);
00093                 }
00094         }
00095 }


Member Data Documentation

string PrintMcInfo::daughters [private]
 

string PrintMcInfo::m_FileName [private]
 

bool PrintMcInfo::m_firstTime [private]
 

int PrintMcInfo::m_OutputLevel [private]
 

int PrintMcInfo::m_pid [private]
 

int PrintMcInfo::m_trkIndex [private]
 

map<int,string> PrintMcInfo::map_pid [private]
 

map<int,string> PrintMcInfo::map_pid [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 16:41:42 2011 for BOSS6.5.5 by  doxygen 1.3.9.1