LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
exampleRE06.cc File Reference

Main program of the RE06 example. More...

#include "G4Types.hh"
#include "G4RunManager.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "G4UImanager.hh"
#include "FTFP_BERT.hh"
#include "G4ParallelWorldPhysics.hh"
#include "RE06DetectorConstruction.hh"
#include "RE06ParallelWorld.hh"
#include "RE06PrimaryGeneratorAction.hh"
#include "RE06RunAction.hh"
#include "RE06SteppingVerbose.hh"
#include "RE06ActionInitialization.hh"
#include "RE06WorkerInitialization.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the RE06 example.

Definition in file exampleRE06.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 57 of file exampleRE06.cc.

58 {
59  // Instantiate G4UIExecutive if there are no arguments (interactive mode)
60  G4UIExecutive* ui = nullptr;
61  if ( argc == 1 ) {
62  ui = new G4UIExecutive(argc, argv);
63  }
64 
65  // Construct the stepping verbose class
66  RE06SteppingVerbose* verbosity = new RE06SteppingVerbose;
67  G4VSteppingVerbose::SetInstance(verbosity);
68 
69  // Construct the run manager
70  //
71 #ifdef G4MULTITHREADED
72  G4MTRunManager * runManager = new G4MTRunManager;
73  runManager->SetNumberOfThreads(4);
74  runManager->SetUserInitialization(new RE06WorkerInitialization);
75 #else
76  G4RunManager* runManager = new G4RunManager;
77 #endif
78 
79  // Set mandatory initialization classes
80  //
81  G4String parallelWorldName = "ParallelScoringWorld";
82  G4VUserDetectorConstruction* detector = new RE06DetectorConstruction;
83  detector->RegisterParallelWorld(new RE06ParallelWorld(parallelWorldName));
84  runManager->SetUserInitialization(detector);
85  //
86  G4VModularPhysicsList* physics = new FTFP_BERT;
87  physics->RegisterPhysics(new G4ParallelWorldPhysics(parallelWorldName));
88  runManager->SetUserInitialization(physics);
89 
90  // Set user action classes
91  //
92  runManager->SetUserInitialization(new RE06ActionInitialization);
93 
94  // Visualization manager
95  //
96  G4VisManager* visManager = new G4VisExecutive;
97  visManager->Initialize();
98 
99  // Initialize G4 kernel
100  //
101  runManager->Initialize();
102 
103  // Get the pointer to the User Interface manager
104  //
105  G4UImanager* UImanager = G4UImanager::GetUIpointer();
106 
107  if (ui) // Define UI session for interactive mode
108  {
109  UImanager->ApplyCommand("/control/execute vis.mac");
110  ui->SessionStart();
111  delete ui;
112  }
113  else // Batch mode
114  {
115  G4String command = "/control/execute ";
116  G4String fileName = argv[1];
117  UImanager->ApplyCommand(command+fileName);
118  }
119 
120  // Job termination
121  // Free the store:
122  // user actions, physics_list and detector_description are
123  // owned and deleted by the run manager, so they should not
124  // be deleted in the main() program !
125 
126  delete visManager;
127  delete runManager;
128 
129  return 0;
130 }