Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
iort_therapy.cc File Reference
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4PhysListFactory.hh"
#include "G4VModularPhysicsList.hh"
#include "IORTEventAction.hh"
#include "IORTPhysicsList.hh"
#include "IORTDetectorSD.hh"
#include "IORTPrimaryGeneratorAction.hh"
#include "IORTRunAction.hh"
#include "IORTMatrix.hh"
#include "Randomize.hh"
#include "G4UImessenger.hh"
#include "globals.hh"
#include "IORTSteppingAction.hh"
#include "IORTAnalysisManager.hh"
#include "IORTGeometryController.hh"
#include "IORTGeometryMessenger.hh"
#include "IORTInteractionParameters.hh"
#include "G4ScoringManager.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 88 of file iort_therapy.cc.

References G4UImanager::ApplyCommand(), IORTAnalysisManager::GetInstance(), IORTMatrix::GetInstance(), G4PhysListFactory::GetReferencePhysList(), G4ScoringManager::GetScoringManager(), G4UImanager::GetUIpointer(), Initialize(), G4UIExecutive::IsGUI(), G4PhysListFactory::IsReferencePhysList(), G4UIExecutive::SessionStart(), IORTGeometryController::SetGeometry(), CLHEP::HepRandom::setTheEngine(), CLHEP::HepRandom::setTheSeed(), G4RunManager::SetUserInitialization(), and G4ScoringManager::SetVerboseLevel().

89 {
90  // Set the Random engine
92 
93  //imported from eliot_geant4.9.3p01// to create a different seed
94  G4int seed = time(NULL);
96  //imported from eliot_geant4.9.3p01
97 
98  G4RunManager* runManager = new G4RunManager;
99  // Geometry controller is responsible for instantiating the
100  // geometries. All geometry specific setup tasks are now in class
101  // IORTGeometryController.
102  IORTGeometryController *geometryController = new IORTGeometryController();
103 
104  // Connect the geometry controller to the G4 user interface
105  IORTGeometryMessenger *geometryMessenger = new IORTGeometryMessenger(geometryController);
106 
108  scoringManager->SetVerboseLevel(1);
109 
110 
111  // Initialize the default IORT geometry
112  geometryController->SetGeometry("default");
113 
114  // Initialize command based scoring
116 
117  // Initialize the physics
118  G4PhysListFactory factory;
119  G4VModularPhysicsList* phys = 0;
120  G4String physName = "";
121 
122  // Physics List name defined via environment variable
123  char* path = getenv("PHYSLIST");
124  if (path) { physName = G4String(path); }
125 
126  if(factory.IsReferencePhysList(physName))
127  {
128  phys = factory.GetReferencePhysList(physName);
129  }
130 
131  if(!phys) { phys = new IORTPhysicsList(); }
132 
133  runManager->SetUserInitialization(phys);
134 
135  // runManager -> SetUserInitialization(new IORTPhysicsList());
136 
137  // Initialize the primary particles
138  IORTPrimaryGeneratorAction *pPrimaryGenerator = new IORTPrimaryGeneratorAction();
139  runManager -> SetUserAction(pPrimaryGenerator);
140 
141  // Optional UserActions: run, event, stepping
142  IORTRunAction* pRunAction = new IORTRunAction();
143  runManager -> SetUserAction(pRunAction);
144 
145  IORTEventAction* pEventAction = new IORTEventAction();
146  runManager -> SetUserAction(pEventAction);
147 
148  IORTSteppingAction* steppingAction = new IORTSteppingAction(pRunAction);
149  runManager -> SetUserAction(steppingAction);
150 
151  // Interaction data: stopping powers
152  IORTInteractionParameters* pInteraction = new IORTInteractionParameters(true);
153 
154  // Initialize analysis
155 
156 #ifdef G4ANALYSIS_USE_ROOT
158  analysis -> book();
159 #endif
160 
161 #ifdef G4VIS_USE
162  // Visualization manager
163  G4VisManager* visManager = new G4VisExecutive;
164  visManager -> Initialize();
165 #endif
166 
167  G4UImanager* UImanager = G4UImanager::GetUIpointer();
168  if (argc!=1) // batch mode
169  {
170  G4String command = "/control/execute ";
171  G4String fileName = argv[1];
172  UImanager->ApplyCommand(command+fileName);
173  }
174  else
175  { // interactive mode : define UI session
176 
177 
178 #ifdef G4UI_USE
179  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
180 #ifdef G4VIS_USE
181  if(factory.IsReferencePhysList(physName))
182  {
183  UImanager->ApplyCommand("/control/execute defaultMacroWithReferencePhysicsList.mac");
184  }
185  else
186  {
187  UImanager->ApplyCommand("/control/execute defaultMacro.mac");
188  }
189 
190 #endif
191  if (ui->IsGUI())
192  ui->SessionStart();
193  delete ui;
194 #endif
195  }
196 
197  // Job termination
198  // Store dose & fluence data to ASCII & ROOT files
199  if ( IORTMatrix * pMatrix = IORTMatrix::GetInstance() )
200  {
201  pMatrix -> TotalEnergyDeposit();
202  pMatrix -> StoreDoseFluenceAscii();
203 #ifdef G4ANALYSIS_USE_ROOT
204  pMatrix -> StoreDoseFluenceRoot();
205 #endif
206  }
207 
208 #ifdef G4ANALYSIS_USE_ROOT
209  if (analysis -> IsTheTFile()) analysis -> flush(); // Finalize & write the root file
210 #endif
211 
212 
213 #ifdef G4VIS_USE
214  delete visManager;
215 #endif
216 
217 
218  delete geometryMessenger;
219  delete geometryController;
220  delete pInteraction;
221  delete runManager;
222  return 0;
223 
224 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void Initialize()
Definition: errprop.cc:96
int G4int
Definition: G4Types.hh:78
static void setTheSeed(long seed, int lux=3)
Definition: Random.cc:131
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4VModularPhysicsList * GetReferencePhysList(const G4String &)
G4bool IsReferencePhysList(const G4String &)
static IORTAnalysisManager * GetInstance()
static void setTheEngine(HepRandomEngine *theNewEngine)
Definition: Random.cc:170
static IORTMatrix * GetInstance()
Definition: IORTMatrix.cc:61
static G4ScoringManager * GetScoringManager()
G4bool IsGUI() const
void SetVerboseLevel(G4int vl)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419