33#include "G4LogicalVolume.hh"
34#include "G4PVReplica.hh"
35#include "G4PhysicalVolumeStore.hh"
36#include "G4RunManager.hh"
37#include "G4SDManager.hh"
38#include "G4SystemOfUnits.hh"
39#include "G4TransportationManager.hh"
40#include "G4VPhysicalVolume.hh"
42#include "DetectorConstruction.hh"
56 double xWidth,
double yWidth,
61 G4Exception(
"VoxelizedSensitiveDetector::createInstance",
"RecreatingVoxelization",
62 FatalException,
"Creating another, new, instance of VoxelizedSensitiveDetector");
78 double yWidth,
double zWidth)
79 : fDetector(det), fVoxelWidthX(xWidth), fVoxelWidthY(yWidth), fVoxelWidthZ(zWidth)
155 G4Exception(
"VoxelizedSensitiveDetector::CalculateVoxelNumber",
"VoxelNumberYEven", JustWarning,
156 "Trying to voxelize with an even number of voxels along the Y axis."
157 "Please select an odd number to prevent from warnings due to tracking");
160 G4Exception(
"VoxelizedSensitiveDetector::CalculateVoxelNumber",
"VoxelNumberZEven", JustWarning,
161 "Trying to voxelize with an even number of voxels along the Z axis."
162 "Please select an odd number to prevent from warnings due to tracking");
174 G4Exception(
"VoxelizedSensitiveDetector::ConstructXDivision",
"WorldNotInit", FatalException,
175 "Voxelizing without having a pointer to world logical volume!");
178 G4Exception(
"VoxelizedSensitiveDetector::ConstructXDivision",
"DetConstInit", FatalException,
179 "Voxelizing without having a pointer to DetectorConstruction!");
186 "VoxelizedDetectorXDivisionLog", 0, 0, 0);
202 "VoxelizedDetectorYDivisionLog", 0, 0, 0);
218 "VoxelizedDetectorZDivisionLog", 0, 0, 0);
264 myVol = store->GetVolume(
"VoxelizedDetectorXDivisionPhys");
265 store->DeRegister(myVol);
266 myVol = store->GetVolume(
"VoxelizedDetectorYDivisionPhys");
267 store->DeRegister(myVol);
268 myVol = store->GetVolume(
"VoxelizedDetectorZDivisionPhys");
269 store->DeRegister(myVol);
282 G4RunManager::GetRunManager()->GeometryHasBeenModified();
283 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
290 G4String sensitiveDetectorName =
"VoxelizedDetector";
293 SD* detectorSD =
new SD(sensitiveDetectorName, HCname);
294 G4SDManager::GetSDMpointer()->AddNewDetector(detectorSD);
309 if (pWorld ==
nullptr)
310 G4Exception(
"VoxelizedSensitiveDetector::InitializeWorldPtr",
"WorldinitNull", FatalException,
311 "Initializing Voxelization Class with a Null Pointer to World!");
323 return z + nz * (y + ny * (x));
Definition of the RadioBio::SD class.
Definition of the RadioBio::VoxelizedSensitiveDetectorMessenger class.
Definition of the RadioBio::VoxelizedSensitiveDetector class.
Mandatory class for the construction of geometry.
G4double GetSizeX() const
G4double GetSizeY() const
G4double GetSizeZ() const
G4Material * GetMaterial()
Returns a pointer to the world material.
RadioBio sensitive detector class.
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.
G4VPhysicalVolume * fVoxelizedDetectorXDivisionPhys
G4VPhysicalVolume * fVoxelizedDetectorZDivisionPhys
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.
G4LogicalVolume * fSensitiveLogicalVolume
void UpdateVoxelVolume()
Private method to calculate the total volume of a voxel given the parameters saved inside the object.
G4Box * fVoxelizedDetectorZDivision
G4Box * fVoxelizedDetectorYDivision
VoxelizedSensitiveDetectorMessenger * fVoxelizedSensitiveDetectorMessenger
void ConstructSD()
Method to make the proper volume sensitive to allow scoring.
DetectorConstruction * fDetector
G4int GetThisVoxelNumber(G4int x, G4int j, G4int k) const
Method to get the absolute voxel index given its indexes in the three dimensions.
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.
~VoxelizedSensitiveDetector()
Destructor.
G4LogicalVolume * fWorldLogical
void ConstructYDivision()
Private method to further slice the X slices along the Y axis, creating some "columns" of material.
G4LogicalVolume * fVoxelizedDetectorXDivisionLog
void Construct()
Method to construct all the volumes for the voxelization of the geometry.
G4Box * fVoxelizedDetectorXDivision
G4VPhysicalVolume * fVoxelizedDetectorYDivisionPhys
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.
void SetVoxelWidthZ(G4double voxWidthZ)
Method to set the voxel Z width.
void ConstructXDivision()
Private method to slice the world volume along the X axis.
G4LogicalVolume * fVoxelizedDetectorYDivisionLog
G4LogicalVolume * fVoxelizedDetectorZDivisionLog