Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
g4b::G4Helper Class Reference

#include <G4Helper.h>

Public Member Functions

 G4Helper ()
 Standard constructor and destructor for an FMWK module. More...
 
 G4Helper (std::string const &g4macropath, std::string const &g4physicslist="QGSP_BERT", std::string const &gdmlFile="")
 
virtual ~G4Helper ()
 
void SetParallelWorlds (std::vector< G4VUserParallelWorld * > pworlds)
 
void SetVolumeStepLimit (std::string const &volumeName, double maxStepSize)
 
void SetOverlapCheck (bool check)
 
void SetValidateGDMLSchema (bool validate)
 
void ConstructDetector (std::string const &gdmlFile)
 
void InitPhysics ()
 Initialization for the Geant4 Monte Carlo. More...
 
void SetUserAction ()
 Initialization for the Geant4 Monte Carlo. More...
 
bool G4Run (std::vector< const simb::MCTruth * > &primaries)
 
bool G4Run (art::Ptr< simb::MCTruth > &primary)
 
bool G4Run (const simb::MCTruth *primary)
 
G4RunManager * GetRunManager ()
 

Protected Member Functions

void SetPhysicsList (std::string physicsList)
 

Protected Attributes

std::string fG4MacroPath
 to be executed before main MC processing. More...
 
std::string fG4PhysListName
 Name of physics list to use. More...
 
std::string fGDMLFile
 Name of the gdml file containing the detector Geometry. More...
 
bool fCheckOverlaps
 Have G4GDML check for overlaps? More...
 
bool fValidateGDMLSchema
 Have G4GDML validate geometry schema? More...
 
bool fUseStepLimits
 Set in SetVolumeStepLimit. More...
 
G4RunManager * fRunManager
 Geant4's run manager. More...
 
G4UImanager * fUIManager
 Geant4's user-interface manager. More...
 
ConvertMCTruthToG4fConvertMCTruth
 Geant4 event generator. More...
 
DetectorConstructionfDetector
 DetectorConstruction object. More...
 
std::vector< G4VUserParallelWorld * > fParallelWorlds
 list of parallel worlds More...
 

Detailed Description

Definition at line 47 of file G4Helper.h.

Constructor & Destructor Documentation

g4b::G4Helper::G4Helper ( )

Standard constructor and destructor for an FMWK module.

Definition at line 55 of file G4Helper.cxx.

56  : fCheckOverlaps (false )
57  , fValidateGDMLSchema(false )
58  , fUseStepLimits (false )
59  , fUIManager (nullptr)
60  , fConvertMCTruth (nullptr)
61  , fDetector (nullptr)
62  {
63  fParallelWorlds.clear();
64  }
bool fValidateGDMLSchema
Have G4GDML validate geometry schema?
Definition: G4Helper.h:114
std::vector< G4VUserParallelWorld * > fParallelWorlds
list of parallel worlds
Definition: G4Helper.h:122
bool fCheckOverlaps
Have G4GDML check for overlaps?
Definition: G4Helper.h:113
DetectorConstruction * fDetector
DetectorConstruction object.
Definition: G4Helper.h:121
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
g4b::G4Helper::G4Helper ( std::string const &  g4macropath,
std::string const &  g4physicslist = "QGSP_BERT",
std::string const &  gdmlFile = "" 
)

Definition at line 68 of file G4Helper.cxx.

71  : fG4MacroPath (g4macropath )
72  , fG4PhysListName (g4physicslist)
73  , fGDMLFile (gdmlFile )
74  , fCheckOverlaps (false )
75  , fValidateGDMLSchema(true )
76  , fUseStepLimits (false )
77  , fUIManager (nullptr )
78  , fConvertMCTruth (nullptr )
79  , fDetector (nullptr )
80  {
81  // Geant4 run manager. Nothing happens in Geant4 until this object
82  // is created.
83  fRunManager = new G4RunManager;
84 
85  // Get the pointer to the User Interface manager
86  fUIManager = G4UImanager::GetUIpointer();
87 
88  fParallelWorlds.clear();
89  }
bool fValidateGDMLSchema
Have G4GDML validate geometry schema?
Definition: G4Helper.h:114
std::vector< G4VUserParallelWorld * > fParallelWorlds
list of parallel worlds
Definition: G4Helper.h:122
std::string fGDMLFile
Name of the gdml file containing the detector Geometry.
Definition: G4Helper.h:112
bool fCheckOverlaps
Have G4GDML check for overlaps?
Definition: G4Helper.h:113
std::string fG4MacroPath
to be executed before main MC processing.
Definition: G4Helper.h:109
DetectorConstruction * fDetector
DetectorConstruction object.
Definition: G4Helper.h:121
G4RunManager * fRunManager
Geant4&#39;s run manager.
Definition: G4Helper.h:117
std::string fG4PhysListName
Name of physics list to use.
Definition: G4Helper.h:111
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
g4b::G4Helper::~G4Helper ( )
virtual

