![]() |
Precalibrated Ion Beam Identification Detector Simulation 1.0
A pilot study detector simulation, written in C++ with Geant4.
|
00001 #include "DetectorConstruction.hh" 00002 00003 DetectorConstruction::DetectorConstruction() 00004 :ScintillatorMaterial(0),GapMaterial(0),defaultMaterial(0), ShieldingMaterial(0), BeamBlockerMaterial(0), 00005 solidWorld(0),logicWorld(0),physiWorld(0), GeDetectorShellMaterial(0), 00006 solidScintillatorBox(0),logicScintillatorBox(0),physiScintillatorBox(0), 00007 solidSlot(0),logicSlot(0),physiSlot(0), 00008 solidScintillator(0),logicScintillator(0),physiScintillator(0), 00009 solidGap (0),logicGap (0),physiGap (0), 00010 solidShielding(0), logicShielding(0), physiShielding(0), 00011 solidTopShielding(0), logicTopShielding(0), physiTopShielding(0), 00012 solidBetaDetector(0), logicBetaDetector(0), physiUpperBetaDetector(0), physiLowerBetaDetector(0), 00013 solidFrontScintillatorPlate(0), logicFrontScintillatorPlate(0), physiUpperFrontScintillatorPlate(0), physiLowerFrontScintillatorPlate(0), 00014 solidBackScintillatorPlate(0), logicBackScintillatorPlate(0), physiBackScintillatorPlate(0), 00015 00016 solidSlowdown(0), logicSlowdown(0), physiUpperSlowdown(0), physiLowerSlowdown(0), SlowdownMaterial(0), 00017 solidGermaniumDetector(0), logicGermaniumDetector(0), physiGermaniumDetector(0), 00018 solidGeDetectorShell(0), logicGeDetectorShell(0), physiGeDetectorShell(0), 00019 solidGeDetectorContainer(0), logicGeDetectorContainer(0), physiGeDetectorContainer(0), 00020 solidBeamBlocker(0), logicBeamBlocker(0), physiBeamBlocker(0) 00021 { 00022 00023 DefineMaterials(); 00024 SetDefaultDetectorParameters(); 00025 00026 detectorMessenger = new DetectorMessenger(this); 00027 } 00028 00029 void DetectorConstruction::SetDefaultDetectorParameters() 00030 { 00031 //Default dimensions of different stuff. 00032 ScintillatorDiameter = 10.*mm; 00033 ScintillatorShieldingGapThickness = 1.*mm; 00034 NumberOfScintillatorsPerBox = 10; 00035 NumberOfScintillatorBoxes = 2; 00036 ScintillatorLength = 10.*cm; 00037 ScintillatorPlateThickness = 1*mm; 00038 ShieldingThickness = 10.*mm; 00039 TopShieldingThickness = ShieldingThickness; 00040 00041 // default values for the germaniumdetector 00042 GeDetectorRadius = 2.3*cm; 00043 GeDetectorShellLength = 12.*cm; 00044 GeDetectorLength = 5.*cm; 00045 GeDetectorShellInnerRadius = 2.6*cm; 00046 GeDetectorShellOuterRadius = 3.0*cm; 00047 00048 BeamBlockerThickness = 10.*cm; 00049 ShieldingBeamBlockerThickness = 3.*cm; 00050 00051 // default values for the slowdown 00052 SlowdownThickness = 40*cm; 00053 SlowdownLength = 50*cm; 00054 EffectiveSlowdownThickness = 30*cm; 00055 PlateShieldingSpacing = 0.5*cm; 00056 00057 00058 FlipBeta = false; 00059 00060 //Some parameters are dependent of the other, compute the value of these. 00061 ComputeDependentDetectorParameters(); 00062 00063 //Set default materials. 00064 SetScintillatorMaterial("Plastic"); 00065 SetGapMaterial(defaultMaterial->GetName()); // "Air"); // 00066 SetShieldingMaterial("quartz"); 00067 SetGeDetectorShellMaterial("Aluminium"); 00068 SetGermaniumDetectorMaterial("Germanium");//("SodiumIodide"); 00069 SetBeamBlockerMaterial("Lead"); 00070 SetSlowdownMaterial("Aluminium"); 00071 SetShieldingBeamBlockerMaterial(defaultMaterial->GetName()); 00072 } 00073 00074 00075 DetectorConstruction::~DetectorConstruction() 00076 { delete detectorMessenger;} 00077 00078 G4VPhysicalVolume* DetectorConstruction::Construct() 00079 { 00080 return ConstructDetector(); 00081 } 00082 00083 void DetectorConstruction::DefineMaterials() 00084 { 00085 00086 G4String symbol; //a=mass of a mole; 00087 G4double a, z, density; //z=mean number of protons; 00088 G4int iz, n; //iz=number of protons in an isotope; 00089 // n=number of nucleons in an isotope; 00090 00091 G4int ncomponents, natoms; 00092 G4double abundance, fractionmass; 00093 00094 // define Elements 00095 G4Element* H = new G4Element("Hydrogen" ,symbol="H" , z= 1., a= 1.01*g/mole); 00096 G4Element* C = new G4Element("Carbon" ,symbol="C" , z= 6., a= 12.01*g/mole); 00097 G4Element* N = new G4Element("Nitrogen" ,symbol="N" , z= 7., a= 14.01*g/mole); 00098 G4Element* O = new G4Element("Oxygen" ,symbol="O" , z= 8., a= 16.00*g/mole); 00099 G4Element* Si = new G4Element("Silicon" ,symbol="Si" , z= 14., a= 28.09*g/mole); 00100 G4Element* Pb = new G4Element("Lead" ,symbol="Pb" , z= 82., a= 207.19*g/mole); 00101 G4Element* W = new G4Element("Tungsten" ,symbol="W" , z= 74., a= 183.84*g/mole); 00102 G4Element* Na = new G4Element("Sodium" ,symbol="Na" , z= 11., a= 22.98976928*g/mole); 00103 G4Element* I = new G4Element("Iodine" ,symbol="I" , z= 53., a= 126.90447*g/mole); 00104 00105 // define an Element from isotopes, by relative abundance 00106 G4Isotope* U5 = new G4Isotope("U235", iz=92, n=235, a=235.01*g/mole); 00107 G4Isotope* U8 = new G4Isotope("U238", iz=92, n=238, a=238.03*g/mole); 00108 00109 G4Element* U = new G4Element("enriched Uranium",symbol="U",ncomponents=2); 00110 U->AddIsotope(U5, abundance= 90.*perCent); 00111 U->AddIsotope(U8, abundance= 10.*perCent); 00112 00113 // define simple materials 00114 new G4Material("Aluminium" , z=13., a=26.98*g/mole, density= 2.700*g/cm3); 00115 new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*g/cm3); 00116 new G4Material("Lead" , z=82., a= 207.19*g/mole, density= 11.35*g/cm3); 00117 new G4Material("Germanium" , z=32., a= 72.64*g/mole, density= 5.323*g/cm3); 00118 new G4Material("Iron", z=26., a=55.85*g/mole, density=7.874*g/cm3); 00119 00120 00121 // define a material from elements. case 1: chemical molecule 00122 G4Material* SodiumIodide = new G4Material("SodiumIodide", density= 3.67*g/cm3, ncomponents=2); 00123 SodiumIodide->AddElement(Na, natoms=1); 00124 SodiumIodide->AddElement(I, natoms=1); 00125 00126 G4Material* Plastic = new G4Material("Plastic", density= 1.032*g/cm3, ncomponents=2); 00127 Plastic->AddElement(C, natoms=9); 00128 Plastic->AddElement(H, natoms=10); 00129 00130 G4Material* LeadTungstate = 00131 new G4Material("Lead Tungstate", density= 8.235*g/cm3, ncomponents=3); 00132 LeadTungstate->AddElement(Pb, natoms=1); 00133 LeadTungstate->AddElement(W, natoms= 1); 00134 LeadTungstate->AddElement(O, natoms= 4); 00135 00136 G4Material* H2O = 00137 new G4Material("Water", density= 1.000*g/cm3, ncomponents=2); 00138 H2O->AddElement(H, natoms=2); 00139 H2O->AddElement(O, natoms=1); 00140 // overwrite computed meanExcitationEnergy with ICRU recommended value 00141 H2O->GetIonisation()->SetMeanExcitationEnergy(75.0*eV); 00142 00143 G4Material* Sci = 00144 new G4Material("Scintillator", density= 1.032*g/cm3, ncomponents=2); 00145 Sci->AddElement(C, natoms=9); 00146 Sci->AddElement(H, natoms=10); 00147 00148 G4Material* Myl = 00149 new G4Material("Mylar", density= 1.397*g/cm3, ncomponents=3); 00150 Myl->AddElement(C, natoms=10); 00151 Myl->AddElement(H, natoms= 8); 00152 Myl->AddElement(O, natoms= 4); 00153 00154 G4Material* SiO2 = 00155 new G4Material("quartz",density= 2.200*g/cm3, ncomponents=2); 00156 SiO2->AddElement(Si, natoms=1); 00157 SiO2->AddElement(O , natoms=2); 00158 00159 // define a material from elements. case 2: mixture by fractional mass 00160 G4Material* Air = 00161 new G4Material("Air" , density= 1.290*mg/cm3, ncomponents=2); 00162 Air->AddElement(N, fractionmass=0.7); 00163 Air->AddElement(O, fractionmass=0.3); 00164 00165 // define a material from elements and/or others materials (mixture of mixtures) 00166 G4Material* Aerog = 00167 new G4Material("Aerogel", density= 0.200*g/cm3, ncomponents=3); 00168 Aerog->AddMaterial(SiO2, fractionmass=62.5*perCent); 00169 Aerog->AddMaterial(H2O , fractionmass=37.4*perCent); 00170 Aerog->AddElement (C , fractionmass= 0.1*perCent); 00171 00172 // examples of gas in non STP conditions 00173 G4Material* CO2 = 00174 new G4Material("CarbonicGas", density= 1.842*mg/cm3, ncomponents=2, 00175 kStateGas, 325.*kelvin, 50.*atmosphere); 00176 CO2->AddElement(C, natoms=1); 00177 CO2->AddElement(O, natoms=2); 00178 00179 G4Material* steam = 00180 new G4Material("WaterSteam", density= 0.3*mg/cm3, ncomponents=1, 00181 kStateGas, 500.*kelvin, 2.*atmosphere); 00182 steam->AddMaterial(H2O, fractionmass=1.); 00183 00184 // examples of vacuum 00185 G4Material* Vacuum = 00186 new G4Material("Galactic", z=1., a=1.01*g/mole,density= universe_mean_density, 00187 kStateGas, 2.73*kelvin, 3.e-18*pascal); 00188 00189 G4Material* beam = 00190 new G4Material("Beam", density= 1.e-5*g/cm3, ncomponents=1, 00191 kStateGas, STP_Temperature, 2.e-2*bar); 00192 beam->AddMaterial(Air, fractionmass=1.); 00193 00194 //If desire to print the material table, we can do that here. 00195 //G4cout << *(G4Material::GetMaterialTable()) << G4endl; 00196 00197 //default materials of the World, vacuum. 00198 defaultMaterial = Vacuum; 00199 } 00200 00201 00202 void DetectorConstruction::ConstructWorld() 00203 { 00204 solidWorld = new G4Box("World", //its name 00205 WorldSizeX/2, 00206 WorldSizeY/2, 00207 WorldSizeZ/2); //its size 00208 00209 logicWorld = new G4LogicalVolume(solidWorld, //its solid 00210 GapMaterial, //its material 00211 "World"); //its name 00212 00213 physiWorld = new G4PVPlacement(0, //no rotation 00214 G4ThreeVector(), //at (0,0,0) 00215 logicWorld, //its logical volume 00216 "World", //its name 00217 0, //its mother volume 00218 false, //no boolean operation 00219 0); //copy number 00220 } 00221 00222 void DetectorConstruction::ConstructBetaDetector() 00223 { 00224 solidBetaDetector=0; logicBetaDetector=0; physiUpperBetaDetector=0; physiLowerBetaDetector=0; 00225 00226 solidBetaDetector = new G4Box("BetaDetector", //its name 00227 ScintillatorBoxSizeX/2, 00228 NumberOfScintillatorBoxes*ScintillatorBoxSizeY/2, 00229 ScintillatorBoxSizeZ/2); //size 00230 00231 logicBetaDetector = new G4LogicalVolume(solidBetaDetector, //its solid 00232 GapMaterial, //its material 00233 "BetaDetector"); //its name 00234 00235 // Upper beta detector 00236 G4RotationMatrix* rmUpperBetaDetector = new G4RotationMatrix(); 00237 if(!FlipBeta) 00238 rmUpperBetaDetector->rotateX(180*degree); //Upper and lower beta detectors are rotation symmetric. 00239 00240 physiUpperBetaDetector = new G4PVPlacement(rmUpperBetaDetector, 00241 G4ThreeVector(-ShieldingBeamBlockerThickness/2, BetaDetectorPositionY, 0), 00242 logicBetaDetector, //its logical volume 00243 "UpperBetaDetector", //its name 00244 logicWorld, //its mother volume 00245 false, //no boolean operation 00246 0); //copy number 00247 00248 00249 G4RotationMatrix* rmLowerBetaDetector = new G4RotationMatrix(); 00250 if(FlipBeta) 00251 rmLowerBetaDetector->rotateX(180*degree); //Upper and lower beta detectors are rotation symmetric. 00252 // LowerBetaDetector 00253 physiLowerBetaDetector = new G4PVPlacement(rmLowerBetaDetector, //no rotation 00254 G4ThreeVector(-ShieldingBeamBlockerThickness/2, -BetaDetectorPositionY, 0), //at (0,0,0) 00255 logicBetaDetector, //its logical volume 00256 "LowerBetaDetector", //its name 00257 logicWorld, //its mother volume 00258 false, //no boolean operation 00259 0); //copy number 00260 } 00261 00262 00263 00264 00265 00266 void DetectorConstruction::ConstructScintillatorBox() 00267 { 00268 // ScintillatorBox 00269 solidScintillatorBox=0; logicScintillatorBox=0; physiScintillatorBox=0; 00270 solidSlot=0; logicSlot=0; physiSlot=0; 00271 00272 solidScintillatorBox = new G4Box("ScintillatorBox", //its name 00273 ScintillatorBoxSizeX/2,ScintillatorBoxSizeY/2,ScintillatorBoxSizeZ/2);//size 00274 00275 logicScintillatorBox = new G4LogicalVolume(solidScintillatorBox, //its solid 00276 GapMaterial, //its material 00277 "ScintillatorBox"); //its name 00278 00279 physiScintillatorBox = new G4PVReplica("ScintillatorBox", //its name 00280 logicScintillatorBox, //its logical volume 00281 logicBetaDetector, //its mother 00282 kYAxis, //axis of replication 00283 NumberOfScintillatorBoxes, //number of replica 00284 SlotWidthY); //witdth of replica 00285 00286 } 00287 00288 00289 void DetectorConstruction::ConstructScintillatorSlot() 00290 { 00291 // Slot 00292 solidSlot = new G4Box("Slot", //its name 00293 ScintillatorBoxSizeX/2, 00294 SlotWidthY/2, 00295 SlotWidthZ/2); //size 00296 00297 logicSlot = new G4LogicalVolume(solidSlot, //its solid 00298 defaultMaterial, //its material 00299 "Slot"); //its name 00300 00301 if (NumberOfScintillatorsPerBox > 1) 00302 physiSlot = new G4PVReplica("Slot", //its name 00303 logicSlot, //its logical volume 00304 logicScintillatorBox, //its mother 00305 kZAxis, //axis of replication 00306 NumberOfScintillatorsPerBox, //number of replica 00307 SlotWidthZ); //witdth of replica 00308 else 00309 physiSlot = new G4PVPlacement(0, //no rotation 00310 G4ThreeVector(), //at (0,0,0) 00311 logicSlot, //its logical volume 00312 "Slot", //its name 00313 logicScintillatorBox, //its mother volume 00314 false, //no boolean operation 00315 0); //copy number 00316 } 00317 00318 void DetectorConstruction::ConstructScintillator() 00319 { 00320 // Scintillator 00321 solidScintillator=0; logicScintillator=0; physiScintillator=0; 00322 00323 if (ScintillatorThickness > 0.) 00324 { 00325 solidScintillator = new G4Tubs("Scintillator", 00326 0*cm, 00327 ScintillatorDiameter/2, 00328 ScintillatorLength/2, 00329 0*degree, 00330 360*degree); 00331 00332 logicScintillator = new G4LogicalVolume(solidScintillator, //its solid 00333 ScintillatorMaterial, //its material 00334 ScintillatorMaterial->GetName()); //name 00335 00336 G4RotationMatrix * rmScintillator = new G4RotationMatrix(); 00337 rmScintillator->rotateY(90*degree); 00338 00339 physiScintillator = new G4PVPlacement(rmScintillator, //rotation 00340 G4ThreeVector(ScintillatorPositionX, ScintillatorPositionY, ScintillatorPositionZ), //its position 00341 logicScintillator, //its logical volume 00342 ScintillatorMaterial->GetName(), //its name 00343 logicSlot, //its mother 00344 false, //no boolean operat 00345 0); //copy number 00346 00347 } 00348 } 00349 00350 void DetectorConstruction::ConstructShielding() 00351 { 00352 // Shielding 00353 solidShielding=0; logicShielding=0; physiShielding=0; 00354 00355 solidShielding = new G4Box("Shielding", 00356 ScintillatorLength/2, 00357 SlotWidthY/2, 00358 ShieldingThickness/2); 00359 00360 logicShielding = new G4LogicalVolume(solidShielding, 00361 ShieldingMaterial, 00362 ShieldingMaterial->GetName()); 00363 00364 physiShielding = new G4PVPlacement(0, //no rotation 00365 G4ThreeVector(ShieldingPositionX, ShieldingPositionY, ShieldingPositionZ), 00366 logicShielding, //its logical volume 00367 ShieldingMaterial->GetName(), //its name 00368 logicSlot, //its mother 00369 false, //no boulean operat 00370 0); //copy number 00371 00372 // TopShielding 00373 solidTopShielding=0; logicTopShielding=0; physiTopShielding=0; 00374 00375 solidTopShielding = new G4Box("TopShielding", 00376 ScintillatorLength/2, 00377 TopShieldingThickness/2, 00378 (SlotWidthZ-ShieldingThickness)/2); 00379 00380 logicTopShielding = new G4LogicalVolume(solidTopShielding, 00381 ShieldingMaterial, 00382 ShieldingMaterial->GetName()); 00383 00384 physiTopShielding = new G4PVPlacement(0, //no rotation 00385 G4ThreeVector(TopShieldingPositionX,TopShieldingPositionY,TopShieldingPositionZ), //its position 00386 logicTopShielding, //its logical volume 00387 ShieldingMaterial->GetName(), //its name 00388 logicSlot, //its mother 00389 false, //no boolean operator 00390 0); //copy number 00391 } 00392 00393 00394 void DetectorConstruction::ConstructBeamBlocker() 00395 { 00396 // Beam blocker 00397 solidBeamBlocker=0; logicBeamBlocker=0; physiBeamBlocker=0; 00398 solidBeamBlocker = new G4Box("BeamBlocker", 00399 BeamBlockerThickness/2, 00400 BeamBlockerYWidth/2, 00401 BeamBlockerZWidth/2 00402 ); 00403 logicBeamBlocker = new G4LogicalVolume(solidBeamBlocker, //its solid 00404 BeamBlockerMaterial, //its material 00405 "BeamBlocker"); //its name 00406 00407 physiBeamBlocker = new G4PVPlacement(0, //no rotation 00408 G4ThreeVector(-(GeDetectorContainerSizeX/2-BeamBlockerThickness/2), 0, 0), 00409 logicBeamBlocker, //its logical volume 00410 "BeamBlocker", //its name 00411 logicGeDetectorContainer, //its mother volume 00412 false, //no boolean operation 00413 0); //copy number 00414 } 00415 00416 void DetectorConstruction::ConstructShieldingBeamBlocker() 00417 { 00418 // Shielding 00419 solidShieldingBeamBlocker=0; logicShieldingBeamBlocker=0; physiShieldingBeamBlocker=0; 00420 00421 solidShieldingBeamBlocker = new G4Box("ShieldingBeamBlocker" , 00422 ShieldingBeamBlockerThickness/2, 00423 SlotWidthY/2, 00424 ShieldingThickness/2); 00425 00426 logicShieldingBeamBlocker = new G4LogicalVolume(solidShieldingBeamBlocker, 00427 ShieldingBeamBlockerMaterial, 00428 ShieldingBeamBlockerMaterial->GetName()); 00429 00430 physiShieldingBeamBlocker = new G4PVPlacement(0, //no rotation 00431 G4ThreeVector(ShieldingBeamBlockerPositionX,ShieldingPositionY, ShieldingPositionZ), 00432 logicShieldingBeamBlocker, //its logical volume 00433 ShieldingBeamBlockerMaterial->GetName(), //its name 00434 logicSlot, //its mother 00435 false, //no boulean operat 00436 0); //copy number 00437 00438 // TopShielding 00439 solidTopShieldingBeamBlocker=0; logicTopShieldingBeamBlocker=0; physiTopShieldingBeamBlocker=0; 00440 00441 solidTopShieldingBeamBlocker = new G4Box("TopShieldingBeamBlocker", 00442 ShieldingBeamBlockerThickness/2, 00443 TopShieldingThickness/2, 00444 (SlotWidthZ-ShieldingThickness)/2); 00445 00446 logicTopShieldingBeamBlocker = new G4LogicalVolume(solidTopShieldingBeamBlocker, 00447 ShieldingBeamBlockerMaterial, 00448 ShieldingBeamBlockerMaterial->GetName()); 00449 00450 physiTopShieldingBeamBlocker = new G4PVPlacement(0, //no rotation 00451 G4ThreeVector(ShieldingBeamBlockerPositionX,TopShieldingPositionY, TopShieldingPositionZ), //its position 00452 logicTopShieldingBeamBlocker, //its logical volume 00453 ShieldingBeamBlockerMaterial->GetName(), //its name 00454 logicSlot, //its mother 00455 false, //no boulean operat 00456 0); //copy number 00457 } 00458 00459 00460 00461 00462 00463 00464 00465 00466 00467 00468 00469 00470 00471 00472 void DetectorConstruction::ConstructScintillatorPlates() 00473 { 00474 // FrontPlateLogicalVolume 00475 solidFrontScintillatorPlate=0; logicFrontScintillatorPlate=0; physiUpperFrontScintillatorPlate=0; physiLowerFrontScintillatorPlate=0; 00476 00477 solidFrontScintillatorPlate = new G4Box("FrontScintillatorPlate", ScintillatorPlateThickness/2,FrontScintillatorPlateSizeY/2,ScintillatorBoxSizeZ/2); 00478 00479 logicFrontScintillatorPlate = new G4LogicalVolume(solidFrontScintillatorPlate, //its solid 00480 ScintillatorMaterial, //its material 00481 "FrontScintillatorPlate"); //its name 00482 G4double displacement = TopShieldingThickness; 00483 if(FlipBeta) 00484 displacement = -displacement; 00485 //UpperFrontScintillatorPlate 00486 physiUpperFrontScintillatorPlate = new G4PVPlacement(0, //no rotation 00487 G4ThreeVector(-ScintillatorBoxSizeX/2 - ShieldingBeamBlockerThickness/2 - ScintillatorPlateThickness - PlateShieldingSpacing, 1.1*GeDetectorShellOuterRadius+(NumberOfScintillatorBoxes*ScintillatorBoxSizeY+displacement)/2, 0), // -(ScintillatorBoxSizeX+ScintillatorPlateThickness)/2 00488 logicFrontScintillatorPlate, //its logical volume 00489 "UpperFrontScintillatorPlate", //its name 00490 logicWorld, //its mother volume 00491 false, //no boolean operation 00492 0); //copy number 00493 00494 //LowerFrontScintillatorPlate 00495 physiLowerFrontScintillatorPlate = new G4PVPlacement(0, //no rotation 00496 G4ThreeVector(-ScintillatorBoxSizeX/2 - ShieldingBeamBlockerThickness/2 - ScintillatorPlateThickness -PlateShieldingSpacing, -(1.1*GeDetectorShellOuterRadius+(NumberOfScintillatorBoxes*ScintillatorBoxSizeY+displacement)/2), 0), //-(ScintillatorBoxSizeX+ScintillatorPlateThickness)/2 00497 logicFrontScintillatorPlate, //its logical volume 00498 "LowerFrontScintillatorPlate", //its name 00499 logicWorld, //its mother volume 00500 false, //no boolean operation 00501 0); //copy number 00502 00503 00504 //BackScintillatorPlate 00505 solidBackScintillatorPlate=0; logicBackScintillatorPlate=0; physiBackScintillatorPlate=0; 00506 00507 solidBackScintillatorPlate = new G4Box("BackScintillatorPlate", ScintillatorPlateThickness/2, BackScintillatorPlateSizeY/2, ScintillatorBoxSizeZ/2); 00508 00509 logicBackScintillatorPlate = new G4LogicalVolume(solidBackScintillatorPlate, //its solid 00510 ScintillatorMaterial, //its material 00511 "BackScintillatorPlate"); //its name 00512 00513 physiBackScintillatorPlate = new G4PVPlacement(0, //no rotation 00514 G4ThreeVector((GeDetectorContainerSizeX+ScintillatorPlateThickness)/2, 0, 0), 00515 logicBackScintillatorPlate, //its logical volume 00516 "BackScintillatorPlate", //its name 00517 logicWorld, //its mother volume 00518 false, //no boolean operation 00519 0); //copy number 00520 00521 } 00522 00523 void DetectorConstruction::ConstructSlowdown() //Wedges. 00524 { 00525 solidSlowdown=0; logicSlowdown=0; physiUpperSlowdown=0; physiLowerSlowdown=0; 00526 solidSlowdown = new G4Trap("Slowdown", 00527 ScintillatorBoxSizeZ, 00528 SlowdownThickness, 00529 SlowdownLength, 00530 .0001*cm); // Just keep it low ok... 00531 00532 00533 00534 logicSlowdown = new G4LogicalVolume(solidSlowdown, //its solid 00535 SlowdownMaterial, //its material 00536 "Slowdown"); //its name 00537 00538 //UpperSlowdown 00539 G4RotationMatrix * rmUpperSlowdown = new G4RotationMatrix(); 00540 rmUpperSlowdown->rotateZ(90*degree); 00541 G4ThreeVector placementUpperSlowdown(-(GeDetectorContainerSizeX/2+BeamBlockerThickness/2+SlowdownThickness/2+1*cm), SlowdownLength/4 + SlowdownHeightGap/2, 0); 00542 00543 physiUpperSlowdown = new G4PVPlacement(rmUpperSlowdown, //+ 90 degree rotation about z axis. 00544 placementUpperSlowdown, 00545 logicSlowdown, //its logical volume 00546 "UpperSlowdown", //its name 00547 logicWorld, //its mother volume 00548 false, //no boolean operation 00549 0); //copy number 00550 00551 //LowerSlowdown 00552 G4RotationMatrix * rmLowerSlowdown = new G4RotationMatrix(); 00553 rmLowerSlowdown->rotateZ(-90*degree); 00554 00555 G4ThreeVector placementLowerSlowdown( -(GeDetectorContainerSizeX/2+BeamBlockerThickness/2+SlowdownThickness/2+1*cm), -SlowdownLength/4 - SlowdownHeightGap/2, 0); 00556 00557 physiLowerSlowdown = new G4PVPlacement(rmLowerSlowdown, //-90 degree rotation about the Z-axis 00558 placementLowerSlowdown, 00559 logicSlowdown, //its logical volume 00560 "LowerSlowdown", //its name 00561 logicWorld, //its mother volume 00562 false, //no boolean operation 00563 0); //copy number 00564 } 00565 00566 void DetectorConstruction::ConstructGermaniumDetector() 00567 { 00568 // Germanium detector container 00569 solidGeDetectorContainer=0; logicGeDetectorContainer=0; physiGeDetectorContainer=0; 00570 00571 solidGeDetectorContainer = new G4Box("GermaniumDetectorContainer", GeDetectorContainerSizeX/2, 1.1*GeDetectorShellOuterRadius, 1.1*GeDetectorShellLength/2); 00572 00573 logicGeDetectorContainer = new G4LogicalVolume(solidGeDetectorContainer, //its solid 00574 defaultMaterial, //its material 00575 "GermaniumDetectorContainer"); //its name 00576 00577 physiGeDetectorContainer = new G4PVPlacement(0, //no rotation 00578 G4ThreeVector(-BeamBlockerThickness/2, 0, 0), 00579 logicGeDetectorContainer, //its logical volume 00580 "GermaniumDetectorContainer", //its name 00581 logicWorld, //its mother volume 00582 false, //no boolean operation 00583 0); //copy number 00584 00585 00586 // Germanium detector shell 00587 solidGeDetectorShell=0; logicGeDetectorShell=0; physiGeDetectorShell=0; 00588 00589 solidGeDetectorShell = new G4Tubs("GeDetectorShell", GeDetectorShellInnerRadius, GeDetectorShellOuterRadius, GeDetectorShellLength/2, 0*degree, 360*degree); 00590 00591 logicGeDetectorShell = new G4LogicalVolume(solidGeDetectorShell, //its solid 00592 GeDetectorShellMaterial, //its material 00593 "GeDetectorShell"); //its name 00594 00595 physiGeDetectorShell = new G4PVPlacement(0, //no rotation 00596 G4ThreeVector(BeamBlockerThickness/2,0,0), 00597 logicGeDetectorShell, //its logical volume 00598 "GeDetectorShell", //its name 00599 logicGeDetectorContainer, //its mother volume 00600 false, //no boolean operation 00601 0); //copy number 00602 00603 solidGeDetectorShellTop=0; logicGeDetectorShellTop=0; physiGeDetectorShellTop=0; 00604 00605 solidGeDetectorShellTop = new G4Tubs("GeDetectorShellTop", 0, GeDetectorShellInnerRadius, (GeDetectorShellOuterRadius-GeDetectorShellInnerRadius)/2, 0*degree, 360*degree); 00606 00607 logicGeDetectorShellTop = new G4LogicalVolume(solidGeDetectorShellTop, //its solid 00608 GeDetectorShellMaterial, //its material 00609 "GeDetectorShellTop"); //its name 00610 00611 physiGeDetectorShellTop = new G4PVPlacement(0, //no rotation 00612 G4ThreeVector(BeamBlockerThickness/2, 0, GeDetectorShellLength/2-(GeDetectorShellOuterRadius-GeDetectorShellInnerRadius)/2), 00613 logicGeDetectorShellTop, //its logical volume 00614 "GeDetectorShellTop", //its name 00615 logicGeDetectorContainer, //its mother volume 00616 false, //no boolean operation 00617 0); //copy number 00618 00619 00620 00621 solidGeDetectorShellBottom=0; logicGeDetectorShellBottom=0; physiGeDetectorShellBottom=0; 00622 00623 solidGeDetectorShellBottom = new G4Tubs("GeDetectorShellBottom", 0, GeDetectorShellInnerRadius, (GeDetectorShellOuterRadius-GeDetectorShellInnerRadius)/2, 0*degree, 360*degree); 00624 00625 logicGeDetectorShellBottom = new G4LogicalVolume(solidGeDetectorShellBottom, //its solid 00626 GeDetectorShellMaterial, //its material 00627 "GeDetectorShellBottom"); //its name 00628 00629 physiGeDetectorShellBottom = new G4PVPlacement(0, //no rotation 00630 G4ThreeVector(BeamBlockerThickness/2, 0, -GeDetectorShellLength/2+(GeDetectorShellOuterRadius-GeDetectorShellInnerRadius)/2), //at (0,0,0) 00631 logicGeDetectorShellBottom, //its logical volume 00632 "GeDetectorShellBottom", //its name 00633 logicGeDetectorContainer, //its mother volume 00634 false, //no boolean operation 00635 0); //copy number 00636 00637 // Germanium detectors 00638 solidGermaniumDetector = new G4Tubs("GermaniumDetector", 0*cm, GeDetectorRadius, GeDetectorLength/2, 0*degree, 360*degree); 00639 00640 logicGermaniumDetector = new G4LogicalVolume(solidGermaniumDetector, //its solid 00641 GermaniumDetectorMaterial, //its material 00642 "GermaniumDetector"); //its name 00643 physiGermaniumDetector = new G4PVReplica("GermaniumDetector", //its name 00644 logicGermaniumDetector, //its logical volume 00645 logicGeDetectorShell, //its mother 00646 kZAxis, //axis of replication 00647 2, //number of replica 00648 GeDetectorLength+1.*cm); //width of replica 00649 00650 } 00651 00652 void DetectorConstruction::SetVisualizationAttributes() 00653 { 00654 // Visualization attributes 00655 logicWorld->SetVisAttributes (G4VisAttributes::Invisible); 00656 logicBetaDetector ->SetVisAttributes (G4VisAttributes::Invisible); 00657 logicScintillatorBox ->SetVisAttributes (G4VisAttributes::Invisible); 00658 logicGeDetectorContainer ->SetVisAttributes (G4VisAttributes::Invisible); 00659 logicSlot ->SetVisAttributes (G4VisAttributes::Invisible); 00660 //logicGap ->SetVisAttributes (G4VisAttributes::Invisible); 00661 00662 00663 // G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,0.5,1.0)); 00664 // simpleBoxVisAtt->SetVisibility(true); 00665 // logicScintillatorBox->SetVisAttributes(simpleBoxVisAtt); 00666 00667 //Scintillator tube Colour 00668 G4VisAttributes* simpleBoxVisAttScintillator = new G4VisAttributes(G4Colour(0.0,1.0,1.0)); 00669 00670 simpleBoxVisAttScintillator->SetVisibility(true); 00671 simpleBoxVisAttScintillator->G4VisAttributes::SetForceSolid(true); 00672 00673 delete logicScintillator->GetVisAttributes(); 00674 logicScintillator->SetVisAttributes(simpleBoxVisAttScintillator); 00675 00676 simpleBoxVisAttScintillator->G4VisAttributes::SetForceAuxEdgeVisible(true); 00677 00678 //Scintillator plate color 00679 G4VisAttributes* simpleBoxVisAttPlate = new G4VisAttributes(G4Color(0.2, 0.8, 0.5)); 00680 simpleBoxVisAttPlate->SetVisibility(true); 00681 simpleBoxVisAttPlate->G4VisAttributes::SetForceSolid(true); 00682 simpleBoxVisAttPlate->SetColor(0.2, 0.8, 0.5, 0.4); 00683 00684 00685 delete logicBackScintillatorPlate->GetVisAttributes(); 00686 logicBackScintillatorPlate->SetVisAttributes(simpleBoxVisAttPlate); 00687 00688 delete logicFrontScintillatorPlate->GetVisAttributes(); 00689 logicFrontScintillatorPlate->SetVisAttributes(simpleBoxVisAttPlate); 00690 00691 //Shielding Colour 00692 G4VisAttributes* simpleBoxVisAttShielding= new G4VisAttributes(G4Colour(1.0,0.0,0.0)); 00693 simpleBoxVisAttShielding->SetVisibility(true); 00694 //simpleBoxVisAttShielding->G4VisAttributes::SetForceAuxEdgeVisible(true); 00695 simpleBoxVisAttShielding->G4VisAttributes::SetForceSolid(true); 00696 delete logicShielding->GetVisAttributes(); 00697 logicShielding->SetVisAttributes(simpleBoxVisAttShielding); 00698 00699 delete logicTopShielding->GetVisAttributes(); 00700 logicTopShielding->SetVisAttributes(simpleBoxVisAttShielding); 00701 00702 //Germanium Detector (germanium) Colour 00703 G4VisAttributes* simpleBoxVisAttGermaniumDetector= new G4VisAttributes(G4Colour(1.0,1.0,1.0)); 00704 simpleBoxVisAttGermaniumDetector->SetVisibility(true); 00705 //simpleBoxVisAttGermaniumDetector->G4VisAttributes::SetForceAuxEdgeVisible(true); 00706 simpleBoxVisAttGermaniumDetector->G4VisAttributes::SetForceSolid(true); 00707 delete logicGermaniumDetector->GetVisAttributes(); 00708 logicGermaniumDetector->SetVisAttributes(simpleBoxVisAttGermaniumDetector); 00709 00710 //Beam Blocker (lead) Colour 00711 G4VisAttributes* simpleBoxVisAttBeamBlocker= new G4VisAttributes(G4Colour(0.8,0.2,0.3)); 00712 simpleBoxVisAttBeamBlocker->SetColor(0.8, 0.2, 0.3, 0.1); 00713 simpleBoxVisAttBeamBlocker->SetVisibility(true); 00714 simpleBoxVisAttBeamBlocker->G4VisAttributes::SetForceWireframe(true);//SetForceSolid(true);//SetForceAuxEdgeVisible(true); 00715 //simpleBoxVisAttBeamBlocker->G4VisAttributes::SetForceSolid(true); 00716 delete logicBeamBlocker->GetVisAttributes(); 00717 logicBeamBlocker->SetVisAttributes(simpleBoxVisAttBeamBlocker); 00718 00719 00720 G4VisAttributes* simpleBoxVisAttBeamBlockerB= new G4VisAttributes(G4Colour(0.8,0.7,0.5)); 00721 simpleBoxVisAttBeamBlockerB->SetColor(0.8, 0.7, 0.5, 0.15); 00722 simpleBoxVisAttBeamBlockerB->SetVisibility(false); 00723 simpleBoxVisAttBeamBlockerB->G4VisAttributes::SetForceWireframe(true); 00724 00725 delete logicShieldingBeamBlocker->GetVisAttributes(); 00726 logicShieldingBeamBlocker->SetVisAttributes(simpleBoxVisAttBeamBlockerB); 00727 00728 00729 00730 G4VisAttributes* simpleBoxVisAttBeamBlockerC= new G4VisAttributes(G4Colour(0.8,0.7,0.5)); 00731 simpleBoxVisAttBeamBlockerC->SetColor(0.8, 0.7, 0.5, 0.15); 00732 simpleBoxVisAttBeamBlockerC->SetVisibility(false); 00733 simpleBoxVisAttBeamBlockerC->G4VisAttributes::SetForceWireframe(true); 00734 00735 delete logicTopShieldingBeamBlocker->GetVisAttributes(); 00736 logicTopShieldingBeamBlocker->SetVisAttributes(simpleBoxVisAttBeamBlockerC); 00737 00738 00739 00740 00741 //Slowdown/Ge Detector Shell (Aluminium) Colour 00742 00743 G4VisAttributes* simpleBoxVisAttSlowdown= new G4VisAttributes(G4Colour(0.55,0.55,0.55)); 00744 simpleBoxVisAttSlowdown->SetVisibility(true); 00745 simpleBoxVisAttSlowdown->G4VisAttributes::SetForceAuxEdgeVisible(true); 00746 //simpleBoxVisAttSlowdown->G4VisAttributes::SetForceSolid(true); 00747 delete logicSlowdown->GetVisAttributes(); 00748 logicSlowdown->SetVisAttributes(simpleBoxVisAttSlowdown); 00749 00750 delete logicGeDetectorShell->GetVisAttributes(); 00751 logicGeDetectorShell->SetVisAttributes(simpleBoxVisAttSlowdown); 00752 00753 delete logicGeDetectorShellTop->GetVisAttributes(); 00754 logicGeDetectorShellTop->SetVisAttributes(simpleBoxVisAttSlowdown); 00755 00756 delete logicGeDetectorShellBottom->GetVisAttributes(); 00757 logicGeDetectorShellBottom->SetVisAttributes(simpleBoxVisAttSlowdown); 00758 } 00759 00760 G4VPhysicalVolume* DetectorConstruction::ConstructDetector() 00761 { 00762 // Clean old geometry, if any 00763 G4GeometryManager::GetInstance()->OpenGeometry(); 00764 G4PhysicalVolumeStore::GetInstance()->Clean(); 00765 G4LogicalVolumeStore::GetInstance()->Clean(); 00766 G4SolidStore::GetInstance()->Clean(); 00767 00768 // complete the detector parameters. 00769 ComputeDependentDetectorParameters(); 00770 00771 ConstructWorld(); 00772 ConstructBetaDetector(); 00773 ConstructScintillatorBox(); 00774 ConstructScintillatorSlot(); 00775 ConstructScintillator(); 00776 ConstructShielding(); 00777 ConstructShieldingBeamBlocker(); 00778 ConstructScintillatorPlates(); 00779 ConstructSlowdown(); 00780 ConstructGermaniumDetector(); 00781 ConstructBeamBlocker(); 00782 00783 SetVisualizationAttributes(); 00784 //Always return the physical world. 00785 return physiWorld; 00786 } 00787 00788 void DetectorConstruction::SetScintillatorMaterial(G4String materialChoice) 00789 { 00790 // search the material by its name 00791 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); 00792 if (pttoMaterial) ScintillatorMaterial = pttoMaterial; 00793 } 00794 00795 void DetectorConstruction::SetSlowdownMaterial(G4String materialChoice) 00796 { 00797 // search the material by its name 00798 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); 00799 if (pttoMaterial) SlowdownMaterial = pttoMaterial; 00800 } 00801 00802 void DetectorConstruction::SetEffectiveSlowdownThickness(G4double thickness) 00803 { 00804 EffectiveSlowdownThickness = thickness; 00805 00806 } 00807 00808 void DetectorConstruction::SetSlowdownLength(G4double length) 00809 { 00810 SlowdownLength = length; 00811 } 00812 00813 void DetectorConstruction::SetSlowdownThickness(G4double thickness) 00814 { 00815 SlowdownThickness = thickness; 00816 } 00817 00818 void DetectorConstruction::SetGapMaterial(G4String materialChoice) 00819 { 00820 // search the material by its name 00821 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); 00822 if (pttoMaterial) GapMaterial = pttoMaterial; 00823 } 00824 00825 void DetectorConstruction::SetGeDetectorShellMaterial(G4String materialChoice) 00826 { 00827 // search the material by its name 00828 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); 00829 if (pttoMaterial) GeDetectorShellMaterial = pttoMaterial; 00830 } 00831 00832 void DetectorConstruction::SetShieldingMaterial(G4String materialChoice) 00833 { 00834 // search the material by its name 00835 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); 00836 if (pttoMaterial) ShieldingMaterial = pttoMaterial; 00837 } 00838 00839 void DetectorConstruction::SetBeamBlockerMaterial(G4String materialChoice) 00840 { 00841 // search the material by its name 00842 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); 00843 if (pttoMaterial) BeamBlockerMaterial = pttoMaterial; 00844 } 00845 00846 00847 void DetectorConstruction::SetShieldingBeamBlockerMaterial(G4String materialChoice) 00848 { 00849 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); 00850 if (pttoMaterial) ShieldingBeamBlockerMaterial = pttoMaterial; 00851 } 00852 00853 void DetectorConstruction::SetGermaniumDetectorMaterial(G4String materialChoice) 00854 { 00855 // search the material by its name 00856 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); 00857 if (pttoMaterial) GermaniumDetectorMaterial = pttoMaterial; 00858 } 00859 00860 void DetectorConstruction::SetScintillatorDiameter(G4double val) 00861 { 00862 // change Absorber thickness and recompute the calorimeter parameters 00863 ScintillatorDiameter = val; 00864 } 00865 00866 void DetectorConstruction::SetScintillatorShieldingGapThickness(G4double val) 00867 { 00868 // change Gap thickness and recompute the calorimeter parameters 00869 ScintillatorShieldingGapThickness = val; 00870 } 00871 00872 void DetectorConstruction::SetBeamBlockerThickness(G4double thickness) 00873 { 00874 BeamBlockerThickness = thickness; 00875 } 00876 00877 void DetectorConstruction::SetShieldingBeamBlockerThickness(G4double thickness) 00878 { 00879 ShieldingBeamBlockerThickness = thickness; 00880 } 00881 00882 void DetectorConstruction::SetShieldingThickness(G4double thickness) 00883 { 00884 ShieldingThickness = thickness; 00885 } 00886 00887 00888 void DetectorConstruction::SetTopShieldingThickness(G4double thickness) 00889 { 00890 TopShieldingThickness = thickness; 00891 } 00892 00893 00894 void DetectorConstruction::SetGeDetectorRadius(G4double radius) 00895 { 00896 GeDetectorRadius = radius; 00897 } 00898 00899 void DetectorConstruction::SetGeDetectorShellLength(G4double length) 00900 { 00901 GeDetectorShellLength = length; 00902 } 00903 00904 void DetectorConstruction::SetGeDetectorLength(G4double length) 00905 { 00906 GeDetectorLength = length; 00907 } 00908 00909 void DetectorConstruction::SetGeDetectorShellInnerRadius(G4double radius) 00910 { 00911 GeDetectorShellInnerRadius = radius; 00912 } 00913 00914 void DetectorConstruction::SetGeDetectorShellOuterRadius(G4double radius) 00915 { 00916 GeDetectorShellOuterRadius = radius; 00917 } 00918 00919 00920 void DetectorConstruction::SetNumberOfScintillatorsPerBox(G4int val) 00921 { 00922 NumberOfScintillatorsPerBox = val; 00923 } 00924 00925 void DetectorConstruction::SetNumberOfScintillatorBoxes(G4int val) 00926 { 00927 NumberOfScintillatorBoxes = val; 00928 } 00929 00930 00931 void DetectorConstruction::SetBetaFlipping(G4bool flip) 00932 { 00933 FlipBeta = flip; 00934 } 00935 00936 00937 void DetectorConstruction::UpdateGeometry() 00938 { 00939 G4RunManager::GetRunManager()->DefineWorldVolume(ConstructDetector()); 00940 } 00941