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
37
#include "
G4Material.hh
"
38
#include "
G4NistManager.hh
"
39
40
#include "
G4Tubs.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 "
G4SystemOfUnits.hh
"
51
#include "
G4PhysicalConstants.hh
"
52
#include "
G4UnitsTable.hh
"
53
54
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55
56
DetectorConstruction::DetectorConstruction
()
57
:
G4VUserDetectorConstruction
(),
58
fTargetMater(0), fLogicTarget(0),
59
fDetectorMater(0), fLogicDetector(0),
60
fWorldMater(0), fPhysiWorld(0),
61
fDetectorMessenger(0)
62
{
63
fTargetLength
= 1*
cm
;
64
fTargetRadius
= 0.5*
cm
;
65
fDetectorLength
= 5*
cm
;
66
fDetectorThickness
= 2*
cm
;
67
68
fWorldLength
=
std::max
(
fTargetLength
,
fDetectorLength
);
69
fWorldRadius
=
fTargetRadius
+
fDetectorThickness
;
70
71
DefineMaterials
();
72
73
fDetectorMessenger
=
new
DetectorMessenger
(
this
);
74
}
75
76
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
77
78
DetectorConstruction::~DetectorConstruction
()
79
{
delete
fDetectorMessenger
;}
80
81
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82
83
G4VPhysicalVolume
*
DetectorConstruction::Construct
()
84
{
85
return
ConstructVolumes
();
86
}
87
88
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
89
90
void
DetectorConstruction::DefineMaterials
()
91
{
92
// build materials
93
//
94
fDetectorMater
=
95
new
G4Material
(
"Germanium"
, 32, 72.61*
g
/
mole
, 5.323*
g
/
cm3
);
96
97
98
G4Element
*
N
=
new
G4Element
(
"Nitrogen"
,
"N"
, 7, 14.01*
g
/
mole
);
99
G4Element
* O =
new
G4Element
(
"Oxygen"
,
"O"
, 8, 16.00*
g
/
mole
);
100
//
101
G4int
ncomponents;
G4double
fractionmass;
102
G4Material
* Air20 =
new
G4Material
(
"Air"
, 1.205*
mg
/
cm3
, ncomponents=2,
103
kStateGas
, 293.*
kelvin
, 1.*
atmosphere
);
104
Air20->
AddElement
(N, fractionmass=0.7);
105
Air20->
AddElement
(O, fractionmass=0.3);
106
//
107
fWorldMater
= Air20;
108
109
// or use G4 materials data base
110
//
111
G4NistManager
* man =
G4NistManager::Instance
();
112
fTargetMater
= man->
FindOrBuildMaterial
(
"G4_CESIUM_IODIDE"
);
113
115
}
116
117
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
118
119
G4VPhysicalVolume
*
DetectorConstruction::ConstructVolumes
()
120
{
121
// Cleanup old geometry
122
G4GeometryManager::GetInstance
()->
OpenGeometry
();
123
G4PhysicalVolumeStore::GetInstance
()->
Clean
();
124
G4LogicalVolumeStore::GetInstance
()->
Clean
();
125
G4SolidStore::GetInstance
()->
Clean
();
126
127
// World
128
//
129
// (re) compute World dimensions if necessary
130
fWorldLength
=
std::max
(
fTargetLength
,
fDetectorLength
);
131
fWorldRadius
=
fTargetRadius
+
fDetectorThickness
;
132
133
G4Tubs
*
134
sWorld =
new
G4Tubs
(
"World"
,
//name
135
0.,
fWorldRadius
, 0.5*
fWorldLength
, 0.,
twopi
);
//dimensions
136
137
G4LogicalVolume
*
138
lWorld =
new
G4LogicalVolume
(sWorld,
//shape
139
fWorldMater
,
//material
140
"World"
);
//name
141
142
fPhysiWorld
=
new
G4PVPlacement
(0,
//no rotation
143
G4ThreeVector
(),
//at (0,0,0)
144
lWorld,
//logical volume
145
"World"
,
//name
146
0,
//mother volume
147
false
,
//no boolean operation
148
0);
//copy number
149
150
// Target
151
//
152
G4Tubs
*
153
sTarget =
new
G4Tubs
(
"Target"
,
//name
154
0.,
fTargetRadius
, 0.5*
fTargetLength
, 0.,
twopi
);
//dimensions
155
156
157
fLogicTarget
=
new
G4LogicalVolume
(sTarget,
//shape
158
fTargetMater
,
//material
159
"Target"
);
//name
160
161
new
G4PVPlacement
(0,
//no rotation
162
G4ThreeVector
(),
//at (0,0,0)
163
fLogicTarget
,
//logical volume
164
"Target"
,
//name
165
lWorld,
//mother volume
166
false
,
//no boolean operation
167
0);
//copy number
168
169
// Detector
170
//
171
G4Tubs
*
172
sDetector =
new
G4Tubs
(
"Detector"
,
173
fTargetRadius
,
fWorldRadius
, 0.5*
fDetectorLength
, 0.,
twopi
);
174
175
176
fLogicDetector
=
new
G4LogicalVolume
(sDetector,
//shape
177
fDetectorMater
,
//material
178
"Detector"
);
//name
179
180
new
G4PVPlacement
(0,
//no rotation
181
G4ThreeVector
(),
//at (0,0,0)
182
fLogicDetector
,
//logical volume
183
"Detector"
,
//name
184
lWorld,
//mother volume
185
false
,
//no boolean operation
186
0);
//copy number
187
188
189
PrintParameters
();
190
191
//always return the root volume
192
//
193
return
fPhysiWorld
;
194
}
195
196
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
197
198
void
DetectorConstruction::PrintParameters
()
199
{
200
G4cout
<<
"\n Target : Length = "
<<
G4BestUnit
(
fTargetLength
,
"Length"
)
201
<<
" Radius = "
<<
G4BestUnit
(
fTargetRadius
,
"Length"
)
202
<<
" Material = "
<<
fTargetMater
->
GetName
();
203
G4cout
<<
"\n Detector : Length = "
<<
G4BestUnit
(
fDetectorLength
,
"Length"
)
204
<<
" Tickness = "
<<
G4BestUnit
(fDetectorThickness,
"Length"
)
205
<<
" Material = "
<<
fDetectorMater
->
GetName
() <<
G4endl
;
206
G4cout
<<
"\n"
<<
fTargetMater
<<
"\n"
<<
fDetectorMater
<<
G4endl
;
207
}
208
209
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
210
211
void
DetectorConstruction::SetTargetMaterial
(
G4String
materialChoice)
212
{
213
// search the material by its name
214
G4Material
* pttoMaterial =
215
G4NistManager::Instance
()->
FindOrBuildMaterial
(materialChoice);
216
217
if
(pttoMaterial) {
218
fTargetMater
= pttoMaterial;
219
if
(
fLogicTarget
) {
fLogicTarget
->
SetMaterial
(
fTargetMater
); }
220
G4RunManager::GetRunManager
()->
PhysicsHasBeenModified
();
221
}
else
{
222
G4cout
<<
"\n--> warning from DetectorConstruction::SetTargetMaterial : "
223
<< materialChoice <<
" not found"
<<
G4endl
;
224
}
225
}
226
227
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
228
229
void
DetectorConstruction::SetDetectorMaterial
(
G4String
materialChoice)
230
{
231
// search the material by its name
232
G4Material
* pttoMaterial =
233
G4NistManager::Instance
()->
FindOrBuildMaterial
(materialChoice);
234
235
if
(pttoMaterial) {
236
fDetectorMater
= pttoMaterial;
237
if
(
fLogicDetector
) {
fLogicDetector
->
SetMaterial
(
fDetectorMater
); }
238
G4RunManager::GetRunManager
()->
PhysicsHasBeenModified
();
239
}
else
{
240
G4cout
<<
"\n--> warning from DetectorConstruction::SetDetectorMaterial : "
241
<< materialChoice <<
" not found"
<<
G4endl
;
242
}
243
}
244
245
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
246
247
void
DetectorConstruction::SetTargetRadius
(
G4double
value
)
248
{
249
fTargetRadius
=
value
;
250
G4RunManager::GetRunManager
()->
ReinitializeGeometry
();
251
}
252
253
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
254
255
void
DetectorConstruction::SetTargetLength
(
G4double
value)
256
{
257
fTargetLength
=
value
;
258
G4RunManager::GetRunManager
()->
ReinitializeGeometry
();
259
}
260
261
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
262
263
void
DetectorConstruction::SetDetectorThickness
(
G4double
value)
264
{
265
fDetectorThickness =
value
;
266
G4RunManager::GetRunManager
()->
ReinitializeGeometry
();
267
}
268
269
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
270
271
void
DetectorConstruction::SetDetectorLength
(
G4double
value)
272
{
273
fDetectorLength
=
value
;
274
G4RunManager::GetRunManager
()->
ReinitializeGeometry
();
275
}
276
277
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
278
279
G4double
DetectorConstruction::GetTargetLength
()
280
{
281
return
fTargetLength
;
282
}
283
284
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
285
286
G4double
DetectorConstruction::GetTargetRadius
()
287
{
288
return
fTargetRadius
;
289
}
290
291
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
292
293
G4Material
*
DetectorConstruction::GetTargetMaterial
()
294
{
295
return
fTargetMater
;
296
}
297
298
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
299
300
G4LogicalVolume
*
DetectorConstruction::GetLogicTarget
()
301
{
302
return
fLogicTarget
;
303
}
304
305
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
306
307
G4double
DetectorConstruction::GetDetectorLength
()
308
{
309
return
fDetectorLength
;
310
}
311
312
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
313
314
G4double
DetectorConstruction::GetDetectorThickness
()
315
{
316
return
fDetectorThickness
;
317
}
318
319
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
320
321
G4Material
*
DetectorConstruction::GetDetectorMaterial
()
322
{
323
return
fDetectorMater
;
324
}
325
326
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
327
328
G4LogicalVolume
*
DetectorConstruction::GetLogicDetector
()
329
{
330
return
fLogicDetector
;
331
}
332
333
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
radioactivedecay
rdecay02
src
DetectorConstruction.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:49
using
1.8.2 with
ECCE GitHub integration