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

Main program of the eventgenerator/exgps example. More...

#include "G4Types.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"
#include "GeometryConstruction.hh"
#include "PhysicsList.hh"
#include "ActionInitialization.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the eventgenerator/exgps example.

Definition in file exgps.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 52 of file exgps.cc.

52  {
53 
54  //detect interactive mode (if no arguments) and define UI session
55  G4UIExecutive* ui = nullptr;
56  if (argc == 1) ui = new G4UIExecutive(argc,argv);
57 
58  // Construct the default run manager
59 #ifdef G4MULTITHREADED
60  G4MTRunManager * runManager = new G4MTRunManager;
61  G4int nThreads = G4Threading::G4GetNumberOfCores();
62  if (argc==3) nThreads = G4UIcommand::ConvertToInt(argv[2]);
63  runManager->SetNumberOfThreads(nThreads);
64 #else
65  G4RunManager * runManager = new G4RunManager;
66 #endif
67 
68  //set mandatory initialization classes
69  GeometryConstruction* detector = new GeometryConstruction;
70  runManager->SetUserInitialization(detector);
71  runManager->SetUserInitialization(new PhysicsList);
72 
73  runManager->SetUserInitialization(new ActionInitialization);
74 
75  //initialize visualization
76  G4VisManager* visManager = nullptr;
77 
78  //get the pointer to the User Interface manager
79  G4UImanager* UImanager = G4UImanager::GetUIpointer();
80 
81  if (ui) {
82  //interactive mode
83  visManager = new G4VisExecutive;
84  visManager->Initialize();
85  UImanager->ApplyCommand("/control/execute vis.mac");
86  ui->SessionStart();
87  delete ui;
88  }
89  else {
90  //batch mode
91  G4String command = "/control/execute ";
92  G4String fileName = argv[1];
93  UImanager->ApplyCommand(command+fileName);
94  }
95 
96  //job termination
97  delete visManager;
98  delete runManager;
99 }