63 : motherPhys(physicalTreatmentRoom),
64 detectorSD(0), detectorROGeometry(0), matrix(0),
65 phantom(0), detector(0),
66 phantomLogicalVolume(0), detectorLogicalVolume(0),
67 phantomPhysicalVolume(0), detectorPhysicalVolume(0),
83 sizeOfVoxelAlongX = 200 *
um;
84 sizeOfVoxelAlongY = 4 *
cm;
85 sizeOfVoxelAlongZ = 4 *
cm;
104 delete detectorROGeometry;
106 delete detectorMessenger;
119 void HadrontherapyDetectorConstruction::ConstructPhantom()
122 phantom =
new G4Box(
"Phantom",
130 "phantomLog", 0, 0, 0);
136 phantomLogicalVolume,
143 red -> SetVisibility(
true);
144 red -> SetForceSolid(
true);
145 red -> SetForceWireframe(
true);
146 phantomLogicalVolume -> SetVisAttributes(red);
170 void HadrontherapyDetectorConstruction::ConstructDetector()
173 detector =
new G4Box(
"Detector",
187 detectorLogicalVolume,
188 phantomPhysicalVolume,
193 skyBlue -> SetVisibility(
true);
194 skyBlue -> SetForceSolid(
true);
196 detectorLogicalVolume -> SetVisAttributes(skyBlue);
206 aRegion =
new G4Region(
"DetectorLog");
207 detectorLogicalVolume -> SetRegion(aRegion);
208 aRegion -> AddRootLogicalVolume(detectorLogicalVolume);
216 detectorToWorldPosition)
222 numberOfVoxelsAlongX,
223 numberOfVoxelsAlongY,
224 numberOfVoxelsAlongZ);
228 void HadrontherapyDetectorConstruction::ParametersCheck()
237 detectorToPhantomPosition
239 G4Exception(
"HadrontherapyDetectorConstruction::ParametersCheck()",
"Hadrontherapy0001",
FatalException,
"Error: Detector is not fully inside Phantom!");
243 if ( detectorSizeX < sizeOfVoxelAlongX) {
244 G4Exception(
"HadrontherapyDetectorConstruction::ParametersCheck()",
"Hadrontherapy0002",
FatalException,
"Error: Detector X size must be bigger or equal than that of Voxel X!");
246 if ( detectorSizeY < sizeOfVoxelAlongY) {
247 G4Exception(
" HadrontherapyDetectorConstruction::ParametersCheck()",
"Hadrontherapy0003",
FatalException,
"Error: Detector Y size must be bigger or equal than that of Voxel Y!");
249 if ( detectorSizeZ < sizeOfVoxelAlongZ) {
250 G4Exception(
" HadrontherapyDetectorConstruction::ParametersCheck()",
"Hadrontherapy0004",
FatalException,
"Error: Detector Z size must be bigger or equal than that of Voxel Z!");
260 phantomMaterial = pMat;
261 detectorMaterial = pMat;
262 if (detectorLogicalVolume && phantomLogicalVolume)
269 G4cout <<
"The material of Phantom/Detector has been changed to " << material <<
G4endl;
274 G4cout <<
"WARNING: material \"" << material <<
"\" doesn't exist in NIST elements/materials"
275 " table [located in $G4INSTALL/source/materials/src/G4NistMaterialBuilder.cc]" <<
G4endl;
276 G4cout <<
"Use command \"/parameter/nist\" to see full materials list!" <<
G4endl;
285 if (sizeX > 0.) phantomSizeX = sizeX;
286 if (sizeY > 0.) phantomSizeY = sizeY;
287 if (sizeZ > 0.) phantomSizeZ = sizeZ;
293 if (sizeX > 0.) {detectorSizeX = sizeX;}
294 if (sizeY > 0.) {detectorSizeY = sizeY;}
295 if (sizeZ > 0.) {detectorSizeZ = sizeZ;}
296 SetVoxelSize(sizeOfVoxelAlongX, sizeOfVoxelAlongY, sizeOfVoxelAlongZ);
302 if (sizeX > 0.) {sizeOfVoxelAlongX = sizeX;}
303 if (sizeY > 0.) {sizeOfVoxelAlongY = sizeY;}
304 if (sizeZ > 0.) {sizeOfVoxelAlongZ = sizeZ;}
310 phantomPosition =
pos;
316 detectorToPhantomPosition = displ;
330 phantom -> SetXHalfLength(phantomSizeX/2);
331 phantom -> SetYHalfLength(phantomSizeY/2);
332 phantom -> SetZHalfLength(phantomSizeZ/2);
333 phantomPhysicalVolume -> SetTranslation(phantomPosition);
335 else ConstructPhantom();
341 detector -> SetXHalfLength(detectorSizeX/2);
342 detector -> SetYHalfLength(detectorSizeY/2);
343 detector -> SetZHalfLength(detectorSizeZ/2);
344 detectorPhysicalVolume -> SetTranslation(detectorPosition);
346 else ConstructDetector();
350 numberOfVoxelsAlongX =
G4lrint(detectorSizeX / sizeOfVoxelAlongX);
351 sizeOfVoxelAlongX = ( detectorSizeX / numberOfVoxelsAlongX );
352 numberOfVoxelsAlongY =
G4lrint(detectorSizeY / sizeOfVoxelAlongY);
353 sizeOfVoxelAlongY = ( detectorSizeY / numberOfVoxelsAlongY );
354 numberOfVoxelsAlongZ =
G4lrint(detectorSizeZ / sizeOfVoxelAlongZ);
355 sizeOfVoxelAlongZ = ( detectorSizeZ / numberOfVoxelsAlongZ );
367 numberOfVoxelsAlongX,
368 numberOfVoxelsAlongY,
369 numberOfVoxelsAlongZ);
376 volumeOfVoxel = sizeOfVoxelAlongX * sizeOfVoxelAlongY * sizeOfVoxelAlongZ;
377 massOfVoxel = detectorMaterial -> GetDensity() * volumeOfVoxel;
380 numberOfVoxelsAlongY,
381 numberOfVoxelsAlongZ,
394 #ifdef G4ANALYSIS_USE_ROOT
410 void HadrontherapyDetectorConstruction::CheckOverlaps()
413 G4cout << thePVStore->size() <<
" physical volumes are defined" <<
G4endl;
414 G4bool overlapFlag =
false;
417 for (
size_t i=0;i<thePVStore->size();i++)
420 overlapFlag = (*thePVStore)[i]->CheckOverlaps(res,tol,
true) | overlapFlag; }
422 G4cout <<
"Check: there are overlapping volumes" <<
G4endl;
429 G4cout <<
"The (X,Y,Z) dimensions of the phantom are : (" <<
430 G4BestUnit( phantom -> GetXHalfLength()*2.,
"Length") <<
',' <<
431 G4BestUnit( phantom -> GetYHalfLength()*2.,
"Length") <<
',' <<
434 G4cout <<
"The (X,Y,Z) dimensions of the detector are : (" <<
435 G4BestUnit( detector -> GetXHalfLength()*2.,
"Length") <<
',' <<
436 G4BestUnit( detector -> GetYHalfLength()*2.,
"Length") <<
',' <<
439 G4cout <<
"Displacement between Phantom and World is: ";
444 G4cout <<
"The (X,Y,Z) sizes of the Voxels are: (" <<
445 G4BestUnit(sizeOfVoxelAlongX,
"Length") <<
',' <<
446 G4BestUnit(sizeOfVoxelAlongY,
"Length") <<
',' <<
449 G4cout <<
"The number of Voxels along (X,Y,Z) is: (" <<
450 numberOfVoxelsAlongX <<
',' <<
451 numberOfVoxelsAlongY <<
',' <<
452 numberOfVoxelsAlongZ <<
')' <<
G4endl;
static HadrontherapyAnalysisManager * GetInstance()
void SetPhantomSize(G4double sizeX, G4double sizeY, G4double sizeZ)
G4VPhysicalVolume * motherPhys
CLHEP::Hep3Vector G4ThreeVector
static HadrontherapyLet * GetInstance()
const G4VUserDetectorConstruction * GetUserDetectorConstruction() const
void Initialize(G4ThreeVector detectorPos, G4double detectorDimX, G4double detectorDimY, G4double detectorDimZ, G4int numberOfVoxelsX, G4int numberOfVoxelsY, G4int numberOfVoxelsZ)
HadrontherapyDetectorConstruction(G4VPhysicalVolume *)
static HadrontherapyDetectorConstruction * GetInstance()
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void SetDetectorSize(G4double sizeX, G4double sizeY, G4double sizeZ)
static G4NistManager * Instance()
static G4PhysicalVolumeStore * GetInstance()
static HadrontherapyMatrix * GetInstance()
G4GLOB_DLL std::ostream G4cout
static constexpr double um
void SetPhantomPosition(G4ThreeVector)
static constexpr double cm
void SetDetectorToPhantomPosition(G4ThreeVector DetectorToPhantomPosition)
bool IsInside(G4double detectorX, G4double detectorY, G4double detectorZ, G4double phantomX, G4double phantomY, G4double phantomZ, G4ThreeVector pos)
G4bool SetPhantomMaterial(G4String material)
G4VUserParallelWorld * GetParallelWorld(G4int i) const
static G4GeometryManager * GetInstance()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void SetDetectorPosition()
static G4RunManager * GetRunManager()
void InitializeDetectorROGeometry(HadrontherapyDetectorROGeometry *, G4ThreeVector detectorToWorldPosition)
void SetVoxelSize(G4double sizeX, G4double sizeY, G4double sizeZ)
G4ThreeVector GetDetectorToWorldPosition()
~HadrontherapyDetectorConstruction()
static const G4double pos