LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
exampleRE06.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 //
28 //
29 //
30 // --------------------------------------------------------------
31 // GEANT 4 - example RE06
32 // --------------------------------------------------------------
33 
34 #include "G4Types.hh"
35 
36 #ifdef G4MULTITHREADED
37 #include "G4MTRunManager.hh"
38 #else
39 #include "G4RunManager.hh"
40 #endif
41 
42 #include "G4VisExecutive.hh"
43 #include "G4UIExecutive.hh"
44 
45 #include "G4UImanager.hh"
46 #include "FTFP_BERT.hh"
47 #include "G4ParallelWorldPhysics.hh"
48 
49 #include "RE06DetectorConstruction.hh"
50 #include "RE06ParallelWorld.hh"
51 #include "RE06PrimaryGeneratorAction.hh"
52 #include "RE06RunAction.hh"
53 #include "RE06SteppingVerbose.hh"
54 #include "RE06ActionInitialization.hh"
55 #include "RE06WorkerInitialization.hh"
56 
57 int main(int argc,char** argv)
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 }
int main(int argc, char **argv)
Definition: exampleRE06.cc:57