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: 31.01.2003 V.Ivanchenko
35
//
36
// Modified:
37
// 04.06.2006 Adoptation of hadr01 (V.Ivanchenko)
38
//
40
//
41
42
#include "DetectorConstruction.hh"
43
#include "DetectorMessenger.hh"
44
45
#include "
G4Tubs.hh
"
46
#include "
G4LogicalVolume.hh
"
47
#include "
G4PVPlacement.hh
"
48
49
#include "
G4RunManager.hh
"
50
51
#include "
G4GeometryManager.hh
"
52
#include "
G4PhysicalVolumeStore.hh
"
53
#include "
G4LogicalVolumeStore.hh
"
54
#include "
G4SolidStore.hh
"
55
56
#include "
G4VisAttributes.hh
"
57
#include "
G4Colour.hh
"
58
59
#include "
G4UnitsTable.hh
"
60
#include "
G4ios.hh
"
61
62
#include "TargetSD.hh"
63
#include "
G4SDManager.hh
"
64
#include "HistoManager.hh"
65
#include "
G4NistManager.hh
"
66
67
#include "
G4PhysicalConstants.hh
"
68
#include "
G4SystemOfUnits.hh
"
69
70
71
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72
73
DetectorConstruction::DetectorConstruction
()
74
:
G4VUserDetectorConstruction
(),
75
fRadius(10.*
cm
),
76
fTargetMaterial(0),
77
fWorldMaterial(0),
78
fTargetSD(0),
79
fLogicTarget(0),
80
fLogicWorld (0),
81
fDetectorMessenger(0)
82
83
{
84
fDetectorMessenger
=
new
DetectorMessenger
(
this
);
85
86
fTargetMaterial
87
=
G4NistManager::Instance
()->
FindOrBuildMaterial
(
"G4_Al"
);
88
fWorldMaterial
=
89
G4NistManager::Instance
()->
FindOrBuildMaterial
(
"G4_Galactic"
);
90
HistoManager::GetPointer
()->
SetTargetMaterial
(
fTargetMaterial
);
91
92
// Prepare sensitive detectors
93
fTargetSD
=
new
TargetSD
(
"targetSD"
);
94
G4SDManager::GetSDMpointer
()->
AddNewDetector
(
fTargetSD
);
95
}
96
97
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
98
99
DetectorConstruction::~DetectorConstruction
()
100
{
101
delete
fDetectorMessenger
;
102
}
103
104
G4VPhysicalVolume
*
DetectorConstruction::Construct
()
105
{
106
// Cleanup old geometry
107
G4GeometryManager::GetInstance
()->
OpenGeometry
();
108
G4PhysicalVolumeStore::GetInstance
()->
Clean
();
109
G4LogicalVolumeStore::GetInstance
()->
Clean
();
110
G4SolidStore::GetInstance
()->
Clean
();
111
112
// Sizes
113
G4double
checkR =
fRadius
+
mm
;
114
G4double
worldR =
fRadius
+
cm
;
115
G4double
targetZ =
HistoManager::GetPointer
()->
Length
()*0.5;
116
G4double
checkZ = targetZ +
mm
;
117
G4double
worldZ = targetZ +
cm
;
118
119
G4int
nSlices =
HistoManager::GetPointer
()->
NumberOfSlices
();
120
G4double
sliceZ = targetZ/
G4double
(nSlices);
121
122
//
123
// World
124
G4Tubs
* solidW =
new
G4Tubs
(
"World"
,0.,worldR,worldZ,0.,
twopi
);
125
fLogicWorld
=
new
G4LogicalVolume
( solidW,
fWorldMaterial
,
"World"
);
126
G4VPhysicalVolume
*
world
=
new
G4PVPlacement
(0,
G4ThreeVector
(),
127
fLogicWorld
,
"World"
,0,
false
,0);
128
//
129
// Check volume
130
//
131
G4Tubs
* solidC =
new
G4Tubs
(
"Check"
,0.,checkR,checkZ,0.,
twopi
);
132
G4LogicalVolume
* logicCheck
133
=
new
G4LogicalVolume
( solidC,
fWorldMaterial
,
"World"
);
134
new
G4PVPlacement
(0,
G4ThreeVector
(),logicCheck,
"World"
,
fLogicWorld
,
false
,0);
135
136
//
137
// Target volume
138
//
139
G4Tubs
* solidA =
new
G4Tubs
(
"Target"
,0.,
fRadius
,sliceZ,0.,
twopi
);
140
fLogicTarget
=
new
G4LogicalVolume
( solidA,
fTargetMaterial
,
"Target"
);
141
fLogicTarget
->
SetSensitiveDetector
(
fTargetSD
);
142
143
G4double
z
= sliceZ - targetZ;
144
145
for
(
G4int
i=0; i<nSlices; i++) {
146
// physC =
147
new
G4PVPlacement
(0,
G4ThreeVector
(0.0,0.0,z),
fLogicTarget
,
148
"Target"
,logicCheck,
false
,i);
149
z += 2.0*sliceZ;
150
}
151
G4cout
<<
"### Target consist of "
<< nSlices
152
<<
" of "
<<
fTargetMaterial
->
GetName
()
153
<<
" disks with R(mm)= "
<<
fRadius
/mm
154
<<
" Width(mm)= "
<< 2.0*sliceZ/mm
155
<<
" Total Length(mm)= "
<< 2.0*targetZ/mm
156
<<
" ###"
<<
G4endl
;
157
158
// colors
159
G4VisAttributes
zero
=
G4VisAttributes::GetInvisible
();
160
fLogicWorld
->
SetVisAttributes
(zero);
161
162
G4VisAttributes
regWcolor(
G4Colour
(0.3, 0.3, 0.3));
163
logicCheck->
SetVisAttributes
(regWcolor);
164
165
G4VisAttributes
regCcolor(
G4Colour
(0., 0.3, 0.7));
166
fLogicTarget
->
SetVisAttributes
(regCcolor);
167
168
G4cout
<< *(
G4Material::GetMaterialTable
()) << G4endl;
169
170
return
world
;
171
}
172
173
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
174
175
void
DetectorConstruction::SetTargetMaterial
(
const
G4String
&
mat
)
176
{
177
// search the material by its name
178
G4Material
*
material
=
G4NistManager::Instance
()->
FindOrBuildMaterial
(mat);
179
180
if
(material && material !=
fTargetMaterial
) {
181
HistoManager::GetPointer
()->
SetTargetMaterial
(material);
182
fTargetMaterial
=
material
;
183
if
(
fLogicTarget
) {
fLogicTarget
->
SetMaterial
(
fTargetMaterial
); }
184
G4RunManager::GetRunManager
()->
PhysicsHasBeenModified
();
185
}
186
}
187
188
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
189
190
void
DetectorConstruction::SetWorldMaterial
(
const
G4String
& mat)
191
{
192
// search the material by its name
193
G4Material
* material =
G4NistManager::Instance
()->
FindOrBuildMaterial
(mat);
194
195
if
(material && material !=
fWorldMaterial
) {
196
fWorldMaterial
=
material
;
197
if
(
fLogicWorld
) {
fLogicWorld
->
SetMaterial
(
fWorldMaterial
); }
198
G4RunManager::GetRunManager
()->
PhysicsHasBeenModified
();
199
}
200
}
201
202
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
203
204
void
DetectorConstruction::SetTargetRadius
(
G4double
val)
205
{
206
if
(val > 0.0) {
207
fRadius
= val;
208
G4RunManager::GetRunManager
()->
GeometryHasBeenModified
();
209
}
210
}
211
212
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
examples
extended
hadronic
Hadr02
src
DetectorConstruction.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:49
using
1.8.2 with
ECCE GitHub integration