BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
PrintMcInfo.cxx
Go to the documentation of this file.
2#include "GaudiKernel/IDataProviderSvc.h"
3#include "GaudiKernel/IHistogramSvc.h"
4#include "GaudiKernel/ISvcLocator.h"
5#include "GaudiKernel/MsgStream.h"
6#include "GaudiKernel/PropertyMgr.h"
7#include "GaudiKernel/SmartDataLocator.h"
8#include "GaudiKernel/SmartDataPtr.h"
9
10#include "EventModel/Event.h"
11#include "EventModel/EventModel.h"
12#include "McTruth/McParticle.h"
13#include "TMath.h"
14#include <fstream>
15
16#include "EventModel/EventHeader.h"
17#include "EvtRecEvent/EvtRecEvent.h"
18#include "EvtRecEvent/EvtRecTrack.h"
19
20#include <string>
21using namespace std;
22
24//------------------
25PrintMcInfo::PrintMcInfo( const std::string& name, ISvcLocator* pSvcLocator )
26 : Algorithm( name, pSvcLocator ) {
27
28 declareProperty( "PrintLevel", m_OutputLevel = 0 );
29 declareProperty( "FileName", m_FileName );
30 declareProperty( "fstreamOption", m_fstreamOption = 1 );
31}
33
35 // make a map for tanslating the PDG code to its name
37
38 if ( m_fstreamOption == 0 ) { os.open( m_FileName.c_str(), ios::app ); }
39 else os.open( m_FileName.c_str() );
40
41 MsgStream log( msgSvc(), name() );
42 log << MSG::INFO << "PrintMcInfo::initialize()" << endmsg;
43
44 StatusCode status;
45 return StatusCode::SUCCESS;
46}
48 MsgStream log( msgSvc(), name() );
49 log << MSG::INFO << "PrintMcInfo::beginRun()" << endmsg;
50 // add your code here
51 return StatusCode::SUCCESS;
52}
53
54//--------------------execute----------------
55
57 MsgStream log( msgSvc(), name() );
58 log << MSG::INFO << "PrintMcInfo::execute()" << endmsg;
59
60 /* if(m_fstreamOption==0)
61 {
62 os.open(m_FileName.c_str(),ios::app);
63 }
64 else os.open(m_FileName.c_str());
65 */
66 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
67 int runNo = eventHeader->runNumber();
68 int event = eventHeader->eventNumber();
69 os << "run number:" << runNo << endl << "event number:" << event << endl << endl;
70
71 SmartDataPtr<Event::McParticleCol> mcPartCol( eventSvc(), "/Event/MC/McParticleCol" );
72 if ( runNo < 0 )
73 {
74 if ( !mcPartCol )
75 {
76 log << MSG::ERROR << "Could not retrieve McParticelCol" << endmsg;
77 return StatusCode::FAILURE;
78 }
79
80 Event::McParticleCol::iterator iter_mc = mcPartCol->begin();
81 for ( ; iter_mc != mcPartCol->end(); iter_mc++ )
82 {
83 bool primary = ( *iter_mc )->primaryParticle();
84 bool gamma = ( ( *iter_mc )->particleProperty() ) == 22 ? true : false;
85 if ( primary && ( !gamma ) )
86 {
87 Event::McParticle* pMcPart = ( *iter_mc );
88 pMcPart->trackIndex();
89 PrintMcInfo::printTree( os, pMcPart, m_OutputLevel, 0 );
90 if ( m_OutputLevel > 0 )
91 {
92 os << endl
93 << "\n- - - - - - - - - - - - - - Information in this decay tree : particle "
94 "level - - - - - - - - - - - - - -- - -- - -\n"
95 << endl;
97 PrintMcInfo::printPartInf( os, pMcPart, 1, 0 );
98 }
99 if ( m_OutputLevel > 1 )
100 {
101 os << endl
102 << "\n- - - - - - - - - - - - - - Information in this decay tree : hit "
103 "level - - - - - - - - - - - - - - - - - - - -\n"
104 << endl;
105 PrintMcInfo::printPartInf( os, pMcPart, 2, 0 );
106 }
107 }
108 }
109 if ( m_OutputLevel > 2 )
110 {
111 os << endl
112 << "\n- - - - - - - - - - - - - - Digi Information in this EVENT - - - - - - - - - "
113 "- - - - - - - - - -\n"
114 << endl;
115 printDigi( os );
116 }
117
118 os << endl
119 << "\n******************************** end of this event "
120 "*********************************\n"
121 << endl;
122
123 } // end of if(runNo < 0)
124 return StatusCode::SUCCESS;
125}
126
128 MsgStream log( msgSvc(), name() );
129 log << MSG::INFO << "PrintMcInfo::finalize()" << endmsg;
130 return StatusCode::SUCCESS;
131}
DECLARE_COMPONENT(BesBdkRc)
int runNo
Definition DQA_TO_DB.cxx:13
IMessageSvc * msgSvc()
StatusCode beginRun()
void printPartInf(ofstream &, Event::McParticle *, int, int)
Definition McTruth.cxx:107
StatusCode execute()
void printTree(ofstream &, Event::McParticle *, int, int)
Definition McTruth.cxx:50
PrintMcInfo(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode finalize()
void printDigi(ofstream &)
Definition Digi.cxx:4
void printTitle(ofstream &os, int)
Definition McTruth.cxx:25
void mkmap()
Definition McTruth.cxx:4
StatusCode initialize()