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

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

#include "G4Types.hh"
#include "G4RunManager.hh"
#include "G4UImanager.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/TestEm16 example.

Definition in file TestEm16.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 53 of file TestEm16.cc.

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