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
//
31
//
32
// DetectorConstruction
33
//
34
// Created: 31.01.2003 V.Ivanchenko
35
//
36
// Modified:
37
// 04.06.2006 Adoptation of Hadr01 (V.Ivanchenko)
38
//
40
//
41
42
#include "DetectorConstruction.hh"
43
#include "DetectorMessenger.hh"
44
45
#include "
G4Tubs.hh
"
46
#include "
G4LogicalVolume.hh
"
47
#include "
G4PVPlacement.hh
"
48
49
#include "
G4RunManager.hh
"
50
51
#include "
G4GeometryManager.hh
"
52
#include "
G4PhysicalVolumeStore.hh
"
53
#include "
G4LogicalVolumeStore.hh
"
54
#include "
G4SolidStore.hh
"
55
56
#include "
G4VisAttributes.hh
"
57
#include "
G4Colour.hh
"
58
59
#include "
G4UnitsTable.hh
"
60
#include "
G4ios.hh
"
61
62
#include "TargetSD.hh"
63
#include "CheckVolumeSD.hh"
64
#include "
G4SDManager.hh
"
65
#include "HistoManager.hh"
66
#include "
G4NistManager.hh
"
67
68
#include "
G4PhysicalConstants.hh
"
69
#include "
G4SystemOfUnits.hh
"
70
71
72
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73
74
DetectorConstruction::DetectorConstruction
()
75
:
G4VUserDetectorConstruction
(),
76
fTargetMaterial(nullptr),
77
fWorldMaterial(nullptr),
78
fSolidW(nullptr),
79
fSolidA(nullptr),
80
fSolidC(nullptr),
81
fLogicTarget(nullptr),
82
fLogicCheck(nullptr),
83
fLogicWorld(nullptr),
84
fPhysWorld(nullptr),
85
fInitialized(
false
)
86
{
87
fDetectorMessenger
=
new
DetectorMessenger
(
this
);
88
89
fRadius
= 10.*
cm
;
90
91
G4NistManager
* nist =
G4NistManager::Instance
();
92
fTargetMaterial
= nist->
FindOrBuildMaterial
(
"G4_Al"
);
93
fWorldMaterial
= nist->
FindOrBuildMaterial
(
"G4_Galactic"
);
94
95
//
96
// define battery material using Bugzilla 2175 data
97
//
98
G4Element
* elH = nist->
FindOrBuildElement
(1);
99
G4Element
* elLi = nist->
FindOrBuildElement
(3);
100
G4Element
* elC = nist->
FindOrBuildElement
(6);
101
G4Element
* elO = nist->
FindOrBuildElement
(8);
102
G4Element
* elAl = nist->
FindOrBuildElement
(13);
103
G4Element
* elTi = nist->
FindOrBuildElement
(22);
104
G4Element
* elCo = nist->
FindOrBuildElement
(27);
105
G4Element
* elCu = nist->
FindOrBuildElement
(29);
106
G4Material
* bat =
new
G4Material
(
"Battery"
,2.165*
CLHEP::g
/
CLHEP::cm3
,8);
107
bat->
AddElement
(elC, 0.19518445618745);
108
bat->
AddElement
(elAl, 0.398);
109
bat->
AddElement
(elTi, 0.02);
110
bat->
AddElement
(elCu, 0.084);
111
bat->
AddElement
(elLi, 0.0170098229419813);
112
bat->
AddElement
(elCo, 0.144570016541753);
113
bat->
AddElement
(elO, 0.134206611504321);
114
bat->
AddElement
(elH, 0.0070290928244947);
115
bat->
GetIonisation
()->
SetMeanExcitationEnergy
(144.88*
eV
);
116
117
ComputeGeomParameters
();
118
}
119
120
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121
122
DetectorConstruction::~DetectorConstruction
()
123
{
124
delete
fDetectorMessenger
;
125
}
126
127
void
DetectorConstruction::ComputeGeomParameters
()
128
{
129
// Sizes
130
fCheckR
=
fRadius
+
CLHEP::mm
;
131
fWorldR
=
fRadius
+
CLHEP::cm
;
132
fTargetZ
=
HistoManager::GetPointer
()->
Length
()*0.5;
133
fCheckZ
=
fTargetZ
+
CLHEP::mm
;
134
fWorldZ
=
fTargetZ
+
CLHEP::cm
;
135
136
fSlices
=
HistoManager::GetPointer
()->
NumberOfSlices
();
137
fSliceZ
=
fTargetZ
/
G4double
(
fSlices
);
138
if
(
fPhysWorld
) {
139
fSolidW
->
SetOuterRadius
(
fWorldR
);
140
fSolidW
->
SetZHalfLength
(
fWorldZ
);
141
fSolidA
->
SetOuterRadius
(
fRadius
);
142
fSolidA
->
SetZHalfLength
(
fSliceZ
);
143
fSolidC
->
SetOuterRadius
(
fCheckR
);
144
fSolidC
->
SetZHalfLength
(
fCheckZ
);
145
}
146
}
147
148
G4VPhysicalVolume
*
DetectorConstruction::Construct
()
149
{
150
if
(
fPhysWorld
) {
return
fPhysWorld
; }
151
ComputeGeomParameters
();
152
153
//
154
// World
155
//
156
fSolidW
=
new
G4Tubs
(
"World"
,0.,
fWorldR
,
fWorldZ
,0.,
twopi
);
157
fLogicWorld
=
new
G4LogicalVolume
(
fSolidW
,
fWorldMaterial
,
"World"
);
158
fPhysWorld
=
new
G4PVPlacement
(
nullptr
,
G4ThreeVector
(0.,0.,0.),
159
fLogicWorld
,
"World"
,
nullptr
,
false
,0);
160
//
161
// Check volume
162
//
163
fSolidC
=
new
G4Tubs
(
"Check"
,0.,
fCheckR
,
fCheckZ
,0.,
twopi
);
164
fLogicCheck
=
new
G4LogicalVolume
(
fSolidC
,
fWorldMaterial
,
"Check"
);
165
new
G4PVPlacement
(
nullptr
,
G4ThreeVector
(),
fLogicCheck
,
"Check"
,
166
fLogicWorld
,
false
,0);
167
168
//
169
// Target volume
170
//
171
fSolidA
=
new
G4Tubs
(
"Target"
,0.,
fRadius
,
fSliceZ
,0.,
twopi
);
172
fLogicTarget
=
new
G4LogicalVolume
(
fSolidA
,
fTargetMaterial
,
"Target"
);
173
174
G4double
z
=
fSliceZ
-
fTargetZ
;
175
176
for
(
G4int
i=0; i<
fSlices
; ++i) {
177
// physC =
178
new
G4PVPlacement
(
nullptr
,
G4ThreeVector
(0.0,0.0,z),
fLogicTarget
,
"Target"
,
179
fLogicCheck
,
false
,i);
180
z += 2.0*
fSliceZ
;
181
}
182
G4cout
<<
"### Target consist of "
<< fSlices
183
<<
" disks of "
<<
fTargetMaterial
->
GetName
()
184
<<
" with R(mm)= "
<<
fRadius
/
mm
185
<<
" Width(mm)= "
<< 2.0*
fSliceZ
/
mm
186
<<
" Total Length(mm)= "
<< 2.0*fTargetZ/
mm
187
<<
" ###"
<<
G4endl
;
188
189
// colors
190
G4VisAttributes
zero
=
G4VisAttributes::GetInvisible
();
191
fLogicWorld
->
SetVisAttributes
(zero);
192
193
G4VisAttributes
regWcolor(
G4Colour
(0.3, 0.3, 0.3));
194
fLogicCheck
->
SetVisAttributes
(regWcolor);
195
196
G4VisAttributes
regCcolor(
G4Colour
(0., 0.3, 0.7));
197
fLogicTarget
->
SetVisAttributes
(regCcolor);
198
199
G4cout
<< *(
G4Material::GetMaterialTable
()) << G4endl;
200
201
return
fPhysWorld
;
202
}
203
204
void
DetectorConstruction::ConstructSDandField
()
205
{
206
if
(!
fInitialized
) {
207
// Prepare sensitive detectors
208
CheckVolumeSD
* fCheckSD =
new
CheckVolumeSD
(
"checkSD"
);
209
(
G4SDManager::GetSDMpointer
())->AddNewDetector( fCheckSD );
210
fLogicCheck
->
SetSensitiveDetector
(fCheckSD);
211
212
TargetSD
*
fTargetSD
=
new
TargetSD
(
"targetSD"
);
213
(
G4SDManager::GetSDMpointer
())->AddNewDetector( fTargetSD );
214
fLogicTarget
->
SetSensitiveDetector
(fTargetSD);
215
fInitialized
=
true
;
216
}
217
}
218
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
219
220
void
DetectorConstruction::SetTargetMaterial
(
const
G4String
&
mat
)
221
{
222
// search the material by its name
223
G4Material
*
material
=
G4NistManager::Instance
()->
FindOrBuildMaterial
(mat);
224
225
if
(material && material !=
fTargetMaterial
) {
226
fTargetMaterial
=
material
;
227
if
(
fLogicTarget
) {
fLogicTarget
->
SetMaterial
(
fTargetMaterial
); }
228
G4RunManager::GetRunManager
()->
PhysicsHasBeenModified
();
229
}
230
}
231
232
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
233
234
void
DetectorConstruction::SetWorldMaterial
(
const
G4String
& mat)
235
{
236
// search the material by its name
237
G4Material
* material =
G4NistManager::Instance
()->
FindOrBuildMaterial
(mat);
238
239
if
(material && material !=
fWorldMaterial
) {
240
fWorldMaterial
=
material
;
241
if
(
fLogicWorld
) {
fLogicWorld
->
SetMaterial
(
fWorldMaterial
); }
242
G4RunManager::GetRunManager
()->
PhysicsHasBeenModified
();
243
}
244
}
245
246
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
247
248
void
DetectorConstruction::SetTargetRadius
(
G4double
val)
249
{
250
if
(val > 0.0) {
251
fRadius
= val;
252
ComputeGeomParameters
();
253
}
254
}
255
256
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
hadronic
Hadr01
src
DetectorConstruction.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:49
using
1.8.2 with
ECCE GitHub integration