Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
examples
extended
medical
electronScattering2
electronScattering2.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
//
28
//
29
30
#include "
G4RunManager.hh
"
31
#include "
Randomize.hh
"
32
#include "
G4ScoringManager.hh
"
33
34
#ifdef G4VIS_USE
35
#include "
G4VisExecutive.hh
"
36
#endif
37
38
#include "
G4UImanager.hh
"
39
#ifdef G4UI_USE
40
#include "
G4UIExecutive.hh
"
41
#endif
42
43
#include "
ElectronBenchmarkDetector.hh
"
44
#include "PhysicsList.hh"
45
#include "
ElectronPrimaryGeneratorAction.hh
"
46
#include "
ElectronRunAction.hh
"
47
#include "
ElectronEventAction.hh
"
48
49
int
main
(
int
argc,
char
** argv) {
50
51
// Parse the arguments
52
G4String
outputFile =
"output.csv"
;
53
G4String
startingSeed =
"1"
;
54
G4String
macroFile =
"None"
;
55
if
(argc > 1) macroFile = argv[1];
56
if
(argc > 2) startingSeed = argv[2];
57
if
(argc > 3) outputFile = argv[3];
58
G4cout
<<
"Starting run with"
<<
G4endl
;
59
G4cout
<<
"Macro File : "
<< macroFile <<
G4endl
;
60
G4cout
<<
"Starting Seed : "
<< startingSeed <<
G4endl
;
61
G4cout
<<
"Output File : "
<< outputFile <<
G4endl
;
62
63
// Instantiate the run manager
64
G4RunManager
* runManager =
new
G4RunManager
;
65
66
// Instantiate the random engine
67
CLHEP::HepRandom::setTheEngine
(
new
CLHEP::MTwistEngine
);
68
69
// Convert the starting seed to integer and feed it to the random engine
70
unsigned
startingSeedInt;
71
std::istringstream is(startingSeed);
72
is >> startingSeedInt;
73
CLHEP::HepRandom::setTheSeed
(startingSeedInt);
74
75
// Instantiate the scoring manager
76
G4ScoringManager::GetScoringManager
();
77
78
// Instantiate the geometry
79
runManager->
SetUserInitialization
(
new
ElectronBenchmarkDetector
);
80
81
// Instantiate the physics list (in turn calls one of four choices of physics list)
82
runManager->
SetUserInitialization
(
new
PhysicsList
);
83
84
// Instantiate the primary generator action (in turn uses the G4GeneralParticleSource)
85
runManager->
SetUserAction
(
new
ElectronPrimaryGeneratorAction
);
86
87
// Instantiate the run action (in turn instantiates ElectronRun, which accumulates and dumps data)
88
runManager->
SetUserAction
(
new
ElectronRunAction
(outputFile));
89
90
// Instantiate the event action (just adds code to periodically report how many events are done)
91
runManager->
SetUserAction
(
new
ElectronEventAction
);
92
93
// Instantiate the visualization System
94
#ifdef G4VIS_USE
95
G4VisManager
* visManager =
new
G4VisExecutive
;
96
visManager->
Initialize
();
97
#endif
98
99
if
(argc == 1)
100
{
101
// Since no macro was specified, instantiate an interactive session
102
// (exact session type depends on user preference expressed in environment variables).
103
#ifdef G4UI_USE
104
G4UIExecutive
* ui =
new
G4UIExecutive
(argc, argv);
105
ui->
SessionStart
();
106
delete
ui;
107
#endif
108
}
109
else
110
{
111
// A macro was specified. Execute it.
112
G4UImanager
* UImanager =
G4UImanager::GetUIpointer
();
113
G4String
command =
"/control/execute "
;
114
UImanager->
ApplyCommand
(command+macroFile);
115
}
116
117
#ifdef G4VIS_USE
118
delete
visManager;
119
#endif
120
delete
runManager;
121
122
return
0;
123
}
Generated on Sat May 25 2013 14:32:57 for Geant4 by
1.8.4