Geant4  10.03
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"
52 
54 #include "RE06ParallelWorld.hh"
56 #include "RE06RunAction.hh"
57 #include "RE06SteppingVerbose.hh"
60 
61 int main(int argc,char** argv)
62 {
63  // Construct the stepping verbose class
66 
67  // Construct the run manager
68  //
69 #ifdef G4MULTITHREADED
70  G4MTRunManager * runManager = new G4MTRunManager;
71  runManager->SetNumberOfThreads(4);
73 #else
74  G4RunManager* runManager = new G4RunManager;
75 #endif
76 
77  // Set mandatory initialization classes
78  //
79  G4String parallelWorldName = "ParallelScoringWorld";
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  //
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 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
int main(int argc, char **argv)
Definition: exampleRE06.cc:61
void RegisterPhysics(G4VPhysicsConstructor *)
Definition of the RE06SteppingVerbose class.
void SetNumberOfThreads(G4int n)
Definition of the RE06ActionInitialization class.
Definition of the RE06ParallelWorld class.
void RegisterParallelWorld(G4VUserParallelWorld *)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
virtual void SetUserInitialization(G4VUserPhysicsList *userPL)
void Initialize()
TFTFP_BERT< G4VModularPhysicsList > FTFP_BERT
Definition: FTFP_BERT.hh:63
static void SetInstance(G4VSteppingVerbose *Instance)
virtual void Initialize()
Definition of the RE06PrimaryGeneratorAction class.
Definition of the RE06DetectorConstruction class.
Definition of the RE06RunAction class.
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446
Definition of the RE06WorkerInitialization class.