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 "
G4Box.hh
"
38
#include "
G4LogicalVolume.hh
"
39
#include "
G4PVPlacement.hh
"
40
#include "
G4UniformMagField.hh
"
41
42
#include "
G4GeometryManager.hh
"
43
#include "
G4UserLimits.hh
"
44
#include "
G4PhysicalVolumeStore.hh
"
45
#include "
G4LogicalVolumeStore.hh
"
46
#include "
G4SolidStore.hh
"
47
#include "
G4StateManager.hh
"
48
49
#include "
G4UnitsTable.hh
"
50
#include "
G4NistManager.hh
"
51
52
#include "
G4MonopoleFieldSetup.hh
"
53
//#include "G4FieldManager.hh"
54
//#include "G4TransportationManager.hh"
55
#include "
G4ThreeVector.hh
"
56
#include "
G4RunManager.hh
"
57
#include "
G4SystemOfUnits.hh
"
58
59
#include "
G4GlobalMagFieldMessenger.hh
"
60
#include "
G4AutoDelete.hh
"
61
62
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63
64
DetectorConstruction::DetectorConstruction
()
65
:
G4VUserDetectorConstruction
(),
66
fWorldMaterial(0),
67
fAbsorMaterial(0),
68
fLogAbsor(0),
69
fMonFieldSetup(),
70
fDetectorMessenger(0)
71
{
72
// default parameter values
73
fAbsorSizeX
=
fAbsorSizeYZ
= 10 *
cm
;
74
fWorldSizeX
=
fWorldSizeYZ
= 1.2 *
fAbsorSizeX
;
75
fMaxStepSize
= 5 *
mm
;
76
77
SetMaterial
(
"G4_Al"
);
78
fWorldMaterial
=
79
G4NistManager::Instance
()->
FindOrBuildMaterial
(
"G4_Galactic"
);
80
81
// create commands for interactive definition of the detector
82
fDetectorMessenger
=
new
DetectorMessenger
(
this
);
83
}
84
85
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
86
87
DetectorConstruction::~DetectorConstruction
()
88
{
89
delete
fDetectorMessenger
;
90
// delete fMonFieldSetup;
91
}
92
93
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
94
95
G4VPhysicalVolume
*
DetectorConstruction::Construct
()
96
{
97
G4GeometryManager::GetInstance
()->
OpenGeometry
();
98
G4PhysicalVolumeStore::GetInstance
()->
Clean
();
99
G4LogicalVolumeStore::GetInstance
()->
Clean
();
100
G4SolidStore::GetInstance
()->
Clean
();
101
102
/**************************** World *****************************/
103
G4Box
* sWorld =
new
G4Box
(
"world"
,
104
fWorldSizeX
/ 2,
fWorldSizeYZ
/ 2,
fWorldSizeYZ
/ 2);
105
106
G4LogicalVolume
* lWorld =
new
G4LogicalVolume
(sWorld,
107
fWorldMaterial
,
108
"world"
);
109
110
G4VPhysicalVolume
* pWorld =
new
G4PVPlacement
(0,
//no rotation
111
G4ThreeVector
(),
//at (0,0,0)
112
lWorld,
//logical volume
113
"world"
,
//name
114
0,
//mother volume
115
false
,
//no boolean operation
116
0);
//copy number
117
118
119
/************************** Absorber ***************************/
120
G4Box
* sAbsor =
new
G4Box
(
"Absorber"
,
121
fAbsorSizeX
/ 2,
fAbsorSizeYZ
/ 2,
fAbsorSizeYZ
/ 2);
122
123
fLogAbsor
=
new
G4LogicalVolume
(sAbsor,
124
fAbsorMaterial
,
125
"Absorber"
);
126
127
new
G4PVPlacement
(0,
//no rotation
128
G4ThreeVector
(),
//at (0,0,0)
129
fLogAbsor
,
//logical volume
130
"Absorber"
,
//name
131
lWorld,
//mother volume
132
false
,
//no boolean operation
133
0);
//copy number
134
fLogAbsor
->
SetUserLimits
(
new
G4UserLimits
(
fMaxStepSize
));
135
136
PrintParameters
();
137
138
/************ always return the World volume *****************/
139
return
pWorld;
140
}
141
142
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
143
144
void
DetectorConstruction::PrintParameters
()
145
{
146
G4cout
<<
"\n---------------------------------------------------------\n"
;
147
G4cout
<<
"---> The Absorber is "
<<
G4BestUnit
(
fAbsorSizeX
,
"Length"
)
148
<<
" of "
<<
fAbsorMaterial
->
GetName
() <<
G4endl
;
149
G4cout
<<
"\n---------------------------------------------------------\n"
;
150
151
}
152
153
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
154
155
void
DetectorConstruction::SetSizeX
(
G4double
value
)
156
{
157
if
(value > 0.0) {
158
fAbsorSizeX
=
value
;
159
fWorldSizeX
= 1.2 *
fAbsorSizeX
;
160
if
(
G4StateManager::GetStateManager
()->GetCurrentState() !=
G4State_PreInit
) {
161
G4RunManager::GetRunManager
()->
ReinitializeGeometry
();
162
}
163
}
164
}
165
166
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
167
168
void
DetectorConstruction::SetSizeYZ
(
G4double
value)
169
{
170
if
(value > 0.0) {
171
fAbsorSizeYZ
=
value
;
172
fWorldSizeYZ
= 1.2 *
fAbsorSizeYZ
;
173
if
(
G4StateManager::GetStateManager
()->GetCurrentState() !=
G4State_PreInit
) {
174
G4RunManager::GetRunManager
()->
ReinitializeGeometry
();
175
}
176
}
177
}
178
179
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
180
181
void
DetectorConstruction::SetMaterial
(
const
G4String
& namemat)
182
{
183
// search the material by its name
184
G4Material
*
mat
=
G4NistManager::Instance
()->
FindOrBuildMaterial
(namemat);
185
if
(!mat) {
186
G4cout
<<
"!!! DetectorConstruction::SetMaterial: WARNING Material <"
187
<< namemat <<
"> does not exist in DB"
<<
G4endl
;
188
return
;
189
}
190
// new material is found out
191
if
(mat !=
fAbsorMaterial
) {
192
fAbsorMaterial
=
mat
;
193
if
(
fLogAbsor
) {
fLogAbsor
->
SetMaterial
(mat); }
194
G4RunManager::GetRunManager
()->
PhysicsHasBeenModified
();
195
}
196
}
197
198
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
199
200
void
DetectorConstruction::ConstructSDandField
()
201
{
202
// Define magnetic field
203
if
( !
fMonFieldSetup
.
Get
() ) {
204
G4MonopoleFieldSetup
* fieldSetup
205
=
new
G4MonopoleFieldSetup
();
206
G4AutoDelete::Register
(fieldSetup);
// Kernel will delete the F01FieldSetup
207
fMonFieldSetup
.
Put
(fieldSetup);
208
}
209
fMonFieldSetup
.
Get
()->
ConstructMagField
();
// add field value
210
}
211
212
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
213
214
void
DetectorConstruction::SetMaxStepSize
(
G4double
step
)
215
{
216
fMaxStepSize
=
step
;
217
if
(
fLogAbsor
) {
fLogAbsor
->
SetUserLimits
(
new
G4UserLimits
(
fMaxStepSize
)); }
218
}
219
220
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
exoticphysics
monopole
src
DetectorConstruction.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:49
using
1.8.2 with
ECCE GitHub integration