source: trunk/examples/advanced/hadrontherapy/Hadrontherapy.cc @ 1185

Last change on this file since 1185 was 807, checked in by garnier, 16 years ago

update

File size: 5.1 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26// $Id: Hadrontherapy.cc Main of the Hadrontherapy example; Version 4.0 May 2005
27// ----------------------------------------------------------------------------
28//                 GEANT 4 - Hadrontherapy example
29// ----------------------------------------------------------------------------
30// Code developed by:
31//
32// G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a)
33//
34// (a) Laboratori Nazionali del Sud
35//     of the INFN, Catania, Italy
36// (b) INFN Section of Genova, Genova, Italy
37//
38// * cirrone@lns.infn.it
39// ----------------------------------------------------------------------------
40#include "G4RunManager.hh"
41#include "G4UImanager.hh"
42#include "G4UIterminal.hh"
43#include "G4UItcsh.hh"
44#ifdef G4UI_USE_XM
45#include "G4UIXm.hh"
46#endif
47#ifdef G4VIS_USE
48#include "G4VisExecutive.hh"
49#endif
50#include "HadrontherapyEventAction.hh"
51#include "HadrontherapyDetectorConstruction.hh"
52#include "HadrontherapyPhysicsList.hh"
53#include "HadrontherapyPhantomSD.hh"
54#include "HadrontherapyPrimaryGeneratorAction.hh"
55#include "HadrontherapyRunAction.hh"
56#include "HadrontherapyMatrix.hh"
57#include "Randomize.hh" 
58#include "G4RunManager.hh"
59#include "G4UImanager.hh"
60#include "G4UImessenger.hh"
61#include "globals.hh"
62#include "HadrontherapySteppingAction.hh"
63#ifdef  G4ANALYSIS_USE
64#include "HadrontherapyAnalysisManager.hh"
65#endif
66
67int main(int argc ,char ** argv)
68{
69
70  // Set the Random engine
71
72  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine());
73
74  G4RunManager* runManager = new G4RunManager;
75
76  // Initialize the geometry
77  runManager -> SetUserInitialization(new HadrontherapyDetectorConstruction());
78 
79  // Initialize the physics
80  runManager -> SetUserInitialization(new HadrontherapyPhysicsList());
81 
82  // Initialize the primary particles 
83  runManager -> SetUserAction(new HadrontherapyPrimaryGeneratorAction());
84
85  // Initialize matrix
86  HadrontherapyMatrix* matrix = new HadrontherapyMatrix();
87  matrix -> Initialize();
88
89  // Optional UserActions: run, event, stepping
90  HadrontherapyRunAction* pRunAction = new HadrontherapyRunAction();
91  runManager -> SetUserAction(pRunAction);
92
93  HadrontherapyEventAction* pEventAction = new HadrontherapyEventAction(matrix);
94  runManager -> SetUserAction(pEventAction);
95
96
97  HadrontherapySteppingAction* steppingAction = new HadrontherapySteppingAction(pRunAction); 
98  runManager -> SetUserAction(steppingAction);   
99
100
101#ifdef G4ANALYSIS_USE
102  HadrontherapyAnalysisManager* analysis = 
103    HadrontherapyAnalysisManager::getInstance();
104  analysis -> book();
105#endif
106 
107#ifdef G4VIS_USE
108  // Visualization manager
109  G4VisManager* visManager = new G4VisExecutive;
110  visManager -> Initialize();
111#endif
112 
113 
114  G4UIsession* session = 0;
115  if (argc == 1)   // Define UI session for interactive mode.
116    {
117      session = new G4UIterminal();
118    } 
119
120  // Get the pointer to the User Interface manager
121  G4UImanager* UI = G4UImanager::GetUIpointer(); 
122  if (session)   // Define UI session for interactive mode.
123    { 
124      G4cout<<" UI session starts ..."<< G4endl;
125      UI -> ApplyCommand("/control/execute defaultMacro.mac");   
126      session -> SessionStart();
127      delete session;
128    }
129  else           // Batch mode
130    { 
131      G4String command = "/control/execute ";
132      G4String fileName = argv[1];
133      UI -> ApplyCommand(command + fileName);
134    } 
135
136  matrix -> TotalEnergyDeposit();
137
138#ifdef G4ANALYSIS_USE
139  analysis -> finish();
140#endif
141 
142  // Job termination
143#ifdef G4VIS_USE
144  delete visManager;
145#endif
146
147  delete runManager;
148
149  return 0;
150}
Note: See TracBrowser for help on using the repository browser.