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

Main program of the RE05 example. More...

#include "G4Types.hh"
#include "G4RunManager.hh"
#include "RE05SteppingVerbose.hh"
#include "G4UImanager.hh"
#include "RE05DetectorConstruction.hh"
#include "RE05CalorimeterParallelWorld.hh"
#include "QBBC.hh"
#include "G4ParallelWorldPhysics.hh"
#include "RE05ActionInitialization.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the RE05 example.

Definition in file exampleRE05.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 55 of file exampleRE05.cc.

56 {
57  // Instantiate G4UIExecutive if there are no arguments (interactive mode)
58  G4UIExecutive* ui = nullptr;
59  if ( argc == 1 ) {
60  ui = new G4UIExecutive(argc, argv);
61  }
62 
63 #ifdef G4MULTITHREADED
64  G4MTRunManager* runManager = new G4MTRunManager;
65  G4int number_of_threads = 4; // default number of threads
66  runManager->SetNumberOfThreads(number_of_threads);
67  runManager->SetUserInitialization(new RE05WorkerInitialization);
68 #else
69  G4VSteppingVerbose* verbosity = new RE05SteppingVerbose;
70  G4VSteppingVerbose::SetInstance(verbosity);
71  G4RunManager* runManager = new G4RunManager;
72 #endif
73 
74  G4String parallelWorldName = "ReadoutWorld";
75  // User Initialization classes (mandatory)
76  //
77  G4VUserDetectorConstruction* detector = new RE05DetectorConstruction();
78  detector->RegisterParallelWorld
79  (new RE05CalorimeterParallelWorld(parallelWorldName));
80  runManager->SetUserInitialization(detector);
81  //
82  G4VModularPhysicsList* physicsList = new QBBC;
83  physicsList
84  ->RegisterPhysics(new G4ParallelWorldPhysics(parallelWorldName));
85  runManager->SetUserInitialization(physicsList);
86  //
87  G4VUserActionInitialization* actions = new RE05ActionInitialization;
88  runManager->SetUserInitialization(actions);
89 
90  runManager->Initialize();
91 
92  G4VisManager* visManager = new G4VisExecutive;
93  visManager->Initialize();
94 
95  //get the pointer to the User Interface manager
96  G4UImanager* UImanager = G4UImanager::GetUIpointer();
97 
98  if (!ui) // batch mode
99  {
100  G4String command = "/control/execute ";
101  G4String fileName = argv[1];
102  UImanager->ApplyCommand(command+fileName);
103  }
104  else // interactive mode : define UI session
105  {
106  UImanager->ApplyCommand("/control/execute vis.mac");
107  ui->SessionStart();
108  delete ui;
109  }
110 
111  delete visManager;
112 
113  // Job termination
114  // Free the store: user actions, physics_list and detector_description are
115  // owned and deleted by the run manager, so they should not
116  // be deleted in the main() program !
117  delete runManager;
118 
119  return 0;
120 }