9 #include <generators/modules/HepevtOutputModule.h>
11 #include <framework/datastore/StoreArray.h>
12 #include <framework/datastore/StoreObjPtr.h>
13 #include <framework/dataobjects/EventMetaData.h>
14 #include <mdst/dataobjects/MCParticle.h>
18 using namespace boost;
33 setDescription(
"HepEvt file output. This module loads an event record from the MCParticle collection and store the content back into the HEPEVT format. HEPEVT format is a standard event record format to contain an event record in a Monte Carlo-independent format.");
36 addParam(
"OutputFilename", m_filename,
"The filename of the output file");
37 addParam(
"MirrorPz", m_mirrorPz,
"If the directions of HER and LER are switched, mirror Pz.",
false);
38 addParam(
"StoreVirtualParticles", m_storeVirtualParticles,
"Store also virtual particles in the HePEvt file.",
false);
39 addParam(
"FullFormat", m_fullFormat,
"Write the full HepEvt format to file. Set it to false for a compact format.",
true);
43 void HepevtOutputModule::initialize()
45 m_fileStream.open(m_filename.c_str());
49 void HepevtOutputModule::event()
58 if (!m_storeVirtualParticles) {
59 for (
int iPart = 0; iPart < nPart; ++iPart) {
65 m_fileStream << format(
"%10d%10d\n") % eventMetaDataPtr->getEvent() % (nPart - nVirtualPart);
67 for (
int iPart = 0; iPart < nPart; ++iPart) {
69 if (!m_storeVirtualParticles && mcPart.
isVirtual())
continue;
72 if (m_mirrorPz) mom.SetZ(-1.0 * mom.Z());
82 m_fileStream << format(
"%5i%12i%10i%10i%10i%10i") % isthep % mcPart.
getPDG() % motherIndex % motherIndex % mcPart.
getFirstDaughter()
84 m_fileStream << format(
"%15.6f%15.6f%15.6f%15.6f%15.6f") % mom.X() % mom.Y() % mom.Z() % mcPart.
getEnergy() % mcPart.
getMass();
88 m_fileStream << format(
"%15.6f%15.6f%15.6f%15.6f%15.6f%15i\n") % mom.X() % mom.Y() % mom.Z() % mcPart.
getEnergy() % mcPart.
getMass()
95 void HepevtOutputModule::terminate()
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.
TVector3 getVertex() const
Return production vertex position, shorthand for getProductionVertex().
TVector3 getMomentum() const
Return momentum.
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.
int getFirstDaughter() const
Get 1-based index of first daughter, 0 if no daughters.
int getEntries() const
Get the number of objects in the array.
Type-safe access to single objects in the data store.
#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.