1818#include "Generators/GeneratorFileOrCmd.h"
1919#include "Generators/GeneratorHepMCParam.h"
2020#include "Generators/GeneratorFileOrCmdParam.h"
21+ #include <iosfwd>
22+ #include <memory>
23+ #include <string>
24+ #include <vector>
2125
2226#ifdef GENERATORS_WITH_HEPMC3_DEPRECATED
2327namespace HepMC
@@ -68,7 +72,7 @@ class GeneratorHepMC : public Generator, public GeneratorFileOrCmd
6872 * simulation configuration. This is implemented as a member
6973 * function so as to better facilitate changes. */
7074 void setup(const GeneratorFileOrCmdParam& param0,
71- const GeneratorHepMCParam & param,
75+ const HepMCGenConfig & param,
7276 const conf::SimConfig& config);
7377 // Generator configuration from external local parameters
7478 void setup(const FileOrCmdGenConfig& param0,
@@ -108,8 +112,19 @@ class GeneratorHepMC : public Generator, public GeneratorFileOrCmd
108112
109113 /** methods that can be overridded **/
110114 void updateHeader(o2::dataformats::MCEventHeader* eventHeader) override;
111- /** Make our reader */
115+ /** Apply the HepMC-specific configuration */
116+ void setupHepMC(const HepMCGenConfig& param);
117+ /** Make our reader, taking the next file off the list of file names */
112118 bool makeReader();
119+ /** Fix the order in which the entries of the input file are served */
120+ void establishEventOrder();
121+ /** Index the events of a file by byte offset and open the reader on it, so
122+ * that any entry can later be reached with a single seek. Available only for ASCII format */
123+ bool buildIndex(const std::string& filename);
124+ /** Read the given entry of the indexed file */
125+ bool readEntry(int entry);
126+ /** Generate an event following the established event order in random mode */
127+ Bool_t generateEventOrdered();
113128
114129 /** Type of function to select particles to keep when pruning
115130 * events */
@@ -127,8 +142,34 @@ class GeneratorHepMC : public Generator, public GeneratorFileOrCmd
127142 HepMC3::GenEvent* mEvent = nullptr;
128143 /** Option whether to prune event */
129144 bool mPrune; //!
130-
131- ClassDefOverride(GeneratorHepMC, 1);
145+ /** Name of the file the reader is attached to, needed to re-open it */
146+ std::string mCurrentFileName; //!
147+ /** Order in which the entries of the input file are served */
148+ std::vector<int> mEventOrder; //!
149+ /** Events already delivered in the current pass over the file */
150+ int mEventCounter = 0; //!
151+ /** Events delivered in total */
152+ int mEventsServed = 0; //!
153+ /** Events contained in the input file */
154+ int mEventsAvailable = 0; //!
155+ /** Entry the reader is currently positioned on, -1 if none */
156+ int mLastEntryRead = -1; //!
157+ /** Option whether to serve the events in random order */
158+ bool mRandomize = false; //!
159+ /** Option whether to start over once all events have been used */
160+ bool mRoundRobin = false; //!
161+ /** Option to have a new order when round-robin enabled */
162+ bool mReshuffleOnRepeat = true; //!
163+ /** Randomizer seed, 0 to leave gRandom alone */
164+ unsigned int mRngSeed = 0; //!
165+ /** Whether the indexed input is HepMC2 rather than HepMC3 ASCII */
166+ bool mIndexedHepMC2 = false; //!
167+ /** The stream the reader is attached to, ours so that we may seek in it */
168+ std::shared_ptr<std::istream> mIndexedStream; //!
169+ /** Byte offset at which every entry of the input file starts */
170+ std::vector<std::streamoff> mEventOffsets; //!
171+
172+ ClassDefOverride(GeneratorHepMC, 2);
132173
133174}; /** class GeneratorHepMC **/
134175
0 commit comments