Definition at line 93 of file G4Helper.cxx.

94  {
95  if( vm_ ) delete vm_;
96 
97  if ( fRunManager != 0 ){
98  // In SetUserAction(), we set all the G4 user-action classes to be the
99  // same action: G4Base::UserActionManager This is convenient, but
100  // it creates a problem here: First the G4RunManager deletes the
101  // G4UserRunAction, then it tries to delete the
102  // G4UserEventAction... but that's the same object, which has
103  // already been deleted. Crash.
104 
105  // To keep this from happening, handle the UserActionManager
106  // clean-up manually, then tell the G4RunManager that all those
107  // classes no longer exist.
108 
110  bool wasStacking = uaManager->DoesAnyActionProvideStacking();
111  uaManager->Close();
112 
113  // Each one of these G4RunManager::SetUserAction methods calls a
114  // different method, based on the type of the argument. We want
115  // to use "0" (a null pointer), but we have to cast that "0" to a
116  // particular type in order for the right SetUserAction method to
117  // be called.
118 
119  fRunManager->SetUserAction( static_cast<G4UserRunAction*>(0) );
120  fRunManager->SetUserAction( static_cast<G4UserEventAction*>(0) );
121  fRunManager->SetUserAction( static_cast<G4UserTrackingAction*>(0) );
122  fRunManager->SetUserAction( static_cast<G4UserSteppingAction*>(0) );
123  if ( wasStacking ) {
124  fRunManager->SetUserAction( static_cast<G4UserStackingAction*>(0) );
125  }
126 
127  delete fRunManager;
128  }
129  else{
130  MF_LOG_ERROR("G4Helper")
131  << "G4Helper never initialized; probably because there were no input primary events";
132  }
133 
134  for(size_t i = 0; i < fParallelWorlds.size(); ++i){
135  if(fParallelWorlds[i]) delete fParallelWorlds[i];
136  }
137  fParallelWorlds.clear();
138 
139  }
virtual bool DoesAnyActionProvideStacking()
#define MF_LOG_ERROR(category)
std::vector< G4VUserParallelWorld * > fParallelWorlds
list of parallel worlds
Definition: G4Helper.h:122
static G4VisExecutive * vm_
Definition: G4Helper.cxx:51
static UserActionManager * Instance()
G4RunManager * fRunManager
Geant4&#39;s run manager.
Definition: G4Helper.h:117

Member Function Documentation

void g4b::G4Helper::ConstructDetector ( std::string const &  gdmlFile)

Definition at line 368 of file G4Helper.cxx.

369  {
370  // Build the Geant4 detector description.
371  bool checkOverlaps = fCheckOverlaps;
372  bool validateGDMLSchema = fValidateGDMLSchema;
373  fDetector = new DetectorConstruction(gdmlFile,
374  checkOverlaps,
375  validateGDMLSchema);
376 
377  return;
378  }
bool fValidateGDMLSchema
Have G4GDML validate geometry schema?
Definition: G4Helper.h:114
bool fCheckOverlaps
Have G4GDML check for overlaps?
Definition: G4Helper.h:113
DetectorConstruction * fDetector
DetectorConstruction object.
Definition: G4Helper.h:121
bool g4b::G4Helper::G4Run ( std::vector< const simb::MCTruth * > &  primaries)

Definition at line 503 of file G4Helper.cxx.

