LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
examplePar01.cc File Reference

Main program of the Par01 example. More...

#include "G4Types.hh"
#include "Par01DetectorConstruction.hh"
#include "Par01ParallelWorldForPion.hh"
#include "FTFP_BERT.hh"
#include "G4FastSimulationPhysics.hh"
#include "G4UImanager.hh"
#include "G4RunManager.hh"
#include "Par01ActionInitialization.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the Par01 example.

Definition in file examplePar01.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 72 of file examplePar01.cc.

References Initialize().

73 {
74  // Instantiate G4UIExecutive if interactive mode
75  G4UIExecutive* ui = nullptr;
76  if ( argc == 1 ) {
77  ui = new G4UIExecutive(argc, argv);
78  }
79 
80  //-------------------------------
81  // Initialization of Run manager
82  //-------------------------------
83 #ifdef G4MULTITHREADED
84  G4MTRunManager * runManager = new G4MTRunManager;
85  runManager->SetNumberOfThreads(4);
86  G4cout<<"+-------------------------------------------------------+"<<G4endl;
87  G4cout<<"| Constructing MT run manager |"<<G4endl;
88  G4cout<<"+-------------------------------------------------------+"<<G4endl;
89 #else
90  G4RunManager * runManager = new G4RunManager;
91  G4cout<<"+-------------------------------------------------------+"<<G4endl;
92  G4cout<<"| Constructing sequential run manager |"<<G4endl;
93  G4cout<<"+-------------------------------------------------------+"<<G4endl;
94 #endif
95 
96  // -----------------------------------------------------
97  // -- Detector/mass geometry and parallel geometry(ies):
98  // -----------------------------------------------------
99  // -- Mass geometry (ie : standard geometry):
100  G4VUserDetectorConstruction* detector = new Par01DetectorConstruction();
101  // -- Parallel geometry for pion parameterisation
102  detector->RegisterParallelWorld(new Par01ParallelWorldForPion("pionGhostWorld"));
103  // -- Passed to the run manager:
104  runManager->SetUserInitialization(detector);
105 
106  // ----------------------------------------------
107  // -- PhysicsList and fast simulation activation:
108  // ----------------------------------------------
109  // -- Create a physics list (note : FTFP_BERT is a G4VModularPhysicsList
110  // -- which allows to use the subsequent G4FastSimulationPhysics tool to
111  // -- activate the fast simulation):
112  FTFP_BERT* physicsList = new FTFP_BERT;
113  // -- Create helper tool, used to activate the fast simulation:
114  G4FastSimulationPhysics* fastSimulationPhysics = new G4FastSimulationPhysics();
115  fastSimulationPhysics->BeVerbose();
116  // -- activation of fast simulation for particles having fast simulation models
117  // -- attached in the mass geometry:
118  fastSimulationPhysics->ActivateFastSimulation("e-");
119  fastSimulationPhysics->ActivateFastSimulation("e+");
120  fastSimulationPhysics->ActivateFastSimulation("gamma");
121  // -- activation of fast simulation for particles having fast simulation models
122  // -- attached in the parallel geometry:
123  fastSimulationPhysics->ActivateFastSimulation("pi+","pionGhostWorld");
124  fastSimulationPhysics->ActivateFastSimulation("pi-","pionGhostWorld");
125  // -- Attach the fast simulation physics constructor to the physics list:
126  physicsList->RegisterPhysics( fastSimulationPhysics );
127  // -- Finally passes the physics list to the run manager:
128  runManager->SetUserInitialization(physicsList);
129 
130  //-------------------------------
131  // UserAction classes
132  //-------------------------------
133  runManager->SetUserInitialization( new Par01ActionInitialization );
134 
135  // Initialize Run manager
136  runManager->Initialize();
137 
138  //----------------
139  // Visualization:
140  //----------------
141  G4cout << "Instantiating Visualization Manager......." << G4endl;
142  G4VisManager* visManager = new G4VisExecutive;
143  visManager -> Initialize ();
144 
145  if(ui)
146  {
147  //--------------------------
148  // Define (G)UI
149  //--------------------------
150  ui->SessionStart();
151  delete ui;
152  }
153  else
154  {
155  G4String command = "/control/execute ";
156  G4String fileName = argv[1];
157  G4UImanager * UImanager = G4UImanager::GetUIpointer();
158  UImanager->ApplyCommand(command+fileName);
159  }
160 
161  // Free the store: user actions, physics_list and detector_description are
162  // owned and deleted by the run manager, so they should not
163  // be deleted in the main() program !
164 
165  delete visManager;
166  delete runManager;
167 
168  return 0;
169 }
void Initialize()
Definition: errprop.cc:100