BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSPrimaryGeneratorFile.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2023.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef BDSPRIMARYGENERATORFILE_H
20#define BDSPRIMARYGENERATORFILE_H
21
22#include "G4ThreeVector.hh"
23#include "G4Types.hh"
24#include "G4VPrimaryGenerator.hh"
25
26class BDSBunch;
28class G4Event;
29class G4VSolid;
30
31namespace GMAD
32{
33 class Beam;
34}
35
49class BDSPrimaryGeneratorFile: public G4VPrimaryGenerator
50{
51public:
52 BDSPrimaryGeneratorFile() = delete;
53 BDSPrimaryGeneratorFile(G4bool loopFileIn,
54 BDSBunchEventGenerator* bunchIn);
56
60 BDSBunch* bunchIn,
61 G4bool recreate,
62 G4int eventOffset,
63 G4bool batchMode);
64
66 G4bool GeneratePrimaryVertexSafe(G4Event* event);
67
69 virtual void RecreateAdvanceToEvent(G4int eventOffset) = 0;
70
73 G4long NEventsInFile() const {return nEventsInFile;}
74
77 G4long NEventsLeftInFile() const;
78
81 G4bool OKToLoopFile() const;
82
84 G4long NEventsReadThatPassedFilters() const {return nEventsReadThatPassedFilters;}
85
87 G4long NEventsSkipped() const {return nEventsSkipped;}
88
90 G4bool DistributionIsFinished() const {return endOfFileReached;}
91
95 void ThrowExceptionIfRecreateOffsetTooHigh(G4long eventOffset) const;
96
97protected:
99 G4bool VertexInsideWorld(const G4ThreeVector& pos) const;
100
101 G4bool loopFile;
103 G4bool endOfFileReached;
104 G4bool vertexGeneratedSuccessfully;
105 G4long currentFileEventIndex;
106 G4long nEventsInFile;
107 G4long nEventsReadThatPassedFilters;
108 G4long nEventsSkipped;
109 mutable G4VSolid* worldSolid;
110};
111
112#endif
A wrapper of BDSBunch to include a filter for the events loaded by an event generator.
The base class for bunch distribution generators.
Definition: BDSBunch.hh:47
Common interface for any primary generators that are file based.
G4long NEventsReadThatPassedFilters() const
Accessor.
G4bool DistributionIsFinished() const
Report whether the distribution is finished generating.
G4bool GeneratePrimaryVertexSafe(G4Event *event)
Return false if not able to generate a primary vertex.
void ThrowExceptionIfRecreateOffsetTooHigh(G4long eventOffset) const
G4bool VertexInsideWorld(const G4ThreeVector &pos) const
Utility function for derived classes to check a position is inside the world.
virtual void RecreateAdvanceToEvent(G4int eventOffset)=0
Advance into the file as required.
static BDSPrimaryGeneratorFile * ConstructGenerator(const GMAD::Beam &beam, BDSBunch *bunchIn, G4bool recreate, G4int eventOffset, G4bool batchMode)
G4long NEventsSkipped() const
Return the offset into the file if any.
Beam loader.
Definition: Beam.hh:37
Beam class.
Definition: beam.h:44
Parser namespace for GMAD language. Combination of Geant4 and MAD.