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

Main program of the runAndEvent/RE03 example. More...

#include "G4Types.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4ScoringManager.hh"
#include "RE03DetectorConstruction.hh"
#include "FTFP_BERT.hh"
#include "RE03ActionInitialization.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 runAndEvent/RE03 example.

Definition in file RE03.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 54 of file RE03.cc.

55 {
56  // Instantiate G4UIExecutive if there are no arguments (interactive mode)
57  G4UIExecutive* ui = nullptr;
58  if ( argc == 1 ) {
59  ui = new G4UIExecutive(argc, argv);
60  }
61 
62  // Construct the run manager
63  //
64 #ifdef G4MULTITHREADED
65  G4MTRunManager * runManager = new G4MTRunManager;
66  runManager->SetNumberOfThreads(4);
67 #else
68  G4RunManager * runManager = new G4RunManager;
69 #endif
70 
71  // Activate UI-command base scorer
72  G4ScoringManager * scManager = G4ScoringManager::GetScoringManager();
73  scManager->SetVerboseLevel(1);
74 
75 //====================================================================
76 // Un-comment this line for user defined score writer
77 // scManager->SetScoreWriter(new RE03UserScoreWriter());
78 //====================================================================
79 
80  // Set mandatory initialization classes
81  //
82  G4VUserDetectorConstruction* detector = new RE03DetectorConstruction;
83  runManager->SetUserInitialization(detector);
84  //
85  G4VUserPhysicsList* physics = new FTFP_BERT;
86  runManager->SetUserInitialization(physics);
87 
88  // Set user action classes through Worker Initialization
89  //
90  RE03ActionInitialization* actions = new RE03ActionInitialization;
91  runManager->SetUserInitialization(actions);
92 
93  // Visualization manager
94  G4VisManager* visManager = new G4VisExecutive;
95  visManager->Initialize();
96 
97  // Initialize G4 kernel
98  //
99  runManager->Initialize();
100 
101  // Get the pointer to the User Interface manager
102  //
103  G4UImanager* UImanager = G4UImanager::GetUIpointer();
104 
105  if (ui) // Define UI session for interactive mode
106  {
107  UImanager->ApplyCommand("/control/execute vis.mac");
108  ui->SessionStart();
109  delete ui;
110  }
111  else // Batch mode
112  {
113  G4String command = "/control/execute ";
114  G4String fileName = argv[1];
115  UImanager->ApplyCommand(command+fileName);
116  }
117 
118  // Job termination
119  // Free the store: user actions, physics_list and detector_description are
120  // owned and deleted by the run manager, so they should not
121  // be deleted in the main() program !
122 
123  delete visManager;
124  delete runManager;
125 
126  return 0;
127 }