Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
hadrontherapy.cc File Reference
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4PhysListFactory.hh"
#include "G4VModularPhysicsList.hh"
#include "HadrontherapyEventAction.hh"
#include "HadrontherapyPhysicsList.hh"
#include "HadrontherapyDetectorSD.hh"
#include "HadrontherapyPrimaryGeneratorAction.hh"
#include "HadrontherapyRunAction.hh"
#include "HadrontherapyMatrix.hh"
#include "Randomize.hh"
#include "G4UImessenger.hh"
#include "globals.hh"
#include "HadrontherapySteppingAction.hh"
#include "HadrontherapyAnalysisManager.hh"
#include "HadrontherapyGeometryController.hh"
#include "HadrontherapyGeometryMessenger.hh"
#include "HadrontherapyInteractionParameters.hh"
#include "HadrontherapyLet.hh"
#include "G4ScoringManager.hh"
#include "G4ParallelWorldPhysics.hh"

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 97 of file hadrontherapy.cc.

References G4UImanager::ApplyCommand(), G4cout, G4endl, HadrontherapyLet::GetInstance(), HadrontherapyAnalysisManager::GetInstance(), HadrontherapyMatrix::GetInstance(), G4PhysListFactory::GetReferencePhysList(), G4ScoringManager::GetScoringManager(), G4UImanager::GetUIpointer(), Initialize(), G4PhysListFactory::IsReferencePhysList(), G4VModularPhysicsList::RegisterPhysics(), G4UIExecutive::SessionStart(), HadrontherapyGeometryController::SetGeometry(), CLHEP::HepRandom::setTheEngine(), G4RunManager::SetUserInitialization(), and G4ScoringManager::SetVerboseLevel().

98 {
99  // Set the Random engine
101 
102  G4RunManager* runManager = new G4RunManager;
103  // Geometry controller is responsible for instantiating the
104  // geometries. All geometry specific setup tasks are now in class
105  // HadrontherapyGeometryController.
107 
108  // Connect the geometry controller to the G4 user interface
109  HadrontherapyGeometryMessenger *geometryMessenger = new HadrontherapyGeometryMessenger(geometryController);
110 
112  scoringManager->SetVerboseLevel(1);
113 
114 
115  // Initialize the default Hadrontherapy geometry
116  geometryController->SetGeometry("default");
117 
118  // Initialize command based scoring
120 
121  // Initialize the physics
122  G4PhysListFactory factory;
123  G4VModularPhysicsList* phys = 0;
124  G4String physName = "";
125 
126  // Physics List name defined via environment variable
127  char* path = getenv("PHYSLIST");
128  if (path) { physName = G4String(path); }
129 
130  if(physName != "" && factory.IsReferencePhysList(physName))
131  {
132  phys = factory.GetReferencePhysList(physName);
133  }
134  if (phys)
135  {
136  G4cout << "Going to register G4ParallelWorldPhysics" << G4endl;
137  phys->RegisterPhysics(new G4ParallelWorldPhysics("DetectorROGeometry"));
138  }
139  else
140  {
141  G4cout << "Using HadrontherapyPhysicsList()" << G4endl;
142  phys = new HadrontherapyPhysicsList();
143  }
144 
145 
146  runManager->SetUserInitialization(phys);
147 
148 
149  // Initialize the primary particles
151  runManager -> SetUserAction(pPrimaryGenerator);
152 
153  // Optional UserActions: run, event, stepping
155  runManager -> SetUserAction(pRunAction);
156 
158  runManager -> SetUserAction(pEventAction);
159 
160  HadrontherapySteppingAction* steppingAction = new HadrontherapySteppingAction(pRunAction);
161  runManager -> SetUserAction(steppingAction);
162 
163  // Interaction data: stopping powers
165 
166  // Initialize analysis
168 #ifdef G4ANALYSIS_USE_ROOT
169  analysis -> book();
170 #endif
171 
172 #ifdef G4VIS_USE
173  // Visualization manager
174  G4VisManager* visManager = new G4VisExecutive;
175  visManager -> Initialize();
176 #endif
177 
178  G4UImanager* UImanager = G4UImanager::GetUIpointer();
179  if (argc!=1) // batch mode
180  {
181  G4String command = "/control/execute ";
182  G4String fileName = argv[1];
183  UImanager->ApplyCommand(command+fileName);
184  }
185  else
186  { // interactive mode : define UI session
187 
188 
189 #ifdef G4UI_USE
190  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
191 #ifdef G4VIS_USE
192  if(factory.IsReferencePhysList(physName))
193  {
194  UImanager->ApplyCommand("/control/execute defaultMacroWithReferencePhysicsList.mac");
195  }
196  else
197  {
198  UImanager->ApplyCommand("/control/execute defaultMacro.mac");
199  }
200 
201 #endif
202  ui->SessionStart();
203  delete ui;
204 #endif
205  }
206 
207  // Job termination
208  // Store dose & fluence data to ASCII & ROOT files
210  {
211  pMatrix -> TotalEnergyDeposit();
212  pMatrix -> StoreDoseFluenceAscii();
213 #ifdef G4ANALYSIS_USE_ROOT
214  pMatrix -> StoreDoseFluenceRoot();
215 #endif
216  }
217 
219  if(let -> doCalculation)
220  {
221  let -> LetOutput(); // Calculate let
222  let -> StoreLetAscii(); // Store it
223 #ifdef G4ANALYSIS_USE_ROOT
224  let -> StoreLetRoot();
225 #endif
226  }
227 
228 
229 #ifdef G4ANALYSIS_USE_ROOT
230  if (analysis -> IsTheTFile()) analysis -> flush(); // Finalize & write the root file
231 #endif
232 
233 
234 #ifdef G4VIS_USE
235  delete visManager;
236 #endif
237 
238 
239  delete geometryMessenger;
240  delete geometryController;
241  delete pInteraction;
242  delete runManager;
243  delete analysis;
244  return 0;
245 
246 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
static HadrontherapyAnalysisManager * GetInstance()
void RegisterPhysics(G4VPhysicsConstructor *)
static HadrontherapyLet * GetInstance()
void Initialize()
Definition: errprop.cc:96
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
static HadrontherapyMatrix * GetInstance()
G4GLOB_DLL std::ostream G4cout
G4VModularPhysicsList * GetReferencePhysList(const G4String &)
G4bool IsReferencePhysList(const G4String &)
#define G4endl
Definition: G4ios.hh:61
static void setTheEngine(HepRandomEngine *theNewEngine)
Definition: Random.cc:170
static G4ScoringManager * GetScoringManager()
void SetVerboseLevel(G4int vl)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419