BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
TruthDemo Class Reference

#include <TruthDemo.h>

+ Inheritance diagram for TruthDemo:

Public Member Functions

 TruthDemo (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 

Detailed Description

Definition at line 9 of file TruthDemo.h.

Constructor & Destructor Documentation

◆ TruthDemo()

TruthDemo::TruthDemo ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 43 of file TruthDemo.cxx.

43 :
44 Algorithm(name, pSvcLocator)
45{
46//Declare the algorithm's properties
47 declareProperty("HistogramFlag", m_produceHistogram = true );
48// declareProperty("HistogramFlag", m_produceHistogram = false );
49}

Member Function Documentation

◆ execute()

StatusCode TruthDemo::execute ( )

Definition at line 68 of file TruthDemo.cxx.

68 {
69// HepMC::IO_PDG_ParticleDataTable pdg_io("PDGTABLE");
70// static HepMC::ParticleDataTable *pp = NULL;
71// if (pp == NULL) pp = pdg_io.read_particle_data_table();
72 MsgStream msglog(messageService(), name());
73 msglog << MSG::INFO << ">>> TruthDemo from execute" << endreq;
74 //
75 // Px/Py Balance and total energy
76 //
77 float totenergy = 0.;
78 float pxbalance = 0.;
79 float pybalance = 0.;
80 // Iterate over MC particles We are using the IsGenStable predicate from
81 IsGenStable ifs;
82 std::vector<const HepMC::GenParticle*> particles;
83 StatusCode stat = m_tesIO->getMC(particles, &ifs);
84 for (std::vector<const HepMC::GenParticle*>::iterator pitr = particles.begin();
85 pitr != particles.end(); pitr++) {
86 pxbalance += (*pitr)->momentum().x();
87 pybalance += (*pitr)->momentum().y();
88 totenergy += (*pitr)->momentum().e();
89 }
90 m_pxBalance->fill(pxbalance, 1.);
91 m_pyBalance->fill(pybalance, 1.);
92 m_totEnergy->fill(totenergy, 1.);
93 // End of execution for each event
94 return StatusCode::SUCCESS;
95}
StatusCode getMC(MCparticleCollection &) const

◆ finalize()

StatusCode TruthDemo::finalize ( )

Definition at line 97 of file TruthDemo.cxx.

97 {
98 MsgStream msglog(messageService(), name());
99 msglog << MSG::INFO << ">>> TruthDemo from finalize" << endreq;
100 return StatusCode::SUCCESS;
101}

◆ initialize()

StatusCode TruthDemo::initialize ( )

Definition at line 51 of file TruthDemo.cxx.

51 {
52 StatusCode result = StatusCode::SUCCESS;
53 MsgStream msglog(messageService(), name());
54 msglog << MSG::INFO << ">>> Truthdemo from Initialize" << endreq;
55 m_hgenerated = histoSvc()->book("/stat/1Dhist/1","Generated",100,0,1200);
56 if (0 == m_hgenerated) {
57 msglog << MSG::ERROR << " ERROR booking histogram" << endreq;
58 result = StatusCode::FAILURE;
59 }
60 m_pxBalance = histoSvc()->book("/stat/1Dhist/25","px balance",50,-10.,10.);
61 m_pyBalance = histoSvc()->book("/stat/1Dhist/26","py balance",50,-10.,10.);
62 m_totEnergy = histoSvc()->book("/stat/1Dhist/27","total energy",50,10000.,20000.);
63 m_tesIO = new GenAccessIO();
64
65// return StatusCode::SUCCESS;
66 return result;
67}
IHistogramSvc * histoSvc()

The documentation for this class was generated from the following files: