LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
gammaknife.cc File Reference
#include "G4Types.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIterminal.hh"
#include "G4UItcsh.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.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 76 of file gammaknife.cc.

References Initialize().

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