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: 20.06.2008 V.Ivanchenko
35
//
36
// Modified:
37
//
39
//
40
41
#include "DetectorConstruction.hh"
42
#include "DetectorMessenger.hh"
43
44
#include "
G4Tubs.hh
"
45
#include "
G4LogicalVolume.hh
"
46
#include "
G4PVPlacement.hh
"
47
48
#include "
G4RunManager.hh
"
49
50
#include "
G4GeometryManager.hh
"
51
#include "
G4PhysicalVolumeStore.hh
"
52
#include "
G4LogicalVolumeStore.hh
"
53
#include "
G4SolidStore.hh
"
54
55
#include "
G4VisAttributes.hh
"
56
#include "
G4Colour.hh
"
57
58
#include "
G4UnitsTable.hh
"
59
#include "
G4ios.hh
"
60
61
#include "
G4NistManager.hh
"
62
63
#include "
G4PhysicalConstants.hh
"
64
#include "
G4SystemOfUnits.hh
"
65
66
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
67
68
DetectorConstruction::DetectorConstruction
()
69
:
G4VUserDetectorConstruction
(),
70
fTargetMaterial(nullptr), fWorldMaterial(nullptr),
71
fSolidW(nullptr), fSolidA(nullptr),
72
fLogicTarget(nullptr), fLogicWorld(nullptr),
73
fPhysWorld(nullptr), fPhysList(nullptr)
74
{
75
fDetectorMessenger
=
new
DetectorMessenger
(
this
);
76
77
fRadius
= 5.*
cm
;
78
fLength
= 10.*
cm
;
79
80
fTargetMaterial
=
G4NistManager::Instance
()->
FindOrBuildMaterial
(
"G4_Al"
);
81
fWorldMaterial
=
82
G4NistManager::Instance
()->
FindOrBuildMaterial
(
"G4_Galactic"
);
83
84
ComputeGeomParameters
();
85
}
86
87
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
88
89
DetectorConstruction::~DetectorConstruction
()
90
{
91
delete
fDetectorMessenger
;
92
}
93
94
void
DetectorConstruction::ComputeGeomParameters
()
95
{
96
// Sizes
97
fWorldR
=
fRadius
+
CLHEP::cm
;
98
fWorldZ
=
fLength
+
CLHEP::cm
;
99
if
(
fPhysWorld
) {
100
fSolidW
->
SetOuterRadius
(
fWorldR
);
101
fSolidW
->
SetZHalfLength
(
fWorldZ
*0.5);
102
fSolidA
->
SetOuterRadius
(
fRadius
);
103
fSolidA
->
SetZHalfLength
(
fLength
*0.5);
104
}
105
}
106
107
G4VPhysicalVolume
*
DetectorConstruction::Construct
()
108
{
109
if
(
fPhysWorld
) {
return
fPhysWorld
; }
110
ComputeGeomParameters
();
111
112
//
113
// World
114
//
115
fSolidW
=
new
G4Tubs
(
"World"
, 0.,
fWorldR
, 0.5*
fWorldZ
, 0.,
twopi
);
116
fLogicWorld
=
new
G4LogicalVolume
(
fSolidW
,
fWorldMaterial
,
"World"
);
117
fPhysWorld
=
new
G4PVPlacement
(
nullptr
,
G4ThreeVector
(0.,0.,0.),
118
fLogicWorld
,
"World"
,
119
nullptr
,
false
, 0);
120
121
//
122
// Target volume
123
//
124
fSolidA
=
new
G4Tubs
(
"Target"
, 0.,
fRadius
, 0.5*
fLength
, 0.,
twopi
);
125
fLogicTarget
=
new
G4LogicalVolume
(
fSolidA
,
fTargetMaterial
,
"Target"
);
126
new
G4PVPlacement
(
nullptr
,
G4ThreeVector
(),
fLogicTarget
,
"Target"
,
127
fLogicWorld
,
false
, 0);
128
129
G4cout
<<
"### Target consist of "
130
<<
fTargetMaterial
->
GetName
()
131
<<
" disks with R(mm)= "
<<
fRadius
/
mm
132
<<
" fLength(mm)= "
<<
fLength
/
mm
133
<<
" ###"
<<
G4endl
;
134
135
// colors
136
fLogicWorld
->
SetVisAttributes
(
G4VisAttributes::GetInvisible
());
137
138
G4VisAttributes
* regCcolor =
new
G4VisAttributes
(
G4Colour
(0., 0.3, 0.7));
139
fLogicTarget
->
SetVisAttributes
(regCcolor);
140
141
G4cout
<< *(
G4Material::GetMaterialTable
()) << G4endl;
142
143
return
fPhysWorld
;
144
}
145
146
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
147
148
void
DetectorConstruction::SetTargetMaterial
(
const
G4String
&
mat
)
149
{
150
// search the material by its name
151
G4Material
*
material
=
G4NistManager::Instance
()->
FindOrBuildMaterial
(mat);
152
153
if
(material && material !=
fTargetMaterial
) {
154
fTargetMaterial
=
material
;
155
if
(
fLogicTarget
) {
fLogicTarget
->
SetMaterial
(
fTargetMaterial
); }
156
G4RunManager::GetRunManager
()->
PhysicsHasBeenModified
();
157
}
158
}
159
160
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
161
162
void
DetectorConstruction::SetWorldMaterial
(
const
G4String
&
mat
)
163
{
164
// search the material by its name
165
G4Material
*
material
=
G4NistManager::Instance
()->
FindOrBuildMaterial
(mat);
166
167
if
(material && material !=
fWorldMaterial
) {
168
fWorldMaterial
=
material
;
169
if
(
fLogicWorld
) {
fLogicWorld
->
SetMaterial
(
fWorldMaterial
); }
170
G4RunManager::GetRunManager
()->
PhysicsHasBeenModified
();
171
}
172
}
173
174
void
DetectorConstruction::SetTargetRadius
(
G4double
val)
175
{
176
if
(val > 0.0 && val !=
fRadius
) {
177
fRadius
= val;
178
ComputeGeomParameters
();
179
}
180
}
181
182
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
183
184
void
DetectorConstruction::SetTargetLength
(
G4double
val)
185
{
186
if
(val > 0.0 && val !=
fLength
) {
187
fLength
= val;
188
ComputeGeomParameters
();
189
}
190
}
191
192
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
hadronic
Hadr00
src
DetectorConstruction.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:49
using
1.8.2 with
ECCE GitHub integration