Class RMGVertexFromFile¶
Defined in File RMGVertexFromFile.hh
Inheritance Relationships¶
Base Type¶
public RMGVVertexGenerator(Class RMGVVertexGenerator)
Class Documentation¶
-
class RMGVertexFromFile : public RMGVVertexGenerator¶
Vertex generator that reads positions sequentially from an ntuple file.
Each row of the ntuple supplies one
(x, y, z) triplet. Used to replay vertices produced by an external sampler (e.g. an MC truth file) into a remage run.Both the RMGAnalysisReader instance and the variables bound to the ntuple columns have static storage duration, i.e. they are shared between all worker threads. The consequences for parallel runs are:
In a multithreaded run all threads pull from the same file cursor, serialized by the reader mutex. Every row is still consumed exactly once, but the order in which the threads reach the reader is not deterministic. The event id in the output therefore does not correspond to the row index in the input, and the assignment is not reproducible from run to run, not even with a fixed random seed. RMGGeneratorFromFile holds a second, independent reader instance, so vertices and kinematics read from two separate tables can be paired inconsistently; the combined position/kinematics table does not suffer from this.
In a multiprocessing run every process is sequential and BeginOfRunAction seeks over the first
p*Nrows, withpthe process number offset andNthe number of events of the run. The processes hence consume disjoint, contiguous blocks of the file, which must hold at leastK*Nrows forKprocesses. Output event ids are offset by the samep*N, so the correspondence between input row index and output event id is preserved.
Public Functions
-
RMGVertexFromFile()¶
-
~RMGVertexFromFile() = default¶
-
RMGVertexFromFile(RMGVertexFromFile const&) = delete¶
-
RMGVertexFromFile &operator=(RMGVertexFromFile const&) = delete¶
-
RMGVertexFromFile(RMGVertexFromFile&&) = delete¶
-
RMGVertexFromFile &operator=(RMGVertexFromFile&&) = delete¶
-
virtual bool GenerateVertex(G4ThreeVector&) override¶
Read the next position row from the file.
- Returns:
False if the input has been exhausted (which aborts the run gracefully).
-
virtual void BeginOfRunAction(const G4Run*) override¶
Open the input file and bind the position columns.
-
virtual void EndOfRunAction(const G4Run*) override¶
Close the input file.
-
void OpenFile(std::string &name)¶
Set the path of the input ntuple file.