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 "TargetSD.hh"
41
#include "
G4SDManager.hh
"
42
43
#include "
G4GeometryManager.hh
"
44
45
#include "
G4UnitsTable.hh
"
46
#include "
G4NistManager.hh
"
47
48
#include "
G4FieldManager.hh
"
49
#include "
G4ThreeVector.hh
"
50
#include "
G4RunManager.hh
"
51
#include "
G4SystemOfUnits.hh
"
52
53
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54
55
DetectorConstruction::DetectorConstruction
()
56
:
G4VUserDetectorConstruction
(),
57
fAbsorMaterial(nullptr),
58
fLogAbsor(nullptr),
59
fWorld(nullptr)
60
{
61
// default parameter values
62
fAbsorSizeZ
=
fAbsorSizeXY
= 10 *
cm
;
63
fWorldSizeZ
=
fWorldSizeXY
= 1.2 *
fAbsorSizeZ
;
64
65
SetMaterial
(
"G4_Al"
);
66
fWorldMaterial
=
67
G4NistManager::Instance
()->
FindOrBuildMaterial
(
"G4_Galactic"
);
68
69
// create commands for interactive definition of the detector
70
fDetectorMessenger
=
new
DetectorMessenger
(
this
);
71
}
72
73
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74
75
DetectorConstruction::~DetectorConstruction
()
76
{
77
delete
fDetectorMessenger
;
78
}
79
80
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81
82
G4VPhysicalVolume
*
DetectorConstruction::Construct
()
83
{
84
if
(
fWorld
) {
return
fWorld
; }
85
86
/**************************** World *****************************/
87
G4Box
* sWorld =
new
G4Box
(
"world"
,
88
fWorldSizeXY
/ 2,
fWorldSizeXY
/ 2,
fWorldSizeZ
/ 2);
89
90
G4LogicalVolume
* lWorld =
new
G4LogicalVolume
(sWorld,
91
fWorldMaterial
,
92
"world"
);
93
94
fWorld
=
new
G4PVPlacement
(0,
//no rotation
95
G4ThreeVector
(),
//at (0,0,0)
96
lWorld,
//logical volume
97
"world"
,
//name
98
0,
//mother volume
99
false
,
//no boolean operation
100
0);
//copy number
101
102
103
/************************** Absorber ***************************/
104
105
G4Box
* sAbsor =
new
G4Box
(
"Absorber"
,
106
fAbsorSizeXY
/ 2,
fAbsorSizeXY
/ 2,
fAbsorSizeZ
/ 2);
107
108
fLogAbsor
=
new
G4LogicalVolume
(sAbsor,
109
fAbsorMaterial
,
110
"Absorber"
);
111
112
new
G4PVPlacement
(0,
//no rotation
113
G4ThreeVector
(),
//at (0,0,0)
114
fLogAbsor
,
//logical volume
115
"Absorber"
,
//name
116
lWorld,
//mother volume
117
false
,
//no boolean operation
118
0);
//copy number
119
120
PrintParameters
();
121
122
/************ always return the World volume *****************/
123
return
fWorld
;
124
}
125
126
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
127
128
void
DetectorConstruction::PrintParameters
()
129
{
130
G4cout
<<
"\n---------------------------------------------------------\n"
;
131
G4cout
<<
"---> The Absorber is "
<<
G4BestUnit
(
fAbsorSizeZ
,
"Length"
)
132
<<
" of "
<<
fAbsorMaterial
->
GetName
() <<
G4endl
;
133
G4cout
<<
"\n---------------------------------------------------------\n"
;
134
135
}
136
137
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
138
139
void
DetectorConstruction::SetSizeZ
(
G4double
value
)
140
{
141
if
(value > 0.0) {
142
fAbsorSizeZ
=
value
;
143
fWorldSizeZ
= 1.2 *
fAbsorSizeZ
;
144
}
145
}
146
147
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
148
149
void
DetectorConstruction::SetSizeXY
(
G4double
value
)
150
{
151
if
(value > 0.0)
152
{
153
fAbsorSizeXY
=
value
;
154
fWorldSizeXY
= 1.2 *
fAbsorSizeXY
;
155
}
156
}
157
158
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
159
160
void
DetectorConstruction::SetMaterial
(
const
G4String
& namemat)
161
{
162
// search the material by its name
163
164
G4Material
*
mat
=
G4NistManager::Instance
()->
FindOrBuildMaterial
(namemat);
165
if
(!mat) {
166
G4cout
<<
"!!! DetectorConstruction::SetMaterial: WARNING Material <"
167
<< namemat <<
"> does not exist in DB"
<<
G4endl
;
168
return
;
169
}
170
// new material is found out
171
if
(mat !=
fAbsorMaterial
) {
172
fAbsorMaterial
=
mat
;
173
if
(
fLogAbsor
) {
fLogAbsor
->
SetMaterial
(mat); }
174
G4RunManager::GetRunManager
()->
PhysicsHasBeenModified
();
175
}
176
}
177
178
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
179
180
void
DetectorConstruction::ConstructSDandField
()
181
{
182
auto
sd =
new
TargetSD
(
"Target"
);
183
G4SDManager::GetSDMpointer
()->
AddNewDetector
(sd);
184
SetSensitiveDetector
(
fLogAbsor
, sd);
185
}
186
187
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
exoticphysics
dmparticle
src
DetectorConstruction.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:49
using
1.8.2 with
ECCE GitHub integration