504  {
505  // Get the event converter ready.
507 
508  // Pass all the MCTruths to our event generator.
509  for(auto primary : primaries)
510  fConvertMCTruth->Append( primary );
511 
512  // Start the simulation for this event. Note: The following
513  // statement increments the G4RunManager's run number. Because of
514  // this, it's important for events to use the run/event number
515  // from the EventDataModel Header, not G4's internal numbers.
516  fUIManager->ApplyCommand("/run/beamOn 1");
517 
518  return true;
519  }
void Reset()
Get ready to convert a new set of MCTruth objects.
void Append(art::Ptr< simb::MCTruth > &mct)
ConvertMCTruthToG4 * fConvertMCTruth
Geant4 event generator.
Definition: G4Helper.h:119
G4UImanager * fUIManager
Geant4&#39;s user-interface manager.
Definition: G4Helper.h:118
bool g4b::G4Helper::G4Run ( art::Ptr< simb::MCTruth > &  primary)

Definition at line 479 of file G4Helper.cxx.

480  {
481  return this->G4Run( primary.get() );
482  }
bool G4Run(std::vector< const simb::MCTruth * > &primaries)
Definition: G4Helper.cxx:503
T const * get() const
Definition: Ptr.h:149
bool g4b::G4Helper::G4Run ( const simb::MCTruth primary)

Definition at line 485 of file G4Helper.cxx.

486  {
487  // Get the event converter ready.
489 
490  // Pass the MCTruth to our event generator.
491  fConvertMCTruth->Append( primary );
492 
493  // Start the simulation for this event. Note: The following
494  // statement increments the G4RunManager's run number. Because of
495  // this, it's important for events to use the run/event number
496  // from the EventDataModel Header, not G4's internal numbers.
497  fUIManager->ApplyCommand("/run/beamOn 1");
498 
499  return true;
500  }
void Reset()
Get ready to convert a new set of MCTruth objects.
void Append(art::Ptr< simb::MCTruth > &mct)
ConvertMCTruthToG4 * fConvertMCTruth
Geant4 event generator.
Definition: G4Helper.h:119
G4UImanager * fUIManager
Geant4&#39;s user-interface manager.
Definition: G4Helper.h:118
G4RunManager* g4b::G4Helper::GetRunManager ( )
inline

Definition at line 100 of file G4Helper.h.

100 { return fRunManager; }
G4RunManager * fRunManager
Geant4&#39;s run manager.
Definition: G4Helper.h:117
void g4b::G4Helper::InitPhysics ( )

Initialization for the Geant4 Monte Carlo.

Definition at line 407 of file G4Helper.cxx.

408  {
410 
411  for(auto pWorld : fParallelWorlds)
412  fDetector->RegisterParallelWorld(pWorld);
413 
414  // define the physics list to use
416 
417  // Pass the detector geometry on to Geant4.
418  fRunManager->SetUserInitialization(fDetector);
419 
420  // Tell the Geant4 run manager how to generate events. The
421  // ConvertMCTruthToG4 class will "generate" events by
422  // converting MCTruth objects from the input into G4Events.
423  fConvertMCTruth = new ConvertMCTruthToG4;
424  fRunManager->SetUserAction(fConvertMCTruth);
425 
426  return;
427  }
void ConstructDetector(std::string const &gdmlFile)
Definition: G4Helper.cxx:368
std::vector< G4VUserParallelWorld * > fParallelWorlds
list of parallel worlds
Definition: G4Helper.h:122
void SetPhysicsList(std::string physicsList)
Definition: G4Helper.cxx:142
std::string fGDMLFile
Name of the gdml file containing the detector Geometry.
Definition: G4Helper.h:112
DetectorConstruction * fDetector
DetectorConstruction object.
Definition: G4Helper.h:121
G4RunManager * fRunManager
Geant4&#39;s run manager.
Definition: G4Helper.h:117
std::string fG4PhysListName
Name of physics list to use.
Definition: G4Helper.h:111
ConvertMCTruthToG4 * fConvertMCTruth
Geant4 event generator.
Definition: G4Helper.h:119
void g4b::G4Helper::SetOverlapCheck ( bool  check)
inline

Definition at line 128 of file G4Helper.h.

128 { fCheckOverlaps = check; }
bool check(const std::vector< std::vector< float > > &outputs)
bool fCheckOverlaps
Have G4GDML check for overlaps?
Definition: G4Helper.h:113
void g4b::G4Helper::SetParallelWorlds ( std::vector< G4VUserParallelWorld * >  pworlds)

