BOSS 7.0.7
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 42 of file TruthDemo.cxx.

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

Member Function Documentation

◆ execute()

StatusCode TruthDemo::execute ( )

Definition at line 67 of file TruthDemo.cxx.

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

◆ finalize()

StatusCode TruthDemo::finalize ( )

Definition at line 96 of file TruthDemo.cxx.

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

◆ initialize()

StatusCode TruthDemo::initialize ( )

Definition at line 50 of file TruthDemo.cxx.

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

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