9 #include <generators/modules/HepevtInputModule.h>
11 #include <framework/logging/Logger.h>
12 #include <framework/datastore/DataStore.h>
13 #include <framework/datastore/StoreArray.h>
14 #include <framework/dataobjects/EventMetaData.h>
15 #include <framework/datastore/StoreObjPtr.h>
25 setDescription(
"HepEvt file input. This module loads an event record from HEPEVT format and store the content into the MCParticle collection. HEPEVT format is a standard event record format to contain an event record in a Monte Carlo-independent format.");
29 addParam(
"inputFileList", m_inputFileNames,
"List of names of Hepevt files");
30 addParam(
"makeMaster", m_makeMaster,
"Boolean to indicate whether the event numbers from input file should be used.",
false);
31 addParam(
"runNum", m_runNum,
"Run number", -1);
32 addParam(
"expNum", m_expNum,
"Experiment number", -1);
33 addParam(
"skipEvents", m_skipEventNumber,
"Skip this number of events before starting.", 0);
34 addParam(
"useWeights", m_useWeights,
"Set to 'true' to if generator weights should be propagated.",
false);
35 addParam(
"nVirtualParticles", m_nVirtual,
"Number of particles at the beginning of the events that should be made virtual.", 0);
36 addParam(
"wrongSignPz", m_wrongSignPz,
"Boolean to signal that directions of HER and LER were switched",
false);
39 void HepevtInputModule::initialize()
41 if (m_expNum < 0 or m_runNum < 0)
42 B2FATAL(
"The exp. and run numbers are not properly initialized: please set the 'expNum' and 'runNum' parameters of the HepevtInput module.");
44 m_eventMetaData.registerInDataStore(DataStore::c_ErrorIfAlreadyRegistered);
45 B2INFO(
"HepevtInput acts as input module for this process. This means the exp., run and event numbers will be set by this module.");
48 if (m_inputFileNames.size() == 0) {
50 B2FATAL(
"Invalid list of input files, no entries found.");
53 m_inputFileName = m_inputFileNames[m_iFile];
56 B2INFO(
"Opening first file: " << m_inputFileName);
57 m_hepevt.open(m_inputFileName);
58 m_hepevt.skipEvents(m_skipEventNumber);
59 }
catch (runtime_error& e) {
62 m_hepevt.m_nVirtual = m_nVirtual;
63 m_hepevt.m_wrongSignPz = m_wrongSignPz;
71 void HepevtInputModule::event()
74 m_eventMetaData.create();
78 int id = m_hepevt.getEvent(mpg, weight);
85 m_eventMetaData->setExperiment(m_expNum);
86 m_eventMetaData->setRun(m_runNum);
87 m_eventMetaData->setEvent(
id);
90 m_eventMetaData->setGeneratedWeight(weight);
91 mpg.generateList(
"", MCParticleGraph::c_setDecayInfo | MCParticleGraph::c_checkCyclic);
92 }
catch (HepevtReader::HepEvtEmptyEventError&) {
93 B2DEBUG(100,
"Reached end of HepEvt file.");
94 m_hepevt.closeCurrentInputFile();
96 if (m_iFile < m_inputFileNames.size()) {
98 m_inputFileName = m_inputFileNames[m_iFile];
99 B2INFO(
"Opening next file: " << m_inputFileName);
100 m_hepevt.open(m_inputFileName);
101 }
catch (runtime_error& e) {
105 m_eventMetaData->setEndOfData();
106 B2DEBUG(100,
"Reached end of all HepEvt files.");
108 }
catch (runtime_error& e) {
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.