6#include "TruthExamples/TruthDemo.h"
7#include "GeneratorObject/McEventCollection.h"
9#include "GaudiKernel/MsgStream.h"
10#include "GaudiKernel/AlgFactory.h"
12#include "GaudiKernel/SmartDataPtr.h"
13#include "GaudiKernel/DataSvc.h"
15#include "GaudiKernel/IHistogramSvc.h"
19#include "AIDA/IHistogram1D.h"
20#include "AIDA/IHistogram2D.h"
22#include "GaudiKernel/PropertyMgr.h"
23#include "GaudiKernel/INTupleSvc.h"
24#include "GaudiKernel/ISvcLocator.h"
25#include "GaudiKernel/IDataProviderSvc.h"
26#include "GaudiKernel/MsgStream.h"
27#include "GaudiKernel/ObjectList.h"
29#include "HepMC/GenEvent.h"
30#include "HepMC/GenParticle.h"
34#include "HepMC/GenVertex.h"
43 Algorithm(name, pSvcLocator)
46 declareProperty(
"HistogramFlag", m_produceHistogram =
true );
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;
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.);
71 MsgStream msglog(messageService(), name());
72 msglog << MSG::INFO <<
">>> TruthDemo from execute" << endreq;
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();
89 m_pxBalance->fill(pxbalance, 1.);
90 m_pyBalance->fill(pybalance, 1.);
91 m_totEnergy->fill(totenergy, 1.);
93 return StatusCode::SUCCESS;
97 MsgStream msglog(messageService(), name());
98 msglog << MSG::INFO <<
">>> TruthDemo from finalize" << endreq;
99 return StatusCode::SUCCESS;
IHistogramSvc * histoSvc()
std::vector< const HepMC::GenParticle * > MCparticleCollection
const IAlgFactory & TruthDemoFactory
StatusCode getMC(MCparticleCollection &) const
TruthDemo(const std::string &name, ISvcLocator *pSvcLocator)