ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
Hadr01.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file Hadr01.cc
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
//
31
// -------------------------------------------------------------
32
// GEANT4 Hadr01
33
//
34
// Application demonstrating Geant4 hadronic physics:
35
// beam interaction with a target
36
//
37
// Authors: A.Bagulya, I.Gudowska, V.Ivanchenko, N.Starkov
38
//
39
// Modified:
40
// 29.12.2009 V.Ivanchenko introduced access to reference PhysLists
41
//
42
// -------------------------------------------------------------
43
//
44
//
45
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47
48
#include "
G4RunManager.hh
"
49
#include "
G4UImanager.hh
"
50
#include "
Randomize.hh
"
51
52
#include "DetectorConstruction.hh"
53
#include "PhysicsList.hh"
54
#include "
G4PhysListFactory.hh
"
55
#include "
G4VModularPhysicsList.hh
"
56
#include "PrimaryGeneratorAction.hh"
57
#include "PhysicsListMessenger.hh"
58
59
#include "RunAction.hh"
60
#include "EventAction.hh"
61
#include "StackingAction.hh"
62
63
#include "
G4UIExecutive.hh
"
64
#include "
G4VisExecutive.hh
"
65
66
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
67
68
int
main
(
int
argc,
char
** argv) {
69
70
//detect interactive mode (if no arguments) and define UI session
71
G4UIExecutive
* ui =
nullptr
;
72
if
(argc == 1) { ui =
new
G4UIExecutive
(argc,argv); }
73
74
//Construct the default run manager
75
G4RunManager
* runManager =
new
G4RunManager
();
76
77
//set mandatory initialization classes
78
runManager->
SetUserInitialization
(
new
DetectorConstruction
());
79
80
G4PhysListFactory
factory;
81
G4VModularPhysicsList
* phys =
nullptr
;
82
PhysicsListMessenger
* mess =
nullptr
;
83
G4String
physName =
""
;
84
85
//Physics List name defined via 3nd argument
86
if
(argc==3) { physName = argv[2]; }
87
88
// Physics List name defined via environment variable
89
if
(
""
== physName) {
90
char
* path = std::getenv(
"PHYSLIST"
);
91
if
(path) { physName =
G4String
(path); }
92
}
93
94
//reference PhysicsList via its name
95
if
(
""
!= physName && factory.
IsReferencePhysList
(physName)) {
96
phys = factory.
GetReferencePhysList
(physName);
97
98
// instantiated messenger
99
mess =
new
PhysicsListMessenger
();
100
}
101
102
//local Physics List
103
if
(!phys) { phys =
new
PhysicsList
(); }
104
105
// define physics
106
runManager->
SetUserInitialization
(phys);
107
runManager->
SetUserAction
(
new
PrimaryGeneratorAction
());
108
109
//set user action classes
110
runManager->
SetUserAction
(
new
RunAction
());
111
runManager->
SetUserAction
(
new
EventAction
());
112
runManager->
SetUserAction
(
new
StackingAction
());
113
114
//initialize visualization
115
G4VisManager
* visManager =
nullptr
;
116
117
//get the pointer to the User Interface manager
118
G4UImanager
* UImanager =
G4UImanager::GetUIpointer
();
119
120
if
(ui) {
121
//interactive mode
122
visManager =
new
G4VisExecutive
;
123
visManager->
Initialize
();
124
ui->
SessionStart
();
125
delete
ui;
126
}
else
{
127
//batch mode
128
G4String
command =
"/control/execute "
;
129
G4String
fileName = argv[1];
130
UImanager->
ApplyCommand
(command+fileName);
131
}
132
133
//job termination
134
delete
mess;
135
delete
visManager;
136
delete
runManager;
137
}
138
139
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
hadronic
Hadr01
Hadr01.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:05
using
1.8.2 with
ECCE GitHub integration