Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
XrayFluoSimulation.cc
Go to the documentation of this file.
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: XrayFluoSimulation.cc
28 //
29 // Author: Elena Guardincerri
30 //
31 // History:
32 // -----------
33 // 28 Nov 2001 Elena Guardincerri Created
34 // 24 Ago 2002 Splitted in a separet class Alfonso Mantero
35 // 18 Jan 2011 adapted to new deexcitation design
36 //
37 // -------------------------------------------------------------------
38 
39 #ifdef G4MULTITHREADED
40 #include "G4MTRunManager.hh"
41 #else
42 #include "G4RunManager.hh"
43 #endif
44 
45 #include "G4UImanager.hh"
46 #include "Randomize.hh"
47 #ifdef G4VIS_USE
48 #include "G4VisExecutive.hh"
49 #endif
50 #ifdef G4UI_USE
51 #include "G4UIExecutive.hh"
52 #endif
56 #include "XrayFluoPhysicsList.hh"
57 #include "XrayFluoSimulation.hh"
58 
61 
62 
64 {;}
65 
66 
68 {;}
69 
70 void XrayFluoSimulation::RunSimulation(int argc,char* argv[])
71 {
72  // choose the Random engine
73  G4Random::setTheEngine(new CLHEP::RanecuEngine);
74  G4Random::setTheSeed(dir);
75 
76 #ifdef G4MULTITHREADED
77  // Construct the default run manager
78  G4MTRunManager* runManager = new G4MTRunManager();
79  G4cout << "Using the MT Run Manager (G4MULTITHREADED=ON)" << G4endl;
80 #else
81  G4RunManager * runManager = new G4RunManager;
82  G4cout << "Using the sequential Run Manager" << G4endl;
83 #endif
84 
85 
86  // chosing Geometry setup
87  G4int geometryNumber = 0;
88 
89  if (argc == 3){
90  geometryNumber = atoi(argv[2]);
91 
92  }
93  while ( (geometryNumber < 1) || (geometryNumber >4)) {
94  G4cout << "Please Select Simulation Geometrical Set-Up: "<< G4endl;
95  G4cout << "1 - Test Beam" << G4endl;
96  G4cout << "2 - Infinite Plane" << G4endl;
97  G4cout << "3 - Planet and Sun"<< G4endl;
98  G4cout << "4 - Phase-Space Production"<< G4endl;
99 
100  G4cin >> geometryNumber;
101  }
102 
103  // set analysis to have the messenger running...
104  XrayFluoAnalysisManager* analysis =
106 
107  // set mandatory initialization
108 
109  //Initialize geometry
110  if (geometryNumber == 1 || geometryNumber == 4) {
111  XrayFluoDetectorConstruction* testBeamDetector
113  if (geometryNumber == 4) {
114  testBeamDetector->PhaseSpaceOn();
115  analysis->PhaseSpaceOn();
116  }
117  runManager->SetUserInitialization(testBeamDetector);
118  }
119  else if (geometryNumber == 2) {
122  runManager->SetUserInitialization(planeDetector);
123  }
124  else if (geometryNumber == 3) {
125  XrayFluoMercuryDetectorConstruction* mercuryDetector =
127  runManager->SetUserInitialization(mercuryDetector);
128  }
129 
130 
131  //Initialize physics
132  runManager->SetUserInitialization(new XrayFluoPhysicsList());
133 
134  //Initialize actions
135  runManager->SetUserInitialization
136  (new XrayFluoActionInitializer(geometryNumber));
137 
138 #ifdef G4VIS_USE
139  //visualization manager
140  G4VisManager* visManager = new G4VisExecutive;
141  visManager->Initialize();
142 #endif
143 
144  // get the pointer to the User Interface manager
145  G4UImanager* UImanager = G4UImanager::GetUIpointer();
146 
147  if (getenv("G4VIS_USE")) {
148  UImanager->ApplyCommand("/control/execute vis.mac");
149  }
150 
151  if (argc == 1) // Define UI session for interactive mode.
152  {
153  UImanager->ApplyCommand("/control/execute initInter.mac");
154 #ifdef G4UI_USE
155  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
156  ui->SessionStart();
157  delete ui;
158 #endif
159  }
160  else // Batch mode
161  {
162  G4String command = "/control/execute ";
163  G4String fileName = argv[1];
164  UImanager->ApplyCommand(command+fileName);
165  }
166 
167  // job termination
168 #ifdef G4VIS_USE
169  delete visManager;
170  G4cout << "visManager deleted"<< G4endl;
171 #endif
172 
173 
174  delete runManager;
175 
176 
177 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
XrayFluoSimulation(G4int seed)
int G4int
Definition: G4Types.hh:78
static XrayFluoDetectorConstruction * GetInstance()
static XrayFluoMercuryDetectorConstruction * GetInstance()
static XrayFluoPlaneDetectorConstruction * GetInstance()
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
#define G4cin
Definition: G4ios.hh:60
G4GLOB_DLL std::ostream G4cout
long seed
Definition: chem4.cc:68
static XrayFluoAnalysisManager * getInstance()
void Initialize()
void RunSimulation(int argc, char *argv[])
#define G4endl
Definition: G4ios.hh:61
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447