Geant4_10
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 //
26 //
27 // $Id: examplePar01.cc 77659 2013-11-27 08:57:46Z gcosmo $
28 //
29 //
30 // --------------------------------------------------------------
31 // GEANT 4 - examplePar01
32 // --------------------------------------------------------------
33 // Comments
34 //
35 // Example of a main program making use of parameterisation
36 // i.e. "Fast Simulation"
37 //-------------------------------------------------------------------
38 
39 //-------------------
40 // Generator action:
41 //-------------------
43 
44 //---------------------------
45 // Parameterisation manager:
46 //---------------------------
48 
49 //------------
50 // Geometries:
51 //------------
54 
55 //-----------------------------------
56 // Par01PhysicsList (makes use of the
57 // G4ParameterisationManagerProcess):
58 //-----------------------------------
59 #include "Par01PhysicsList.hh"
60 
61 #include "G4UImanager.hh"
62 #ifdef G4MULTITHREADED
63 #include "G4MTRunManager.hh"
64 #else
65 #include "G4RunManager.hh"
66 #endif
68 
69 #ifdef G4VIS_USE
70 #include "G4VisExecutive.hh"
71 #endif
72 
73 #ifdef G4UI_USE
74 #include "G4UIExecutive.hh"
75 #endif
76 
77 int main(int argc, char** argv)
78 {
79  //-------------------------------
80  // Initialization of Run manager
81  //-------------------------------
82 #ifdef G4MULTITHREADED
83  G4MTRunManager * runManager = new G4MTRunManager;
84  runManager->SetNumberOfThreads(4);
85  G4cout<<"+-------------------------------------------------------+"<<G4endl;
86  G4cout<<"| Constructing MT run manager |"<<G4endl;
87  G4cout<<"+-------------------------------------------------------+"<<G4endl;
88 #else
89  G4RunManager * runManager = new G4RunManager;
90  G4cout<<"+-------------------------------------------------------+"<<G4endl;
91  G4cout<<"| Constructing sequential run manager |"<<G4endl;
92  G4cout<<"+-------------------------------------------------------+"<<G4endl;
93 #endif
94 
95  // Detector/mass geometry and parallel geometry(ies):
97  // -- Parallel geometry for pion parameterisation
98  detector->RegisterParallelWorld(new Par01ParallelWorldForPion("pionGhostWorld"));
99  // -- The name passed must be the same passed to the
100  // -- G4FastSimulationManagerProcess attached to the pions
101  runManager->SetUserInitialization(detector);
102 
103  // PhysicsList (including G4FastSimulationManagerProcess)
104  G4VUserPhysicsList* physicsList = new Par01PhysicsList;
105  runManager->SetUserInitialization(physicsList);
106 
107  //-------------------------------
108  // UserAction classes
109  //-------------------------------
111 
112  // Initialize Run manager
113  runManager->Initialize();
114 
115  //----------------
116  // Visualization:
117  //----------------
118 #ifdef G4VIS_USE
119  G4cout << "Instantiating Visualization Manager......." << G4endl;
120  G4VisManager* visManager = new G4VisExecutive;
121  visManager -> Initialize ();
122 #endif
123 
124  if(argc==1)
125  {
126  //--------------------------
127  // Define (G)UI
128  //--------------------------
129 #ifdef G4UI_USE
130  G4UIExecutive * ui = new G4UIExecutive(argc, argv);
131  ui->SessionStart();
132  delete ui;
133 #endif
134  }
135  else
136  {
137  G4String command = "/control/execute ";
138  G4String fileName = argv[1];
139  G4UImanager * UImanager = G4UImanager::GetUIpointer();
140  UImanager->ApplyCommand(command+fileName);
141  }
142 
143  // Free the store: user actions, physics_list and detector_description are
144  // owned and deleted by the run manager, so they should not
145  // be deleted in the main() program !
146 
147 #ifdef G4VIS_USE
148  delete visManager;
149 #endif
150  delete runManager;
151 
152  return 0;
153 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetNumberOfThreads(G4int n)
void Initialize()
Definition: errprop.cc:96
int main(int argc, char **argv)
Definition: genwindef.cpp:30
void RegisterParallelWorld(G4VUserParallelWorld *)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
virtual void Initialize()
#define G4endl
Definition: G4ios.hh:61
Definition of the Par01ActionInitialization class.
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419