Definition at line 357 of file G4Helper.cxx.

358  {
359  for(auto const& pw : pworlds){
360  MF_LOG_DEBUG("G4Helper") << pw->GetName();
361  fParallelWorlds.push_back(pw);
362  }
363 
364  return;
365  }
std::vector< G4VUserParallelWorld * > fParallelWorlds
list of parallel worlds
Definition: G4Helper.h:122
#define MF_LOG_DEBUG(id)
void g4b::G4Helper::SetPhysicsList ( std::string  physicsList)
protected

Set up the physics list for Geant4, and pass it to Geant4's run manager. Without a physics list, Geant4 won't do anything. G4 comes with a number of pre-constructed lists, and for now I plan to use "QGSP_BERT". It has the following properties:

  • Standard EM physics processes.
  • Quark-gluon string model for high energies (> 20GeV)
  • Low Energy Parameterized (LEP) for medium energies (10<E<20GeV)
  • Gertini-style cascade for low energies (< 10GeV)
  • LEP, HEP for all anti-baryons (LEP,HEP = low/high energy parameterized, from GHEISHA)
  • Gamma-nuclear model added for E<3.5 GeV (comments from "Guided Tour of Geant4 Physics List II", talk given at JPL by Dennis Wright)

if we decide that QGSP_BERT is not what we want, then we will have to write a new physics list class that derives from G4VUserPhysicsList that does what we want.

Definition at line 142 of file G4Helper.cxx.

