67 : motherPhys(physicalTreatmentRoom),
68 detectorSD(0), detectorROGeometry(0), matrix(0),
69 phantom(0), detector(0),
70 phantomLogicalVolume(0), detectorLogicalVolume(0),
71 phantomPhysicalVolume(0), detectorPhysicalVolume(0),
87 sizeOfVoxelAlongX = 200 *CLHEP::um;
88 sizeOfVoxelAlongY = 4 *CLHEP::cm;
89 sizeOfVoxelAlongZ = 4 *CLHEP::cm;
107 delete detectorROGeometry;
109 delete detectorMessenger;
117 void HadrontherapyDetectorConstruction::ConstructPhantom()
120 phantom =
new G4Box(
"Phantom",
128 "phantomLog", 0, 0, 0);
134 phantomLogicalVolume,
141 red -> SetVisibility(
true);
142 red -> SetForceSolid(
true);
143 red -> SetForceWireframe(
true);
144 phantomLogicalVolume -> SetVisAttributes(red);
169 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);
215 void HadrontherapyDetectorConstruction::ConstructSensitiveDetector(
G4ThreeVector detectorToWorldPosition)
218 delete detectorROGeometry;
224 static G4String sensitiveDetectorName =
"Detector";
231 static G4String ROGeometryName =
"DetectorROGeometry";
233 detectorToWorldPosition,
237 numberOfVoxelsAlongX,
238 numberOfVoxelsAlongY,
239 numberOfVoxelsAlongZ);
241 G4cout <<
"Instantiating new Read Out Geometry \"" << ROGeometryName <<
"\""<<
G4endl;
243 detectorROGeometry -> BuildROGeometry();
245 detectorSD -> SetROgeometry(detectorROGeometry);
247 if (!sensitiveDetectorManager -> FindSensitiveDetector(sensitiveDetectorName,
false))
249 G4cout <<
"Registering new DetectorSD \"" << sensitiveDetectorName <<
"\""<<
G4endl;
251 sensitiveDetectorManager -> AddNewDetector(detectorSD);
253 detectorLogicalVolume -> SetSensitiveDetector(detectorSD);
256 void HadrontherapyDetectorConstruction::ParametersCheck()
265 detectorToPhantomPosition
267 G4Exception(
"HadrontherapyDetectorConstruction::ParametersCheck()",
"Hadrontherapy0001",
FatalException,
"Error: Detector is not fully inside Phantom!");
271 if ( detectorSizeX < sizeOfVoxelAlongX) {
272 G4Exception(
"HadrontherapyDetectorConstruction::ParametersCheck()",
"Hadrontherapy0002",
FatalException,
"Error: Detector X size must be bigger or equal than that of Voxel X!");
274 if ( detectorSizeY < sizeOfVoxelAlongY) {
275 G4Exception(
" HadrontherapyDetectorConstruction::ParametersCheck()",
"Hadrontherapy0003",
FatalException,
"Error: Detector Y size must be bigger or equal than that of Voxel Y!");
277 if ( detectorSizeZ < sizeOfVoxelAlongZ) {
278 G4Exception(
" HadrontherapyDetectorConstruction::ParametersCheck()",
"Hadrontherapy0004",
FatalException,
"Error: Detector Z size must be bigger or equal than that of Voxel Z!");
291 phantomMaterial = pMat;
292 detectorMaterial = pMat;
293 if (detectorLogicalVolume && phantomLogicalVolume)
300 G4cout <<
"The material of Phantom/Detector has been changed to " << material <<
G4endl;
305 G4cout <<
"WARNING: material \"" << material <<
"\" doesn't exist in NIST elements/materials"
306 " table [located in $G4INSTALL/source/materials/src/G4NistMaterialBuilder.cc]" <<
G4endl;
307 G4cout <<
"Use command \"/parameter/nist\" to see full materials list!" <<
G4endl;
316 if (sizeX > 0.) phantomSizeX = sizeX;
317 if (sizeY > 0.) phantomSizeY = sizeY;
318 if (sizeZ > 0.) phantomSizeZ = sizeZ;
324 if (sizeX > 0.) {detectorSizeX = sizeX;}
325 if (sizeY > 0.) {detectorSizeY = sizeY;}
326 if (sizeZ > 0.) {detectorSizeZ = sizeZ;}
327 SetVoxelSize(sizeOfVoxelAlongX, sizeOfVoxelAlongY, sizeOfVoxelAlongZ);
333 if (sizeX > 0.) {sizeOfVoxelAlongX = sizeX;}
334 if (sizeY > 0.) {sizeOfVoxelAlongY = sizeY;}
335 if (sizeZ > 0.) {sizeOfVoxelAlongZ = sizeZ;}
339 phantomPosition = pos;
345 detectorToPhantomPosition = displ;
358 phantom -> SetXHalfLength(phantomSizeX/2);
359 phantom -> SetYHalfLength(phantomSizeY/2);
360 phantom -> SetZHalfLength(phantomSizeZ/2);
361 phantomPhysicalVolume -> SetTranslation(phantomPosition);
363 else ConstructPhantom();
369 detector -> SetXHalfLength(detectorSizeX/2);
370 detector -> SetYHalfLength(detectorSizeY/2);
371 detector -> SetZHalfLength(detectorSizeZ/2);
372 detectorPhysicalVolume -> SetTranslation(detectorPosition);
374 else ConstructDetector();
377 numberOfVoxelsAlongX =
G4lrint(detectorSizeX / sizeOfVoxelAlongX);
378 sizeOfVoxelAlongX = ( detectorSizeX / numberOfVoxelsAlongX );
380 numberOfVoxelsAlongY =
G4lrint(detectorSizeY / sizeOfVoxelAlongY);
381 sizeOfVoxelAlongY = ( detectorSizeY / numberOfVoxelsAlongY );
383 numberOfVoxelsAlongZ =
G4lrint(detectorSizeZ / sizeOfVoxelAlongZ);
384 sizeOfVoxelAlongZ = ( detectorSizeZ / numberOfVoxelsAlongZ );
388 volumeOfVoxel = sizeOfVoxelAlongX * sizeOfVoxelAlongY * sizeOfVoxelAlongZ;
389 massOfVoxel = detectorMaterial -> GetDensity() * volumeOfVoxel;
392 numberOfVoxelsAlongY,
393 numberOfVoxelsAlongZ,
397 #ifdef G4ANALYSIS_USE_ROOT
412 G4cout <<
"The (X,Y,Z) dimensions of the phantom are : (" <<
413 G4BestUnit( phantom -> GetXHalfLength()*2.,
"Length") <<
',' <<
414 G4BestUnit( phantom -> GetYHalfLength()*2.,
"Length") <<
',' <<
417 G4cout <<
"The (X,Y,Z) dimensions of the detector are : (" <<
418 G4BestUnit( detector -> GetXHalfLength()*2.,
"Length") <<
',' <<
419 G4BestUnit( detector -> GetYHalfLength()*2.,
"Length") <<
',' <<
422 G4cout <<
"Displacement between Phantom and World is: ";
427 G4cout <<
"The (X,Y,Z) sizes of the Voxels are: (" <<
428 G4BestUnit(sizeOfVoxelAlongX,
"Length") <<
',' <<
429 G4BestUnit(sizeOfVoxelAlongY,
"Length") <<
',' <<
432 G4cout <<
"The number of Voxels along (X,Y,Z) is: (" <<
433 numberOfVoxelsAlongX <<
',' <<
434 numberOfVoxelsAlongY <<
',' <<
435 numberOfVoxelsAlongZ <<
')' <<
G4endl;