Geant4  10.02.p03
TestEm11.cc File Reference

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

#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"
#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include "ActionInitialization.hh"
#include "SteppingVerbose.hh"
Include dependency graph for TestEm11.cc:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the electromagnetic/TestEm11 example.

Definition in file TestEm11.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 58 of file TestEm11.cc.

58  {
59 
60  //choose the Random engine
61  G4Random::setTheEngine(new CLHEP::RanecuEngine);
63 
64  //Construct the default run manager
65 #ifdef G4MULTITHREADED
66  G4MTRunManager* runManager = new G4MTRunManager;
67  // Number of threads can be defined via 3rd argument
68  G4int nThreads = 4;
69  if (argc==3) {
70  if(G4String(argv[2]) == "NMAX") {
72  } else {
73  nThreads = G4UIcommand::ConvertToInt(argv[2]);
74  }
75  } else if(argc==1) {
76  nThreads = 1;
77  }
78  if (nThreads > 0) { runManager->SetNumberOfThreads(nThreads); }
79  G4cout << "===== TestEm11 is started with "
80  << runManager->GetNumberOfThreads() << " threads =====" << G4endl;
81 #else
82  G4RunManager* runManager = new G4RunManager;
83 #endif
84 
85  //set mandatory initialization classes
87  runManager->SetUserInitialization(det);
88 
89  PhysicsList* phys = new PhysicsList;
90  runManager->SetUserInitialization(phys);
91 
92  runManager->SetUserInitialization(new ActionInitialization(det, phys));
93 
94  //get the pointer to the User Interface manager
96 
97  if (argc!=1) // batch mode
98  {
99  G4String command = "/control/execute ";
100  G4String fileName = argv[1];
101  UI->ApplyCommand(command+fileName);
102  }
103  else //define visualization and UI terminal for interactive mode
104  {
105 #ifdef G4VIS_USE
106  G4VisManager* visManager = new G4VisExecutive;
107  visManager->Initialize();
108 #endif
109 
110 #ifdef G4UI_USE
111  G4UIExecutive * ui = new G4UIExecutive(argc,argv);
112  ui->SessionStart();
113  delete ui;
114 #endif
115 
116 #ifdef G4VIS_USE
117  delete visManager;
118 #endif
119  }
120 
121  //job termination
122  //
123  delete runManager;
124 
125  return 0;
126 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetNumberOfThreads(G4int n)
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
G4int G4GetNumberOfCores()
Definition: G4Threading.cc:133
G4int GetNumberOfThreads() const
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:435
void Initialize()
static void SetInstance(G4VSteppingVerbose *Instance)
Detector construction class to define materials and geometry.
#define G4endl
Definition: G4ios.hh:61
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446
Here is the call graph for this function: