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