Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
XrayFluoSimulation Class Reference

#include <XrayFluoSimulation.hh>

Public Member Functions

 XrayFluoSimulation (G4int seed)
 
 ~XrayFluoSimulation ()
 
void RunSimulation (int argc, char *argv[])
 

Detailed Description

Definition at line 40 of file XrayFluoSimulation.hh.

Constructor & Destructor Documentation

XrayFluoSimulation::XrayFluoSimulation ( G4int  seed)

Definition at line 64 of file XrayFluoSimulation.cc.

64  :dir(seed)
65 
66 { }
XrayFluoSimulation::~XrayFluoSimulation ( )

Definition at line 68 of file XrayFluoSimulation.cc.

70 { }

Member Function Documentation

void XrayFluoSimulation::RunSimulation ( int  argc,
char *  argv[] 
)

Definition at line 72 of file XrayFluoSimulation.cc.

References G4UImanager::ApplyCommand(), G4cin, G4cout, G4endl, XrayFluoPlaneDetectorConstruction::GetInstance(), XrayFluoMercuryDetectorConstruction::GetInstance(), XrayFluoDetectorConstruction::GetInstance(), G4UImanager::GetUIpointer(), G4VisManager::Initialize(), G4UIExecutive::IsGUI(), XrayFluoDetectorConstruction::PhaseSpaceOn(), G4UIExecutive::SessionStart(), G4VSteppingVerbose::SetInstance(), XrayFluoSteppingAction::SetMercuryFlag(), CLHEP::HepRandom::setTheEngine(), CLHEP::HepRandom::setTheSeed(), G4RunManager::SetUserAction(), and G4RunManager::SetUserInitialization().

Referenced by main().

73 {
74 
75  // choose the Random engine
78 
79  //XrayFluo Verbose output class
81 
82  // Construct the default run manager
83  G4RunManager * runManager = new G4RunManager;
84 
85  // set mandatory initialization
86 
87  XrayFluoPhysicsList* xrayList = new XrayFluoPhysicsList();
88 
89  // chosing Geometry setup
90 
91  G4int geometryNumber = 0;
92 
93  if (argc == 3){
94  geometryNumber = atoi(argv[2]);
95 
96  }
97  while ( (geometryNumber != 1) && (geometryNumber !=2) && (geometryNumber !=3) && (geometryNumber !=4)) {
98  G4cout << "Please Select Simulation Geometrical Set-Up: "<< G4endl;
99  G4cout << "1 - Test Beam" << G4endl;
100  G4cout << "2 - Infinite Plane" << G4endl;
101  G4cout << "3 - Planet and Sun"<< G4endl;
102  G4cout << "4 - Phase-Space Production"<< G4endl;
103 
104 
105  G4cin >> geometryNumber;
106  }
107 
108  XrayFluoDetectorConstruction* testBeamDetector = 0;
109  XrayFluoPlaneDetectorConstruction* planeDetector = 0;
110  XrayFluoMercuryDetectorConstruction* mercuryDetector = 0;
111 
112 
113 
114  if (geometryNumber == 1 || geometryNumber == 4) {
115  testBeamDetector = XrayFluoDetectorConstruction::GetInstance();
116  if (geometryNumber == 4) {
117  testBeamDetector->PhaseSpaceOn();
118  }
119  runManager->SetUserInitialization(testBeamDetector);
120  }
121  else if (geometryNumber == 2) {
123  runManager->SetUserInitialization(planeDetector);
124  }
125  else if (geometryNumber == 3) {
127  runManager->SetUserInitialization(mercuryDetector);
128  }
129 
130 
131  runManager->SetUserInitialization(xrayList);
132 
133 #ifdef G4VIS_USE
134  //visualization manager
135  G4VisManager* visManager = new G4VisExecutive;
136  visManager->Initialize();
137 #endif
138 
139 #ifdef G4ANALYSIS_USE
140  // set analysis to have the messenger running...
141  XrayFluoAnalysisManager* analysis = XrayFluoAnalysisManager::getInstance();
142 #endif
143  XrayFluoEventAction* eventAction = 0;
144  XrayFluoRunAction* runAction = new XrayFluoRunAction();
146 
147 
148  //Selecting the PrimaryGenerator depending upon Geometry setup selected
149 
150  if (geometryNumber == 1 || geometryNumber == 4) {
151  if (geometryNumber == 4) {
152 #ifdef G4ANALYSIS_USE
153  analysis->PhaseSpaceOn();
154  analysis->CreatePersistency();
155 #endif
156  }
157  eventAction = new XrayFluoEventAction(testBeamDetector);
158  runManager->SetUserAction(new XrayFluoPrimaryGeneratorAction(testBeamDetector));
159  }
160 
161  else if (geometryNumber == 2) {
162  eventAction = new XrayFluoEventAction(planeDetector);
163  runManager->SetUserAction(new XrayFluoPlanePrimaryGeneratorAction(planeDetector));
164  }
165 
166  else if (geometryNumber == 3) {
167  stepAction->SetMercuryFlag(true);
168  eventAction = new XrayFluoEventAction(mercuryDetector);
169  runManager->SetUserAction(new XrayFluoMercuryPrimaryGeneratorAction(mercuryDetector));
170  }
171 
172  runManager->SetUserAction(eventAction);
173  runManager->SetUserAction(runAction);
174  runManager->SetUserAction(stepAction);
175 
176  //Initialize G4 kernel
177  //runManager->Initialize();
178 
179  // get the pointer to the User Interface manager
180  G4UImanager* UImanager = G4UImanager::GetUIpointer();
181 
182  if (getenv("G4VIS_USE")) {
183  UImanager->ApplyCommand("/control/execute vis.mac");
184  }
185 
186  if (argc == 1) // Define UI session for interactive mode.
187  {
188  UImanager->ApplyCommand("/control/execute initInter.mac");
189 #ifdef G4UI_USE
190  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
191 
192  if (ui->IsGUI())
193  UImanager->ApplyCommand("/control/execute gui.mac");
194  ui->SessionStart();
195  delete ui;
196 #endif
197  }
198  else // Batch mode
199  {
200  G4String command = "/control/execute ";
201  G4String fileName = argv[1];
202  UImanager->ApplyCommand(command+fileName);
203  }
204 
205  // job termination
206 
207 #ifdef G4VIS_USE
208  delete visManager;
209  G4cout << "visManager deleted"<< G4endl;
210 #endif
211 
212 // if (testBeamDetector) delete testBeamDetector;
213 // if (planeDetector) delete planeDetector;
214 // if (mercuryDetector) delete mercuryDetector;
215 
216 
217  delete runManager;
218 
219 
220 
221 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
int G4int
Definition: G4Types.hh:78
static XrayFluoDetectorConstruction * GetInstance()
static XrayFluoMercuryDetectorConstruction * GetInstance()
static XrayFluoPlaneDetectorConstruction * GetInstance()
static void setTheSeed(long seed, int lux=3)
Definition: Random.cc:131
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
#define G4cin
Definition: G4ios.hh:60
G4GLOB_DLL std::ostream G4cout
void Initialize()
static void SetInstance(G4VSteppingVerbose *Instance)
#define G4endl
Definition: G4ios.hh:61
static void setTheEngine(HepRandomEngine *theNewEngine)
Definition: Random.cc:170
G4bool IsGUI() const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419
virtual void SetUserAction(G4UserRunAction *userAction)

The documentation for this class was generated from the following files: