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
#include "
G4Tubs.hh
"
40
#include "
G4LogicalVolume.hh
"
41
#include "
G4VPhysicalVolume.hh
"
42
#include "
G4PVPlacement.hh
"
43
44
#include "
G4GeometryManager.hh
"
45
#include "
G4PhysicalVolumeStore.hh
"
46
#include "
G4LogicalVolumeStore.hh
"
47
#include "
G4SolidStore.hh
"
48
49
#include "
G4UnitsTable.hh
"
50
#include "
G4PhysicalConstants.hh
"
51
#include "
G4SystemOfUnits.hh
"
52
53
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54
55
DetectorConstruction::DetectorConstruction
()
56
: fWall(nullptr), fCavity(nullptr)
57
{
58
// default parameter values
59
fCavityThickness
= 2*
mm
;
60
fCavityRadius
= 1*
cm
;
61
62
fWallThickness
= 5*
mm
;
63
64
DefineMaterials
();
65
SetWallMaterial
(
"G4_WATER"
);
66
SetCavityMaterial
(
"g4Water_gas"
);
67
68
// create commands for interactive definition of the detector
69
fDetectorMessenger
=
new
DetectorMessenger
(
this
);
70
}
71
72
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73
74
DetectorConstruction::~DetectorConstruction
()
75
{
76
delete
fDetectorMessenger
;
77
}
78
79
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
80
81
void
DetectorConstruction::DefineMaterials
()
82
{
83
G4double
z
,
a
;
84
85
G4Element
*
H
=
new
G4Element
(
"Hydrogen"
,
"H"
, z= 1., a= 1.01*
g
/
mole
);
86
G4Element
* O =
new
G4Element
(
"Oxygen"
,
"O"
, z= 8., a= 16.00*
g
/
mole
);
87
88
G4Material
* H2O =
89
new
G4Material
(
"Water"
, 1.0*
g
/
cm3
, 2);
90
H2O->
AddElement
(H, 2);
91
H2O->
AddElement
(O, 1);
92
H2O->
GetIonisation
()->
SetMeanExcitationEnergy
(78.0*
eV
);
93
94
G4Material
* gas =
95
new
G4Material
(
"Water_gas"
, 1.0*
mg
/
cm3
, 2);
96
gas->
AddElement
(H, 2);
97
gas->
AddElement
(O, 1);
98
gas->
GetIonisation
()->
SetMeanExcitationEnergy
(78.0*
eV
);
99
100
new
G4Material
(
"Graphite"
, 6, 12.01*
g
/
mole
, 2.265*
g
/
cm3
);
101
new
G4Material
(
"Graphite_gas"
, 6, 12.01*
g
/
mole
, 2.265*
mg
/
cm3
);
102
103
new
G4Material
(
"Aluminium"
, 13, 26.98*
g
/
mole
, 2.700*
g
/
cm3
);
104
new
G4Material
(
"Aluminium_gas"
, 13, 26.98*
g
/
mole
, 2.700*
mg
/
cm3
);
105
106
// alternatively, use G4 data base
107
//
108
G4NistManager
* nist =
G4NistManager::Instance
();
109
110
nist->
FindOrBuildMaterial
(
"G4_WATER"
);
111
nist->
BuildMaterialWithNewDensity
(
"g4Water_gas"
,
"G4_WATER"
, 1.0*
mg
/
cm3
);
112
113
// printout
114
G4cout
<< *(
G4Material::GetMaterialTable
()) <<
G4endl
;
115
}
116
117
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
118
119
G4VPhysicalVolume
*
DetectorConstruction::Construct
()
120
{
121
if
(
fWall
) {
return
fWall
; }
122
123
// Chamber
124
//
125
fTotalThickness
=
fCavityThickness
+ 2*
fWallThickness
;
126
fWallRadius
=
fCavityRadius
+
fWallThickness
;
127
128
G4Tubs
*
129
sChamber =
new
G4Tubs
(
"Chamber"
,
//name
130
0.,
fWallRadius
,0.5*
fTotalThickness
,0.,
twopi
);
//size
131
132
G4LogicalVolume
*
133
lChamber =
new
G4LogicalVolume
(sChamber,
//solid
134
fWallMaterial
,
//material
135
"Chamber"
);
//name
136
137
fWall
=
new
G4PVPlacement
(0,
//no rotation
138
G4ThreeVector
(),
//at (0,0,0)
139
lChamber,
//logical volume
140
"Wall"
,
//name
141
0,
//mother volume
142
false
,
//no boolean operation
143
0);
//copy number
144
145
// Cavity
146
//
147
G4Tubs
*
148
sCavity =
new
G4Tubs
(
"Cavity"
,
149
0.,
fCavityRadius
,0.5*
fCavityThickness
,0.,
twopi
);
150
151
G4LogicalVolume
*
152
lCavity =
new
G4LogicalVolume
(sCavity,
//shape
153
fCavityMaterial
,
//material
154
"Cavity"
);
//name
155
156
fCavity
=
new
G4PVPlacement
(0,
//no rotation
157
G4ThreeVector
(),
//at (0,0,0)
158
lCavity,
//logical volume
159
"Cavity"
,
//name
160
lChamber,
//mother volume
161
false
,
//no boolean operation
162
1);
//copy number
163
164
PrintParameters
();
165
166
//
167
//always return the root volume
168
//
169
return
fWall
;
170
}
171
172
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
173
174
void
DetectorConstruction::PrintParameters
()
175
{
176
G4cout
<<
"\n---------------------------------------------------------\n"
;
177
G4cout
<<
"---> The Wall is "
<<
G4BestUnit
(fWallThickness,
"Length"
)
178
<<
" of "
<<
fWallMaterial
->
GetName
() <<
" ( "
179
<<
G4BestUnit
(
fWallMaterial
->
GetDensity
(),
"Volumic Mass"
) <<
" )\n"
;
180
G4cout
<<
" The Cavity is "
<<
G4BestUnit
(
fCavityThickness
,
"Length"
)
181
<<
" of "
<<
fCavityMaterial
->
GetName
() <<
" ( "
182
<<
G4BestUnit
(
fCavityMaterial
->
GetDensity
(),
"Volumic Mass"
) <<
" )"
;
183
G4cout
<<
"\n---------------------------------------------------------\n"
;
184
G4cout <<
G4endl
;
185
}
186
187
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
188
189
void
DetectorConstruction::SetWallThickness
(
G4double
value
)
190
{
191
fWallThickness =
value
;
192
}
193
194
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
195
196
void
DetectorConstruction::SetWallMaterial
(
const
G4String
& materialChoice)
197
{
198
// search the material by its name
199
G4Material
* pttoMaterial =
G4Material::GetMaterial
(materialChoice);
200
if
(pttoMaterial)
fWallMaterial
= pttoMaterial;
201
}
202
203
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
204
205
void
DetectorConstruction::SetCavityThickness
(
G4double
value
)
206
{
207
fCavityThickness
=
value
;
208
}
209
210
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
211
212
void
DetectorConstruction::SetCavityRadius
(
G4double
value
)
213
{
214
fCavityRadius
=
value
;
215
}
216
217
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
218
219
void
DetectorConstruction::SetCavityMaterial
(
const
G4String
& materialChoice)
220
{
221
// search the material by its name
222
G4Material
* pttoMaterial =
G4Material::GetMaterial
(materialChoice);
223
if
(pttoMaterial)
fCavityMaterial
= pttoMaterial;
224
}
225
226
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
medical
fanoCavity
src
DetectorConstruction.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:49
using
1.8.2 with
ECCE GitHub integration