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
ML2PhantomConstruction.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file ML2PhantomConstruction.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 "
ML2PhantomConstruction.hh
"
45
#include "
ML2PhantomConstructionMessenger.hh
"
46
47
#include "
G4ios.hh
"
48
#include "
G4SystemOfUnits.hh
"
49
50
CML2PhantomConstruction::CML2PhantomConstruction
(
void
): PVPhmWorld(0)
51
{
52
phantomContstructionMessenger
=
new
CML2PhantomConstructionMessenger
(
this
);
53
idCurrentCentre
= 0;
54
}
55
56
CML2PhantomConstruction::~CML2PhantomConstruction
(
void
)
57
{}
58
59
CML2PhantomConstruction
*
CML2PhantomConstruction::instance
= 0;
60
61
CML2PhantomConstruction
*
CML2PhantomConstruction::GetInstance
(
void
)
62
{
63
if
(
instance
== 0)
64
{
65
instance
=
new
CML2PhantomConstruction
();
66
67
}
68
return
instance
;
69
}
70
bool
CML2PhantomConstruction::design
(
void
)
71
{
72
// switch between two different phantoms according to the macro ml2.mac
73
bool
bPhanExists =
false
;
74
75
G4cout
<<
"I'm building "
<<
phantomName
<<
" phantom"
<<
G4endl
;
76
77
if
(
phantomName
==
"fullWater"
)
78
{
79
Ph_fullWater
=
new
CML2Ph_FullWater
();
80
bPhanExists=
true
;
81
halfPhantomInsideSize
=
Ph_fullWater
->
getHalfContainerSize
();
82
}
83
else
if
(
phantomName
==
"boxInBox"
)
84
{
85
Ph_BoxInBox
=
new
CML2Ph_BoxInBox
();
86
bPhanExists=
true
;
87
halfPhantomInsideSize
=
Ph_BoxInBox
->
getHalfContainerSize
();
88
}
89
90
if
(
centre
.size() < 1)
91
{
92
addNewCentre
(
G4ThreeVector
(0.,0.,0.));
93
}
94
return
bPhanExists;
95
}
96
G4int
CML2PhantomConstruction::getTotalNumberOfEvents
()
97
{
98
G4cout
<<
"Not implemented at the moment "
<<
G4endl
;
99
/*if (phantomName == "fullWater")
100
{
101
return Ph_fullWater->getTotalNumberOfEvents();
102
}
103
else if (phantomName == "boxInBox")
104
{
105
return Ph_BoxInBox->getTotalNumberOfEvents();
106
}
107
108
*/
109
return
0;
110
}
111
112
bool
CML2PhantomConstruction::Construct
(
G4VPhysicalVolume
*PVWorld,
113
G4int
voxelX,
G4int
voxelY,
G4int
voxelZ,
G4bool
bOV)
114
{
115
idVolumeName
= 0;
116
bOnlyVisio
= bOV;
117
// a call to select the right phantom
118
if
(
design
())
119
{
120
phantomContstructionMessenger
->
SetReferenceWorld
(bOV);
// create the phantom-world box
121
G4Material
*Vacuum=
G4NistManager::Instance
()->
FindOrBuildMaterial
(
"G4_Galactic"
);
122
123
G4Box
*phmWorldB =
new
G4Box
(
"phmWorldG"
,
halfPhantomInsideSize
.
getX
(),
124
halfPhantomInsideSize
.
getY
(),
halfPhantomInsideSize
.
getZ
());
125
G4LogicalVolume
*phmWorldLV =
new
G4LogicalVolume
(phmWorldB, Vacuum,
"phmWorldL"
, 0, 0, 0);
126
G4VisAttributes
* simpleAlSVisAtt=
new
G4VisAttributes
(
G4Colour::White
());
127
simpleAlSVisAtt->
SetVisibility
(
false
);
128
phmWorldLV->SetVisAttributes(simpleAlSVisAtt);
129
130
131
PVPhmWorld
=
new
G4PVPlacement
(0,
G4ThreeVector
(0.,0.,0.),
"phmWorldPV"
, phmWorldLV, PVWorld,
false
, 0);
132
133
// create the actual phantom
134
if
(
phantomName
==
"fullWater"
)
135
{
136
Ph_fullWater
->
Construct
(
PVPhmWorld
, voxelX, voxelY, voxelZ);
// provide the voxelisation to the phantom
137
//sensDet=Ph_fullWater->getSensDet();
138
createPhysicalVolumeNamesList
(
Ph_fullWater
->
getPhysicalVolume
());
139
Ph_fullWater
->
writeInfo
();
140
}
141
else
if
(
phantomName
==
"boxInBox"
)
142
{
143
Ph_BoxInBox
->
Construct
(
PVPhmWorld
);
144
//sensDet=Ph_BoxInBox->getSensDet();
145
createPhysicalVolumeNamesList
(
Ph_BoxInBox
->
getPhysicalVolume
());
146
Ph_BoxInBox
->
writeInfo
();
147
148
}
149
150
}
151
else
152
{
153
return
false
;
154
}
155
return
true
;
156
}
157
void
CML2PhantomConstruction::createPhysicalVolumeNamesList
(
G4String
*matNames,
G4int
nMatNames)
158
{
159
SvolumeNameId
svnid;
160
for
(
int
i=0;i< nMatNames; i++)
161
{
162
svnid.
volumeId
=i;
163
svnid.
volumeName
=matNames[i];
164
volumeNameIdLink
.push_back(svnid);
165
}
166
}
167
void
CML2PhantomConstruction::createPhysicalVolumeNamesList
(
G4VPhysicalVolume
*PV)
168
{
169
int
nLVD1;
170
nLVD1=(
int
) PV->
GetLogicalVolume
()->
GetNoDaughters
();
171
SvolumeNameId
svnid;
172
G4cout
<<
"PV in name: "
<<PV->
GetName
() <<
G4endl
;
173
if
(nLVD1>0)
174
{
175
for
(
int
i=0; i <nLVD1; i++)
176
{
177
createPhysicalVolumeNamesList
(PV->
GetLogicalVolume
()->
GetDaughter
(i));
178
}
179
idVolumeName
++;
180
svnid.
volumeId
=
idVolumeName
;
181
svnid.
volumeName
=PV->
GetLogicalVolume
()->
GetMaterial
()->
GetName
();
182
volumeNameIdLink
.push_back(svnid);
183
G4cout
<<
"physical volume name: "
<<svnid.
volumeName
<<
G4endl
;
184
}
185
else
186
{
187
idVolumeName
++;
188
svnid.
volumeId
=
idVolumeName
;
189
svnid.
volumeName
=PV->
GetLogicalVolume
()->
GetMaterial
()->
GetName
();
190
volumeNameIdLink
.push_back(svnid);
191
G4cout
<<
"physical volume name: "
<<svnid.
volumeName
<<
G4endl
;
192
}
193
}
194
bool
CML2PhantomConstruction::applyNewCentre
()
195
{
196
if
(
idCurrentCentre
<(
int
)
centre
.size())
197
{
198
currentCentre
=
centre
[
idCurrentCentre
];
199
applyNewCentre
(
currentCentre
);
200
idCurrentCentre
++;
201
return
true
;
202
}
203
return
false
;
204
}
205
void
CML2PhantomConstruction::writeInfo
()
206
{
207
if
(!
bOnlyVisio
)
208
{
209
G4cout
<<
"Actual centre: "
<<
idCurrentCentre
<<
"/"
<<
centre
.size() <<
" "
<<
G4endl
;
210
}
211
G4cout
<<
"Phantom and its ROG centre: "
<<
currentCentre
<<
G4endl
;
212
}
213
void
CML2PhantomConstruction::applyNewCentre
(
G4ThreeVector
ctr)
214
{
215
if
(
PVPhmWorld
)
216
{
217
currentCentre
=ctr;
218
G4GeometryManager::GetInstance
()->
OpenGeometry
();
219
PVPhmWorld
->
SetTranslation
(ctr);
220
G4GeometryManager::GetInstance
()->
CloseGeometry
();
221
G4RunManager::GetRunManager
()->
GeometryHasBeenModified
();
222
}
223
}
224
G4String
CML2PhantomConstruction::getCurrentTranslationString
()
225
{
226
char
cT[5];
227
G4int
cTI;
228
G4String
translationName;
229
cTI=(
G4int
)((
currentCentre
.
getX
()/
mm
));
230
sprintf(cT,
"%d"
,cTI);
231
translationName=
"_TrX"
+
G4String
(cT)+
"_"
;
232
cTI=(
G4int
)((
currentCentre
.
getY
()/
mm
));
233
sprintf(cT,
"%d"
,cTI);
234
translationName+=
"Y"
+
G4String
(cT)+
"_"
;
235
cTI=(
G4int
)((
currentCentre
.
getZ
()/
mm
));
236
sprintf(cT,
"%d"
,cTI);
237
translationName+=
"Z"
+
G4String
(cT);
238
return
translationName;
239
}
240
geant4
tree
geant4-10.6-release
examples
advanced
medical_linac
src
ML2PhantomConstruction.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:00
using
1.8.2 with
ECCE GitHub integration