6#include "AthLinks/ElementLink.h"
8#include "GaudiKernel/MsgStream.h"
9#include "GaudiKernel/DataSvc.h"
10#include "GaudiKernel/PhysicalConstants.h"
31 return StatusCode::SUCCESS;
43 return StatusCode::FAILURE;
48 ATH_MSG_INFO(
"Number of pile-up events in this Athena event: " << mcColl->size()-1);
51 for (
unsigned int cntr = 0; cntr < mcColl->size(); ++cntr) {
61 return StatusCode::SUCCESS;
68 cout <<
"--------------------------------------------------------------------------------\n";
69 cout <<
"GenEvent: #" <<
"NNN" <<
"\n";
70 cout <<
" Entries this event: " <<
event->vertices_size() <<
" vertices, " <<
event->particles_size() <<
" particles.\n";
71 cout <<
" GenParticle Legend\n";
72 if (do4momPtEtaPhi) cout <<
" Barcode PDG ID ( pt, eta, phi, E ) Stat DecayVtx\n";
73 else cout <<
" Barcode PDG ID ( Px, Py, Pz, E ) Stat DecayVtx\n";
74 cout <<
"--------------------------------------------------------------------------------\n";
75 for (
const auto& iv: event->vertices()) {
printVertex(iv, do4momPtEtaPhi); }
76 cout <<
"--------------------------------------------------------------------------------\n";
83 std::ios::fmtflags f( cout.flags() );
84 cout <<
"GenVertex (" << vertex <<
"):";
86 if (vertex->position().x() != 0.0 && vertex->position().y() != 0.0 && vertex->position().z() != 0.0) {
95 cout.setf(std::ios::scientific, std::ios::floatfield);
96 cout.setf(std::ios_base::showpos);
97 cout << vertex->position().x() <<
",";
100 cout << vertex->position().y() <<
",";
103 cout << vertex->position().z() <<
",";
106 cout << vertex->position().t();
107 cout.setf(std::ios::fmtflags(0), std::ios::floatfield);
108 cout.unsetf(std::ios_base::showpos);
115 cout << vertex->id();
116 cout <<
" (X,cT): 0";
123 if (vertex->position().x() != 0.0 && vertex->position().y() != 0.0 && vertex->position().z() != 0.0) {
127 cout << vertex->id();
131 cout.setf(std::ios::scientific, std::ios::floatfield);
132 cout.setf(std::ios_base::showpos);
133 cout << vertex->position().x();
136 cout << vertex->position().y();
139 cout << vertex->position().z();
142 cout << vertex->position().t();
143 cout.setf(std::ios::fmtflags(0), std::ios::floatfield);
144 cout.unsetf(std::ios_base::showpos);
150 cout << vertex->id();
157 for (
const auto& iPIn: vertex->particles_in()) {
158 if ( iPIn == vertex->particles_in().front() ) {
161 cout << vertex->particles_in().size();
165 for (
const auto& iPOut: vertex->particles_out()) {
166 if ( iPOut == vertex->particles_out().front()) {
169 cout << vertex->particles_out().size();
179 if (!particle)
return;
180 std::ios::fmtflags f( cout.flags() );
185 cout << particle->pdg_id() <<
" ";
188 cout.setf(std::ios::scientific, std::ios::floatfield);
189 cout.setf(std::ios_base::showpos);
190 if (do4momPtEtaPhi) cout << particle->momentum().perp() <<
",";
191 else cout << particle->momentum().px() <<
",";
194 if (do4momPtEtaPhi) cout << particle->momentum().pseudoRapidity() <<
",";
195 else cout << particle->momentum().py() <<
",";
198 if (do4momPtEtaPhi) cout << particle->momentum().phi() <<
",";
199 else cout << particle->momentum().pz() <<
",";
202 cout << particle->momentum().e() <<
" ";
203 cout.setf(std::ios::fmtflags(0), std::ios::floatfield);
204 cout.unsetf(std::ios_base::showpos);
208 cout << particle->status() <<
" ";
214 cout << particle->status();
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
Helpers for checking error return status codes and reporting errors.
ATLAS-specific HepMC functions.
Handle class for reading from StoreGate.
An algorithm that can be simultaneously executed in multiple threads.
static void printVertex(const HepMC::ConstGenVertexPtr &vtx, bool do4momPtEtaPhi)
virtual StatusCode initialize()
Function initialising the algorithm.
HepMCTruthReader(const std::string &name, ISvcLocator *svcLoc)
Regular algorithm constructor.
Gaudi::Property< bool > m_do4momPtEtaPhi
Flag to printout in pt,eta,phi instead of px,py,pz.
static void printEvent(const HepMC::GenEvent *evt, bool do4momPtEtaPhi)
SG::ReadHandleKey< McEventCollection > m_hepMCContainerKey
The key of the input HepMC truth container.
static void printParticle(const HepMC::ConstGenParticlePtr &part, bool do4momPtEtaPhi)
virtual StatusCode execute(const EventContext &ctx) const
Function executing the algorithm.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
HepMC3::ConstGenVertexPtr ConstGenVertexPtr
HepMC3::GenEvent GenEvent
bool isDecayed(const T &p)
Identify if the particle decayed.