EDepSimUserPrimaryGeneratorAction.hh
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////
2 // $Id: EDepSim::UserPrimaryGeneratorAction.hh,v 1.7 2012/05/10 16:27:26 mcgrew Exp $
3 //
4 
5 #ifndef EDepSim_PrimaryGeneratorAction_hh
6 #define EDepSim_PrimaryGeneratorAction_hh 1
7 
8 #include <map>
9 #include <vector>
10 
11 #include "G4VUserPrimaryGeneratorAction.hh"
12 
13 namespace EDepSim {class UserPrimaryGeneratorMessenger;}
14 class G4VPrimaryGenerator;
15 
16 namespace EDepSim {class UserPrimaryGeneratorAction;}
18  : public G4VUserPrimaryGeneratorAction {
19 
20 public:
23 
24  /// Generate all of the primaries for and event and place them into a
25  /// primary vertex. This may generate several primary vertices (in no
26  /// particular order).
27  virtual void GeneratePrimaries(G4Event* anEvent);
28 
29  /// Add a new EDepSim::PrimaryGenerator to the list of generators adding
30  /// primary vertices to the event.
31  void AddGenerator(G4VPrimaryGenerator* generator) {
32  fPrimaryGenerators.push_back(generator);
33  }
34 
35  /// Clear the current list of generators.
36  void ClearGenerators();
37 
38  /// Get the generators used to create events. There will be at least one.
39  const G4VPrimaryGenerator* GetGenerator(int i) const {
40  return fPrimaryGenerators[i];
41  }
42 
43  /// Get the number of generators being used to create events.
44  int GetGeneratorCount() const {
45  return fPrimaryGenerators.size();
46  }
47 
48  /// Set a flag that events that don't contain a real vertex are allowed.
49  /// If the flag is true, then empty events are allowed.
50  void SetAllowEmptyEvents(bool flag) {fAllowEmptyEvents = flag;}
51 
52  /// Set a flag that events that it's to run out of events in the
53  /// kinematics file. If the flag is true, then partial events are
54  /// allowed.
55  void SetAllowPartialEvents(bool flag) {fAllowPartialEvents = flag;}
56 
57  /// Set a flag that events without a real vertex should have a fake
58  /// GEANTINO generated. This only has an effect with
59  /// SetAllowEmptyEvents() has been called with true.
60  void SetAddFakeGeantino(bool flag) {fAddFakeGeantino = flag;}
61 
62 private:
63 
64  /// A vector of generator sets to use to generate events. Each of these
65  /// primary factories will be called in sequence.
66  std::vector<G4VPrimaryGenerator*> fPrimaryGenerators;
67 
68  /// A flag that empty events are allowed. If this is set to be true, the
69  /// generator will return events even if there are no real vertices.
71 
72  /// A flag that any empty event should be filled with a fake GEANTINO
73  /// vertex. This only has an affect with fAllowEmptyEvents is true.
75 
76  /// A flag to allow an event to be generated even if the input kinematics
77  /// has run out of data. This is useful when a single spill of
78  /// interactions has been generated and you want to generate a single
79  /// event containing every interaction in the kinematic input file.
81 
82  /// The messenger for this action
84 };
85 #endif
EDepSim::UserPrimaryGeneratorMessenger * fMessenger
The messenger for this action.
void AddGenerator(G4VPrimaryGenerator *generator)
void ClearGenerators()
Clear the current list of generators.
int GetGeneratorCount() const
Get the number of generators being used to create events.
Construct a module from components.
Definition: TG4HitSegment.h:10
generator
Definition: train.py:468
std::vector< G4VPrimaryGenerator * > fPrimaryGenerators
const G4VPrimaryGenerator * GetGenerator(int i) const
Get the generators used to create events. There will be at least one.