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
DetectorConstruction.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file DetectorConstruction.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
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33
34
#include "DetectorConstruction.hh"
35
#include "DetectorMessenger.hh"
36
#include "
G4Material.hh
"
37
#include "
G4NistManager.hh
"
38
39
#include "
G4Box.hh
"
40
#include "
G4Sphere.hh
"
41
#include "
G4LogicalVolume.hh
"
42
#include "
G4PVPlacement.hh
"
43
44
#include "
G4GeometryManager.hh
"
45
#include "
G4PhysicalVolumeStore.hh
"
46
#include "
G4LogicalVolumeStore.hh
"
47
#include "
G4SolidStore.hh
"
48
#include "
G4RunManager.hh
"
49
50
#include "
G4UnitsTable.hh
"
51
#include "
G4SystemOfUnits.hh
"
52
#include "
G4PhysicalConstants.hh
"
53
54
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55
56
DetectorConstruction::DetectorConstruction
()
57
:
G4VUserDetectorConstruction
(),
58
fMaterial(0), fLAbsor(0), fWorldMat(0), fPWorld(0), fDetectorMessenger(0)
59
{
60
fRadius
= 30*
cm
;
61
fWorldSize
= 1.1*
fRadius
;
62
DefineMaterials
();
63
SetMaterial
(
"Water_ts"
);
64
fDetectorMessenger
=
new
DetectorMessenger
(
this
);
65
}
66
67
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68
69
DetectorConstruction::~DetectorConstruction
()
70
{
delete
fDetectorMessenger
;}
71
72
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73
74
G4VPhysicalVolume
*
DetectorConstruction::Construct
()
75
{
76
return
ConstructVolumes
();
77
}
78
79
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
80
81
void
DetectorConstruction::DefineMaterials
()
82
{
83
// specific element name for thermal neutronHP
84
// (see G4ParticleHPThermalScatteringNames.cc)
85
86
G4int
ncomponents, natoms;
87
88
// pressurized water
89
G4Element
*
H
=
new
G4Element
(
"TS_H_of_Water"
,
"H"
, 1., 1.0079*
g
/
mole
);
90
G4Element
* O =
new
G4Element
(
"Oxygen"
,
"O"
, 8., 16.00*
g
/
mole
);
91
G4Material
* H2O =
92
new
G4Material
(
"Water_ts"
, 1.000*
g
/
cm3
, ncomponents=2,
93
kStateLiquid
, 593*
kelvin
, 150*
bar
);
94
H2O->
AddElement
(H, natoms=2);
95
H2O->
AddElement
(O, natoms=1);
96
H2O->
GetIonisation
()->
SetMeanExcitationEnergy
(78.0*
eV
);
97
98
// heavy water
99
G4Isotope
* H2 =
new
G4Isotope
(
"H2"
,1,2);
100
G4Element
*
D
=
new
G4Element
(
"TS_D_of_Heavy_Water"
,
"D"
, 1);
101
D->
AddIsotope
(H2, 100*
perCent
);
102
G4Material
* D2O =
new
G4Material
(
"HeavyWater"
, 1.11*
g
/
cm3
, ncomponents=2,
103
kStateLiquid
, 293.15*
kelvin
, 1*
atmosphere
);
104
D2O->
AddElement
(D, natoms=2);
105
D2O->
AddElement
(O, natoms=1);
106
107
// graphite
108
G4Isotope
* C12 =
new
G4Isotope
(
"C12"
, 6, 12);
109
G4Element
*
C
=
new
G4Element
(
"TS_C_of_Graphite"
,
"C"
, ncomponents=1);
110
C->
AddIsotope
(C12, 100.*
perCent
);
111
G4Material
* graphite =
112
new
G4Material
(
"graphite"
, 2.27*
g
/
cm3
, ncomponents=1,
113
kStateSolid
, 293*
kelvin
, 1*
atmosphere
);
114
graphite->
AddElement
(C, natoms=1);
115
116
//NE213
117
G4Material
* ne213 =
118
new
G4Material
(
"NE213"
, 0.874*
g
/
cm3
, ncomponents=2);
119
ne213->
AddElement
(H, 9.2*
perCent
);
120
ne213->
AddElement
(C, 90.8*
perCent
);
121
122
// example of vacuum
123
fWorldMat
=
new
G4Material
(
"Galactic"
, 1, 1.01*
g
/
mole
,
universe_mean_density
,
124
kStateGas
, 2.73*
kelvin
, 3.
e
-18*
pascal
);
125
127
}
128
129
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
130
131
G4Material
*
DetectorConstruction::MaterialWithSingleIsotope
(
G4String
name
,
132
G4String
symbol,
G4double
density,
G4int
Z
,
G4int
A
)
133
{
134
// define a material from an isotope
135
//
136
G4int
ncomponents;
137
G4double
abundance, massfraction;
138
139
G4Isotope
* isotope =
new
G4Isotope
(symbol, Z, A);
140
141
G4Element
* element =
new
G4Element
(name, symbol, ncomponents=1);
142
element->
AddIsotope
(isotope, abundance= 100.*
perCent
);
143
144
G4Material
*
material
=
new
G4Material
(name, density, ncomponents=1);
145
material->
AddElement
(element, massfraction=100.*
perCent
);
146
147
return
material
;
148
}
149
150
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
151
152
G4VPhysicalVolume
*
DetectorConstruction::ConstructVolumes
()
153
{
154
// Cleanup old geometry
155
G4GeometryManager::GetInstance
()->
OpenGeometry
();
156
G4PhysicalVolumeStore::GetInstance
()->
Clean
();
157
G4LogicalVolumeStore::GetInstance
()->
Clean
();
158
G4SolidStore::GetInstance
()->
Clean
();
159
160
// World
161
//
162
G4Box
*
163
sWorld =
new
G4Box
(
"World"
,
//name
164
fWorldSize
,
fWorldSize
,
fWorldSize
);
//dimensions
165
166
G4LogicalVolume
*
167
lWorld =
new
G4LogicalVolume
(sWorld,
//shape
168
fWorldMat
,
//material
169
"World"
);
//name
170
171
fPWorld
=
new
G4PVPlacement
(0,
//no rotation
172
G4ThreeVector
(),
//at (0,0,0)
173
lWorld,
//logical volume
174
"World"
,
//name
175
0,
//mother volume
176
false
,
//no boolean operation
177
0);
//copy number
178
179
// Absorber
180
//
181
G4Sphere
*
182
sAbsor =
new
G4Sphere
(
"Absorber"
,
//name
183
0.,
fRadius
, 0.,
twopi
, 0.,
pi
);
//dimensions
184
185
fLAbsor
=
new
G4LogicalVolume
(sAbsor,
//shape
186
fMaterial
,
//material
187
fMaterial
->
GetName
());
//name
188
189
new
G4PVPlacement
(0,
//no rotation
190
G4ThreeVector
(),
//at (0,0,0)
191
fLAbsor
,
//logical volume
192
fMaterial
->
GetName
(),
//name
193
lWorld,
//mother volume
194
false
,
//no boolean operation
195
0);
//copy number
196
PrintParameters
();
197
198
//always return the root volume
199
//
200
return
fPWorld
;
201
}
202
203
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
204
205
void
DetectorConstruction::PrintParameters
()
206
{
207
G4cout
<<
"\n The Absorber is "
<<
G4BestUnit
(
fRadius
,
"Length"
)
208
<<
" of "
<<
fMaterial
->
GetName
()
209
<<
"\n \n"
<<
fMaterial
<<
G4endl
;
210
}
211
212
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
213
214
void
DetectorConstruction::SetMaterial
(
G4String
materialChoice)
215
{
216
// search the material by its name
217
G4Material
* pttoMaterial =
218
G4NistManager::Instance
()->
FindOrBuildMaterial
(materialChoice);
219
220
if
(pttoMaterial) {
221
fMaterial
= pttoMaterial;
222
if
(
fLAbsor
) {
fLAbsor
->
SetMaterial
(
fMaterial
); }
223
G4RunManager::GetRunManager
()->
PhysicsHasBeenModified
();
224
}
else
{
225
G4cout
<<
"\n--> warning from DetectorConstruction::SetMaterial : "
226
<< materialChoice <<
" not found"
<<
G4endl
;
227
}
228
}
229
230
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
231
232
void
DetectorConstruction::SetRadius
(
G4double
value
)
233
{
234
fRadius
=
value
;
235
G4RunManager::GetRunManager
()->
ReinitializeGeometry
();
236
}
237
238
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
239
geant4
tree
geant4-10.6-release
examples
extended
hadronic
Hadr06
src
DetectorConstruction.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:49
using
1.8.2 with
ECCE GitHub integration