BOSS 7.1.2
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
23DECLARE_COMPONENT(PrintMcInfo)
24//------------------
25PrintMcInfo::PrintMcInfo(const std::string& name, ISvcLocator* pSvcLocator):Algorithm(name,pSvcLocator)
26{
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)
39 {
40 os.open(m_FileName.c_str(),ios::app);
41 }
42 else os.open(m_FileName.c_str());
43
44
45
46
47
48 MsgStream log(msgSvc(), name());
49 log<<MSG::INFO<<"PrintMcInfo::initialize()"<<endreq;
50
51 StatusCode status;
52 return StatusCode::SUCCESS;
53}
55 MsgStream log(msgSvc(), name());
56 log<<MSG::INFO<<"PrintMcInfo::beginRun()"<<endreq;
57 //add your code here
58 return StatusCode::SUCCESS;
59
60}
61
62
63//--------------------execute----------------
64
65
67 MsgStream log(msgSvc(), name());
68 log<<MSG::INFO<<"PrintMcInfo::execute()"<<endreq;
69
70
71/* if(m_fstreamOption==0)
72 {
73 os.open(m_FileName.c_str(),ios::app);
74 }
75 else os.open(m_FileName.c_str());
76*/
77 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
78 int runNo=eventHeader->runNumber();
79 int event=eventHeader->eventNumber();
80 os<<"run number:"<<runNo<<endl
81 <<"event number:"<<event<<endl<<endl;
82
83
84 SmartDataPtr<Event::McParticleCol> mcPartCol(eventSvc(), "/Event/MC/McParticleCol");
85 if (runNo < 0)
86 {
87 if(!mcPartCol)
88 {
89 log << MSG::ERROR << "Could not retrieve McParticelCol" << endreq;
90 return StatusCode::FAILURE;
91 }
92
93 Event::McParticleCol::iterator iter_mc = mcPartCol->begin();
94 for (;iter_mc !=mcPartCol->end();iter_mc++)
95 {
96 bool primary = (*iter_mc)->primaryParticle();
97 bool gamma = ((*iter_mc)->particleProperty())==22?true:false;
98 if(primary&&(!gamma))
99 {
100 Event::McParticle* pMcPart = (*iter_mc);
101 pMcPart->trackIndex();
102 PrintMcInfo::printTree(os,pMcPart,m_OutputLevel,0);
103 if(m_OutputLevel>0)
104 {
105 os<<endl<<"\n- - - - - - - - - - - - - - Information in this decay tree : particle level - - - - - - - - - - - - - -- - -- - -\n"<<endl;
107 PrintMcInfo::printPartInf(os,pMcPart,1,0);
108 }
109 if(m_OutputLevel>1)
110 {
111 os<<endl<<"\n- - - - - - - - - - - - - - Information in this decay tree : hit level - - - - - - - - - - - - - - - - - - - -\n"<<endl;
112 PrintMcInfo::printPartInf(os,pMcPart,2,0);
113 }
114 }
115 }
116 if(m_OutputLevel>2)
117 {
118 os<<endl<<"\n- - - - - - - - - - - - - - Digi Information in this EVENT - - - - - - - - - - - - - - - - - - -\n"<<endl;
119 printDigi(os);
120 }
121
122 os<<endl<<"\n******************************** end of this event *********************************\n"<<endl;
123
124
125 }//end of if(runNo < 0)
126 return StatusCode::SUCCESS;
127}
128
129
130
131
133 MsgStream log(msgSvc(), name());
134 log<<MSG::INFO<<"PrintMcInfo::endRun()"<<endreq;
135 return StatusCode::SUCCESS;
136
137}
139 MsgStream log(msgSvc(), name());
140 log<<MSG::INFO<<"PrintMcInfo::finalize()"<<endreq;
141 return StatusCode::SUCCESS;
142
143}
144
145
int runNo
Definition DQA_TO_DB.cxx:12
IMessageSvc * msgSvc()
int trackIndex() const
Definition McParticle.h:131
StatusCode beginRun()
StatusCode endRun()
void printPartInf(ofstream &, Event::McParticle *, int, int)
Definition McTruth.cxx:113
StatusCode execute()
void printTree(ofstream &, Event::McParticle *, int, int)
Definition McTruth.cxx:55
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()