BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
BDSPrimaryGeneratorAction.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2022.
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 BDSPRIMARYGENERATORACTION_H
20#define BDSPRIMARYGENERATORACTION_H
21
22#include "BDSExtent.hh"
23
24#include "globals.hh"
25#include "G4VUserPrimaryGeneratorAction.hh"
26
27class BDSBunch;
28class BDSOutputLoader;
31class G4Event;
32class G4ParticleGun;
33
34namespace GMAD
35{
36 class Beam;
37}
38
39#ifdef USE_HEPMC3
40class BDSHepMC3Reader;
41#endif
42
48class BDSPrimaryGeneratorAction: public G4VUserPrimaryGeneratorAction
49{
50public:
53 const GMAD::Beam& beam);
55
57 virtual void GeneratePrimaries(G4Event*);
58
60 inline void SetWorldExtent(const BDSExtent worldExtentIn) {worldExtent = worldExtentIn;}
64private:
65
66 G4ParticleGun* particleGun;
70 G4bool recreate;
73 G4bool ionPrimary;
76
79
82 G4bool ionCached;
83
86
87#ifdef USE_HEPMC3
90#endif
91 BDSROOTSamplerReader* samplerReader;
92};
93
94#endif
The base class for bunch distribution generators.
Definition: BDSBunch.hh:47
Holder for +- extents in 3 dimensions.
Definition: BDSExtent.hh:39
Loader to use any HepMC3 compatible file.
Loader of ROOT Event output for recreating events.
Class to load and use PTC 1 turn map.
Generates primary particle vertices using BDSBunch.
G4bool recreate
Whether to load seed state at start of event from rootevent file.
G4ParticleGun * particleGun
Geant4 particle gun that creates single particles.
G4int eventOffset
The offset in the file to read events from when setting the seed.
G4bool useASCIISeedState
Whether to use the ascii seed state each time.
G4bool ionPrimary
The primary particle will be an ion.
BDSPrimaryGeneratorAction(BDSBunch *bunchIn, const GMAD::Beam &beam)
Bunch must have a valid particle definition (ie not nullptr).
G4bool useEventGeneratorFile
Whether to use event generator file.
void RegisterPTCOneTurnMap(BDSPTCOneTurnMap *otmIn)
void SetWorldExtent(const BDSExtent worldExtentIn)
Set the world extent that particle coordinates will be checked against.
BDSExtent worldExtent
World extent that particle coordinates are checked against to ensure they're inside it.
G4bool useSamplerLoader
Whether to use a sampler loader.
BDSBunch * bunch
BDSIM particle generator.
virtual void GeneratePrimaries(G4Event *)
Main interface for Geant4. Prepare primary(ies) for the event.
BDSHepMC3Reader * hepMC3Reader
Event generator file loader.
BDSPTCOneTurnMap * oneTurnMap
Cached OTM for setting first turn primary coords.
G4bool writeASCIISeedState
Cache of whether to write seed state as ASCII per event.
BDSOutputLoader * recreateFile
Optional output handler for restoring seed state.
Loader to read a specific sampler from a BDSIM ROOT output file.
Beam loader.
Definition: Beam.hh:37
Beam class.
Definition: beam.h:44
Parser namespace for GMAD language. Combination of Geant4 and MAD.