9#include <generators/modules/hepmcwriter/HepmcOutputModule.h>
11#include <framework/datastore/StoreArray.h>
12#include <framework/dataobjects/EventMetaData.h>
13#include <framework/datastore/StoreObjPtr.h>
14#include <framework/gearbox/Unit.h>
15#include <mdst/dataobjects/MCParticle.h>
31 setDescription(
"HepMC file output. This module loads an event record from the MCParticle collection and store the content back into the HepMC (2) format. HepMC format is a standard event record format to contain an event record in a Monte Carlo-independent format.");
54 for (
int iPart = 0; iPart < nPart; ++iPart) {
63 HepMC::HEPEVT_Wrapper::zero_everything();
64 HepMC::HEPEVT_Wrapper::set_event_number(eventMetaDataPtr->getEvent());
65 HepMC::HEPEVT_Wrapper::set_number_entries(nPart - nVirtualPart);
68 for (
int iPart = 1; iPart <= nPart; ++iPart) {
70 MCParticle& mcPart = *mcPartCollection[iPart - 1];
77 ROOT::Math::XYZVector vert = mcPart.
getVertex();
87 HepMC::HEPEVT_Wrapper::set_status(iPart, isthep);
88 HepMC::HEPEVT_Wrapper::set_id(iPart, mcPart.
getPDG());
89 HepMC::HEPEVT_Wrapper::set_parents(iPart, motherIndex, motherIndex);
91 HepMC::HEPEVT_Wrapper::set_momentum(iPart,
97 HepMC::HEPEVT_Wrapper::set_position(iPart,
105 HepMC::GenEvent* evt =
m_hepevtio.read_next_event();
106 evt->use_units(HepMC::Units::GEV, HepMC::Units::CM);
static const double speedOfLight
[cm/ns]
HepMCOutputModule()
Constructor.
std::unique_ptr< HepMC::IO_GenEvent > m_ascii_io
The text file stream.
virtual void initialize() override
Initializes the module.
bool m_storeVirtualParticles
Flag which specifies if virtual particles are stored in the HEPEvt file.
virtual void event() override
method is called for each event.
virtual void terminate() override
method is called at end
std::string m_filename
The output filename.
HepMC::IO_HEPEVT m_hepevtio
wrapper/buffer for hepevt conversion.
A Class to store the Monte Carlo particle information.
float getEnergy() const
Return particle energy in GeV.
int getIndex() const
Get 1-based index of the particle in the corresponding MCParticle list.
float getMass() const
Return the particle mass in GeV.
ROOT::Math::XYZVector getVertex() const
Return production vertex position, shorthand for getProductionVertex().
int getLastDaughter() const
Get 1-based index of last daughter, 0 if no daughters.
int getPDG() const
Return PDG code of particle.
float getProductionTime() const
Return production time in ns.
ROOT::Math::XYZVector getMomentum() const
Return momentum.
int getFirstDaughter() const
Get 1-based index of first daughter, 0 if no daughters.
void setDescription(const std::string &description)
Sets the description of the module.
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
Type-safe access to single objects in the data store.
static const double cm
Standard units with the value = 1.
static const double GeV
Standard of [energy, momentum, mass].
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
bool isInitial() const
Check if particle is an initial particle such as ISR.
MCParticle * getMother() const
Returns a pointer to the mother particle.
bool isVirtual() const
Check if particle is virtual.
Abstract base class for different kinds of events.