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
common
detectorConstruction
src
ExG4DetectorConstruction01.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
//
26
// $Id$
27
//
30
31
#include "
ExG4DetectorConstruction01.hh
"
32
#include "
ExG4DetectorConstruction01Messenger.hh
"
33
34
#include "
G4Material.hh
"
35
#include "
G4NistManager.hh
"
36
#include "
G4Box.hh
"
37
#include "
G4LogicalVolume.hh
"
38
#include "
G4PVPlacement.hh
"
39
40
41
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42
43
ExG4DetectorConstruction01::ExG4DetectorConstruction01
(
44
const
G4String
& materialName,
45
G4double
hx,
G4double
hy,
G4double
hz)
46
:
G4VUserDetectorConstruction
(),
47
fMessenger(this),
48
fMaterialName(materialName),
49
fDimensions(hx, hy, hz),
50
fWorldVolume(0)
51
{
52
}
53
54
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55
56
ExG4DetectorConstruction01::~ExG4DetectorConstruction01
()
57
{
58
}
59
60
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61
62
G4VPhysicalVolume
*
ExG4DetectorConstruction01::Construct
()
63
{
64
// Define materials via NIST manager
65
//
66
G4NistManager
* nistManager =
G4NistManager::Instance
();
67
68
G4bool
fromIsotopes =
false
;
69
70
G4Material
*
material
71
= nistManager->
FindOrBuildMaterial
(fMaterialName, fromIsotopes);
72
73
// World
74
//
75
G4Box
* sWorld
76
=
new
G4Box
(
"World"
,
//name
77
fDimensions.
x
(),
//dimensions (half-lentghs)
78
fDimensions.
y
(),
79
fDimensions.
z
());
80
81
fWorldVolume
82
=
new
G4LogicalVolume
(sWorld,
//shape
83
material,
//material
84
"World"
);
//name
85
86
G4VPhysicalVolume
* pWorld
87
=
new
G4PVPlacement
(0,
//no rotation
88
G4ThreeVector
(),
//at (0,0,0)
89
fWorldVolume,
//logical volume
90
"World"
,
//name
91
0,
//mother volume
92
false
,
//no boolean operation
93
0);
//copy number
94
95
//always return the root volume
96
//
97
return
pWorld;
98
}
99
100
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
101
102
void
ExG4DetectorConstruction01::SetMaterial
(
const
G4String
& materialName)
103
{
104
G4NistManager
* nistManager =
G4NistManager::Instance
();
105
G4bool
fromIsotopes =
false
;
106
107
G4Material
* newMaterial
108
= nistManager->
FindOrBuildMaterial
(materialName, fromIsotopes);
109
110
if
( ! newMaterial ) {
111
G4cerr
<<
"Material "
<< materialName <<
" not found."
<<
G4endl
;
112
G4cerr
<<
"The box material was not changed."
<<
G4endl
;
113
return
;
114
}
115
116
if
( fWorldVolume ) fWorldVolume->
SetMaterial
(newMaterial);
117
G4cout
<<
"Material of box changed to "
<< materialName <<
G4endl
;
118
}
119
120
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121
122
void
ExG4DetectorConstruction01::SetDimensions
(
123
G4double
hx,
G4double
hy,
G4double
hz)
124
{
127
128
fDimensions =
G4ThreeVector
(hx, hy, hz);
129
}
130
131
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Generated on Sat May 25 2013 14:32:18 for Geant4 by
1.8.4