Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
examples
extended
hadronic
Hadr02
src
DetectorConstruction.cc
Go to the documentation of this file.
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
// $Id$
30
//
32
//
33
// DetectorConstruction
34
//
35
// Created: 31.01.2003 V.Ivanchenko
36
//
37
// Modified:
38
// 04.06.2006 Adoptation of hadr01 (V.Ivanchenko)
39
//
41
//
42
43
#include "DetectorConstruction.hh"
44
#include "DetectorMessenger.hh"
45
46
#include "
G4Tubs.hh
"
47
#include "
G4LogicalVolume.hh
"
48
#include "
G4PVPlacement.hh
"
49
50
#include "
G4RunManager.hh
"
51
52
#include "
G4GeometryManager.hh
"
53
#include "
G4PhysicalVolumeStore.hh
"
54
#include "
G4LogicalVolumeStore.hh
"
55
#include "
G4SolidStore.hh
"
56
57
#include "
G4VisAttributes.hh
"
58
#include "
G4Colour.hh
"
59
60
#include "
G4UnitsTable.hh
"
61
#include "
G4ios.hh
"
62
63
#include "TargetSD.hh"
64
#include "
G4SDManager.hh
"
65
#include "HistoManager.hh"
66
#include "
G4NistManager.hh
"
67
68
#include "
G4PhysicalConstants.hh
"
69
#include "
G4SystemOfUnits.hh
"
70
71
72
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73
74
DetectorConstruction::DetectorConstruction
()
75
{
76
logicTarget = 0;
77
logicCheck = 0;
78
logicWorld = 0;
79
detectorMessenger =
new
DetectorMessenger
(
this
);
80
81
radius = 10.*
cm
;
82
83
targetMaterial =
G4NistManager::Instance
()->
FindOrBuildMaterial
(
"G4_Al"
);
84
worldMaterial =
G4NistManager::Instance
()->
FindOrBuildMaterial
(
"G4_Galactic"
);
85
HistoManager::GetPointer
()->
SetTargetMaterial
(targetMaterial);
86
87
// Prepare sensitive detectors
88
targetSD =
new
TargetSD
(
"targetSD"
);
89
(
G4SDManager::GetSDMpointer
())->AddNewDetector( targetSD );
90
}
91
92
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
93
94
DetectorConstruction::~DetectorConstruction
()
95
{
96
delete
detectorMessenger;
97
}
98
99
G4VPhysicalVolume
*
DetectorConstruction::Construct
()
100
{
101
// Cleanup old geometry
102
G4GeometryManager::GetInstance
()->
OpenGeometry
();
103
G4PhysicalVolumeStore::GetInstance
()->
Clean
();
104
G4LogicalVolumeStore::GetInstance
()->
Clean
();
105
G4SolidStore::GetInstance
()->
Clean
();
106
107
// Sizes
108
G4double
checkR = radius +
mm
;
109
G4double
worldR = radius +
cm
;
110
G4double
targetZ =
HistoManager::GetPointer
()->
Length
()*0.5;
111
G4double
checkZ = targetZ +
mm
;
112
G4double
worldZ = targetZ +
cm
;
113
114
G4int
nSlices =
HistoManager::GetPointer
()->
NumberOfSlices
();
115
G4double
sliceZ = targetZ/
G4double
(nSlices);
116
117
//
118
// World
119
G4Tubs
* solidW =
new
G4Tubs
(
"World"
,0.,worldR,worldZ,0.,
twopi
);
120
logicWorld =
new
G4LogicalVolume
( solidW,worldMaterial,
"World"
);
121
G4VPhysicalVolume
* world =
new
G4PVPlacement
(0,
G4ThreeVector
(),
122
logicWorld,
"World"
,0,
false
,0);
123
//
124
// Check volume
125
//
126
G4Tubs
* solidC =
new
G4Tubs
(
"Check"
,0.,checkR,checkZ,0.,
twopi
);
127
logicCheck =
new
G4LogicalVolume
( solidC,worldMaterial,
"World"
);
128
// G4VPhysicalVolume* physC =
129
new
G4PVPlacement
(0,
G4ThreeVector
(),logicCheck,
"World"
,logicWorld,
false
,0);
130
131
//
132
// Target volume
133
//
134
G4Tubs
* solidA =
new
G4Tubs
(
"Target"
,0.,radius,sliceZ,0.,
twopi
);
135
logicTarget =
new
G4LogicalVolume
( solidA,targetMaterial,
"Target"
);
136
logicTarget->
SetSensitiveDetector
(targetSD);
137
138
G4double
z
= sliceZ - targetZ;
139
140
for
(
G4int
i=0; i<nSlices; i++) {
141
// physC =
142
new
G4PVPlacement
(0,
G4ThreeVector
(0.0,0.0,z),logicTarget,
"Target"
,logicCheck,
false
,i);
143
z += 2.0*sliceZ;
144
}
145
G4cout
<<
"### Target consist of "
<< nSlices
146
<<
" of "
<< targetMaterial->
GetName
()
147
<<
" disks with R(mm)= "
<< radius/mm
148
<<
" Width(mm)= "
<< 2.0*sliceZ/mm
149
<<
" Total Length(mm)= "
<< 2.0*targetZ/mm
150
<<
" ###"
<<
G4endl
;
151
152
// colors
153
G4VisAttributes
zero =
G4VisAttributes::Invisible
;
154
logicWorld->
SetVisAttributes
(&zero);
155
156
G4VisAttributes
regWcolor(
G4Colour
(0.3, 0.3, 0.3));
157
logicCheck->
SetVisAttributes
(®Wcolor);
158
159
G4VisAttributes
regCcolor(
G4Colour
(0., 0.3, 0.7));
160
logicTarget->
SetVisAttributes
(®Ccolor);
161
162
G4cout
<< *(
G4Material::GetMaterialTable
()) << G4endl;
163
164
return
world;
165
}
166
167
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
168
169
void
DetectorConstruction::SetTargetMaterial
(
const
G4String
&
mat
)
170
{
171
// search the material by its name
172
G4Material
*
material
=
G4NistManager::Instance
()->
FindOrBuildMaterial
(mat);
173
174
if
(material && material != targetMaterial) {
175
HistoManager::GetPointer
()->
SetTargetMaterial
(material);
176
targetMaterial =
material
;
177
if
(logicTarget) { logicTarget->
SetMaterial
(targetMaterial); }
178
G4RunManager::GetRunManager
()->
PhysicsHasBeenModified
();
179
}
180
}
181
182
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
183
184
void
DetectorConstruction::SetWorldMaterial
(
const
G4String
& mat)
185
{
186
// search the material by its name
187
G4Material
* material =
G4NistManager::Instance
()->
FindOrBuildMaterial
(mat);
188
189
if
(material && material != worldMaterial) {
190
worldMaterial =
material
;
191
if
(logicWorld) { logicWorld->
SetMaterial
(worldMaterial); }
192
G4RunManager::GetRunManager
()->
PhysicsHasBeenModified
();
193
}
194
}
195
196
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
197
198
void
DetectorConstruction::SetTargetRadius
(
G4double
val)
199
{
200
if
(val > 0.0) {
201
radius = val;
202
G4RunManager::GetRunManager
()->
GeometryHasBeenModified
();
203
}
204
}
205
206
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Generated on Sat May 25 2013 14:31:56 for Geant4 by
1.8.4