Loading...
Searching...
No Matches
VoxelizedSensitiveDetector.hh
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/// \file radiobiology/include/VoxelizedSensitiveDetector.hh
27/// \brief Definition of the RadioBio::VoxelizedSensitiveDetector class
28
29#ifndef RadiobiologyVoxelizedSensitiveDetector_h
30#define RadiobiologyVoxelizedSensitiveDetector_h 1
31
32#include "G4ThreeVector.hh"
33
34class G4Box;
35class G4LogicalVolume;
37
38namespace RadioBio
39{
40
41// Forward declariation of other radiobiology classes
42class DetectorConstruction;
43class VoxelizedSensitiveDetectorMessenger;
44
45/**
46 * @brief Singleton class performing the voxelization of the
47 * world volume and tracking of a voxel index given the three-dimensional
48 * coordinates
49 *
50 * This class is used to voxelize the world volume created in
51 * DetectorConstruction class. It works only if the world already exists:
52 * the constructor needs a pointer to DetectorConstruction.
53 *
54 * This class does not insert a further material, but uses the same
55 * material saved in DetectorConstruction class. It is responsible
56 * for the voxelization of the space and for the tracking of voxels
57 * index.
58 *
59 * Internally, the voxel volume, mass and density are updated every
60 * time something relevant changes in the geometry
61 *
62 * @note Although in this class the word \a "sensitive" appears,
63 * this is class is not an implementation of the sensitive detector,
64 * nevertheless it crates the environment for sensitiveness. It is
65 * meant to be similar to a DetectorConstruction class, providing
66 * voxelization of the world.
67 */
68
69class VoxelizedSensitiveDetector
70{
71 // This class has a 'singleton' structure
72
73 private:
74 /** @brief Private constructor using a pointer to
75 * DetectorConstruction and the three dimensions for one voxel */
76 VoxelizedSensitiveDetector(DetectorConstruction* det, double xWidth, double yWidth,
77 double zWidth);
79
80 public:
81 /** @brief Static method to retrieve a pointer
82 * to the only object existing in the simulation */
84
85 /** @brief Static method to create the pointer
86 * to the only object existing in the simulation
87 *
88 * @param det A pointer to the DetectorConstruction object
89 * @param xWidth X dimension of a single voxel
90 * @param yWidth Y dimension of a single voxel
91 * @param zWidth Z dimension of a single voxel
92 * */
94 double yWidth, double zWidth);
95
96 /** Destructor */
98
99 // Setting of parameters
100 /** @brief Method to set the voxel shape
101 * to be a box with given sides
102 *
103 * @param voxWidth ThreeVector containing the
104 * three-dimensionals sides for the voxel
105 */
106 void SetVoxelWidth(G4ThreeVector voxWidth);
107
108 /** @brief Method to set the voxel X width
109 *
110 * @param voxWidthX X width for the voxel
111 */
112 void SetVoxelWidthX(G4double voxWidthX);
113
114 /** @brief Method to set the voxel Y width
115 *
116 * @param voxWidthY Y width for the voxel
117 */
118 void SetVoxelWidthY(G4double voxWidthY);
119
120 /** @brief Method to set the voxel Z width
121 *
122 * @param voxWidthZ Z width for the voxel
123 */
124 void SetVoxelWidthZ(G4double voxWidthZ);
125
126 /** @brief Method to update voxelized geometry.
127 * If voxelized geometry is not built, it returns
128 * immediately.
129 * Otherwise, geometrical parameters are re-calculated and
130 * voxelized geometry is destroyed, de-registered
131 * and built once again from scratch.
132 *
133 */
135
136 // Initialize pointer to the world
137 // Should be called only from DetectorConstruction
138 /** @brief Method to properly initialize the pointer
139 * to the World physical volume. It is meant
140 * to be called **only** by DetectorConstruction
141 * itself.
142 *
143 * @param pWorld Pointer to the world physical volume
144 *
145 */
147
148 // 'Construct' methods
149 /** Method to construct all the volumes for the
150 * voxelization of the geometry. */
151 void Construct();
152
153 /** Method to make the proper volume
154 * sensitive to allow scoring. */
155 void ConstructSD();
156
157 // List of 'Get' methods
158 public:
159 /** Method to get the three vector
160 * containing the dimensions for the voxel */
161 G4ThreeVector GetVoxelWidth() const
162 {
163 return G4ThreeVector{fVoxelWidthX, fVoxelWidthY, fVoxelWidthZ};
164 }
165
166 /** Method to get X width of the voxel. */
167 G4double GetVoxelWidthX() const
168 {
169 return fVoxelWidthX;
170 }
171
172 /** Method to get Y width of the voxel. */
173 G4double GetVoxelWidthY() const
174 {
175 return fVoxelWidthY;
176 }
177
178 /** Method to get Z width of the voxel. */
179 G4double GetVoxelWidthZ() const
180 {
181 return fVoxelWidthZ;
182 }
183
184 /** Method to get total voxel volume. */
185 G4double GetVoxelVolume() const
186 {
187 return fVoxelVolume;
188 }
189
190 /** Method to get the voxel number along X axis. */
191 G4double GetVoxelNumberAlongX() const
192 {
193 return fVoxelNumberAlongX;
194 }
195
196 /** Method to get the voxel number along Y axis. */
197 G4double GetVoxelNumberAlongY() const
198 {
199 return fVoxelNumberAlongY;
200 }
201
202 /** Method to get the voxel number along Z axis. */
203 G4double GetVoxelNumberAlongZ() const
204 {
205 return fVoxelNumberAlongZ;
206 }
207
208 /** Method to get the total voxel number. */
210 {
211 return fTotalVoxelNumber;
212 }
213
214 /** Method to get the mass of a voxel.
215 *
216 * @note In this implementation, there is only
217 * one material for the whole simulation. This
218 * means that all the voxels (that already share the
219 * same shape and dimensions) also share the same
220 * mass and density
221 */
222 G4double GetVoxelMass() const
223 {
224 return fVoxelMass;
225 }
226
227 /** Method to get the density of a voxel.
228 *
229 * @note In this implementation, there is only
230 * one material for the whole simulation. This
231 * means that all the voxels (that already share the
232 * same shape and dimensions) also share the same
233 * mass and density
234 */
235 G4double GetVoxelDensity() const
236 {
237 return fVoxelDensity;
238 }
239
240 // To get the onedimensional voxel number given the three indexes
241 // This function will be used from other classes as well, and
242 // is defined only here for clarity purpose
243 /** Method to get the absolute voxel index given its
244 * indexes in the three dimensions.
245 *
246 * This helper function is heavily used throughout
247 * the simulation and is here because the voxelized
248 * detector is meant to know how many voxels there
249 * are and how they are ordered.
250 */
251 G4int GetThisVoxelNumber(G4int x, G4int j, G4int k) const;
252
253 private:
254 /** Private method to construct the voxelized
255 * detector
256 */
258
260
261 G4double fVoxelWidthX = -1.;
262 G4double fVoxelWidthY = -1.;
263 G4double fVoxelWidthZ = -1.;
264
265 G4double fVoxelVolume = -1.;
266
270
272 G4double fVoxelMass = 0.;
273 G4double fVoxelDensity = 0.;
274
275 // Voxelized objects
279
284
288
289 // Pointer to world
291
292 G4bool fIsBuilt = false;
293
294 /** Private method to calculate
295 * the total volume of a voxel given the
296 * parameters saved inside the object
297 */
298 void UpdateVoxelVolume();
299
300 /** Private method to calculate
301 * the total voxel number given the
302 * parameters saved inside the object
303 */
305
306 /** Private method to slice
307 * the world volume along the X
308 * axis.
309 */
310 void ConstructXDivision();
311
312 /** Private method to further slice
313 * the X slices along the Y
314 * axis, creating some "columns" of material.
315 */
316 void ConstructYDivision();
317
318 /** Private method to further slice
319 * the Y columns along the Z
320 * axis, creating some boxes of material.
321 *
322 * This is the final step for voxelization
323 * of space.
324 */
325 void ConstructZDivision();
326
328};
329
330} // namespace RadioBio
331
332#endif // VoxelizedSensitiveDetector_h
Mandatory class for the construction of geometry.
Singleton class performing the voxelization of the world volume and tracking of a voxel index given t...
void InitializeWorldPtr(G4VPhysicalVolume *pWorld)
Method to properly initialize the pointer to the World physical volume.
G4double GetVoxelWidthZ() const
Method to get Z width of the voxel.
static VoxelizedSensitiveDetector * GetInstance()
Static method to retrieve a pointer to the only object existing in the simulation.
G4double GetVoxelNumberAlongZ() const
Method to get the voxel number along Z axis.
G4bool ConstructVoxelizedDetector()
Private method to construct the voxelized detector.
G4int GetTotalVoxelNumber() const
Method to get the total voxel number.
void UpdateVoxelVolume()
Private method to calculate the total volume of a voxel given the parameters saved inside the object.
G4double GetVoxelWidthX() const
Method to get X width of the voxel.
VoxelizedSensitiveDetectorMessenger * fVoxelizedSensitiveDetectorMessenger
void ConstructSD()
Method to make the proper volume sensitive to allow scoring.
G4double GetVoxelNumberAlongX() const
Method to get the voxel number along X axis.
G4int GetThisVoxelNumber(G4int x, G4int j, G4int k) const
Method to get the absolute voxel index given its indexes in the three dimensions.
G4double GetVoxelMass() const
Method to get the mass of a voxel.
void SetVoxelWidthY(G4double voxWidthY)
Method to set the voxel Y width.
static VoxelizedSensitiveDetector * fInstance
void CalculateVoxelNumber()
Private method to calculate the total voxel number given the parameters saved inside the object.
static VoxelizedSensitiveDetector * CreateInstance(DetectorConstruction *det, double xWidth, double yWidth, double zWidth)
Static method to create the pointer to the only object existing in the simulation.
void ConstructZDivision()
Private method to further slice the Y columns along the Z axis, creating some boxes of material.
G4double GetVoxelNumberAlongY() const
Method to get the voxel number along Y axis.
VoxelizedSensitiveDetector(DetectorConstruction *det, double xWidth, double yWidth, double zWidth)
Private constructor using a pointer to DetectorConstruction and the three dimensions for one voxel.
void ConstructYDivision()
Private method to further slice the X slices along the Y axis, creating some "columns" of material.
void Construct()
Method to construct all the volumes for the voxelization of the geometry.
G4double GetVoxelVolume() const
Method to get total voxel volume.
void SetVoxelWidth(G4ThreeVector voxWidth)
Method to set the voxel shape to be a box with given sides.
void UpdateVoxelizedGeometry()
Method to update voxelized geometry.
void SetVoxelWidthX(G4double voxWidthX)
Method to set the voxel X width.
G4double GetVoxelWidthY() const
Method to get Y width of the voxel.
void SetVoxelWidthZ(G4double voxWidthZ)
Method to set the voxel Z width.
G4double GetVoxelDensity() const
Method to get the density of a voxel.
void ConstructXDivision()
Private method to slice the world volume along the X axis.
G4ThreeVector GetVoxelWidth() const
Method to get the three vector containing the dimensions for the voxel.

Applications | User Support | Publications | Collaboration