Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // 23 // 27 /// \file medical/GammaTherapy/src/DetectorCon << 28 /// \brief Implementation of the DetectorConst << 29 // << 30 // << 31 // ------------------------------------------- 24 // ------------------------------------------------------------- 32 // GEANT4 ibrem test 25 // GEANT4 ibrem test 33 // 26 // 34 // Authors: V.Grichine, V.Ivanchenko 27 // Authors: V.Grichine, V.Ivanchenko 35 // 28 // 36 // Modified: 29 // Modified: 37 // 30 // 38 // 18-02-03 V.Ivanchenko create 31 // 18-02-03 V.Ivanchenko create 39 // 32 // 40 // ------------------------------------------- 33 // ------------------------------------------------------------- 41 34 42 //....oooOO0OOooo........oooOO0OOooo........oo << 35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 43 //....oooOO0OOooo........oooOO0OOooo........oo << 36 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 44 37 45 #include "DetectorConstruction.hh" 38 #include "DetectorConstruction.hh" 46 << 47 #include "CheckVolumeSD.hh" << 48 #include "DetectorMessenger.hh" 39 #include "DetectorMessenger.hh" 49 #include "PhantomSD.hh" 40 #include "PhantomSD.hh" 50 #include "TargetSD.hh" 41 #include "TargetSD.hh" >> 42 #include "CheckVolumeSD.hh" >> 43 #include "Histo.hh" 51 44 52 #include "G4Box.hh" 45 #include "G4Box.hh" 53 #include "G4Colour.hh" << 46 #include "G4Tubs.hh" 54 #include "G4GeometryManager.hh" << 55 #include "G4LogicalVolume.hh" 47 #include "G4LogicalVolume.hh" 56 #include "G4LogicalVolumeStore.hh" << 48 #include "G4VPhysicalVolume.hh" 57 #include "G4Material.hh" << 58 #include "G4NistManager.hh" << 59 #include "G4PVPlacement.hh" 49 #include "G4PVPlacement.hh" 60 #include "G4PhysicalConstants.hh" << 50 #include "G4Material.hh" 61 #include "G4PhysicalVolumeStore.hh" << 62 #include "G4RunManager.hh" << 63 #include "G4SDManager.hh" 51 #include "G4SDManager.hh" >> 52 #include "PhantomSD.hh" >> 53 >> 54 #include "G4PhysicalVolumeStore.hh" >> 55 #include "G4LogicalVolumeStore.hh" 64 #include "G4SolidStore.hh" 56 #include "G4SolidStore.hh" 65 #include "G4SystemOfUnits.hh" << 57 #include "G4RunManager.hh" 66 #include "G4Tubs.hh" << 58 67 #include "G4VPhysicalVolume.hh" << 59 68 #include "G4VisAttributes.hh" 60 #include "G4VisAttributes.hh" 69 #include "G4ios.hh" << 61 #include "G4Colour.hh" >> 62 70 #include "globals.hh" 63 #include "globals.hh" >> 64 #include "G4ios.hh" 71 65 72 //....oooOO0OOooo........oooOO0OOooo........oo << 66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 73 67 74 DetectorConstruction::DetectorConstruction() 68 DetectorConstruction::DetectorConstruction() 75 { 69 { 76 fLogicTarget1 = 0; << 70 Initialise(); 77 fLogicTarget2 = 0; << 71 } 78 72 79 fMessenger = new DetectorMessenger(this); << 73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 80 fVerbose = false; << 81 74 82 fNumZ = 60; << 75 DetectorConstruction::~DetectorConstruction() 83 fNumR = 80; << 76 {} 84 77 85 fNumE = 200; << 78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 86 fMaxEnergy = 50.0 * MeV; << 87 79 88 fDistanceVacuumTarget = 30. * mm, << 80 void DetectorConstruction::Initialise() >> 81 { >> 82 logicTarget1 = 0; >> 83 logicTarget2 = 0; >> 84 DefineMaterials(); >> 85 dMessenger = new DetectorMessenger(this); >> 86 >> 87 checkSD = new CheckVolumeSD("checkSD"); >> 88 (G4SDManager::GetSDMpointer())->AddNewDetector( checkSD ); >> 89 calorimeterSD = new PhantomSD("phantomSD"); >> 90 (G4SDManager::GetSDMpointer())->AddNewDetector( calorimeterSD ); >> 91 targetSD = new TargetSD("targetSD"); >> 92 (G4SDManager::GetSDMpointer())->AddNewDetector( targetSD ); >> 93 >> 94 fDistanceVacuumTarget = 30.*mm, >> 95 >> 96 fDelta = 0.001*mm; >> 97 >> 98 fTargetRadius = 100.*mm; >> 99 fTarget1Z = 9.*mm; >> 100 fTarget2Z = 6.*mm; >> 101 >> 102 fGasVolumeRadius = 210.*mm; >> 103 fGasVolumeZ = 690.*mm; >> 104 fMylarVolumeZ = 0.02*mm; >> 105 >> 106 fCheckVolumeZ = 0.1*mm; >> 107 fCheckShiftZ = 200.*mm; >> 108 >> 109 fAbsorberRadius = 200.*mm; >> 110 fPhantomRadius = 300.*mm; >> 111 fPhantomZ = 300.*mm; >> 112 >> 113 fAirZ = 210.*mm; >> 114 fAbsorberShiftZ = 70.*mm; >> 115 fWindowZ = 0.05*mm; >> 116 } 89 117 90 fDelta = 0.001 * mm; << 91 118 92 fTargetRadius = 100. * mm; << 119 /////////////////////////////////////////////////////////////// 93 fTarget1Z = 9. * mm; << 94 fTarget2Z = 6. * mm; << 95 120 96 fGasVolumeRadius = 210. * mm; << 121 void DetectorConstruction::InitialiseGeometryParameters() 97 fGasVolumeZ = 690. * mm; << 122 { 98 fMylarVolumeZ = 0.02 * mm; << 123 // Volumee sizes 99 124 100 fCheckVolumeZ = 0.1 * mm; << 125 G4double factor = 1.2; 101 fCheckShiftZ = 200. * mm; << 102 126 103 fAbsorberRadius = 200. * mm; << 127 fWorldXY = factor*std::max(fPhantomRadius,fGasVolumeRadius); 104 fPhantomRadius = 300. * mm; << 128 G4double nz = (G4int)((Histo::GetPointer())->GetNumberDivZ()); 105 fPhantomZ = 300. * mm; << 129 fAbsorberZ = fPhantomZ/nz; >> 130 fGasVolumeZ = 1000.*mm - fAbsorberShiftZ - fAirZ - fTarget1Z - fTarget2Z; 106 131 107 fAirZ = 210. * mm; << 132 G4double ztot = fGasVolumeZ + fAirZ + fPhantomZ + fDistanceVacuumTarget; 108 fAbsorberShiftZ = 70. * mm; << 133 fTargetVolumeZ = fDistanceVacuumTarget + fTarget2Z + fTarget1Z + fDelta; 109 fWindowZ = 0.05 * mm; << 134 fWorldZ = factor*ztot*0.5; 110 135 111 G4NistManager* man = G4NistManager::Instance << 136 if(fCheckShiftZ < fDelta) fCheckShiftZ = fDelta; 112 // man->SetVerbose(1); << 137 if(fCheckShiftZ > fAirZ - fCheckVolumeZ -fDelta) >> 138 fCheckShiftZ = fAirZ - fCheckVolumeZ -fDelta; 113 139 114 fTarget1Material = man->FindOrBuildMaterial( << 140 // Z position of volumes from upstream to downstream 115 fWindowMaterial = fTarget1Material; << 116 fTarget2Material = man->FindOrBuildMaterial( << 117 fLightMaterial = man->FindOrBuildMaterial("G << 118 fAbsorberMaterial = man->FindOrBuildMaterial << 119 fWorldMaterial = man->FindOrBuildMaterial("G << 120 fMylar = man->FindOrBuildMaterial("G4_MYLAR" << 121 141 122 G4cout << *(G4Material::GetMaterialTable()) << 142 fWindowPosZ = -(ztot + fWindowZ)*0.5; >> 143 fGeneratorPosZ = fWindowPosZ - 0.5*fWindowZ - fDelta; >> 144 >> 145 fTargetVolumePosZ= -0.5*(ztot - fTargetVolumeZ); >> 146 fTarget1PosZ = -0.5*(fTargetVolumeZ - fTarget1Z) + fDistanceVacuumTarget; >> 147 fTarget2PosZ = fTarget1PosZ + 0.5*(fTarget2Z + fTarget1Z); >> 148 >> 149 fGasVolumePosZ = fTargetVolumePosZ + 0.5*(fTargetVolumeZ + fGasVolumeZ); >> 150 fCheckVolumePosZ = fGasVolumePosZ + 0.5*(fGasVolumeZ + fCheckVolumeZ) >> 151 + fCheckShiftZ; >> 152 fMylarPosZ = fGasVolumePosZ + 0.5*(fGasVolumeZ + fMylarVolumeZ) + fDelta; >> 153 >> 154 fPhantomPosZ = fGasVolumePosZ + 0.5*(fGasVolumeZ + fPhantomZ) + fAirZ; >> 155 fAbsorberPosZ = fAbsorberShiftZ - 0.5*(fPhantomZ - fAbsorberZ); >> 156 (Histo::GetPointer())->SetAbsorberZ(fPhantomZ); >> 157 (Histo::GetPointer())->SetAbsorberR(fAbsorberRadius); >> 158 (Histo::GetPointer())->SetScoreZ(fAbsorberShiftZ); >> 159 G4double shiftZPh = fPhantomPosZ-0.5*fPhantomZ; >> 160 calorimeterSD->setShiftZ(shiftZPh); >> 161 G4cout << "===================================================" << G4endl; >> 162 G4cout << "# IBREM geometry #" << G4endl; >> 163 G4cout << "===================================================" << G4endl; >> 164 G4cout << " World width= " << fWorldZ/mm << " mm " << G4endl; >> 165 G4cout << " Window width= " << fWindowZ/mm << " mm position = " >> 166 << fWindowPosZ/mm << " mm:" << G4endl; >> 167 G4cout << " TargetV width= " << fTargetVolumeZ/mm << " mm position = " >> 168 << fTargetVolumePosZ/mm << " mm:" << G4endl; >> 169 G4cout << " Target1 width= " << fTarget1Z/mm << " mm position = " >> 170 << fTarget1PosZ/mm << " mm:" << G4endl; >> 171 G4cout << " Target2 width= " << fTarget2Z/mm << " mm position = " >> 172 << fTarget2PosZ/mm << " mm:" << G4endl; >> 173 G4cout << " Gas width= " << fGasVolumeZ/mm << " mm position = " >> 174 << fGasVolumePosZ/mm << " mm:" << G4endl; >> 175 G4cout << " Mylar width= " << fMylarVolumeZ/mm << " mm position = " >> 176 << fMylarPosZ/mm << " mm:" << G4endl; >> 177 G4cout << " Check width= " << fCheckVolumeZ/mm << " mm position = " >> 178 << fCheckVolumePosZ/mm << " mm:" << G4endl; >> 179 G4cout << " Air width= " << fAirZ/mm << " mm " << G4endl; >> 180 G4cout << " Phantom width= " << fPhantomZ/mm << " mm position = " >> 181 << fPhantomPosZ/mm << " mm:" << G4endl; >> 182 G4cout << " Absorb width= " << fAbsorberZ/mm << " mm position = " >> 183 << fAbsorberPosZ/mm << " mm:" << G4endl; >> 184 G4cout << " Absorb shift= " << shiftZPh/mm << " mm " << G4endl; >> 185 G4cout << " Target1 " << fTarget1Material->GetName() << G4endl; >> 186 G4cout << " Target2 " << fTarget2Material->GetName() << G4endl; >> 187 G4cout << " Phantom " << fAbsorberMaterial->GetName() << G4endl; >> 188 G4cout << "===================================================" << G4endl; 123 } 189 } 124 190 125 //....oooOO0OOooo........oooOO0OOooo........oo << 191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 126 192 127 DetectorConstruction::~DetectorConstruction() << 193 G4VPhysicalVolume* DetectorConstruction::Construct() 128 { 194 { 129 delete fMessenger; << 195 return ConstructVolumes(); 130 } 196 } 131 197 132 //....oooOO0OOooo........oooOO0OOooo........oo << 198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 133 199 134 void DetectorConstruction::InitialiseGeometryP << 200 void DetectorConstruction::DefineMaterials() 135 { 201 { 136 // Volumee sizes << 137 202 138 G4double factor = 1.2; << 203 G4String name, symbol; //a=mass of a mole; >> 204 G4double a, z, density; //z=mean number of protons; 139 205 140 fWorldXY = factor * std::max(fPhantomRadius, << 206 G4int iz,n,ncomponents, natoms; 141 fAbsorberZ = fPhantomZ / fNumZ; << 207 G4double fractionmass; 142 fGasVolumeZ = 1000. * mm - fAbsorberShiftZ - << 208 G4double temperature, pressure; 143 209 144 G4double ztot = fGasVolumeZ + fAirZ + fPhant << 210 // std::vector<G4Material*> list; 145 fTargetVolumeZ = fDistanceVacuumTarget + fTa << 211 G4Material* ma = 0; 146 fWorldZ = factor * ztot * 0.5; << 147 212 148 if (fCheckShiftZ < fDelta) { << 213 // 149 fCheckShiftZ = fDelta; << 214 // define Elements 150 } << 215 // 151 if (fCheckShiftZ > fAirZ - fCheckVolumeZ - f << 152 fCheckShiftZ = fAirZ - fCheckVolumeZ - fDe << 153 } << 154 216 155 // Z position of volumes from upstream to do << 217 // a = 1.01*g/mole; >> 218 // G4Element* elH = new G4Element(name="Hydrogen",symbol="H", z= 1., a); 156 219 157 fWindowPosZ = -(ztot + fWindowZ) * 0.5; << 220 a = 1.01*g/mole; 158 fGeneratorPosZ = fWindowPosZ - 0.5 * fWindow << 221 G4Isotope* ih1 = new G4Isotope("Hydrogen",iz=1,n=1,a); 159 222 160 fTargetVolumePosZ = -0.5 * (ztot - fTargetVo << 223 a = 2.01*g/mole; 161 fTarget1PosZ = -0.5 * (fTargetVolumeZ - fTar << 224 G4Isotope* ih2 = new G4Isotope("Deuterium",iz=1,n=2,a); 162 fTarget2PosZ = fTarget1PosZ + 0.5 * (fTarget << 163 225 164 fGasVolumePosZ = fTargetVolumePosZ + 0.5 * ( << 226 G4Element* elH = new G4Element(name="Hydrogen",symbol="H",2); 165 fCheckVolumePosZ = fGasVolumePosZ + 0.5 * (f << 227 elH->AddIsotope(ih1,.999); 166 fMylarPosZ = fGasVolumePosZ + 0.5 * (fGasVol << 228 elH->AddIsotope(ih2,.001); 167 229 168 fPhantomPosZ = fGasVolumePosZ + 0.5 * (fGasV << 169 fAbsorberPosZ = fAbsorberShiftZ - 0.5 * (fPh << 170 230 171 fShiftZPh = fPhantomPosZ - 0.5 * fPhantomZ; << 231 a = 14.01*g/mole; >> 232 G4Element* elN = new G4Element(name="Nitrogen",symbol="N" , z= 7., a); 172 233 173 DumpGeometryParameters(); << 234 a = 16.00*g/mole; 174 } << 235 G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a); 175 236 176 //....oooOO0OOooo........oooOO0OOooo........oo << 237 a = 12.00*g/mole; >> 238 G4Element* elC = new G4Element(name="Carbon" ,symbol="C" , z= 6., a); 177 239 178 G4VPhysicalVolume* DetectorConstruction::Const << 240 a = 39.948*g/mole; 179 { << 241 G4Element* elAr = new G4Element(name="Argon", symbol="Ar", z=18., a); 180 InitialiseGeometryParameters(); << 181 242 182 G4GeometryManager::GetInstance()->OpenGeomet << 243 a = 69.723*g/mole; 183 G4PhysicalVolumeStore::GetInstance()->Clean( << 244 G4Element* elGa = new G4Element(name="Gallium" ,symbol="Ga" , z= 31., a); 184 G4LogicalVolumeStore::GetInstance()->Clean() << 245 185 G4SolidStore::GetInstance()->Clean(); << 246 a = 74.9216*g/mole; 186 // << 247 G4Element* elAs = new G4Element(name="Arsenicum" ,symbol="As" , z= 33., a); 187 // World << 188 // << 189 248 190 G4Box* solidWorld = new G4Box("World", fWorl << 249 G4Element* Cs = new G4Element ("Cesium" , "Cs", 55. , 132.905*g/mole); 191 G4LogicalVolume* logicWorld = new G4LogicalV << 250 192 G4VPhysicalVolume* physWorld = << 251 G4Element* I = new G4Element ("Iodide" , "I", 53. , 126.9044*g/mole); 193 new G4PVPlacement(0, G4ThreeVector(), "Wor << 252 >> 253 >> 254 // >> 255 // define simple materials >> 256 // >> 257 density = 1.848*g/cm3; >> 258 a = 9.01*g/mole; >> 259 ma = new G4Material(name="Be", z=4., a, density); >> 260 fTarget1Material = ma; >> 261 fWindowMaterial = ma; >> 262 >> 263 density = 19.35*g/cm3; >> 264 a = 183.85*g/mole; >> 265 ma = new G4Material(name="W", z=74., a, density); >> 266 fTarget2Material = ma; >> 267 >> 268 density = 8.960*g/cm3; >> 269 a = 63.55*g/mole; >> 270 ma = new G4Material(name="Cu" , z=29., a, density); >> 271 >> 272 // Helium as light gas volume >> 273 >> 274 density = 0.178*mg/cm3 ; >> 275 a = 4.0026*g/mole ; >> 276 G4Material* He = new G4Material(name="He",z=2., a, density ); >> 277 fLightMaterial = He; >> 278 >> 279 density = 2.699*g/cm3; >> 280 a = 26.98*g/mole; >> 281 ma = new G4Material(name="Aluminum", z=13., a, density); >> 282 >> 283 density = 2.265*g/cm3; >> 284 a = 12.0107*g/mole; >> 285 ma = new G4Material(name="Carbon", z=6., a, density); >> 286 >> 287 density = 2.330*g/cm3; >> 288 a = 28.09*g/mole; >> 289 ma = new G4Material(name="Silicon", z=14., a, density); >> 290 >> 291 density = 1.390*g/cm3; >> 292 a = 39.95*g/mole; >> 293 ma = new G4Material(name="LiquidArgon", z=18., a, density); >> 294 >> 295 density = 3.02*g/cm3; >> 296 a = 131.29*g/mole; >> 297 ma = new G4Material(name="LiquidXenon", z=54., a, density); >> 298 >> 299 density = 7.874*g/cm3; >> 300 a = 55.85*g/mole; >> 301 ma = new G4Material(name="Iron" , z=26., a, density); >> 302 >> 303 density = 5.323*g/cm3; >> 304 a = 72.61*g/mole; >> 305 ma = new G4Material(name="Germanium", z=32., a, density); >> 306 >> 307 density = 19.32*g/cm3; >> 308 a =196.97*g/mole; >> 309 ma = new G4Material(name="Gold" , z=79., a, density); >> 310 >> 311 density = 11.35*g/cm3; >> 312 a = 207.19*g/mole; >> 313 ma = new G4Material(name="Lead" , z=82., a, density); >> 314 >> 315 // >> 316 // define a material from elements. case 1: chemical molecule >> 317 // >> 318 >> 319 >> 320 density = 1.000*g/cm3; >> 321 ma = new G4Material("Water", density, 2); >> 322 ma->SetChemicalFormula("H_2O"); >> 323 ma->AddElement(elH, natoms=2); >> 324 ma->AddElement(elO, natoms=1); >> 325 G4double exc = ma->GetIonisation()->FindMeanExcitationEnergy("H_2O"); >> 326 ma->GetIonisation()->SetMeanExcitationEnergy(exc); >> 327 fAbsorberMaterial = ma; >> 328 >> 329 density = 0.0006672*g/cm3; >> 330 ma = new G4Material("Methane", density, 2); >> 331 ma->SetChemicalFormula("CH_4"); >> 332 ma->AddElement(elH, natoms=4); >> 333 ma->AddElement(elC, natoms=1); >> 334 >> 335 ma = new G4Material("Graphite", 2.265*g/cm3, 1); >> 336 ma->SetChemicalFormula("Graphite"); >> 337 ma->AddElement( elC, 1 ); >> 338 >> 339 density = 5.3176*g/cm3; >> 340 ma = new G4Material("GaAs", density, ncomponents=2); >> 341 ma->SetChemicalFormula("GaAS"); >> 342 ma->AddElement(elGa, natoms=1); >> 343 ma->AddElement(elAs, natoms=1); >> 344 >> 345 ma = new G4Material ("Ethane" , 0.4241*g/cm3, 2); >> 346 ma->SetChemicalFormula("C_2H_6"); >> 347 ma->AddElement(elH,6); >> 348 ma->AddElement(elC,2); >> 349 >> 350 ma = new G4Material ("CsI" , 4.51*g/cm3, 2); >> 351 ma->SetChemicalFormula("CsI"); >> 352 ma->AddElement(Cs,1); >> 353 ma->AddElement(I,1); >> 354 >> 355 // >> 356 // define a material from elements. case 2: mixture by fractional mass >> 357 // >> 358 >> 359 // Dry air (average composition) >> 360 >> 361 density = 1.25053*mg/cm3 ; // STP >> 362 G4Material* Nitrogen = new G4Material(name="N2" , density, ncomponents=1); >> 363 Nitrogen->AddElement(elN, 2); >> 364 >> 365 density = 1.4289*mg/cm3 ; // STP >> 366 G4Material* Oxygen = new G4Material(name="O2" , density, ncomponents=1); >> 367 Oxygen->AddElement(elO, 2); >> 368 >> 369 density = 1.7836*mg/cm3 ; // STP >> 370 G4Material* Argon = new G4Material(name="Argon" , density, ncomponents=1); >> 371 Argon->AddElement(elAr, 1); >> 372 >> 373 density = 1.2928*mg/cm3 ; // STP >> 374 G4Material* Air = new G4Material(name="Air" , density, ncomponents=3); >> 375 Air->AddMaterial( Nitrogen, fractionmass = 0.7557 ) ; >> 376 Air->AddMaterial( Oxygen, fractionmass = 0.2315 ) ; >> 377 Air->AddMaterial( Argon, fractionmass = 0.0128 ) ; >> 378 >> 379 fWorldMaterial = Air; >> 380 >> 381 density = 1.39*g/cm3; >> 382 ma = new G4Material("Mylar" , density, ncomponents=3); >> 383 ma->AddElement(elC, natoms=10); >> 384 ma->AddElement(elH, natoms=18); >> 385 ma->AddElement(elO, natoms=5); >> 386 fMylar = ma; >> 387 >> 388 density = universe_mean_density; //from PhysicalConstants.h >> 389 pressure = 3.e-18*pascal; >> 390 temperature = 2.73*kelvin; >> 391 a = 1.01*g/mole; >> 392 z = 1.0; >> 393 ma = new G4Material("Vacuum", z, a, density, >> 394 kStateGas,temperature,pressure); >> 395 G4cout << *(G4Material::GetMaterialTable()) << G4endl; >> 396 >> 397 } >> 398 >> 399 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 400 >> 401 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes() >> 402 { >> 403 // Cleanup old geometry >> 404 G4PhysicalVolumeStore::GetInstance()->Clean(); >> 405 G4LogicalVolumeStore::GetInstance()->Clean(); >> 406 G4SolidStore::GetInstance()->Clean(); >> 407 >> 408 // >> 409 InitialiseGeometryParameters(); >> 410 >> 411 // >> 412 // World >> 413 // >> 414 >> 415 G4VPhysicalVolume* pv; >> 416 >> 417 G4Box* solidWorld = new G4Box("World",fWorldXY,fWorldXY,fWorldZ); >> 418 >> 419 G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, >> 420 fWorldMaterial,"World"); >> 421 G4VPhysicalVolume* physWorld = new G4PVPlacement(0,G4ThreeVector(),"World", >> 422 logicWorld,0,false,0); 194 423 195 // Be Vacuum window 424 // Be Vacuum window 196 G4Tubs* solidWin = new G4Tubs("Window", 0., << 425 G4Tubs* solidWin = new G4Tubs("Window",0.,fTargetRadius*0.25,0.5*fWindowZ,0.,twopi); 197 G4LogicalVolume* logicWin = new G4LogicalVol << 426 G4LogicalVolume* logicWin = new G4LogicalVolume(solidWin,fWindowMaterial,"Window"); 198 new G4PVPlacement(0, G4ThreeVector(0., 0., f << 427 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fWindowPosZ),"Window",logicWin, >> 428 physWorld,false,0); 199 429 200 // Target Volume 430 // Target Volume 201 G4Tubs* solidTGVolume = << 431 G4Tubs* solidTGVolume = new G4Tubs("TargetVolume",0.,fTargetRadius, 202 new G4Tubs("TargetVolume", 0., fTargetRadi << 432 0.5*fTargetVolumeZ,0.,twopi); 203 G4LogicalVolume* logicTGVolume = << 433 G4LogicalVolume* logicTGVolume = new G4LogicalVolume(solidTGVolume, 204 new G4LogicalVolume(solidTGVolume, fLightM << 434 fLightMaterial,"TargetVolume"); 205 new G4PVPlacement(0, G4ThreeVector(0., 0., f << 435 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fTargetVolumePosZ),logicTGVolume,"TargetVolume", 206 logicWorld, false, 0); << 436 logicWorld,false,0); 207 437 208 // Target 1 438 // Target 1 209 G4Tubs* solidTarget1 = new G4Tubs("Target1", << 439 G4Tubs* solidTarget1 = new G4Tubs("Target1",0.,fTargetRadius*0.5,0.5*fTarget1Z,0.,twopi); 210 fLogicTarget1 = new G4LogicalVolume(solidTar << 440 logicTarget1 = new G4LogicalVolume(solidTarget1,fTarget1Material,"Target1"); 211 fTarget1 = new G4PVPlacement(0, G4ThreeVecto << 441 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fTarget1PosZ),logicTarget1,"Target1", 212 logicTGVolume, << 442 logicTGVolume,false,0); 213 // fLogicTarget1->SetSensitiveDetector(fTar << 443 (Histo::GetPointer())->SetTarget1(pv); >> 444 logicTarget1->SetSensitiveDetector(targetSD); >> 445 214 446 215 // Target 2 (for combined targets) 447 // Target 2 (for combined targets) 216 G4Tubs* solidTarget2 = new G4Tubs("Target2", << 448 G4Tubs* solidTarget2 = new G4Tubs("Target2",0.,fTargetRadius*0.5,0.5*fTarget2Z,0.,twopi); 217 fLogicTarget2 = new G4LogicalVolume(solidTar << 449 logicTarget2 = new G4LogicalVolume(solidTarget2,fTarget2Material,"Target2"); 218 fTarget2 = new G4PVPlacement(0, G4ThreeVecto << 450 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fTarget2PosZ),logicTarget2,"Target2", 219 logicTGVolume, << 451 logicTGVolume,false,0); 220 452 221 // fLogicTarget2->SetSensitiveDetector(fTar << 453 (Histo::GetPointer())->SetTarget2(pv); >> 454 logicTarget2->SetSensitiveDetector(targetSD); 222 455 223 // Gas Volume 456 // Gas Volume 224 G4Tubs* solidGasVolume = << 457 225 new G4Tubs("GasVolume", 0., fGasVolumeRadi << 458 G4Tubs* solidGasVolume = new G4Tubs("GasVolume",0.,fGasVolumeRadius, 226 G4LogicalVolume* logicGasVolume = << 459 0.5*fGasVolumeZ,0.,twopi); 227 new G4LogicalVolume(solidGasVolume, fLight << 460 G4LogicalVolume* logicGasVolume = new G4LogicalVolume(solidGasVolume, 228 fGasVolume = new G4PVPlacement(0, G4ThreeVec << 461 fLightMaterial,"GasVolume"); 229 logicGasVolum << 462 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fGasVolumePosZ), >> 463 "GasVolume",logicGasVolume, >> 464 physWorld,false,0); >> 465 (Histo::GetPointer())->SetGasVolume(pv); 230 466 231 // Mylar window 467 // Mylar window 232 G4Tubs* sMylarVolume = new G4Tubs("Mylar", 0 << 468 233 G4LogicalVolume* lMylarVolume = new G4Logica << 469 G4Tubs* sMylarVolume = new G4Tubs("Mylar",0.,fGasVolumeRadius, 234 new G4PVPlacement(0, G4ThreeVector(0., 0., f << 470 0.5*fMylarVolumeZ,0.,twopi); 235 0); << 471 G4LogicalVolume* lMylarVolume = new G4LogicalVolume(sMylarVolume, >> 472 fMylar,"Mylar"); >> 473 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fMylarPosZ),"Mylar",lMylarVolume, >> 474 physWorld,false,0); >> 475 236 476 237 // Check Volume 477 // Check Volume 238 G4Tubs* solidCheckVolume = << 478 239 new G4Tubs("CheckVolume", 0., fGasVolumeRa << 479 G4Tubs* solidCheckVolume = new G4Tubs("CheckVolume",0.,fGasVolumeRadius, 240 fLogicCheckVolume = new G4LogicalVolume(soli << 480 0.5*fCheckVolumeZ,0.,twopi); 241 fCheckVolume = new G4PVPlacement(0, G4ThreeV << 481 G4LogicalVolume* logicCheckVolume = new G4LogicalVolume(solidCheckVolume, 242 fLogicCheck << 482 fWorldMaterial,"CheckVolume"); 243 // logicCheckVolume->SetSensitiveDetector(f << 483 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fCheckVolumePosZ), >> 484 "CheckVolume",logicCheckVolume, >> 485 physWorld,false,0); >> 486 (Histo::GetPointer())->SetCheckVolume(pv); >> 487 logicCheckVolume->SetSensitiveDetector(checkSD); 244 488 245 // Phantom 489 // Phantom 246 G4Box* solidPhantom = new G4Box("Phantom", f << 247 G4LogicalVolume* logicPhantom = new G4Logica << 248 G4VPhysicalVolume* physPhantom = new G4PVPla << 249 << 250 << 251 G4Tubs* solidPh = new G4Tubs("PhantomSD", 0. << 252 fLogicPh = new G4LogicalVolume(solidPh, fAbs << 253 fPhantom = << 254 new G4PVPlacement(0, G4ThreeVector(0., 0., << 255 G4cout << "Phantom R= " << fAbsorberRadius < << 256 490 257 // Sensitive Absorber << 491 G4Box* solidPhantom = new G4Box("Phantom",fPhantomRadius,fPhantomRadius, 258 G4double absWidth = 0.5 * fAbsorberZ; << 492 0.5*fPhantomZ); 259 G4Tubs* solidAbsorber = new G4Tubs("Absorber << 493 G4LogicalVolume* logicPhantom = new G4LogicalVolume(solidPhantom, 260 fLogicAbsorber = new G4LogicalVolume(solidAb << 494 fAbsorberMaterial,"Phantom"); 261 G4cout << "Absorber R= " << fAbsorberRadius << 495 G4VPhysicalVolume* physPhantom = new G4PVPlacement(0, 262 << G4endl; << 496 G4ThreeVector(0.,0.,fPhantomPosZ), >> 497 "Phantom",logicPhantom, >> 498 physWorld,false,0); >> 499 >> 500 G4Tubs* solidPh = new G4Tubs("PhantomSD",0.,fAbsorberRadius,0.5*fPhantomZ,0.,twopi); >> 501 G4LogicalVolume* logicPh = new G4LogicalVolume(solidPh,fAbsorberMaterial,"PhantomSD"); >> 502 G4VPhysicalVolume* physPh = new G4PVPlacement(0,G4ThreeVector(0.,0.,0.), >> 503 "Phantom",logicPh, >> 504 physPhantom,false,0); >> 505 G4cout << "Phantom R= " << fAbsorberRadius << " dz= " << 0.5*fPhantomZ << G4endl; 263 506 264 new G4PVPlacement(0, G4ThreeVector(0., 0., f << 507 // Sensitive Absorber 265 false, 0); << 266 508 267 G4double stepR = fAbsorberRadius / (G4double << 509 G4double absWidth = 0.5*fAbsorberZ; >> 510 G4Tubs* solidAbsorber = new G4Tubs("Absorber",0.,fAbsorberRadius,absWidth,0.,twopi); >> 511 G4LogicalVolume* logicAbsorber = new G4LogicalVolume(solidAbsorber, >> 512 fAbsorberMaterial,"Absorber"); >> 513 G4cout << "Absorber R= " << fAbsorberRadius << " dz= " << absWidth << " posZ= " << fAbsorberPosZ<< G4endl; >> 514 >> 515 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fAbsorberPosZ),"Absorber",logicAbsorber, >> 516 physPh,false,0); >> 517 (Histo::GetPointer())->SetPhantom(physPh); >> 518 G4int numR = (Histo::GetPointer())->GetNumberDivR(); >> 519 G4double stepR = fAbsorberRadius/(G4double)numR; 268 520 269 G4double r1 = 0.0; 521 G4double r1 = 0.0; 270 G4double r2 = 0.0; 522 G4double r2 = 0.0; 271 G4Tubs* solidRing; 523 G4Tubs* solidRing; >> 524 G4LogicalVolume* logicRing; 272 525 273 G4VisAttributes* VisAtt_ring = new G4VisAttr << 526 for(G4int k=0; k<numR; k++) { 274 for (G4int k = 0; k < fNumR; k++) { << 275 r2 = r1 + stepR; 527 r2 = r1 + stepR; 276 if (k == fNumR - 1) r2 = fAbsorberRadius; << 528 if(k == numR-1) r2 = fAbsorberRadius; 277 // G4cout << "New ring r1= " << r1 << " << 529 // G4cout << "New ring r1= " << r1 << " r2= " << r2 << " dz= " << absWidth << G4endl; 278 // << " dz= " << absWidth << G4endl; << 530 solidRing = new G4Tubs("Ring",r1,r2,absWidth,0.,twopi); 279 solidRing = new G4Tubs("Ring", r1, r2, abs << 531 logicRing = new G4LogicalVolume(solidRing,fAbsorberMaterial,"Ring"); 280 G4LogicalVolume* logicRing = new G4Logical << 532 logicRing->SetSensitiveDetector(calorimeterSD); 281 // logicRing->SetSensitiveDetector(fPha << 533 logicRing->SetVisAttributes(G4VisAttributes::Invisible); 282 logicRing->SetVisAttributes(VisAtt_ring); << 534 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,0.),logicRing,"Ring", 283 fLogicRing.push_back(logicRing); << 535 logicAbsorber,false,k); 284 new G4PVPlacement(0, G4ThreeVector(0., 0., << 285 r1 = r2; 536 r1 = r2; 286 } 537 } 287 538 288 // 539 // >> 540 // Sensitive Detectors: Absorber >> 541 // >> 542 >> 543 logicPh->SetSensitiveDetector(calorimeterSD); >> 544 logicAbsorber->SetSensitiveDetector(calorimeterSD); >> 545 >> 546 // 289 // Visualization attributes 547 // Visualization attributes 290 // 548 // 291 G4VisAttributes* VisAtt = 0; 549 G4VisAttributes* VisAtt = 0; 292 VisAtt = new G4VisAttributes(G4Colour(1.0, 1 << 550 VisAtt = new G4VisAttributes(G4Colour(1.0,1.0,1.0)); 293 VisAtt->SetVisibility(true); 551 VisAtt->SetVisibility(true); 294 fLogicAbsorber->SetVisAttributes(VisAtt); << 552 logicAbsorber->SetVisAttributes(VisAtt); 295 553 296 VisAtt = new G4VisAttributes(G4Colour(1.0, 1 << 554 VisAtt= new G4VisAttributes(G4Colour(1.0,1.0,2.0)); 297 VisAtt->SetVisibility(true); 555 VisAtt->SetVisibility(true); 298 logicPhantom->SetVisAttributes(VisAtt); 556 logicPhantom->SetVisAttributes(VisAtt); 299 557 300 VisAtt = new G4VisAttributes(G4Colour(1.0, 0 << 558 VisAtt= new G4VisAttributes(G4Colour(1.0,0.0,2.0)); 301 VisAtt->SetVisibility(true); 559 VisAtt->SetVisibility(true); 302 fLogicPh->SetVisAttributes(VisAtt); << 560 logicPh->SetVisAttributes(VisAtt); 303 561 304 VisAtt = new G4VisAttributes(G4Colour(1.0, 1 << 562 VisAtt= new G4VisAttributes(G4Colour(1.0,1.0,0.0)); 305 VisAtt->SetVisibility(true); 563 VisAtt->SetVisibility(true); 306 fLogicAbsorber->SetVisAttributes(VisAtt); << 564 logicAbsorber->SetVisAttributes(VisAtt); 307 565 308 VisAtt = new G4VisAttributes(G4Colour(0.1, 1 << 566 VisAtt= new G4VisAttributes(G4Colour(0.1,1.0,2.0)); 309 VisAtt->SetVisibility(true); 567 VisAtt->SetVisibility(true); 310 logicWorld->SetVisAttributes(VisAtt); 568 logicWorld->SetVisAttributes(VisAtt); 311 569 312 VisAtt = new G4VisAttributes(G4Colour(1.0, 1 << 570 VisAtt= new G4VisAttributes(G4Colour(1.0,1.0,0.0)); 313 VisAtt->SetVisibility(true); 571 VisAtt->SetVisibility(true); 314 logicGasVolume->SetVisAttributes(VisAtt); 572 logicGasVolume->SetVisAttributes(VisAtt); 315 573 316 VisAtt = new G4VisAttributes(G4Colour(0.0, 0 << 574 VisAtt= new G4VisAttributes(G4Colour(0.0,0.5,1.0)); 317 VisAtt->SetVisibility(true); 575 VisAtt->SetVisibility(true); 318 fLogicTarget1->SetVisAttributes(VisAtt); << 576 logicTarget1->SetVisAttributes(VisAtt); 319 fLogicTarget2->SetVisAttributes(VisAtt); << 577 logicTarget2->SetVisAttributes(VisAtt); 320 logicTGVolume->SetVisAttributes(VisAtt); 578 logicTGVolume->SetVisAttributes(VisAtt); 321 579 322 return physWorld; 580 return physWorld; 323 } 581 } 324 582 325 void DetectorConstruction::ConstructSDandField << 326 { << 327 static G4ThreadLocal G4bool initialized = fa << 328 if (!initialized) { << 329 // Prepare sensitive detectors << 330 CheckVolumeSD* fCheckSD = new CheckVolumeS << 331 (G4SDManager::GetSDMpointer())->AddNewDete << 332 fLogicCheckVolume->SetSensitiveDetector(fC << 333 << 334 TargetSD* fTargetSD = new TargetSD("target << 335 (G4SDManager::GetSDMpointer())->AddNewDete << 336 fLogicTarget1->SetSensitiveDetector(fTarge << 337 fLogicTarget2->SetSensitiveDetector(fTarge << 338 << 339 PhantomSD* fPhantomSD = new PhantomSD("pha << 340 (G4SDManager::GetSDMpointer())->AddNewDete << 341 fPhantomSD->SetShiftZ(fShiftZPh); << 342 for (auto& v : fLogicRing) << 343 v->SetSensitiveDetector(fPhantomSD); << 344 fLogicPh->SetSensitiveDetector(fPhantomSD) << 345 fLogicAbsorber->SetSensitiveDetector(fPhan << 346 initialized = true; << 347 } << 348 } << 349 << 350 //....oooOO0OOooo........oooOO0OOooo........oo 583 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 351 584 352 void DetectorConstruction::SetTarget1Material( << 585 void DetectorConstruction::UpdateGeometry() 353 { 586 { 354 // search the material by its name << 587 G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes()); 355 G4Material* pttoMaterial = G4NistManager::In << 356 if (!pttoMaterial) { << 357 G4cout << "Material " << mat << " is not f << 358 } << 359 else if (pttoMaterial != fTarget1Material) { << 360 G4cout << "New target1 material " << mat < << 361 if (fLogicTarget1) { << 362 fLogicTarget1->SetMaterial(fTarget1Mater << 363 } << 364 G4RunManager::GetRunManager()->PhysicsHasB << 365 } << 366 } 588 } 367 589 368 //....oooOO0OOooo........oooOO0OOooo........oo 590 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 369 591 370 void DetectorConstruction::SetTarget2Material( << 592 void DetectorConstruction::setTarget1Material(const G4String& materialChoice) 371 { 593 { 372 // search the material by its name 594 // search the material by its name 373 G4Material* pttoMaterial = G4NistManager::In << 595 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); 374 << 596 if (pttoMaterial) 375 if (!pttoMaterial) { << 597 { 376 G4cout << "Material " << mat << " is not f << 598 fTarget1Material = pttoMaterial; 377 } << 599 G4cout << "New target1 material " << materialChoice << G4endl; 378 else if (pttoMaterial != fTarget2Material) { << 600 if(logicTarget1) logicTarget1->SetMaterial(fTarget1Material); 379 fTarget2Material = pttoMaterial; << 601 } 380 G4cout << "New target2 material " << mat < << 602 else 381 if (fLogicTarget2) { << 603 G4cout << "Material " << materialChoice << " is not found out!" << G4endl; 382 fLogicTarget2->SetMaterial(fTarget2Mater << 383 } << 384 G4RunManager::GetRunManager()->PhysicsHasB << 385 } << 386 } 604 } 387 605 388 //....oooOO0OOooo........oooOO0OOooo........oo 606 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 389 607 390 void DetectorConstruction::DumpGeometryParamet << 608 void DetectorConstruction::setTarget2Material(const G4String& materialChoice) 391 { 609 { 392 G4cout << "================================= << 610 // search the material by its name 393 G4cout << "# GammaTherapy Geometry << 611 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); 394 G4cout << "================================= << 612 if (pttoMaterial) 395 G4cout << " World width= " << fWorldZ / m << 613 { 396 G4cout << " Window width= " << fWindowZ / << 614 fTarget2Material = pttoMaterial; 397 << " mm:" << G4endl; << 615 G4cout << "New target2 material " << materialChoice << G4endl; 398 G4cout << " TargetV width= " << fTargetVolu << 616 if(logicTarget2) logicTarget2->SetMaterial(fTarget2Material); 399 << " mm position = " << fTargetVolum << 617 } 400 G4cout << " Target1 width= " << fTarget1Z / << 618 else 401 << " mm:" << G4endl; << 619 G4cout << "Material " << materialChoice << " is not found out!" << G4endl; 402 G4cout << " Target2 width= " << fTarget2Z / << 403 << " mm:" << G4endl; << 404 G4cout << " Gas width= " << fGasVolumeZ << 405 << " mm:" << G4endl; << 406 G4cout << " Mylar width= " << fMylarVolum << 407 << " mm:" << G4endl; << 408 G4cout << " Check width= " << fCheckVolum << 409 << " mm position = " << fCheckVol << 410 G4cout << " Air width= " << fAirZ / mm << 411 G4cout << " Phantom width= " << fPhantomZ / << 412 << " mm:" << G4endl; << 413 G4cout << " Absorb width= " << fAbsorberZ << 414 << " mm:" << G4endl; << 415 G4cout << " Absorb shift= " << fShiftZPh / << 416 G4cout << " Target1 " << fTarget1Mat << 417 G4cout << " Target2 " << fTarget2Mat << 418 G4cout << " Phantom " << fAbsorberMa << 419 G4cout << "================================= << 420 } 620 } >> 621 >> 622 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 421 623