71 : motherPhys(physicalTreatmentRoom),
72 detectorSD(0), detectorROGeometry(0), matrix(0),
73 phantom(0), detector(0),
74 phantomLogicalVolume(0), detectorLogicalVolume(0),
75 phantomPhysicalVolume(0), detectorPhysicalVolume(0),
91 sizeOfVoxelAlongX = 200 *um;
92 sizeOfVoxelAlongY = 4 *
cm;
93 sizeOfVoxelAlongZ = 4 *
cm;
113 delete detectorROGeometry;
115 delete detectorMessenger;
131 void HadrontherapyDetectorConstruction::ConstructPhantom()
134 phantom =
new G4Box(
"Phantom",
142 "phantomLog", 0, 0, 0);
148 phantomLogicalVolume,
155 red -> SetVisibility(
true);
156 red -> SetForceSolid(
true);
157 red -> SetForceWireframe(
true);
158 phantomLogicalVolume -> SetVisAttributes(red);
183 void HadrontherapyDetectorConstruction::ConstructDetector()
187 detector =
new G4Box(
"Detector",
201 detectorLogicalVolume,
202 phantomPhysicalVolume,
207 skyBlue -> SetVisibility(
true);
208 skyBlue -> SetForceSolid(
true);
210 detectorLogicalVolume -> SetVisAttributes(skyBlue);
220 aRegion =
new G4Region(
"DetectorLog");
221 detectorLogicalVolume -> SetRegion(aRegion);
222 aRegion -> AddRootLogicalVolume(detectorLogicalVolume);
233 detectorToWorldPosition)
239 numberOfVoxelsAlongX,
240 numberOfVoxelsAlongY,
241 numberOfVoxelsAlongZ);
250 void HadrontherapyDetectorConstruction::ParametersCheck()
259 detectorToPhantomPosition
261 G4Exception(
"HadrontherapyDetectorConstruction::ParametersCheck()",
"Hadrontherapy0001",
FatalException,
"Error: Detector is not fully inside Phantom!");
265 if ( detectorSizeX < sizeOfVoxelAlongX) {
266 G4Exception(
"HadrontherapyDetectorConstruction::ParametersCheck()",
"Hadrontherapy0002",
FatalException,
"Error: Detector X size must be bigger or equal than that of Voxel X!");
268 if ( detectorSizeY < sizeOfVoxelAlongY) {
269 G4Exception(
" HadrontherapyDetectorConstruction::ParametersCheck()",
"Hadrontherapy0003",
FatalException,
"Error: Detector Y size must be bigger or equal than that of Voxel Y!");
271 if ( detectorSizeZ < sizeOfVoxelAlongZ) {
272 G4Exception(
" HadrontherapyDetectorConstruction::ParametersCheck()",
"Hadrontherapy0004",
FatalException,
"Error: Detector Z size must be bigger or equal than that of Voxel Z!");
285 phantomMaterial = pMat;
286 detectorMaterial = pMat;
287 if (detectorLogicalVolume && phantomLogicalVolume)
294 G4cout <<
"The material of Phantom/Detector has been changed to " << material <<
G4endl;
299 G4cout <<
"WARNING: material \"" << material <<
"\" doesn't exist in NIST elements/materials"
300 " table [located in $G4INSTALL/source/materials/src/G4NistMaterialBuilder.cc]" <<
G4endl;
301 G4cout <<
"Use command \"/parameter/nist\" to see full materials list!" <<
G4endl;
310 if (sizeX > 0.) phantomSizeX = sizeX;
311 if (sizeY > 0.) phantomSizeY = sizeY;
312 if (sizeZ > 0.) phantomSizeZ = sizeZ;
318 if (sizeX > 0.) {detectorSizeX = sizeX;}
319 if (sizeY > 0.) {detectorSizeY = sizeY;}
320 if (sizeZ > 0.) {detectorSizeZ = sizeZ;}
321 SetVoxelSize(sizeOfVoxelAlongX, sizeOfVoxelAlongY, sizeOfVoxelAlongZ);
327 if (sizeX > 0.) {sizeOfVoxelAlongX = sizeX;}
328 if (sizeY > 0.) {sizeOfVoxelAlongY = sizeY;}
329 if (sizeZ > 0.) {sizeOfVoxelAlongZ = sizeZ;}
333 phantomPosition = pos;
339 detectorToPhantomPosition = displ;
352 phantom -> SetXHalfLength(phantomSizeX/2);
353 phantom -> SetYHalfLength(phantomSizeY/2);
354 phantom -> SetZHalfLength(phantomSizeZ/2);
355 phantomPhysicalVolume -> SetTranslation(phantomPosition);
357 else ConstructPhantom();
363 detector -> SetXHalfLength(detectorSizeX/2);
364 detector -> SetYHalfLength(detectorSizeY/2);
365 detector -> SetZHalfLength(detectorSizeZ/2);
366 detectorPhysicalVolume -> SetTranslation(detectorPosition);
368 else ConstructDetector();
372 numberOfVoxelsAlongX =
G4lrint(detectorSizeX / sizeOfVoxelAlongX);
374 sizeOfVoxelAlongX = ( detectorSizeX / numberOfVoxelsAlongX );
376 numberOfVoxelsAlongY =
G4lrint(detectorSizeY / sizeOfVoxelAlongY);
378 sizeOfVoxelAlongY = ( detectorSizeY / numberOfVoxelsAlongY );
380 numberOfVoxelsAlongZ =
G4lrint(detectorSizeZ / sizeOfVoxelAlongZ);
382 sizeOfVoxelAlongZ = ( detectorSizeZ / numberOfVoxelsAlongZ );
396 numberOfVoxelsAlongX,
397 numberOfVoxelsAlongY,
398 numberOfVoxelsAlongZ);
403 volumeOfVoxel = sizeOfVoxelAlongX * sizeOfVoxelAlongY * sizeOfVoxelAlongZ;
404 massOfVoxel = detectorMaterial -> GetDensity() * volumeOfVoxel;
407 numberOfVoxelsAlongY,
408 numberOfVoxelsAlongZ,
421 #ifdef G4ANALYSIS_USE_ROOT
436 G4cout <<
"The (X,Y,Z) dimensions of the phantom are : (" <<
437 G4BestUnit( phantom -> GetXHalfLength()*2.,
"Length") <<
',' <<
438 G4BestUnit( phantom -> GetYHalfLength()*2.,
"Length") <<
',' <<
441 G4cout <<
"The (X,Y,Z) dimensions of the detector are : (" <<
442 G4BestUnit( detector -> GetXHalfLength()*2.,
"Length") <<
',' <<
443 G4BestUnit( detector -> GetYHalfLength()*2.,
"Length") <<
',' <<
446 G4cout <<
"Displacement between Phantom and World is: ";
451 G4cout <<
"The (X,Y,Z) sizes of the Voxels are: (" <<
452 G4BestUnit(sizeOfVoxelAlongX,
"Length") <<
',' <<
453 G4BestUnit(sizeOfVoxelAlongY,
"Length") <<
',' <<
456 G4cout <<
"The number of Voxels along (X,Y,Z) is: (" <<
457 numberOfVoxelsAlongX <<
',' <<
458 numberOfVoxelsAlongY <<
',' <<
459 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 HadrontherapyMatrix * GetInstance()
G4GLOB_DLL std::ostream G4cout
void SetPhantomPosition(G4ThreeVector)
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()