LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
examplePar02.cc File Reference
#include "G4Types.hh"
#include "G4UImanager.hh"
#include "G4RunManager.hh"
#include "Par02DetectorConstruction.hh"
#include "Par02PhysicsList.hh"
#include "Par02ActionInitialization.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 58 of file examplePar02.cc.

58  {
59 
60  // Instantiate G4UIExecutive if interactive mode
61  G4UIExecutive* ui = nullptr;
62  if ( argc == 1 ) {
63  ui = new G4UIExecutive(argc, argv);
64  }
65 
66  //-------------------------------
67  // Initialization of Run manager
68  //-------------------------------
69  #ifdef G4MULTITHREADED
70  G4MTRunManager* runManager = new G4MTRunManager;
71  runManager->SetNumberOfThreads(4);
72  G4cout<<"+-------------------------------------------------------+"<<G4endl;
73  G4cout<<"| Constructing MT run manager |"<<G4endl;
74  G4cout<<"+-------------------------------------------------------+"<<G4endl;
75  #else
76  G4RunManager* runManager = new G4RunManager;
77  G4cout<<"+-------------------------------------------------------+"<<G4endl;
78  G4cout<<"| Constructing sequential run manager |"<<G4endl;
79  G4cout<<"+-------------------------------------------------------+"<<G4endl;
80  #endif
81 
82  // Detector/mass geometry:
83  G4VUserDetectorConstruction* detector = new Par02DetectorConstruction();
84  runManager->SetUserInitialization( detector );
85 
86  // PhysicsList (including G4FastSimulationManagerProcess)
87  G4VUserPhysicsList* physicsList = new Par02PhysicsList;
88  runManager->SetUserInitialization( physicsList );
89 
90  //-------------------------------
91  // UserAction classes
92  //-------------------------------
93  runManager->SetUserInitialization( new Par02ActionInitialization );
94 
95  // Initialize Run manager
96  runManager->Initialize();
97 
98  //----------------
99  // Visualization:
100  //----------------
101  G4cout << "Instantiating Visualization Manager......." << G4endl;
102  G4VisManager* visManager = new G4VisExecutive;
103  visManager->Initialize();
104 
105  if ( ui ) {
106  //--------------------------
107  // Define (G)UI
108  //--------------------------
109  ui->SessionStart();
110  delete ui;
111  } else {
112  G4String command = "/control/execute ";
113  G4String fileName = argv[1];
114  G4UImanager * UImanager = G4UImanager::GetUIpointer();
115  UImanager->ApplyCommand( command+fileName );
116  }
117 
118  // Free the store: user actions, physics_list and detector_description are
119  // owned and deleted by the run manager, so they should not
120  // be deleted in the main() program !
121 
122  delete visManager;
123  delete runManager;
124 
125  return 0;
126 }