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

Main program of the electromagnetic/TestEm2 example. More...

#include "G4RunManager.hh"
#include "G4MTRunManager.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "Randomize.hh"
#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include "ActionInitialization.hh"
#include "SteppingVerbose.hh"
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the electromagnetic/TestEm2 example.

Definition in file TestEm2.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 50 of file TestEm2.cc.

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