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

Main program of the medical/GammaTherapy example. More...

#include "G4Types.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"
#include "DetectorConstruction.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 medical/GammaTherapy example.

Definition in file GammaTherapy.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 65 of file GammaTherapy.cc.

65  {
66 
67  //detect interactive mode (if no arguments) and define UI session
68  G4UIExecutive* ui = nullptr;
69  if (argc == 1) ui = new G4UIExecutive(argc,argv);
70 
71  //choose the Random engine
72  G4Random::setTheEngine(new CLHEP::RanecuEngine);
73 
74  // Construct the default run manager
75 #ifdef G4MULTITHREADED
76  G4MTRunManager* runManager = new G4MTRunManager;
77  G4int nThreads = std::min(G4Threading::G4GetNumberOfCores(),2);
78  if (argc==3) nThreads = G4UIcommand::ConvertToInt(argv[2]);
79  runManager->SetNumberOfThreads(nThreads);
80  G4cout << "===== GammaTherapy is started with "
81  << runManager->GetNumberOfThreads() << " threads =====" << G4endl;
82 #else
83  G4RunManager* runManager = new G4RunManager();
84 #endif
85 
86  //set mandatory initialization classes
88  runManager->SetUserInitialization(det);
89 
90  runManager->SetUserInitialization(new PhysicsList());
91 
92  // set user action classes
93  runManager->SetUserInitialization(new ActionInitialization(det));
94 
95  //initialize visualization
96  G4VisManager* visManager = nullptr;
97 
98  //get the pointer to the User Interface manager
99  G4UImanager* UImanager = G4UImanager::GetUIpointer();
100 
101  if (ui) {
102  //interactive mode
103  visManager = new G4VisExecutive;
104  visManager->Initialize();
105  UImanager->ApplyCommand("/control/execute vis.mac");
106  ui->SessionStart();
107  delete ui;
108  }
109  else {
110  //batch mode
111  G4String command = "/control/execute ";
112  G4String fileName = argv[1];
113  UImanager->ApplyCommand(command+fileName);
114  }
115 
116  //job termination
117  delete visManager;
118  delete runManager;
119 }
TConfigurablePhysicsList< ModularPhysicsList > PhysicsList
Definition: PhysicsList.h:83