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
advanced
dnaphysics
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
//
26
// -------------------------------------------------------------------
27
// $Id$
28
// -------------------------------------------------------------------
29
30
#include "DetectorConstruction.hh"
31
#include "DetectorMessenger.hh"
32
#include "
G4SystemOfUnits.hh
"
33
#include "
G4Region.hh
"
34
#include "
G4ProductionCuts.hh
"
35
#include "
G4UserLimits.hh
"
36
#include "
G4NistManager.hh
"
37
#include "
G4RunManager.hh
"
38
39
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
40
41
DetectorConstruction::DetectorConstruction
()
42
:physiWorld(NULL), logicWorld(NULL), solidWorld(NULL)
43
{
44
// create commands for interactive definition of the detector
45
fDetectorMessenger =
new
DetectorMessenger
(
this
);
46
}
47
48
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
49
50
DetectorConstruction::~DetectorConstruction
()
51
{
52
delete
fDetectorMessenger;
53
}
54
55
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
56
57
G4VPhysicalVolume
*
DetectorConstruction::Construct
()
58
59
{
60
DefineMaterials();
61
return
ConstructDetector();
62
}
63
64
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
65
66
void
DetectorConstruction::DefineMaterials()
67
{
68
69
// Water is defined from NIST material database
70
G4NistManager
* man =
G4NistManager::Instance
();
71
72
//G4Material * H2O = man->FindOrBuildMaterial("G4_WATER");
73
74
// If one wishes to test other density value for water material, one should use instead:
75
G4Material
* H2O = man->
BuildMaterialWithNewDensity
(
"G4_WATER_MODIFIED"
,
"G4_WATER"
,1000*
g
/
cm
/
cm
/
cm
);
76
77
// Note: any string for "G4_WATER_MODIFIED" parameter is accepted
78
// and "G4_WATER" parameter should not be changed
79
// Both materials are created and can be selected from dna.mac
80
81
waterMaterial = H2O;
82
83
//G4cout << "-> Density of water material (g/cm3)=" << waterMaterial->GetDensity()/(g/cm/cm/cm) << G4endl;
84
85
G4cout
<< *(
G4Material::GetMaterialTable
()) <<
G4endl
;
86
}
87
88
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
89
G4VPhysicalVolume
* DetectorConstruction::ConstructDetector()
90
{
91
92
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
93
94
// WORLD VOLUME
95
96
WorldSizeX = 100*
micrometer
;
97
WorldSizeY = WorldSizeX;
98
WorldSizeZ = WorldSizeX;
99
100
solidWorld =
new
G4Box
(
"World"
,
//its name
101
WorldSizeX/2,WorldSizeY/2,WorldSizeZ/2);
//its size
102
103
104
logicWorld =
new
G4LogicalVolume
(solidWorld,
//its solid
105
waterMaterial,
//its material
106
"World"
);
//its name
107
108
physiWorld =
new
G4PVPlacement
(0,
//no rotation
109
G4ThreeVector
(),
//at (0,0,0)
110
"World"
,
//its name
111
logicWorld,
//its logical volume
112
0,
//its mother volume
113
false
,
//no boolean operation
114
0);
//copy number
115
116
117
// Visualization attributes
118
G4VisAttributes
* worldVisAtt=
new
G4VisAttributes
(
G4Colour
(1.0,1.0,1.0));
//White
119
worldVisAtt->
SetVisibility
(
true
);
120
logicWorld->
SetVisAttributes
(worldVisAtt);
121
122
G4VisAttributes
* worldVisAtt1 =
new
G4VisAttributes
(
G4Colour
(1.0,0.0,0.0));
123
worldVisAtt1->
SetVisibility
(
true
);
124
125
//
126
127
//logicWorld->SetUserLimits(new G4UserLimits(DBL_MAX,DBL_MAX,DBL_MAX,20*eV));
128
129
return
physiWorld;
130
}
131
132
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
133
134
void
DetectorConstruction::SetMaterial
(
G4String
materialChoice)
135
{
136
// search the material by its name
137
G4Material
* pttoMaterial =
138
G4NistManager::Instance
()->
FindOrBuildMaterial
(materialChoice);
139
if
(pttoMaterial) {
140
waterMaterial = pttoMaterial;
141
logicWorld->
SetMaterial
(waterMaterial);
142
G4RunManager::GetRunManager
()->
PhysicsHasBeenModified
();
143
}
144
}
145
146
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
147
148
void
DetectorConstruction::UpdateGeometry
()
149
{
150
G4RunManager::GetRunManager
()->
PhysicsHasBeenModified
();
151
G4RunManager::GetRunManager
()->
DefineWorldVolume
(ConstructDetector());
152
}
Generated on Sat May 25 2013 14:31:55 for Geant4 by
1.8.4