LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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 // $Id: exampleRE06.cc 97979 2016-06-30 09:36:20Z gcosmo $
30 //
31 // --------------------------------------------------------------
32 // GEANT 4 - example RE06
33 // --------------------------------------------------------------
34 
35 #ifdef G4MULTITHREADED
36 #include "G4MTRunManager.hh"
37 #else
38 #include "G4RunManager.hh"
39 #endif
40 
41 #ifdef G4VIS_USE
42 #include "G4VisExecutive.hh"
43 #endif
44 
45 #ifdef G4UI_USE
46 #include "G4UIExecutive.hh"
47 #endif
48 
49 #include "G4UImanager.hh"
50 #include "FTFP_BERT.hh"
51 #include "G4ParallelWorldPhysics.hh"
52 
53 #include "RE06DetectorConstruction.hh"
54 #include "RE06ParallelWorld.hh"
55 #include "RE06PrimaryGeneratorAction.hh"
56 #include "RE06RunAction.hh"
57 #include "RE06SteppingVerbose.hh"
58 #include "RE06ActionInitialization.hh"
59 #include "RE06WorkerInitialization.hh"
60 
61 int main(int argc,char** argv)
62 {
63  // Construct the stepping verbose class
64  RE06SteppingVerbose* verbosity = new RE06SteppingVerbose;
65  G4VSteppingVerbose::SetInstance(verbosity);
66 
67  // Construct the run manager
68  //
69 #ifdef G4MULTITHREADED
70  G4MTRunManager * runManager = new G4MTRunManager;
71  runManager->SetNumberOfThreads(4);
72  runManager->SetUserInitialization(new RE06WorkerInitialization);
73 #else
74  G4RunManager* runManager = new G4RunManager;
75 #endif
76 
77  // Set mandatory initialization classes
78  //
79  G4String parallelWorldName = "ParallelScoringWorld";
80  G4VUserDetectorConstruction* detector = new RE06DetectorConstruction;
81  detector->RegisterParallelWorld(new RE06ParallelWorld(parallelWorldName));
82  runManager->SetUserInitialization(detector);
83  //
84  G4VModularPhysicsList* physics = new FTFP_BERT;
85  physics->RegisterPhysics(new G4ParallelWorldPhysics(parallelWorldName));
86  runManager->SetUserInitialization(physics);
87 
88  // Set user action classes
89  //
90  runManager->SetUserInitialization(new RE06ActionInitialization);
91 
92 #ifdef G4VIS_USE
93  // Visualization manager
94  //
95  G4VisManager* visManager = new G4VisExecutive;
96  visManager->Initialize();
97 #endif
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 (argc==1) // Define UI session for interactive mode
108  {
109 #ifdef G4UI_USE
110  G4UIExecutive * ui = new G4UIExecutive(argc,argv);
111 #ifdef G4VIS_USE
112  UImanager->ApplyCommand("/control/execute vis.mac");
113 #endif
114  ui->SessionStart();
115  delete ui;
116 #endif
117  }
118  else // Batch mode
119  {
120  G4String command = "/control/execute ";
121  G4String fileName = argv[1];
122  UImanager->ApplyCommand(command+fileName);
123  }
124 
125  // Job termination
126  // Free the store:
127  // user actions, physics_list and detector_description are
128  // owned and deleted by the run manager, so they should not
129  // be deleted in the main() program !
130 
131 #ifdef G4VIS_USE
132  delete visManager;
133 #endif
134  delete runManager;
135 
136  return 0;
137 }
int main(int argc, char **argv)
Definition: exampleRE06.cc:61