12#include "GaudiKernel/ITHistSvc.h"
13#include "Gaudi/Property.h"
14#include "GaudiKernel/GaudiException.h"
21#include "CLHEP/Units/SystemOfUnits.h"
29 const std::string& name,
30 const IInterface* parent ) :
31 base_class(
type, name, parent ),
39 declareProperty(
"Output",
41 "Name of the output file which will contain the HepMC tuple"
45 declareProperty(
"OutputStream",
47 "Name of the stream which will contain the HepMC tuple"
50 declareProperty(
"McEvents",
52 "Input location of the McEventCollection to write out" );
69 if ( !evtStore().retrieve().isSuccess() ) {
71 return StatusCode::FAILURE;
77 return StatusCode::FAILURE;
86 return StatusCode::SUCCESS;
92 return StatusCode::SUCCESS;
99 if ( evtStore()->retrieve( mcEvts,
m_mcEventsName ).isFailure() ||
nullptr == mcEvts ) {
101 return StatusCode::FAILURE;
104 if ( mcEvts->
empty() ) {
106 return StatusCode::FAILURE;
109 const HepMC::GenEvent * evt = mcEvts->
front();
111 ATH_MSG_ERROR(
"Retrieved NULL pointer to HepMC::GenEvent !!");
112 return StatusCode::FAILURE;
124 m_particles.m_nParticles = std::min<std::size_t>(
s_nMax, evt->particles_size() );
126 for (
const auto& p: *evt)
128 if (i ==
static_cast<std::size_t
>(
m_particles.m_nParticles))
break;
130 const HepMC::FourVector mom = p->momentum();
144 return StatusCode::SUCCESS;
156 throw GaudiException(
"Could not retrieve THistSvc", name(), StatusCode::FAILURE );
161 const std::string propName =
"Output";
165 updatedProp.push_back
173 throw GaudiException(
"Could not configure THistSvc output file !!", name(), StatusCode::FAILURE );
181 TTree* t =
new TTree(
"hepmc",
"HepMC validation tuple");
182 if ( !
m_tupleSvc->regTree(
"/" + streamName +
"/hepmc", t ).isSuccess() ) {
183 ATH_MSG_ERROR(
"Could not register HepMC validation tuple !!");
184 delete t; t =
nullptr;
185 throw GaudiException(
"Could not register HepMC validation tuple !!", name(), StatusCode::FAILURE );
189 t->Branch(
"nParts", &
m_particles.m_nParticles,
"nParts/I" );
191 t->Branch(
"px",
m_particles.m_px.data(),
"px[nParts]/D" );
192 t->Branch(
"py",
m_particles.m_py.data(),
"py[nParts]/D" );
193 t->Branch(
"pz",
m_particles.m_pz.data(),
"pz[nParts]/D" );
194 t->Branch(
"m",
m_particles.m_m.data(),
"m[nParts]/D" );
195 t->Branch(
"e",
m_particles.m_ene.data(),
"e[nParts]/D" );
197 t->Branch(
"pdgId",
m_particles.m_pdgId.data(),
"pdgId[nParts]/I" );
198 t->Branch(
"sc",
m_particles.m_status.data(),
"sc[nParts]/I" );
199 t->Branch(
"bc",
m_particles.m_barcode.data(),
"bc[nParts]/I" );
#define ATH_MSG_WARNING(x)
static const std::string outputFileName
const T * front() const
Access the first element in the collection as an rvalue.
bool empty() const noexcept
Returns true if the collection is empty.
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...