Geant4  10.03
examplePar01.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 // $Id: examplePar01.cc 101151 2016-11-08 08:06:16Z gcosmo $
31 //
32 //
33 // --------------------------------------------------------------
34 // Geant4 - examplePar01
35 // --------------------------------------------------------------
36 // Comments
37 //
38 // Example of a main program making use of parameterisation
39 // i.e. "Fast Simulation"
40 //-------------------------------------------------------------------
41 
42 //---------------
43 // -- Geometries:
44 //---------------
47 
48 //---------------------------------------------------------------------
49 // -- Physics list, and tool to modify it and activate fast simulation:
50 //---------------------------------------------------------------------
51 #include "FTFP_BERT.hh"
53 
54 #include "G4UImanager.hh"
55 #ifdef G4MULTITHREADED
56 #include "G4MTRunManager.hh"
57 #else
58 #include "G4RunManager.hh"
59 #endif
60 
61 // ----------------------------------------------------------------
62 // -- Action initialization (includes the primary generator action:
63 // ----------------------------------------------------------------
65 
66 #ifdef G4VIS_USE
67 #include "G4VisExecutive.hh"
68 #endif
69 
70 #ifdef G4UI_USE
71 #include "G4UIExecutive.hh"
72 #endif
73 
74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75 
76 int main(int argc, char** argv)
77 {
78  //-------------------------------
79  // Initialization of Run manager
80  //-------------------------------
81 #ifdef G4MULTITHREADED
82  G4MTRunManager * runManager = new G4MTRunManager;
83  runManager->SetNumberOfThreads(4);
84  G4cout<<"+-------------------------------------------------------+"<<G4endl;
85  G4cout<<"| Constructing MT run manager |"<<G4endl;
86  G4cout<<"+-------------------------------------------------------+"<<G4endl;
87 #else
88  G4RunManager * runManager = new G4RunManager;
89  G4cout<<"+-------------------------------------------------------+"<<G4endl;
90  G4cout<<"| Constructing sequential run manager |"<<G4endl;
91  G4cout<<"+-------------------------------------------------------+"<<G4endl;
92 #endif
93 
94  // -----------------------------------------------------
95  // -- Detector/mass geometry and parallel geometry(ies):
96  // -----------------------------------------------------
97  // -- Mass geometry (ie : standard geometry):
99  // -- Parallel geometry for pion parameterisation
100  detector->RegisterParallelWorld(new Par01ParallelWorldForPion("pionGhostWorld"));
101  // -- Passed to the run manager:
102  runManager->SetUserInitialization(detector);
103 
104  // ----------------------------------------------
105  // -- PhysicsList and fast simulation activation:
106  // ----------------------------------------------
107  // -- Create a physics list (note : FTFP_BERT is a G4VModularPhysicsList
108  // -- which allows to use the subsequent G4FastSimulationPhysics tool to
109  // -- activate the fast simulation):
110  FTFP_BERT* physicsList = new FTFP_BERT;
111  // -- Create helper tool, used to activate the fast simulation:
112  G4FastSimulationPhysics* fastSimulationPhysics = new G4FastSimulationPhysics();
113  fastSimulationPhysics->BeVerbose();
114  // -- activation of fast simulation for particles having fast simulation models
115  // -- attached in the mass geometry:
116  fastSimulationPhysics->ActivateFastSimulation("e-");
117  fastSimulationPhysics->ActivateFastSimulation("e+");
118  fastSimulationPhysics->ActivateFastSimulation("gamma");
119  // -- activation of fast simulation for particles having fast simulation models
120  // -- attached in the parallel geometry:
121  fastSimulationPhysics->ActivateFastSimulation("pi+","pionGhostWorld");
122  fastSimulationPhysics->ActivateFastSimulation("pi-","pionGhostWorld");
123  // -- Attach the fast simulation physics constructor to the physics list:
124  physicsList->RegisterPhysics( fastSimulationPhysics );
125  // -- Finally passes the physics list to the run manager:
126  runManager->SetUserInitialization(physicsList);
127 
128  //-------------------------------
129  // UserAction classes
130  //-------------------------------
132 
133  // Initialize Run manager
134  runManager->Initialize();
135 
136  //----------------
137  // Visualization:
138  //----------------
139 #ifdef G4VIS_USE
140  G4cout << "Instantiating Visualization Manager......." << G4endl;
141  G4VisManager* visManager = new G4VisExecutive;
142  visManager -> Initialize ();
143 #endif
144 
145  if(argc==1)
146  {
147  //--------------------------
148  // Define (G)UI
149  //--------------------------
150 #ifdef G4UI_USE
151  G4UIExecutive * ui = new G4UIExecutive(argc, argv);
152  ui->SessionStart();
153  delete ui;
154 #endif
155  }
156  else
157  {
158  G4String command = "/control/execute ";
159  G4String fileName = argv[1];
160  G4UImanager * UImanager = G4UImanager::GetUIpointer();
161  UImanager->ApplyCommand(command+fileName);
162  }
163 
164  // Free the store: user actions, physics_list and detector_description are
165  // owned and deleted by the run manager, so they should not
166  // be deleted in the main() program !
167 
168 #ifdef G4VIS_USE
169  delete visManager;
170 #endif
171  delete runManager;
172 
173  return 0;
174 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void ActivateFastSimulation(const G4String &particleName)
void SetNumberOfThreads(G4int n)
void Initialize()
Definition: errprop.cc:101
Definition of the Par01ParallelWorldForPion class.
void RegisterParallelWorld(G4VUserParallelWorld *)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
int main(int argc, char **argv)
Definition: examplePar01.cc:76
G4GLOB_DLL std::ostream G4cout
TFTFP_BERT< G4VModularPhysicsList > FTFP_BERT
Definition: FTFP_BERT.hh:63
Action initialization class.
virtual void Initialize()
#define G4endl
Definition: G4ios.hh:61
Definition of the Par01ActionInitialization class.
Definition of the Par01DetectorConstruction class.
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446