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
medical_linac
src
ML2WorldConstruction.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
// The code was written by :
27
// ^Claudio Andenna claudio.andenna@ispesl.it, claudio.andenna@iss.infn.it
28
// *Barbara Caccia barbara.caccia@iss.it
29
// with the support of Pablo Cirrone (LNS, INFN Catania Italy)
30
// with the contribute of Alessandro Occhigrossi*
31
//
32
// ^INAIL DIPIA - ex ISPESL and INFN Roma, gruppo collegato Sanità, Italy
33
// *Istituto Superiore di Sanità and INFN Roma, gruppo collegato Sanità, Italy
34
// Viale Regina Elena 299, 00161 Roma (Italy)
35
// tel (39) 06 49902246
36
// fax (39) 06 49387075
37
//
38
// more information:
39
// http://g4advancedexamples.lngs.infn.it/Examples/medical-linac
40
//
41
//*******************************************************//
42
43
#include "
ML2WorldConstruction.hh
"
44
#include "
G4SystemOfUnits.hh
"
45
46
CML2WorldConstruction::CML2WorldConstruction
():acceleratorEnv(0),phantomEnv(0),PVWorld(0),phaseSpace(0),backScatteredPlane(0)
47
{
48
phantomEnv=
CML2PhantomConstruction::GetInstance
();
49
acceleratorEnv=
CML2AcceleratorConstruction::GetInstance
();
50
bWorldCreated=
false
;
51
}
52
53
CML2WorldConstruction::~CML2WorldConstruction
(
void
)
54
{
55
delete
PVWorld;
56
delete
phantomEnv;
57
delete
acceleratorEnv;
58
delete
phaseSpace;
59
delete
backScatteredPlane;
60
}
61
62
CML2WorldConstruction
* CML2WorldConstruction::instance = 0;
63
64
CML2WorldConstruction
*
CML2WorldConstruction::GetInstance
()
65
{
66
if
(instance == 0)
67
{
68
instance =
new
CML2WorldConstruction
();
69
}
70
return
instance;
71
}
72
73
G4VPhysicalVolume
*
CML2WorldConstruction::Construct
()
74
{
75
return
PVWorld;
76
}
77
78
bool
CML2WorldConstruction::create
(
SInputData
*inputData,
bool
bOV)
79
{
80
// create the world box
81
bOnlyVisio=bOV;
82
G4double
halfSize=3000.*
mm
;
83
G4Material
*Vacuum=
G4NistManager::Instance
()->
FindOrBuildMaterial
(
"G4_Galactic"
);
84
G4Box
*worldB =
new
G4Box
(
"worldG"
, halfSize, halfSize, halfSize);
85
G4LogicalVolume
*worldLV =
new
G4LogicalVolume
(worldB, Vacuum,
"worldL"
, 0, 0, 0);
86
G4VisAttributes
* simpleWorldVisAtt=
new
G4VisAttributes
(
G4Colour::Black
());
87
simpleWorldVisAtt->
SetVisibility
(
false
);
88
// simpleWorldVisAtt->SetForceSolid(false);
89
worldLV->
SetVisAttributes
(simpleWorldVisAtt);
90
PVWorld=
new
G4PVPlacement
(0,
G4ThreeVector
(0.,0.,0.),
"worldPV"
, worldLV, 0,
false
, 0);
91
92
// create the accelerator-world box
93
if
(!acceleratorEnv->
Construct
(PVWorld, bOV))
94
{
95
std::cout <<
"\n\n The macro file '"
<<inputData->
generalData
.
StartFileInputData
<<
"' refers to a not defined accelerator.\n"
<< acceleratorEnv->
getAcceleratorName
()<<
"\n\nSTOP\n\n"
<<
G4endl
;
96
return
false
;
97
}
98
99
// create the phantom-world box
100
if
(!phantomEnv->
Construct
(PVWorld, inputData->
generalData
.
saving_in_ROG_Voxels_every_events
, inputData->
generalData
.
seed
, inputData->
generalData
.
ROGOutFile
, inputData->
generalData
.
bSaveROG
, bOV))
101
{
102
std::cout <<
"\n\n The macro file '"
<<inputData->
generalData
.
StartFileInputData
<<
"' refers to a not defined phantom.\n"
<< phantomEnv->
getPhantomName
()<<
"\n\nSTOP\n\n"
<<
G4endl
;
103
return
false
;
104
}
105
106
// if the bSavePhaseSpace flag is true create a phase plane
107
if
(inputData->
generalData
.
bSavePhaseSpace
)
108
{
109
phaseSpace=
new
CML2PhaseSpaces
();
110
if
(inputData->
generalData
.
bForcePhaseSpaceBeforeJaws
)
111
{inputData->
generalData
.
centrePhaseSpace
.
setZ
(acceleratorEnv->
getZ_Value_PhaseSpaceBeforeJaws
());}
112
phaseSpace->
createPlane
(
idSD_PhaseSpace
, inputData->
generalData
.
max_N_particles_in_PhSp_File
, inputData->
generalData
.
seed
, inputData->
generalData
.
nMaxParticlesInRamPlanePhaseSpace
, acceleratorEnv->
getPhysicalVolume
(),
"PhSp"
, inputData->
generalData
.
PhaseSpaceOutFile
, inputData->
generalData
.
bSavePhaseSpace
, inputData->
generalData
.
bStopAtPhaseSpace
, inputData->
generalData
.
centrePhaseSpace
, inputData->
generalData
.
halfSizePhaseSpace
,&inputData->
primaryParticleData
, acceleratorEnv->
getAcceleratorIsoCentre
());
113
}
114
115
// create a killer plane to destroy the particles back scattered from the target
116
backScatteredPlane=
new
CML2PhaseSpaces
();
117
backScatteredPlane->
createPlane
(acceleratorEnv->
getPhysicalVolume
(),
"killerPlane"
,
G4ThreeVector
(0, 0, -50*
mm
),
G4ThreeVector
(200*
mm
, 200*
mm
, 1*
mm
));
118
119
bWorldCreated=
true
;
120
return
true
;
121
}
122
void
CML2WorldConstruction::checkVolumeOverlap
()
123
{
124
// loop inside all the daughters volumes
125
std::cout<<
G4endl
;
126
// bool bCheckOverlap;
127
// bCheckOverlap=false;
128
129
int
nSubWorlds, nSubWorlds2;
130
for
(
int
i=0; i<(
int
) PVWorld->
GetLogicalVolume
()->
GetNoDaughters
(); i++)
131
{
132
PVWorld->
GetLogicalVolume
()->
GetDaughter
(i)->
CheckOverlaps
();
133
nSubWorlds=(
int
) PVWorld->
GetLogicalVolume
()->
GetDaughter
(i)->
GetLogicalVolume
()->
GetNoDaughters
();
134
for
(
int
j=0; j<nSubWorlds; j++)
135
{
136
PVWorld->
GetLogicalVolume
()->
GetDaughter
(i)->
GetLogicalVolume
()->
GetDaughter
(j)->
CheckOverlaps
();
137
nSubWorlds2=(
int
) PVWorld->
GetLogicalVolume
()->
GetDaughter
(i)->
GetLogicalVolume
()->
GetDaughter
(j)->
GetLogicalVolume
()->
GetNoDaughters
();
138
for
(
int
k=0; k<nSubWorlds2; k++)
139
{
140
PVWorld->
GetLogicalVolume
()->
GetDaughter
(i)->
GetLogicalVolume
()->
GetDaughter
(j)->
GetLogicalVolume
()->
GetDaughter
(k)->
CheckOverlaps
();
141
}
142
}
143
}
144
std::cout<<
G4endl
;
145
}
146
bool
CML2WorldConstruction::newGeometry
()
147
{
148
G4bool
bNewRotation=
false
;
149
G4bool
bNewCentre=
false
;
150
G4bool
bNewGeometry=
false
;
151
bNewCentre=phantomEnv->
applyNewCentre
();
152
G4RotationMatrix
*rmInv=acceleratorEnv->
rotateAccelerator
();
153
if
(rmInv!=0)
154
{
155
CML2PrimaryGenerationAction::GetInstance
()->
setRotation
(rmInv);
156
bNewRotation=
true
;
157
}
158
if
(bNewRotation || bNewCentre){bNewGeometry=
true
;}
159
return
bNewGeometry;
160
}
161
Generated on Sat May 25 2013 14:32:13 for Geant4 by
1.8.4