143  {
144  /// Set up the physics list for Geant4, and pass it to Geant4's
145  /// run manager.
146  /// Without a physics list, Geant4 won't do anything. G4 comes with a
147  /// number of pre-constructed lists, and for now I plan to use
148  /// "QGSP_BERT". It has the following properties:
149  ///
150  /// - Standard EM physics processes.
151  /// - Quark-gluon string model for high energies (> 20GeV)
152  /// - Low Energy Parameterized (LEP) for medium energies (10<E<20GeV)
153  /// - Gertini-style cascade for low energies (< 10GeV)
154  /// - LEP, HEP for all anti-baryons (LEP,HEP = low/high energy parameterized, from GHEISHA)
155  /// - Gamma-nuclear model added for E<3.5 GeV
156  /// (comments from "Guided Tour of Geant4 Physics List II",
157  /// talk given at JPL by Dennis Wright)
158  ///
159  /// if we decide that QGSP_BERT is not what we want, then we will
160  /// have to write a new physics list class that derives from
161  /// G4VUserPhysicsList that does what we want.
162 
163  G4VUserPhysicsList* physics = 0;
164  std::string bywhom = "User";
165  std::string factoryname = "G4PhysListFactory";
166  bool list_known_procs = true;
167 
168  // physics list name is the first part, anything afterwards is
169  // extra physics processes to be added to the base list
170  // ie. "QGSP_BERT ; myspace::MonopolePhysics ; MyOtherSpecialPhysics "
171  std::vector< std::string > pstrings;
172  // don't use ":" as a separator because it's used in namespaces
173  boost::algorithm::split( pstrings, physicsString, boost::is_any_of(";"),
174  boost::token_compress_on );
175  // trim lead/trail space
176  for (unsigned int j=0; j < pstrings.size(); ++j )
177  boost::algorithm::trim(pstrings[j]);
178 
179  if ( pstrings.size() < 1 ) pstrings.push_back(""); // non-empty
180  std::string phListName = pstrings[0];
181 
182  //for (unsigned int j=0; j < pstrings.size(); ++j )
183  // std::cout << "G4Helper pstrings[" << j << "] = \""
184  // << pstrings[j] << "\"" << std::endl;
185 
186  if ( ! physics ) {
187 #ifdef TRY_NEW_PL_FACTORY
188  // user extensible physics list factory
189  alt::G4PhysListFactory factory;
190  factoryname = "alt::G4PhysListFactory";
191 #else
192  // The official Geant4 G4PhysListFactory _isn't_ a modern factory;
193  // it can only generate items that have pre-programmed blueprints
194  // already known to it (via if/else-if calls to various ctors) and
195  // is not user extensible (i.e. you can't send it blueprints and
196  // have it make them for you). If we have our own physics list
197  // then we need to select on and construct it ourselves before
198  // looking to the factory.
199 
200  // Put if/then/else statement here for user defined physics lists
201  // when using old stodgy offical G4 factory.
202  // Example:
203  /*
204  // string name actual class ctor
205  if ( "MY_COOL_PL" == phListName ) {physics = new My_Cool_PL();}
206  else if ( "MY_OTHER_PL" == phListName ) {physics = new My_Other_PL();}
207  */
208 
209  G4PhysListFactory factory; // official G4 factory
210 #endif
211 
212  if ( ! physics ) {
213  if ( factory.IsReferencePhysList(phListName) ) {
214  bywhom = factoryname;
215  physics = factory.GetReferencePhysList(phListName);
216  }
217  else {
218  // in the case of non-default name
219  if ( phListName != "" ) {
220  std::cerr << std::endl << factoryname
221  << " failed to find ReferencePhysList \""
222  << phListName << "\"" << std::endl;
223 #ifdef TRY_NEW_PL_FACTORY
224  factory.PrintAvailablePhysLists();
225 #else
226  std::vector<G4String> list = factory.AvailablePhysLists();
227  MF_LOG_VERBATIM("G4Helper")
228  << "For reference: PhysicsLists in G4PhysListFactory are: ";
229  for (size_t indx=0; indx < list.size(); ++indx ) {
230  MF_LOG_VERBATIM("G4Helper")
231  << " [" << std::setw(2) << indx << "] "
232  << "\"" << list[indx] << "\"";
233  }
234 #endif
235  }
236  } // query factory
237  } // no predetermined user list
238 
239  if ( ! physics ) {
240  MF_LOG_ERROR("G4Helper")
241  << "G4PhysListFactory could not construct \""
242  << phListName
243  << "\","
244  << std::endl
245  << "fall back to using QGSP_BERT";
246 
247  physics = new QGSP_BERT;
248  phListName = "QGSP_BERT";
249 
250  } else {
251  MF_LOG_VERBATIM("G4Helper")
252  << bywhom
253  << " constructed G4VUserPhysicsList \""
254  << phListName
255  << "\"";
256  }
257 
258  }
259 
260  // Extend the physics list with additional physics processes
261  // Already used pstrings[0] entry for physics list name.
262  // The rest should be semi-colon separated list of:
263  // physicsProcessName ( optional UI command , more UI commands )
264  for (unsigned int k=1; k < pstrings.size(); ++k ) {
265  std::string physProcAddition = pstrings[k];
266 
267  // break off UI commands from process name
268  std::vector< std::string > physProcParts;
269  boost::algorithm::split( physProcParts, physProcAddition,
270  boost::is_any_of("(,)"),
271  boost::token_compress_on );
272  // trim lead/trail spaces
273  for (unsigned int j=0; j < physProcParts.size(); ++j )
274  boost::algorithm::trim(physProcParts[j]);
275 
276  // element 0 is the physics process name
277  std::string physProcName = physProcParts[0];
278  if ( physProcName == "" ) continue; // not real, user has trailing ";"
279  G4PhysicsProcessFactorySingleton& procFactory =
281 
282  if ( ! procFactory.IsKnownPhysicsProcess(physProcName) ) {
283  MF_LOG_VERBATIM("G4Helper")
284  << "G4PhysicsProcessFactorySingleton could not "
285  << "construct a \""
286  << physProcName
287  << "\"";
288 
289  if ( ! list_known_procs ) continue;
290  list_known_procs = false;
291  std::vector<G4String> list = procFactory.AvailablePhysicsProcesses();
292  MF_LOG_VERBATIM("G4Helper")
293  << "For reference: PhysicsProcesses in "
294  << "G4PhysicsProcessFactorySingleton are: ";
295 
296  if ( list.empty() )
297  MF_LOG_VERBATIM("G4Helper")
298  << " ... no registered processes";
299  else {
300  for (size_t indx=0; indx < list.size(); ++indx ) {
301  MF_LOG_VERBATIM("G4Helper")
302  << " [" << std::setw(2) << indx << "] "
303  << "\"" << list[indx] << "\"";
304  }
305  }
306  continue;
307  }
308 
309  MF_LOG_VERBATIM("G4Helper")
310  << "Adding \""
311  << physProcName
312  << "\" physics process to \""
313  << phListName
314  << "\"";
315 
316  // construct physics process, add it to the base physics list
317  G4VPhysicsConstructor* pctor = procFactory.GetPhysicsProcess(physProcName);
318 
319 
320  G4VModularPhysicsList* mpl = dynamic_cast<G4VModularPhysicsList*>(physics);
321  if ( ! pctor ) MF_LOG_VERBATIM("G4Helper") << " ... failed with null pointer";
322  else if ( ! mpl ) MF_LOG_VERBATIM("G4Helper") << " ... failed, physics list wasn't a G4VModularPhysicsList";
323  else mpl->RegisterPhysics(pctor);
324 
325  // Handle associated UI commands
326  // One must do it here for cases where values need to be set *before*
327  // one calls SetUserInitialization(physics)
328 
329  for ( unsigned int i=1; i < physProcParts.size(); ++i ) {
330  if ( physProcParts[i] == "" ) continue;
331  MF_LOG_VERBATIM("G4Helper")
332  << physProcParts[i];
333 
334  fUIManager->ApplyCommand(physProcParts[i]);
335  }
336 
337  }
338 
339  // User should have called SetVolumeStepLimit before calling this
340  // method, otherwise fUseStepLimits is always false.
341  if(fUseStepLimits){
342  auto mpl = dynamic_cast<G4VModularPhysicsList*>(physics);
343  if(mpl) mpl->RegisterPhysics(new G4StepLimiterPhysics());
344  else
345  MF_LOG_WARNING("G4Helper")
346  << "Step limits requested, but unable to register G4StepLimiterPhysics"
347  << "\n NO STEP LIMITS WILL BE APPLIED";
348  }
349 
350  // pass off (possibly augmented) physics list to run manager
351  // which calls G4RunManagerKernel->SetPhysics() on it
352  // which itself call ConstructParticle() for the list
353  fRunManager->SetUserInitialization(physics);
354  }
static std::string trim(const std::string &str, const std::string &whitespace=" \t")
Definition: doxyindexer.cpp:47
std::string string
Definition: nybbler.cc:12
#define MF_LOG_ERROR(category)
const std::vector< G4String > & AvailablePhysicsProcesses() const
G4VModularPhysicsList * GetReferencePhysList(const G4String &)
static G4PhysicsProcessFactorySingleton & Instance()
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
#define MF_LOG_VERBATIM(category)
G4RunManager * fRunManager
Geant4&#39;s run manager.
Definition: G4Helper.h:117
void split(std::string const &s, char c, OutIter dest)
Definition: split.h:35
bool fUseStepLimits
Set in SetVolumeStepLimit.
Definition: G4Helper.h:115
#define MF_LOG_WARNING(category)
G4VPhysicsConstructor * GetPhysicsProcess(const G4String &)
QTextStream & endl(QTextStream &s)
G4UImanager * fUIManager
Geant4&#39;s user-interface manager.
Definition: G4Helper.h:118
void g4b::G4Helper::SetUserAction ( )

