Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
gammaknife.cc File Reference
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIterminal.hh"
#include "G4UItcsh.hh"
#include "GammaKnifeDetectorConstruction.hh"
#include "GammaKnifePhysicsList.hh"
#include "GammaKnifePrimaryGeneratorAction.hh"
#include "GammaKnifeRunAction.hh"
#include "GammaKnifeActionInitialization.hh"
#include "Randomize.hh"
#include "G4UImessenger.hh"
#include "G4ScoringManager.hh"
#include "globals.hh"
#include "GammaKnifeController.hh"
#include "G4PhysListFactory.hh"
#include <ctime>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 77 of file gammaknife.cc.

References G4UImanager::ApplyCommand(), G4PhysListFactory::GetReferencePhysList(), G4ScoringManager::GetScoringManager(), G4UImanager::GetUIpointer(), Initialize(), G4RunManager::Initialize(), G4PhysListFactory::IsReferencePhysList(), GammaKnifeController::ReadFile(), G4UIExecutive::SessionStart(), and G4RunManager::SetUserInitialization().

78 {
79 
80  G4Random::setTheEngine(new CLHEP::RanecuEngine);
81  G4int seconds = time(NULL);
82  G4Random::setTheSeed(seconds);
83 
84 #ifdef G4MULTITHREADED
85  G4MTRunManager * runManager = new G4MTRunManager;
86 #else
87  G4RunManager * runManager = new G4RunManager;
88 #endif
89 
90  G4ScoringManager::GetScoringManager(); // This enables scoring
91 
92  // Initialize the geometry
94  runManager -> SetUserInitialization(detector);
95 
96  // Initialize the physics
97  G4PhysListFactory factory;
98  G4VModularPhysicsList* phys = 0;
99  G4String physName = "";
100 
101  // Physics List name defined via environment variable
102  char* path = getenv("PHYSLIST");
103  if (path) { physName = G4String(path); }
104 
105  if(physName != "" && factory.IsReferencePhysList(physName))
106  {
107  phys = factory.GetReferencePhysList(physName);
108  }
109 
110  if(!phys) { phys = new GammaKnifePhysicsList(); }
111 
112  runManager->SetUserInitialization(phys);
113 
114 
116  runManager->SetUserInitialization(actionInitialization);
117 
118  GammaKnifeController* controller = new GammaKnifeController( detector );
119  controller->ReadFile("MachineAngle.in"); // pre-load default
120 
121  // Initialize G4 kernel
122  //
123  runManager->Initialize();
124 
125 #ifdef G4VIS_USE
126  // Visualization manager
127  G4VisManager* visManager = new G4VisExecutive;
128  visManager -> Initialize();
129 #endif
130 
131  // Get the pointer to the User Interface manager
132  G4UImanager* UImanager = G4UImanager::GetUIpointer();
133 
134  if (argc!=1) {
135  // batch mode
136  G4String command = "/control/execute ";
137  G4String fileName = argv[1];
138  UImanager->ApplyCommand(command+fileName);
139  }
140  else {
141  // interactive mode : define UI session
142 #ifdef G4UI_USE
143  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
144 #ifdef G4VIS_USE
145  UImanager->ApplyCommand("/control/execute defaultMacro.mac");
146 #else
147  UImanager->ApplyCommand("/control/execute batch.mac");
148 #endif
149  ui->SessionStart();
150  delete ui;
151 #endif
152  }
153 
154  // Job termination
155 #ifdef G4VIS_USE
156  delete visManager;
157 #endif
158 
159  delete runManager;
160  delete controller;
161 
162  return 0;
163 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void ReadFile(std::string fileName)
void Initialize()
Definition: errprop.cc:96
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4VModularPhysicsList * GetReferencePhysList(const G4String &)
G4bool IsReferencePhysList(const G4String &)
virtual void Initialize()
static G4ScoringManager * GetScoringManager()
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419