LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
G4Helper.h
Go to the documentation of this file.
1 
17 
18 #ifndef G4BASE_G4HELPER_H
19 #define G4BASE_G4HELPER_H
20 
21 // nutools includes
23 
24 #include <cstring>
25 
26 // ART Includes
29 
30 #include "Geant4/G4RunManager.hh"
31 #include "Geant4/G4VUserParallelWorld.hh"
32 
33 // Forward declarations
34 class G4UImanager;
35 
36 namespace simb{ class MCTruth; }
37 namespace rndm { class ParticleList; }
38 
40 namespace g4b {
41 
42  // Forward declarations within namespace.
43  class ParticleListAction;
44  class ConvertPrimaryToGeant4;
46 
47  class G4Helper {
48 
49  public:
50 
52  G4Helper();
53  G4Helper(std::string const& g4macropath,
54  std::string const& g4physicslist = "QGSP_BERT",
55  std::string const& gdmlFile = "");
56  virtual ~G4Helper();
57 
58  // have to call this before InitPhysics if you want to load in
59  // parallel worlds. G4Helper takes over ownership
60  void SetParallelWorlds(std::vector<G4VUserParallelWorld*> pworlds);
61 
62  // Call this method to set a step size limit in the chosen volume
63  // It must be called before InitPhysics (which calls SetPhysicsList)
64  // so that the physics list will know to register a step limiter
65  void SetVolumeStepLimit(std::string const& volumeName,
66  double maxStepSize);
67 
68  // extra control over how GDML is parsed
69  inline void SetOverlapCheck(bool check);
70  inline void SetValidateGDMLSchema(bool validate);
71 
72  // have to call this before InitPhysics if you want to control
73  // when the detector is constructed, useful if you need to
74  // muck with G4LogicalVolumes
75  // if the fDetector pointer is null when InitMC is called
76  // it will just construct the fDetector
77  void ConstructDetector(std::string const& gdmlFile);
78 
79  // Initialization for the Geant4 Monte Carlo, called before the
80  // first event is simulated. InitPhysics gets the G4 physics
81  // initialized, and the UserPrimaryGeneratorAction (ConvertMCTruthToG4).
82  // SetUserAction hands the UserActionManager over (so call it
83  // after it is fully configured) to the RunManager; it also
84  // runs the initial command macro and completes the initialization.
85  // These two should be called in this order with any UserActionManager
86  // configuration in between.
87  void InitPhysics();
88  void SetUserAction();
89 
90  // This is the method that actually passes a list of MCTruth objects to G4
91  // so it can create a list of particles
92  bool G4Run(std::vector<const simb::MCTruth*> &primaries);
93 
94  // Pass a single MCTruth object to G4
95  bool G4Run(art::Ptr<simb::MCTruth>& primary);
96 
97  // Pass a single MCTruth object to G4
98  bool G4Run(const simb::MCTruth* primary);
99 
100  G4RunManager* GetRunManager() { return fRunManager; }
101 
102  protected:
103 
104  void SetPhysicsList(std::string physicsList);
105 
106  // These variables are "protected" rather than private, because I
107  // can forsee that it may be desirable to derive other simulation
108  // routines from this one.
109  std::string fG4MacroPath;
110  std::string fG4PhysListName;
112  std::string fGDMLFile;
116 
117  G4RunManager* fRunManager;
118  G4UImanager* fUIManager;
120  DetectorConstruction* fDetector;
122  std::vector<G4VUserParallelWorld*> fParallelWorlds;
123  };
124 
125 } // namespace g4b
126 
127 #ifndef __GCCXML__
128 inline void g4b::G4Helper::SetOverlapCheck(bool check) { fCheckOverlaps = check; }
129 inline void g4b::G4Helper::SetValidateGDMLSchema(bool validate) { fValidateGDMLSchema = validate; }
130 #endif
131 
132 
133 #endif // G4BASE_G4HELPER_H
bool fValidateGDMLSchema
Have G4GDML validate geometry schema?
Definition: G4Helper.h:114
std::vector< G4VUserParallelWorld * > fParallelWorlds
list of parallel worlds
Definition: G4Helper.h:122
void SetValidateGDMLSchema(bool validate)
Definition: G4Helper.h:129
G4RunManager * GetRunManager()
Definition: G4Helper.h:100
void SetOverlapCheck(bool check)
Definition: G4Helper.h:128
std::string fGDMLFile
Name of the gdml file containing the detector Geometry.
Definition: G4Helper.h:112
Convert MCTruth to G4Event; Geant4 event generator.
bool fCheckOverlaps
Have G4GDML check for overlaps?
Definition: G4Helper.h:113
basic interface to Geant4 for ART-based software
std::string fG4MacroPath
to be executed before main MC processing.
Definition: G4Helper.h:109
Framework includes.
G4RunManager * fRunManager
Geant4&#39;s run manager.
Definition: G4Helper.h:117
Definition: G4Helper.h:37
Event generator information.
Definition: MCTruth.h:30
bool fUseStepLimits
Set in SetVolumeStepLimit.
Definition: G4Helper.h:115
ConvertMCTruthToG4 * fConvertMCTruth
Geant4 event generator.
Definition: G4Helper.h:119
G4UImanager * fUIManager
Geant4&#39;s user-interface manager.
Definition: G4Helper.h:118