Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/extended/medical/radiobiology/src/VoxelizedSensitiveDetector.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/medical/radiobiology/src/VoxelizedSensitiveDetector.cc (Version 11.3.0) and /examples/extended/medical/radiobiology/src/VoxelizedSensitiveDetector.cc (Version 11.2.2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
 27 /// \file radiobiology/src/VoxelizedSensitiveD     27 /// \file radiobiology/src/VoxelizedSensitiveDetector.cc
 28 /// \brief Implementation of the RadioBio::Vox     28 /// \brief Implementation of the RadioBio::VoxelizedSensitiveDetector class
 29                                                    29 
 30 #include "VoxelizedSensitiveDetector.hh"           30 #include "VoxelizedSensitiveDetector.hh"
 31                                                    31 
 32 #include "G4Box.hh"                                32 #include "G4Box.hh"
 33 #include "G4LogicalVolume.hh"                      33 #include "G4LogicalVolume.hh"
 34 #include "G4PVReplica.hh"                          34 #include "G4PVReplica.hh"
 35 #include "G4PhysicalVolumeStore.hh"                35 #include "G4PhysicalVolumeStore.hh"
 36 #include "G4RunManager.hh"                         36 #include "G4RunManager.hh"
 37 #include "G4SDManager.hh"                          37 #include "G4SDManager.hh"
 38 #include "G4SystemOfUnits.hh"                      38 #include "G4SystemOfUnits.hh"
 39 #include "G4TransportationManager.hh"              39 #include "G4TransportationManager.hh"
 40 #include "G4VPhysicalVolume.hh"                    40 #include "G4VPhysicalVolume.hh"
 41                                                    41 
 42 #include "DetectorConstruction.hh"                 42 #include "DetectorConstruction.hh"
 43 #include "SD.hh"                                   43 #include "SD.hh"
 44 #include "VoxelizedSensitiveDetectorMessenger.     44 #include "VoxelizedSensitiveDetectorMessenger.hh"
 45                                                    45 
 46 namespace RadioBio                                 46 namespace RadioBio
 47 {                                                  47 {
 48                                                    48 
 49 //....oooOO0OOooo........oooOO0OOooo........oo     49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 50                                                    50 
 51 VoxelizedSensitiveDetector* VoxelizedSensitive     51 VoxelizedSensitiveDetector* VoxelizedSensitiveDetector::fInstance = nullptr;
 52                                                    52 
 53 //....oooOO0OOooo........oooOO0OOooo........oo     53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 54                                                    54 
 55 VoxelizedSensitiveDetector* VoxelizedSensitive     55 VoxelizedSensitiveDetector* VoxelizedSensitiveDetector::CreateInstance(DetectorConstruction* det,
 56                                                    56                                                                        double xWidth, double yWidth,
 57                                                    57                                                                        double zWidth)
 58 {                                                  58 {
 59   if (fInstance) {                                 59   if (fInstance) {
 60     delete fInstance;                              60     delete fInstance;
 61     G4Exception("VoxelizedSensitiveDetector::c     61     G4Exception("VoxelizedSensitiveDetector::createInstance", "RecreatingVoxelization",
 62                 FatalException, "Creating anot     62                 FatalException, "Creating another, new, instance of VoxelizedSensitiveDetector");
 63   }                                                63   }
 64   fInstance = new VoxelizedSensitiveDetector(d     64   fInstance = new VoxelizedSensitiveDetector(det, xWidth, yWidth, zWidth);
 65   return fInstance;                                65   return fInstance;
 66 }                                                  66 }
 67                                                    67 
 68 //....oooOO0OOooo........oooOO0OOooo........oo     68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 69                                                    69 
 70 VoxelizedSensitiveDetector* VoxelizedSensitive     70 VoxelizedSensitiveDetector* VoxelizedSensitiveDetector::GetInstance()
 71 {                                                  71 {
 72   return fInstance;                                72   return fInstance;
 73 }                                                  73 }
 74                                                    74 
 75 //....oooOO0OOooo........oooOO0OOooo........oo     75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 76                                                    76 
 77 VoxelizedSensitiveDetector::VoxelizedSensitive     77 VoxelizedSensitiveDetector::VoxelizedSensitiveDetector(DetectorConstruction* det, double xWidth,
 78                                                    78                                                        double yWidth, double zWidth)
 79   : fDetector(det), fVoxelWidthX(xWidth), fVox     79   : fDetector(det), fVoxelWidthX(xWidth), fVoxelWidthY(yWidth), fVoxelWidthZ(zWidth)
 80 {                                                  80 {
 81   fVoxelizedSensitiveDetectorMessenger = new V     81   fVoxelizedSensitiveDetectorMessenger = new VoxelizedSensitiveDetectorMessenger(this);
 82   UpdateVoxelVolume();                             82   UpdateVoxelVolume();
 83   CalculateVoxelNumber();                          83   CalculateVoxelNumber();
 84 }                                                  84 }
 85                                                    85 
 86 //....oooOO0OOooo........oooOO0OOooo........oo     86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 87                                                    87 
 88 VoxelizedSensitiveDetector::~VoxelizedSensitiv     88 VoxelizedSensitiveDetector::~VoxelizedSensitiveDetector()
 89 {                                                  89 {
 90   delete fVoxelizedSensitiveDetectorMessenger;     90   delete fVoxelizedSensitiveDetectorMessenger;
 91 }                                                  91 }
 92                                                    92 
 93 //....oooOO0OOooo........oooOO0OOooo........oo     93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 94                                                    94 
 95 void VoxelizedSensitiveDetector::UpdateVoxelVo     95 void VoxelizedSensitiveDetector::UpdateVoxelVolume()
 96 {                                                  96 {
 97   fVoxelVolume = fVoxelWidthX * fVoxelWidthY *     97   fVoxelVolume = fVoxelWidthX * fVoxelWidthY * fVoxelWidthZ;
 98   fVoxelDensity = fDetector->GetMaterial()->Ge     98   fVoxelDensity = fDetector->GetMaterial()->GetDensity();
 99   fVoxelMass = fVoxelVolume * fVoxelDensity;       99   fVoxelMass = fVoxelVolume * fVoxelDensity;
100 }                                                 100 }
101                                                   101 
102 //....oooOO0OOooo........oooOO0OOooo........oo    102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
103                                                   103 
104 void VoxelizedSensitiveDetector::SetVoxelWidth    104 void VoxelizedSensitiveDetector::SetVoxelWidth(G4ThreeVector voxWidth)
105 {                                                 105 {
106   fVoxelWidthX = voxWidth.getX();                 106   fVoxelWidthX = voxWidth.getX();
107   fVoxelWidthY = voxWidth.getY();                 107   fVoxelWidthY = voxWidth.getY();
108   fVoxelWidthZ = voxWidth.getZ();                 108   fVoxelWidthZ = voxWidth.getZ();
109   CalculateVoxelNumber();                         109   CalculateVoxelNumber();
110 }                                                 110 }
111                                                   111 
112 //....oooOO0OOooo........oooOO0OOooo........oo    112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
113                                                   113 
114 void VoxelizedSensitiveDetector::SetVoxelWidth    114 void VoxelizedSensitiveDetector::SetVoxelWidthX(G4double voxWidthX)
115 {                                                 115 {
116   if (fVoxelWidthX == voxWidthX) return;          116   if (fVoxelWidthX == voxWidthX) return;
117   fVoxelWidthX = voxWidthX;                       117   fVoxelWidthX = voxWidthX;
118   CalculateVoxelNumber();                         118   CalculateVoxelNumber();
119 }                                                 119 }
120                                                   120 
121 //....oooOO0OOooo........oooOO0OOooo........oo    121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
122                                                   122 
123 void VoxelizedSensitiveDetector::SetVoxelWidth    123 void VoxelizedSensitiveDetector::SetVoxelWidthY(G4double voxWidthY)
124 {                                                 124 {
125   if (fVoxelWidthY == voxWidthY) return;          125   if (fVoxelWidthY == voxWidthY) return;
126   fVoxelWidthY = voxWidthY;                       126   fVoxelWidthY = voxWidthY;
127   CalculateVoxelNumber();                         127   CalculateVoxelNumber();
128 }                                                 128 }
129                                                   129 
130 //....oooOO0OOooo........oooOO0OOooo........oo    130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
131                                                   131 
132 void VoxelizedSensitiveDetector::SetVoxelWidth    132 void VoxelizedSensitiveDetector::SetVoxelWidthZ(G4double voxWidthZ)
133 {                                                 133 {
134   if (fVoxelWidthZ == voxWidthZ) return;          134   if (fVoxelWidthZ == voxWidthZ) return;
135   fVoxelWidthZ = voxWidthZ;                       135   fVoxelWidthZ = voxWidthZ;
136   CalculateVoxelNumber();                         136   CalculateVoxelNumber();
137 }                                                 137 }
138                                                   138 
139 //....oooOO0OOooo........oooOO0OOooo........oo    139 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
140                                                   140 
141 // Calculte number of voxel approximating for     141 // Calculte number of voxel approximating for an integer number of voxels
142 // Then recalculates voxels size according to     142 // Then recalculates voxels size according to approximations
143 void VoxelizedSensitiveDetector::CalculateVoxe    143 void VoxelizedSensitiveDetector::CalculateVoxelNumber()
144 {                                                 144 {
145   fVoxelNumberAlongX = G4int(fDetector->GetSiz    145   fVoxelNumberAlongX = G4int(fDetector->GetSizeX() / fVoxelWidthX);
146   fVoxelWidthX = fDetector->GetSizeX() / G4dou    146   fVoxelWidthX = fDetector->GetSizeX() / G4double(fVoxelNumberAlongX);
147                                                   147 
148   fVoxelNumberAlongY = G4int(fDetector->GetSiz    148   fVoxelNumberAlongY = G4int(fDetector->GetSizeY() / fVoxelWidthY);
149   fVoxelWidthY = fDetector->GetSizeY() / G4dou    149   fVoxelWidthY = fDetector->GetSizeY() / G4double(fVoxelNumberAlongY);
150                                                   150 
151   fVoxelNumberAlongZ = G4int(fDetector->GetSiz    151   fVoxelNumberAlongZ = G4int(fDetector->GetSizeZ() / fVoxelWidthZ);
152   fVoxelWidthZ = fDetector->GetSizeZ() / G4dou    152   fVoxelWidthZ = fDetector->GetSizeZ() / G4double(fVoxelNumberAlongZ);
153                                                   153 
154   if (fVoxelNumberAlongY % 2 == 0)                154   if (fVoxelNumberAlongY % 2 == 0)
155     G4Exception("VoxelizedSensitiveDetector::C    155     G4Exception("VoxelizedSensitiveDetector::CalculateVoxelNumber", "VoxelNumberYEven", JustWarning,
156                 "Trying to voxelize with an ev    156                 "Trying to voxelize with an even number of voxels along the Y axis."
157                 "Please select an odd number t    157                 "Please select an odd number to prevent from warnings due to tracking");
158                                                   158 
159   if (fVoxelNumberAlongZ % 2 == 0)                159   if (fVoxelNumberAlongZ % 2 == 0)
160     G4Exception("VoxelizedSensitiveDetector::C    160     G4Exception("VoxelizedSensitiveDetector::CalculateVoxelNumber", "VoxelNumberZEven", JustWarning,
161                 "Trying to voxelize with an ev    161                 "Trying to voxelize with an even number of voxels along the Z axis."
162                 "Please select an odd number t    162                 "Please select an odd number to prevent from warnings due to tracking");
163                                                   163 
164   fTotalVoxelNumber = fVoxelNumberAlongX * fVo    164   fTotalVoxelNumber = fVoxelNumberAlongX * fVoxelNumberAlongY * fVoxelNumberAlongZ;
165                                                   165 
166   UpdateVoxelVolume();                            166   UpdateVoxelVolume();
167 }                                                 167 }
168                                                   168 
169 //....oooOO0OOooo........oooOO0OOooo........oo    169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
170                                                   170 
171 void VoxelizedSensitiveDetector::ConstructXDiv    171 void VoxelizedSensitiveDetector::ConstructXDivision()
172 {                                                 172 {
173   if (fWorldLogical == nullptr)                   173   if (fWorldLogical == nullptr)
174     G4Exception("VoxelizedSensitiveDetector::C    174     G4Exception("VoxelizedSensitiveDetector::ConstructXDivision", "WorldNotInit", FatalException,
175                 "Voxelizing without having a p    175                 "Voxelizing without having a pointer to world logical volume!");
176                                                   176 
177   if (!fDetector)                                 177   if (!fDetector)
178     G4Exception("VoxelizedSensitiveDetector::C    178     G4Exception("VoxelizedSensitiveDetector::ConstructXDivision", "DetConstInit", FatalException,
179                 "Voxelizing without having a p    179                 "Voxelizing without having a pointer to DetectorConstruction!");
180                                                   180 
181   fVoxelizedDetectorXDivision = new G4Box("Vox    181   fVoxelizedDetectorXDivision = new G4Box("VoxelizedDetectorXDivision", fVoxelWidthX / 2,
182                                           fDet    182                                           fDetector->GetSizeY() / 2, fDetector->GetSizeZ() / 2);
183                                                   183 
184   fVoxelizedDetectorXDivisionLog =                184   fVoxelizedDetectorXDivisionLog =
185     new G4LogicalVolume(fVoxelizedDetectorXDiv    185     new G4LogicalVolume(fVoxelizedDetectorXDivision, fWorldLogical->GetMaterial(),
186                         "VoxelizedDetectorXDiv    186                         "VoxelizedDetectorXDivisionLog", 0, 0, 0);
187                                                   187 
188   fVoxelizedDetectorXDivisionPhys =               188   fVoxelizedDetectorXDivisionPhys =
189     new G4PVReplica("VoxelizedDetectorXDivisio    189     new G4PVReplica("VoxelizedDetectorXDivisionPhys", fVoxelizedDetectorXDivisionLog, fWorldLogical,
190                     kXAxis, fVoxelNumberAlongX    190                     kXAxis, fVoxelNumberAlongX, fVoxelWidthX);
191 }                                                 191 }
192                                                   192 
193 //....oooOO0OOooo........oooOO0OOooo........oo    193 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
194                                                   194 
195 void VoxelizedSensitiveDetector::ConstructYDiv    195 void VoxelizedSensitiveDetector::ConstructYDivision()
196 {                                                 196 {
197   fVoxelizedDetectorYDivision = new G4Box("Vox    197   fVoxelizedDetectorYDivision = new G4Box("VoxelizedDetectorYDivision", fVoxelWidthX / 2,
198                                           fVox    198                                           fVoxelWidthY / 2, fDetector->GetSizeZ() / 2);
199                                                   199 
200   fVoxelizedDetectorYDivisionLog =                200   fVoxelizedDetectorYDivisionLog =
201     new G4LogicalVolume(fVoxelizedDetectorYDiv    201     new G4LogicalVolume(fVoxelizedDetectorYDivision, fWorldLogical->GetMaterial(),
202                         "VoxelizedDetectorYDiv    202                         "VoxelizedDetectorYDivisionLog", 0, 0, 0);
203                                                   203 
204   fVoxelizedDetectorYDivisionPhys =               204   fVoxelizedDetectorYDivisionPhys =
205     new G4PVReplica("VoxelizedDetectorYDivisio    205     new G4PVReplica("VoxelizedDetectorYDivisionPhys", fVoxelizedDetectorYDivisionLog,
206                     fVoxelizedDetectorXDivisio    206                     fVoxelizedDetectorXDivisionLog, kYAxis, fVoxelNumberAlongY, fVoxelWidthY);
207 }                                                 207 }
208                                                   208 
209 //....oooOO0OOooo........oooOO0OOooo........oo    209 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
210                                                   210 
211 void VoxelizedSensitiveDetector::ConstructZDiv    211 void VoxelizedSensitiveDetector::ConstructZDivision()
212 {                                                 212 {
213   fVoxelizedDetectorZDivision =                   213   fVoxelizedDetectorZDivision =
214     new G4Box("VoxelizedDetectorZDivision", fV    214     new G4Box("VoxelizedDetectorZDivision", fVoxelWidthX / 2, fVoxelWidthY / 2, fVoxelWidthZ / 2);
215                                                   215 
216   fVoxelizedDetectorZDivisionLog =                216   fVoxelizedDetectorZDivisionLog =
217     new G4LogicalVolume(fVoxelizedDetectorZDiv    217     new G4LogicalVolume(fVoxelizedDetectorZDivision, fWorldLogical->GetMaterial(),
218                         "VoxelizedDetectorZDiv    218                         "VoxelizedDetectorZDivisionLog", 0, 0, 0);
219                                                   219 
220   fVoxelizedDetectorZDivisionPhys =               220   fVoxelizedDetectorZDivisionPhys =
221     new G4PVReplica("VoxelizedDetectorZDivisio    221     new G4PVReplica("VoxelizedDetectorZDivisionPhys", fVoxelizedDetectorZDivisionLog,
222                     fVoxelizedDetectorYDivisio    222                     fVoxelizedDetectorYDivisionPhys, kZAxis, fVoxelNumberAlongZ, fVoxelWidthZ);
223                                                   223 
224   fSensitiveLogicalVolume = fVoxelizedDetector    224   fSensitiveLogicalVolume = fVoxelizedDetectorZDivisionLog;
225 }                                                 225 }
226                                                   226 
227 //....oooOO0OOooo........oooOO0OOooo........oo    227 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
228                                                   228 
229 // First voxelize along X, then Y, then Z         229 // First voxelize along X, then Y, then Z
230 G4bool VoxelizedSensitiveDetector::ConstructVo    230 G4bool VoxelizedSensitiveDetector::ConstructVoxelizedDetector()
231 {                                                 231 {
232   // Creating X division                          232   // Creating X division
233   ConstructXDivision();                           233   ConstructXDivision();
234                                                   234 
235   // Creating Y division                          235   // Creating Y division
236   ConstructYDivision();                           236   ConstructYDivision();
237                                                   237 
238   // Creating Z division                          238   // Creating Z division
239   ConstructZDivision();                           239   ConstructZDivision();
240                                                   240 
241   // Set last, smallest volumes as sensitive      241   // Set last, smallest volumes as sensitive
242   fSensitiveLogicalVolume = fVoxelizedDetector    242   fSensitiveLogicalVolume = fVoxelizedDetectorZDivisionLog;
243   fIsBuilt = true;                                243   fIsBuilt = true;
244                                                   244 
245   return true;                                    245   return true;
246 }                                                 246 }
247                                                   247 
248 //....oooOO0OOooo........oooOO0OOooo........oo    248 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
249                                                   249 
250 void VoxelizedSensitiveDetector::UpdateVoxeliz    250 void VoxelizedSensitiveDetector::UpdateVoxelizedGeometry()
251 {                                                 251 {
252   // Nothing happens if the voxelized geometry    252   // Nothing happens if the voxelized geometry is not built. But parameters are properly set.
253   if (!fIsBuilt) {                                253   if (!fIsBuilt) {
254     return;                                       254     return;
255   }                                               255   }
256                                                   256 
257   CalculateVoxelNumber();                         257   CalculateVoxelNumber();
258                                                   258 
259   // Volume that will be deleted in order to u    259   // Volume that will be deleted in order to update
260   G4VPhysicalVolume* myVol;                       260   G4VPhysicalVolume* myVol;
261                                                   261 
262   G4PhysicalVolumeStore* store = G4PhysicalVol    262   G4PhysicalVolumeStore* store = G4PhysicalVolumeStore::GetInstance();
263                                                   263 
264   myVol = store->GetVolume("VoxelizedDetectorX    264   myVol = store->GetVolume("VoxelizedDetectorXDivisionPhys");
265   store->DeRegister(myVol);                       265   store->DeRegister(myVol);
266   myVol = store->GetVolume("VoxelizedDetectorY    266   myVol = store->GetVolume("VoxelizedDetectorYDivisionPhys");
267   store->DeRegister(myVol);                       267   store->DeRegister(myVol);
268   myVol = store->GetVolume("VoxelizedDetectorZ    268   myVol = store->GetVolume("VoxelizedDetectorZDivisionPhys");
269   store->DeRegister(myVol);                       269   store->DeRegister(myVol);
270   fVoxelizedDetectorXDivisionPhys =               270   fVoxelizedDetectorXDivisionPhys =
271     new G4PVReplica("VoxelizedDetectorXDivisio    271     new G4PVReplica("VoxelizedDetectorXDivisionPhys", fVoxelizedDetectorXDivisionLog, fWorldLogical,
272                     kXAxis, fVoxelNumberAlongX    272                     kXAxis, fVoxelNumberAlongX, fVoxelWidthX);
273                                                   273 
274   fVoxelizedDetectorYDivisionPhys =               274   fVoxelizedDetectorYDivisionPhys =
275     new G4PVReplica("VoxelizedDetectorYDivisio    275     new G4PVReplica("VoxelizedDetectorYDivisionPhys", fVoxelizedDetectorYDivisionLog,
276                     fVoxelizedDetectorXDivisio    276                     fVoxelizedDetectorXDivisionPhys, kYAxis, fVoxelNumberAlongY, fVoxelWidthY);
277                                                   277 
278   fVoxelizedDetectorZDivisionPhys =               278   fVoxelizedDetectorZDivisionPhys =
279     new G4PVReplica("VoxelizedDetectorZDivisio    279     new G4PVReplica("VoxelizedDetectorZDivisionPhys", fVoxelizedDetectorZDivisionLog,
280                     fVoxelizedDetectorYDivisio    280                     fVoxelizedDetectorYDivisionPhys, kZAxis, fVoxelNumberAlongZ, fVoxelWidthZ);
281                                                   281 
282   G4RunManager::GetRunManager()->GeometryHasBe    282   G4RunManager::GetRunManager()->GeometryHasBeenModified();
283   G4RunManager::GetRunManager()->PhysicsHasBee    283   G4RunManager::GetRunManager()->PhysicsHasBeenModified();
284 }                                                 284 }
285                                                   285 
286 //....oooOO0OOooo........oooOO0OOooo........oo    286 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
287                                                   287 
288 void VoxelizedSensitiveDetector::ConstructSD()    288 void VoxelizedSensitiveDetector::ConstructSD()
289 {                                                 289 {
290   G4String sensitiveDetectorName = "VoxelizedD    290   G4String sensitiveDetectorName = "VoxelizedDetector";
291   G4String HCname = "LETdata";                    291   G4String HCname = "LETdata";
292                                                   292 
293   SD* detectorSD = new SD(sensitiveDetectorNam    293   SD* detectorSD = new SD(sensitiveDetectorName, HCname);
294   G4SDManager::GetSDMpointer()->AddNewDetector    294   G4SDManager::GetSDMpointer()->AddNewDetector(detectorSD);
295   fSensitiveLogicalVolume->SetSensitiveDetecto    295   fSensitiveLogicalVolume->SetSensitiveDetector(detectorSD);
296 }                                                 296 }
297                                                   297 
298 //....oooOO0OOooo........oooOO0OOooo........oo    298 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
299                                                   299 
300 void VoxelizedSensitiveDetector::Construct()      300 void VoxelizedSensitiveDetector::Construct()
301 {                                                 301 {
302   ConstructVoxelizedDetector();                   302   ConstructVoxelizedDetector();
303 }                                                 303 }
304                                                   304 
305 //....oooOO0OOooo........oooOO0OOooo........oo    305 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
306                                                   306 
307 void VoxelizedSensitiveDetector::InitializeWor    307 void VoxelizedSensitiveDetector::InitializeWorldPtr(G4VPhysicalVolume* pWorld)
308 {                                                 308 {
309   if (pWorld == nullptr)                          309   if (pWorld == nullptr)
310     G4Exception("VoxelizedSensitiveDetector::I    310     G4Exception("VoxelizedSensitiveDetector::InitializeWorldPtr", "WorldinitNull", FatalException,
311                 "Initializing Voxelization Cla    311                 "Initializing Voxelization Class with a Null Pointer to World!");
312   fWorldLogical = pWorld->GetLogicalVolume();     312   fWorldLogical = pWorld->GetLogicalVolume();
313 }                                                 313 }
314                                                   314 
315 //....oooOO0OOooo........oooOO0OOooo........oo    315 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
316                                                   316 
317 // Returns absolute voxel index given matrix i    317 // Returns absolute voxel index given matrix indexes
318 G4int VoxelizedSensitiveDetector::GetThisVoxel    318 G4int VoxelizedSensitiveDetector::GetThisVoxelNumber(G4int x, G4int y, G4int z) const
319 {                                                 319 {
320   G4int nz = GetVoxelNumberAlongZ();              320   G4int nz = GetVoxelNumberAlongZ();
321   G4int ny = GetVoxelNumberAlongY();              321   G4int ny = GetVoxelNumberAlongY();
322                                                   322 
323   return z + nz * (y + ny * (x));                 323   return z + nz * (y + ny * (x));
324 }                                                 324 }
325                                                   325 
326 //....oooOO0OOooo........oooOO0OOooo........oo    326 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
327                                                   327 
328 }  // namespace RadioBio                          328 }  // namespace RadioBio
329                                                   329