Initialization for the Geant4 Monte Carlo.

Tell Geant4 to initialize the run manager. We're ready to simulate events in the detector.

Definition at line 432 of file G4Helper.cxx.

433  {
434  // Geant4 comes with "user hooks" that allows users to perform
435  // special tasks at the beginning and end of runs, events, tracks,
436  // steps. By using the UserActionManager, we've separated each
437  // set of user tasks into their own class; e.g., there can be one
438  // class for processing particles, one class for histograms, etc.
439 
440  // Use the UserActionManager to handle all the Geant4 user hooks.
441  UserActionManager* uaManager = UserActionManager::Instance();
442 
443  // Tell the run manager about our user-action classes. We convert
444  // the UserActionManager into different types so Geant4's run and
445  // event managers will initialize them properly.
446  G4UserRunAction* runAction = (G4UserRunAction* ) uaManager;
447  G4UserEventAction* eventAction = (G4UserEventAction* ) uaManager;
448  G4UserTrackingAction* trackingAction = (G4UserTrackingAction*) uaManager;
449  G4UserSteppingAction* steppingAction = (G4UserSteppingAction*) uaManager;
450  fRunManager->SetUserAction( runAction );
451  fRunManager->SetUserAction( eventAction );
452  fRunManager->SetUserAction( trackingAction );
453  fRunManager->SetUserAction( steppingAction );
454 
455  if ( uaManager->DoesAnyActionProvideStacking() ) {
456  G4UserStackingAction* stackingAction = (G4UserStackingAction*) uaManager;
457  fRunManager->SetUserAction( stackingAction );
458  }
459 
460  /// Tell Geant4 to initialize the run manager. We're ready to
461  /// simulate events in the detector.
462  fRunManager->Initialize();
463 
464  if(!vm_) vm_ = new G4VisExecutive();
465  vm_->Initialize();
466 
467  // Tell the manager to execute the contents of the Geant4 macro
468  // file.
469  if ( ! fG4MacroPath.empty() ) {
470  G4String command = "/control/execute " + G4String(fG4MacroPath);
471  fUIManager->ApplyCommand(command);
472  }
473 
474 
475  return;
476  }
int command
static G4VisExecutive * vm_
Definition: G4Helper.cxx:51
std::string fG4MacroPath
to be executed before main MC processing.
Definition: G4Helper.h:109
static UserActionManager * Instance()
G4RunManager * fRunManager
Geant4&#39;s run manager.
Definition: G4Helper.h:117
G4UImanager * fUIManager
Geant4&#39;s user-interface manager.
Definition: G4Helper.h:118
void g4b::G4Helper::SetValidateGDMLSchema ( bool  validate)
inline

