LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
exampleRE05.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
29 //
30 
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "G4Types.hh"
35 
36 #ifdef G4MULTITHREADED
37 #include "G4MTRunManager.hh"
38 #include "RE05WorkerInitialization.hh"
39 #else
40 #include "G4RunManager.hh"
41 #include "RE05SteppingVerbose.hh"
42 #endif
43 
44 #include "G4UImanager.hh"
45 
46 #include "RE05DetectorConstruction.hh"
47 #include "RE05CalorimeterParallelWorld.hh"
48 #include "QBBC.hh"
49 #include "G4ParallelWorldPhysics.hh"
50 #include "RE05ActionInitialization.hh"
51 
52 #include "G4VisExecutive.hh"
53 #include "G4UIExecutive.hh"
54 
55 int main(int argc,char** argv)
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 }
121 
122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int main(int argc, char **argv)
Definition: exampleRE05.cc:55