source: trunk/examples/extended/parallel/ExDiane/src/BrachySimulation.cc@ 1343

Last change on this file since 1343 was 1337, checked in by garnier, 15 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 4.7 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//
27// $Id: BrachySimulation.cc
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
29//
30// --------------------------------------------------------------
31// GEANT 4 - Brachytherapy example
32// --------------------------------------------------------------
33//
34// Code developed by: S.Guatelli, K. Moscicki
35//
36//
37// *******************************
38// * *
39// * BrachySimualtion.cc *
40// * *
41// *******************************
42//
43#include "G4RunManager.hh"
44#include "G4UImanager.hh"
45#include "G4UIterminal.hh"
46#include "G4UItcsh.hh"
47#include "BrachyFactoryIr.hh"
48#ifdef G4UI_USE_XM
49#include "G4UIXm.hh"
50#endif
51
52#ifdef G4VIS_USE
53#include "G4VisExecutive.hh"
54#endif
55
56#include "BrachyDetectorConstruction.hh"
57#include "BrachyPhysicsList.hh"
58#include "BrachyPhantomSD.hh"
59#include "BrachyPrimaryGeneratorActionIr.hh"
60#include "G4SDManager.hh"
61#include "BrachyRunAction.hh"
62#include "Randomize.hh"
63#include "G4RunManager.hh"
64#include "G4SDManager.hh"
65#include "G4UImanager.hh"
66#include "G4UImessenger.hh"
67#include "BrachySimulation.hh"
68
69BrachySimulation::BrachySimulation(G4int sd)
70{
71 pRunManager = 0;
72 seed = sd;
73}
74
75BrachySimulation::~BrachySimulation()
76
77{ }
78void BrachySimulation::setSeed(G4int sd)
79{
80 seed = sd;
81 CLHEP::HepRandom::setTheSeed(seed);
82}
83
84G4bool BrachySimulation::initialize(int ,char** )
85{
86 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
87
88 G4cout << "G4 initializing" << G4endl;
89
90 pRunManager = new G4RunManager;
91
92 G4String sensitiveDetectorName = "Phantom";
93
94 BrachyDetectorConstruction *pDetectorConstruction = new BrachyDetectorConstruction(sensitiveDetectorName);
95
96 pRunManager -> SetUserInitialization(pDetectorConstruction);
97 pRunManager -> SetUserInitialization(new BrachyPhysicsList);
98
99 // output environment variables:
100#ifdef G4ANALYSIS_USE
101 G4cout << G4endl << G4endl << G4endl
102 << " User Environment " << G4endl
103 << " Using AIDA 3.2.1 analysis " << G4endl;
104# else
105 G4cout << G4endl << G4endl << G4endl
106 << " User Environment " << G4endl
107 << " G4ANALYSIS_USE environment variable not set, NO ANALYSIS "
108 << G4endl;
109#endif
110
111 BrachyRunAction *pRunAction = new BrachyRunAction();
112 pRunManager -> SetUserAction(pRunAction);
113
114 //Initialize G4 kernel
115 pRunManager -> Initialize();
116
117 return true;
118}
119void BrachySimulation::executeMacro(std::string macroFileName)
120{
121 G4UImanager* UI = G4UImanager::GetUIpointer();
122
123 // Batch mode
124
125 std::string fileName = macroFileName;
126 G4cout << fileName << " <---------- in batch -----------------" << G4endl;
127 G4cout << macroFileName << " executed"<<G4endl;
128
129 std::string command = "/control/execute ";
130
131 if(!UI)
132 G4cout << "FATAL ERROR: UI pointer does not exist" << G4endl;
133 else
134 UI -> ApplyCommand(command+fileName);
135}
136std::string BrachySimulation::getOutputFilename()
137{
138 return "brachytherapy.xml";
139}
140
141void BrachySimulation::finish()
142{
143 delete pRunManager;
144}
145
146//// This is all the application needs to run in parallel mode through DIANE
147extern "C"
148DIANE::IG4Simulation* createG4Simulation(int seed)
149{return new BrachySimulation(seed); }
150///////////
Note: See TracBrowser for help on using the repository browser.