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
ML2WorldConstruction.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file ML2WorldConstruction.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
// 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
44
#include "
ML2WorldConstruction.hh
"
45
#include "
G4SystemOfUnits.hh
"
46
47
CML2WorldConstruction::CML2WorldConstruction
():acceleratorEnv(0),phantomEnv(0),PVWorld(0),phaseSpace(0),backScatteredPlane(0)
48
{
49
phantomEnv
=
CML2PhantomConstruction::GetInstance
();
50
acceleratorEnv
=
CML2AcceleratorConstruction::GetInstance
();
51
bWorldCreated
=
false
;
52
bOnlyVisio
= 0;
53
}
54
55
CML2WorldConstruction::~CML2WorldConstruction
(
void
)
56
{
57
delete
phaseSpace
;
58
delete
backScatteredPlane
;
59
}
60
61
CML2WorldConstruction
*
CML2WorldConstruction::instance
= 0;
62
63
CML2WorldConstruction
*
CML2WorldConstruction::GetInstance
()
64
{
65
if
(
instance
== 0)
66
{
67
instance
=
new
CML2WorldConstruction
();
68
}
69
return
instance
;
70
}
71
72
G4VPhysicalVolume
*
CML2WorldConstruction::Construct
()
73
{
74
return
PVWorld
;
75
}
76
77
bool
CML2WorldConstruction::create
(
SInputData
*inputData,
bool
bOV)
78
{
79
// create the world box
80
bOnlyVisio
= bOV;
81
G4double
halfSize = 3000.*
mm
;
82
G4Material
*Vacuum =
G4NistManager::Instance
()->
FindOrBuildMaterial
(
"G4_Galactic"
);
83
G4Box
*worldB =
new
G4Box
(
"worldG"
, halfSize, halfSize, halfSize);
84
G4LogicalVolume
*worldLV =
new
G4LogicalVolume
(worldB, Vacuum,
"worldL"
, 0, 0, 0);
85
G4VisAttributes
* simpleWorldVisAtt =
new
G4VisAttributes
(
G4Colour::Black
());
86
simpleWorldVisAtt -> SetVisibility(
true
);
87
worldLV -> SetVisAttributes(simpleWorldVisAtt);
88
PVWorld
=
new
G4PVPlacement
(0,
G4ThreeVector
(0.,0.,0.),
"worldPV"
, worldLV, 0,
false
, 0);
89
90
// create the accelerator-world box
91
if
(!
acceleratorEnv
->
Construct
(
PVWorld
, bOV))
92
{
93
G4cout
<<
"\n\n The macro file '"
<< inputData->
generalData
.
StartFileInputData
<<
94
"' refers to a not defined accelerator.\n"
<<
acceleratorEnv
->
getAcceleratorName
() <<
95
"\n\nSTOP\n\n"
<<
G4endl
;
96
return
false
;
97
}
98
99
// create the phantom-world box
100
if
( !
phantomEnv
->
Construct
(
PVWorld
,
101
inputData->
voxelSegmentation
.
nX
,
102
inputData->
voxelSegmentation
.
nY
,
103
inputData->
voxelSegmentation
.
nZ
,
104
bOV) )
105
{
106
G4cout
<<
"\n\n The macro file '"
<< inputData->
generalData
.
StartFileInputData
<<
107
"' refers to a not defined phantom.\n"
<<
phantomEnv
->
getPhantomName
() <<
108
"\n\nSTOP\n\n"
<<
G4endl
;
109
return
false
;
110
}
111
112
// if the bSavePhaseSpace flag is true create a phase plane
113
/*
114
if (inputData -> generalData.bSavePhaseSpace)
115
{
116
phaseSpace = new CML2PhaseSpaces();
117
if (inputData -> generalData.bForcePhaseSpaceBeforeJaws)
118
{
119
inputData -> generalData.centrePhaseSpace.setZ(acceleratorEnv->getZ_Value_PhaseSpaceBeforeJaws());
120
}
121
122
phaseSpace -> createPlane(idSD_PhaseSpace,
123
inputData->generalData.max_N_particles_in_PhSp_File,
124
inputData->generalData.seed,
125
inputData->generalData.nMaxParticlesInRamPlanePhaseSpace,
126
acceleratorEnv->getPhysicalVolume(), "PhSp",
127
inputData->generalData.PhaseSpaceOutFile,
128
inputData->generalData.bSavePhaseSpace,
129
inputData->generalData.bStopAtPhaseSpace,
130
inputData->generalData.centrePhaseSpace,
131
inputData->generalData.halfSizePhaseSpace,
132
&inputData->primaryParticleData,
133
acceleratorEnv->getAcceleratorIsoCentre()); // phase space plane, yellow
134
}
135
136
// create a killer plane to destroy the particles back scattered from the target
137
backScatteredPlane = new CML2PhaseSpaces();
138
backScatteredPlane -> createPlane(acceleratorEnv->getPhysicalVolume(),
139
"killerPlane", G4ThreeVector(0, 0, -50*mm), G4ThreeVector(200*mm, 200*mm, 1*mm)); // killer plane, cyan
140
*/
141
bWorldCreated
=
true
;
142
return
bWorldCreated
;
143
}
144
void
CML2WorldConstruction::checkVolumeOverlap
()
145
{
146
// loop inside all the daughters volumes
147
G4cout
<<
G4endl
;
148
// bool bCheckOverlap;
149
// bCheckOverlap=false;
150
151
int
nSubWorlds, nSubWorlds2;
152
for
(
int
i=0; i<(
int
)
PVWorld
->
GetLogicalVolume
()->
GetNoDaughters
(); i++)
153
{
154
PVWorld
->
GetLogicalVolume
()->
GetDaughter
(i)->
CheckOverlaps
();
155
nSubWorlds=(
int
)
PVWorld
->
GetLogicalVolume
()->
GetDaughter
(i)->
GetLogicalVolume
()->
GetNoDaughters
();
156
for
(
int
j=0; j<nSubWorlds; j++)
157
{
158
PVWorld
->
GetLogicalVolume
()->
GetDaughter
(i)->
GetLogicalVolume
()->
GetDaughter
(j)->
CheckOverlaps
();
159
nSubWorlds2=(
int
)
PVWorld
->
GetLogicalVolume
()->
GetDaughter
(i)->
GetLogicalVolume
()->
GetDaughter
(j)->
GetLogicalVolume
()->
GetNoDaughters
();
160
for
(
int
k
=0;
k
<nSubWorlds2;
k
++)
161
{
162
PVWorld
->
GetLogicalVolume
()->
GetDaughter
(i)->
GetLogicalVolume
()->
GetDaughter
(j)->
GetLogicalVolume
()->
GetDaughter
(
k
)->
CheckOverlaps
();
163
}
164
}
165
}
166
G4cout
<<
G4endl
;
167
}
168
bool
CML2WorldConstruction::newGeometry
()
169
{
170
171
G4bool
bNewRotation =
false
;
172
G4bool
bNewCentre =
false
;
173
G4bool
bNewGeometry =
false
;
174
bNewCentre =
phantomEnv
-> applyNewCentre();
175
G4RotationMatrix
*rmInv =
acceleratorEnv
-> rotateAccelerator();
176
if
(rmInv!=0)
177
{
178
CML2PrimaryGenerationAction::GetInstance
()->
setRotation
(rmInv);
179
bNewRotation =
true
;
180
}
181
if
(bNewRotation || bNewCentre)
182
{
183
bNewGeometry =
true
;
184
}
185
186
return
bNewGeometry;
187
}
188
geant4
tree
geant4-10.6-release
examples
advanced
medical_linac
src
ML2WorldConstruction.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:00
using
1.8.2 with
ECCE GitHub integration