Definition at line 129 of file G4Helper.h.

bool fValidateGDMLSchema
Have G4GDML validate geometry schema?
Definition: G4Helper.h:114
def validate(nxgraph, desc)
Definition: graph.py:45
void g4b::G4Helper::SetVolumeStepLimit ( std::string const &  volumeName,
double  maxStepSize 
)

Definition at line 381 of file G4Helper.cxx.

383  {
384  // get the logical volume for the desired volume name
385  G4LogicalVolume* logVol = G4LogicalVolumeStore::GetInstance()->GetVolume(volumeName);
386 
387  if(logVol){
388  // the logical volume takes ownership of the G4UserLimits pointer
389  G4UserLimits *stepLimit = new G4UserLimits(maxStepSize);
390  logVol->SetUserLimits(stepLimit);
391 
392  fUseStepLimits = true;
393  }
394  else{
395  MF_LOG_WARNING("G4Helper")
396  << "Unable to find volume "
397  << volumeName
398  << " and set step size limit";
399  }
400 
401  return;
402  }
bool fUseStepLimits
Set in SetVolumeStepLimit.
Definition: G4Helper.h:115
#define MF_LOG_WARNING(category)

Member Data Documentation

bool g4b::G4Helper::fCheckOverlaps
protected

Have G4GDML check for overlaps?

Definition at line 113 of file G4Helper.h.

ConvertMCTruthToG4* g4b::G4Helper::fConvertMCTruth
protected

Geant4 event generator.

Converts MCTruth objects;

Definition at line 119 of file G4Helper.h.

DetectorConstruction* g4b::G4Helper::fDetector
protected

DetectorConstruction object.

Definition at line 121 of file G4Helper.h.

std::string g4b::G4Helper::fG4MacroPath
protected

to be executed before main MC processing.

Full directory path for Geant4 macro file

Definition at line 109 of file G4Helper.h.

std::string g4b::G4Helper::fG4PhysListName
protected

Name of physics list to use.

Definition at line 111 of file G4Helper.h.

std::string g4b::G4Helper::fGDMLFile
protected

Name of the gdml file containing the detector Geometry.

Definition at line 112 of file G4Helper.h.

std::vector<G4VUserParallelWorld*> g4b::G4Helper::fParallelWorlds
protected

list of parallel worlds

Definition at line 122 of file G4Helper.h.

G4RunManager* g4b::G4Helper::fRunManager
protected

Geant4's run manager.

Definition at line 117 of file G4Helper.h.

G4UImanager* g4b::G4Helper::fUIManager
protected

Geant4's user-interface manager.

Definition at line 118 of file G4Helper.h.

bool g4b::G4Helper::fUseStepLimits
protected

Set in SetVolumeStepLimit.

Definition at line 115 of file G4Helper.h.

bool g4b::G4Helper::fValidateGDMLSchema
protected

Have G4GDML validate geometry schema?

Definition at line 114 of file G4Helper.h.


The documentation for this class was generated from the following files: