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