#include <TruthDemo.h>
Public Member Functions | |
TruthDemo (const std::string &name, ISvcLocator *pSvcLocator) | |
StatusCode | initialize () |
StatusCode | execute () |
StatusCode | finalize () |
Private Attributes | |
bool | m_produceHistogram |
IHistogram1D * | m_hgenerated |
IHistogram1D * | m_pxBalance |
IHistogram1D * | m_pyBalance |
IHistogram1D * | m_totEnergy |
IHistogram1D * | m_negStatus |
GenAccessIO * | m_tesIO |
Definition at line 9 of file TruthDemo.h.
TruthDemo::TruthDemo | ( | const std::string & | name, | |
ISvcLocator * | pSvcLocator | |||
) |
Definition at line 42 of file TruthDemo.cxx.
References m_produceHistogram.
00042 : 00043 Algorithm(name, pSvcLocator) 00044 { 00045 //Declare the algorithm's properties 00046 declareProperty("HistogramFlag", m_produceHistogram = true ); 00047 // declareProperty("HistogramFlag", m_produceHistogram = false ); 00048 }
StatusCode TruthDemo::execute | ( | ) |
Definition at line 67 of file TruthDemo.cxx.
References GenAccessIO::getMC(), Bes_Common::INFO, m_pxBalance, m_pyBalance, m_tesIO, and m_totEnergy.
00067 { 00068 // HepMC::IO_PDG_ParticleDataTable pdg_io("PDGTABLE"); 00069 // static HepMC::ParticleDataTable *pp = NULL; 00070 // if (pp == NULL) pp = pdg_io.read_particle_data_table(); 00071 MsgStream msglog(messageService(), name()); 00072 msglog << MSG::INFO << ">>> TruthDemo from execute" << endreq; 00073 // 00074 // Px/Py Balance and total energy 00075 // 00076 float totenergy = 0.; 00077 float pxbalance = 0.; 00078 float pybalance = 0.; 00079 // Iterate over MC particles We are using the IsGenStable predicate from 00080 IsGenStable ifs; 00081 std::vector<const HepMC::GenParticle*> particles; 00082 StatusCode stat = m_tesIO->getMC(particles, &ifs); 00083 for (std::vector<const HepMC::GenParticle*>::iterator pitr = particles.begin(); 00084 pitr != particles.end(); pitr++) { 00085 pxbalance += (*pitr)->momentum().x(); 00086 pybalance += (*pitr)->momentum().y(); 00087 totenergy += (*pitr)->momentum().e(); 00088 } 00089 m_pxBalance->fill(pxbalance, 1.); 00090 m_pyBalance->fill(pybalance, 1.); 00091 m_totEnergy->fill(totenergy, 1.); 00092 // End of execution for each event 00093 return StatusCode::SUCCESS; 00094 }
StatusCode TruthDemo::finalize | ( | ) |
Definition at line 96 of file TruthDemo.cxx.
References Bes_Common::INFO.
00096 { 00097 MsgStream msglog(messageService(), name()); 00098 msglog << MSG::INFO << ">>> TruthDemo from finalize" << endreq; 00099 return StatusCode::SUCCESS; 00100 }
StatusCode TruthDemo::initialize | ( | ) |
Definition at line 50 of file TruthDemo.cxx.
References calibUtil::ERROR, histoSvc(), Bes_Common::INFO, m_hgenerated, m_pxBalance, m_pyBalance, m_tesIO, and m_totEnergy.
00050 { 00051 StatusCode result = StatusCode::SUCCESS; 00052 MsgStream msglog(messageService(), name()); 00053 msglog << MSG::INFO << ">>> Truthdemo from Initialize" << endreq; 00054 m_hgenerated = histoSvc()->book("/stat/1Dhist/1","Generated",100,0,1200); 00055 if (0 == m_hgenerated) { 00056 msglog << MSG::ERROR << " ERROR booking histogram" << endreq; 00057 result = StatusCode::FAILURE; 00058 } 00059 m_pxBalance = histoSvc()->book("/stat/1Dhist/25","px balance",50,-10.,10.); 00060 m_pyBalance = histoSvc()->book("/stat/1Dhist/26","py balance",50,-10.,10.); 00061 m_totEnergy = histoSvc()->book("/stat/1Dhist/27","total energy",50,10000.,20000.); 00062 m_tesIO = new GenAccessIO(); 00063 00064 // return StatusCode::SUCCESS; 00065 return result; 00066 }
IHistogram1D* TruthDemo::m_hgenerated [private] |
IHistogram1D* TruthDemo::m_negStatus [private] |
Definition at line 24 of file TruthDemo.h.
bool TruthDemo::m_produceHistogram [private] |
IHistogram1D* TruthDemo::m_pxBalance [private] |
IHistogram1D* TruthDemo::m_pyBalance [private] |
GenAccessIO* TruthDemo::m_tesIO [private] |
IHistogram1D* TruthDemo::m_totEnergy [private] |