/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Simulation/BOOST/PrintMcInfo/PrintMcInfo-00-00-03/src/PrintMcInfo.cxx

Go to the documentation of this file.
00001 #include "PrintMcInfo/PrintMcInfo.h"
00002 #include "GaudiKernel/IHistogramSvc.h"
00003 #include "GaudiKernel/MsgStream.h"
00004 #include "GaudiKernel/ISvcLocator.h"
00005 #include "GaudiKernel/SmartDataPtr.h"
00006 #include "GaudiKernel/SmartDataLocator.h"
00007 #include "GaudiKernel/IDataProviderSvc.h"
00008 #include "GaudiKernel/PropertyMgr.h"
00009 
00010 #include "TMath.h"
00011 #include "EventModel/EventModel.h"
00012 #include "EventModel/Event.h"
00013 #include "McTruth/McParticle.h"
00014 #include <fstream>
00015 
00016 #include "EvtRecEvent/EvtRecEvent.h"
00017 #include "EvtRecEvent/EvtRecTrack.h"
00018 #include "EventModel/EventHeader.h"
00019 
00020 #include <string>
00021 using namespace std;
00022 
00023 //------------------
00024 PrintMcInfo::PrintMcInfo(const std::string& name, ISvcLocator* pSvcLocator):Algorithm(name,pSvcLocator)
00025 {
00026 
00027         declareProperty("PrintLevel", m_OutputLevel=0);
00028         declareProperty("FileName", m_FileName );
00029         declareProperty("fstreamOption",m_fstreamOption=1);
00030 }
00031 PrintMcInfo::~PrintMcInfo() {  }
00032 
00033 StatusCode PrintMcInfo::initialize(){
00034         //make a map for tanslating the PDG code to its name 
00035         PrintMcInfo::mkmap();
00036 
00037         if(m_fstreamOption==0)
00038         {
00039                 os.open(m_FileName.c_str(),ios::app);   
00040         }
00041         else    os.open(m_FileName.c_str());
00042 
00043 
00044 
00045 
00046 
00047         MsgStream log(msgSvc(), name());
00048         log<<MSG::INFO<<"PrintMcInfo::initialize()"<<endreq;
00049 
00050         StatusCode status;
00051         return StatusCode::SUCCESS;
00052 }
00053 StatusCode PrintMcInfo::beginRun(){
00054         MsgStream log(msgSvc(), name());
00055         log<<MSG::INFO<<"PrintMcInfo::beginRun()"<<endreq;
00056         //add your code here
00057         return StatusCode::SUCCESS;
00058 
00059 }
00060 
00061 
00062 //--------------------execute----------------
00063 
00064 
00065 StatusCode PrintMcInfo::execute(){
00066         MsgStream log(msgSvc(), name());
00067         log<<MSG::INFO<<"PrintMcInfo::execute()"<<endreq;
00068 
00069 
00070 /*      if(m_fstreamOption==0)
00071         {
00072                 os.open(m_FileName.c_str(),ios::app);   
00073         }
00074         else    os.open(m_FileName.c_str());
00075 */
00076         SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
00077         int runNo=eventHeader->runNumber();
00078         int event=eventHeader->eventNumber();
00079         os<<"run number:"<<runNo<<endl
00080                 <<"event number:"<<event<<endl<<endl;
00081 
00082 
00083         SmartDataPtr<Event::McParticleCol> mcPartCol(eventSvc(), "/Event/MC/McParticleCol");
00084         if (runNo < 0) 
00085         {
00086                 if(!mcPartCol)
00087                 {
00088                         log << MSG::ERROR << "Could not retrieve McParticelCol" << endreq;
00089                         return StatusCode::FAILURE;
00090                 }
00091 
00092                 Event::McParticleCol::iterator iter_mc = mcPartCol->begin();
00093                 for (;iter_mc !=mcPartCol->end();iter_mc++)
00094                 {
00095                         bool primary = (*iter_mc)->primaryParticle();
00096                         bool gamma = ((*iter_mc)->particleProperty())==22?true:false;
00097                         if(primary&&(!gamma))
00098                         {       
00099                                 Event::McParticle* pMcPart = (*iter_mc);
00100                                 pMcPart->trackIndex();
00101                                 PrintMcInfo::printTree(os,pMcPart,m_OutputLevel,0);
00102                                 if(m_OutputLevel>0)
00103                                 {       
00104                                         os<<endl<<"\n- - - - - - - - - - - - - -  Information in this decay tree :   particle level  - - - - - - - - - - - - - -- - -- - -\n"<<endl;
00105                                         PrintMcInfo::printTitle(os,1);
00106                                         PrintMcInfo::printPartInf(os,pMcPart,1,0);
00107                                 }
00108                                 if(m_OutputLevel>1)
00109                                 {       
00110                                         os<<endl<<"\n- - - - - - - - - - - - - -  Information in this decay tree :      hit level  - - - - - - - - - - - - - - - - - - - -\n"<<endl;
00111                                         PrintMcInfo::printPartInf(os,pMcPart,2,0);
00112                                 }
00113                         }                       
00114                 }
00115                 if(m_OutputLevel>2)
00116                 {
00117                         os<<endl<<"\n- - - - - -  - - - - - - - -  Digi Information in this EVENT - - - - - - - - - - - - - - - - - -  -\n"<<endl;
00118                         printDigi(os);
00119                 }
00120 
00121                 os<<endl<<"\n********************************   end of this event   *********************************\n"<<endl;
00122 
00123 
00124         }//end of if(runNo < 0)
00125         return StatusCode::SUCCESS;
00126 }
00127 
00128 
00129 
00130 
00131 StatusCode PrintMcInfo::endRun(){
00132         MsgStream log(msgSvc(), name());
00133         log<<MSG::INFO<<"PrintMcInfo::endRun()"<<endreq;
00134         return StatusCode::SUCCESS;
00135 
00136 }
00137 StatusCode PrintMcInfo::finalize(){
00138         MsgStream log(msgSvc(), name());
00139         log<<MSG::INFO<<"PrintMcInfo::finalize()"<<endreq;
00140         return StatusCode::SUCCESS;
00141 
00142 }
00143 
00144 

Generated on Tue Nov 29 23:14:30 2016 for BOSS_7.0.2 by  doxygen 1.4.7