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
//
26
// This example is provided by the Geant4-DNA collaboration
27
// Any report or published results obtained using the Geant4-DNA software
28
// shall cite the following Geant4-DNA collaboration publications:
29
// Phys. Med. 31 (2015) 861-874
30
// Med. Phys. 37 (2010) 4692-4708
31
// The Geant4-DNA web site is available at http://geant4-dna.org
32
//
35
36
#include "DetectorConstruction.hh"
37
#include "DetectorMessenger.hh"
38
#include "TrackerSD.hh"
39
40
#include "
G4Material.hh
"
41
#include "
G4NistManager.hh
"
42
43
#include "
G4Box.hh
"
44
#include "
G4PVPlacement.hh
"
45
46
#include "
G4GeometryTolerance.hh
"
47
#include "
G4GeometryManager.hh
"
48
49
#include "
G4SystemOfUnits.hh
"
50
#include "
G4UserLimits.hh
"
51
#include "
G4UnitsTable.hh
"
52
53
#include "
G4SDManager.hh
"
54
55
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56
57
DetectorConstruction::DetectorConstruction
()
58
:
G4VUserDetectorConstruction
(),
59
fDetectorMessenger(0)
60
{
61
// Default tracking cut
62
fpTrackingCut
= 11.*
eV
;
63
64
// Default maximum step size
65
fpMaxStepSize
=
DBL_MAX
;
66
67
// Create commands for interactive definition of the detector
68
fDetectorMessenger
=
new
DetectorMessenger
(
this
);
69
}
70
71
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72
73
DetectorConstruction::~DetectorConstruction
()
74
{
75
delete
fDetectorMessenger
;
76
}
77
78
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79
80
G4VPhysicalVolume
*
DetectorConstruction::Construct
()
81
{
82
// Define materials
83
DefineMaterials
();
84
85
// Define volumes
86
return
DefineVolumes
();
87
}
88
89
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90
91
void
DetectorConstruction::DefineMaterials
()
92
{
93
// Water is defined from NIST material database
94
G4NistManager
* man =
G4NistManager::Instance
();
95
96
G4Material
* H2O = man->
FindOrBuildMaterial
(
"G4_WATER"
);
97
98
fpWaterMaterial
= H2O;
99
100
// Print materials
101
G4cout
<< *(
G4Material::GetMaterialTable
()) <<
G4endl
;
102
}
103
104
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
105
106
G4VPhysicalVolume
*
DetectorConstruction::DefineVolumes
()
107
{
108
G4double
worldLength = 10*
m
;
109
110
// World
111
112
G4GeometryManager::GetInstance
()->
SetWorldMaximumExtent
(worldLength);
113
114
G4cout
<<
"Computed tolerance = "
115
<<
G4GeometryTolerance::GetInstance
()->
GetSurfaceTolerance
()/
nm
116
<<
" nm"
<<
G4endl
;
117
118
G4Box
* worldS
119
=
new
G4Box
(
"world"
,
//its name
120
worldLength/2,worldLength/2,worldLength/2);
//its size
121
122
G4LogicalVolume
* worldLV
123
=
new
G4LogicalVolume
(
124
worldS,
//its solid
125
fpWaterMaterial
,
//its material
126
"World_LV"
);
//its name
127
128
G4VPhysicalVolume
* worldPV
129
=
new
G4PVPlacement
(
130
0,
// no rotation
131
G4ThreeVector
(),
// at (0,0,0)
132
worldLV,
// its logical volume
133
"World"
,
// its name
134
0,
// its mother volume
135
false
,
// no boolean operations
136
0,
// copy number
137
false
);
// checking overlaps
138
139
worldLV->
SetUserLimits
(
new
G4UserLimits
(
fpMaxStepSize
,
DBL_MAX
,
DBL_MAX
,
140
fpTrackingCut
));
141
142
PrintParameters
();
143
144
return
worldPV;
145
}
146
147
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
148
149
void
DetectorConstruction::ConstructSDandField
()
150
{
151
// Sensitive detectors
152
153
G4String
trackerChamberSDname =
"TrackerChamberSD"
;
154
155
TrackerSD
* aTrackerSD =
new
TrackerSD
(trackerChamberSDname,
156
"TrackerHitsCollection"
);
157
158
G4SDManager::GetSDMpointer
()->
AddNewDetector
(aTrackerSD);
159
160
// Setting aTrackerSD to all logical volumes with the same name
161
// of "Chamber_LV".
162
SetSensitiveDetector
(
"World_LV"
, aTrackerSD,
true
);
163
164
}
165
166
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
167
168
void
DetectorConstruction::SetTrackingCut
(
G4double
value
)
169
{
170
fpTrackingCut
=
value
;
171
}
172
173
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
174
175
void
DetectorConstruction::SetMaxStepSize
(
G4double
value
)
176
{
177
fpMaxStepSize
=
value
;
178
}
179
180
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
181
182
void
DetectorConstruction::PrintParameters
()
const
183
{
184
G4cout
<<
"\n---------------------------------------------------------\n"
;
185
G4cout
<<
"---> The tracking cut is set to "
186
<<
G4BestUnit
(
fpTrackingCut
,
"Energy"
) <<
G4endl
;
187
G4cout
<<
"---> The maximum step size is set to "
188
<<
G4BestUnit
(
fpMaxStepSize
,
"Length"
) <<
G4endl
;
189
G4cout
<<
"\n---------------------------------------------------------\n"
;
190
}
191
192
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
193
geant4
tree
geant4-10.6-release
examples
extended
medical
dna
microyz
src
DetectorConstruction.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:49
using
1.8.2 with
ECCE GitHub integration