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