Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // 27 // -------------------------------------------------------------- 28 // GEANT 4 - Brachytherapy example 29 // -------------------------------------------------------------- 30 // 31 // Code developed by: 32 // D. Cutajar 33 // 34 // **************************************** 35 // * * 36 // * BrachyDetectorConstructionTG186.cc * 37 // * * 38 // **************************************** 39 // 40 // 41 #include "BrachyDetectorConstructionTG186.hh" 42 #include "globals.hh" 43 #include "G4SystemOfUnits.hh" 44 #include "G4Sphere.hh" 45 #include "G4RunManager.hh" 46 #include "G4Box.hh" 47 #include "G4Tubs.hh" 48 #include "G4LogicalVolume.hh" 49 #include "G4ThreeVector.hh" 50 #include "G4PVPlacement.hh" 51 #include "G4Transform3D.hh" 52 #include "G4RotationMatrix.hh" 53 #include "G4TransportationManager.hh" 54 #include "G4VisAttributes.hh" 55 #include "G4Colour.hh" 56 #include "G4NistManager.hh" 57 58 BrachyDetectorConstructionTG186::BrachyDetectorConstructionTG186(): 59 fTG186capsule(nullptr), fTG186capsuleLog(nullptr), 60 fTG186capsulePhys(nullptr), 61 fTG186capsuleTip(nullptr), fTG186capsuleTipLog(nullptr), 62 fTG186capsuleTipPhys(nullptr), 63 fTG186iridiumCore(nullptr), fTG186iridiumCoreLog(nullptr), 64 fTG186iridiumCorePhys(nullptr), 65 fTG186cable(nullptr), fTG186cableLog(nullptr), 66 fTG186cablePhys(nullptr), 67 fTG186simpleCapsuleVisAtt(nullptr), fTG186simpleCapsuleTipVisAtt(nullptr), fTG186simpleIridiumVisAtt(nullptr), 68 fTG186simpleCableVisAtt(nullptr) 69 {} 70 71 void BrachyDetectorConstructionTG186::ConstructTG186(G4VPhysicalVolume* mother) 72 { 73 G4Colour red (1.0, 0.0, 0.0) ; 74 G4Colour magenta (1.0, 0.0, 1.0) ; 75 76 G4NistManager* nist = G4NistManager::Instance(); 77 auto iridium = nist -> FindOrBuildMaterial("G4_Ir"); 78 79 // Stainless steel (Medical Physics, Vol 25, No 10, Oct 1998) 80 constexpr G4double d = 8.02*g/cm3; 81 G4int Z; //atomic number of the element 82 G4Element* elMn = nist -> FindOrBuildElement(Z=12); 83 G4Element* elSi = nist -> FindOrBuildElement(Z=14); 84 G4Element* elCr = nist -> FindOrBuildElement(Z=24); 85 G4Element* elFe = nist -> FindOrBuildElement(Z=26); 86 G4Element* elNi = nist -> FindOrBuildElement(Z=28); 87 auto capsuleMat = new G4Material("Stainless steel",d,5); 88 capsuleMat -> AddElement(elMn, 0.02); 89 capsuleMat -> AddElement(elSi, 0.01); 90 capsuleMat -> AddElement(elCr, 0.19); 91 capsuleMat -> AddElement(elNi, 0.10); 92 capsuleMat -> AddElement(elFe, 0.68); 93 94 95 // Capsule main body 96 fTG186capsule = new G4Tubs("TG186-Capsule",0,0.5*mm,2.25*mm,0.*deg,360.*deg); 97 fTG186capsuleLog = new G4LogicalVolume(fTG186capsule,capsuleMat,"TG186-CapsuleLog"); 98 fTG186capsulePhys = new G4PVPlacement(nullptr, 99 G4ThreeVector(0,0,-0.4*mm), 100 "TG186-IridiumCapsulePhys", 101 fTG186capsuleLog, 102 mother, 103 false, 104 0, true); 105 106 // Capsule tip 107 fTG186capsuleTip = new G4Sphere("Tg186-CapsuleTipIridium", 108 0.*mm, 109 0.5*mm, 110 0.*deg, 111 360.*deg, 112 0.*deg, 113 90.*deg); 114 115 fTG186capsuleTipLog = new G4LogicalVolume(fTG186capsuleTip, 116 capsuleMat, 117 "CapsuleTipIridumLog"); 118 119 fTG186capsuleTipPhys = new G4PVPlacement(nullptr, 120 G4ThreeVector(0.,0.,1.85*mm), 121 "TG186-CapsuleTipIridiumPhys", 122 fTG186capsuleTipLog, 123 mother, 124 false, 125 0, true); 126 127 fTG186cable = new G4Tubs("TG186-cable", 128 0.*mm, 129 0.5*mm, 130 1.0*mm, 131 0.*deg, 132 360.*deg); 133 134 fTG186cableLog = new G4LogicalVolume(fTG186cable, 135 capsuleMat, 136 "TG186-cableLog"); 137 138 fTG186cablePhys = new G4PVPlacement(nullptr, 139 G4ThreeVector(0.,0.,-3.65*mm), 140 "TG186-CablePhys", 141 fTG186cableLog, 142 mother, 143 false, 144 0, true); 145 146 // Iridium core 147 fTG186iridiumCore = new G4Tubs("TG186-IrCore",0,0.30*mm,1.75*mm,0.*deg,360.*deg); 148 149 fTG186iridiumCoreLog = new G4LogicalVolume(fTG186iridiumCore, 150 iridium, 151 "TG186-IridiumCoreLog"); 152 153 fTG186iridiumCorePhys = new G4PVPlacement(nullptr, 154 G4ThreeVector(0,0,0.4*mm), 155 "TG186-IridiumCorePhys", 156 fTG186iridiumCoreLog, 157 fTG186capsulePhys, 158 false, 159 0, true); 160 161 fTG186simpleCapsuleVisAtt = new G4VisAttributes(red); 162 fTG186simpleCapsuleVisAtt -> SetVisibility(true); 163 fTG186simpleCapsuleVisAtt -> SetForceWireframe(true); 164 fTG186capsuleLog -> SetVisAttributes(fTG186simpleCapsuleVisAtt); 165 166 fTG186simpleCapsuleTipVisAtt = new G4VisAttributes(red); 167 fTG186simpleCapsuleTipVisAtt -> SetVisibility(true); 168 fTG186simpleCapsuleTipVisAtt -> SetForceSolid(true); 169 fTG186capsuleTipLog -> SetVisAttributes(fTG186simpleCapsuleTipVisAtt); 170 171 fTG186simpleIridiumVisAtt = new G4VisAttributes(magenta); 172 fTG186simpleIridiumVisAtt -> SetVisibility(true); 173 fTG186simpleIridiumVisAtt -> SetForceWireframe(true); 174 fTG186iridiumCoreLog -> SetVisAttributes(fTG186simpleIridiumVisAtt); 175 176 fTG186simpleCableVisAtt = new G4VisAttributes(red); 177 fTG186simpleCableVisAtt -> SetVisibility(true); 178 fTG186simpleCableVisAtt -> SetForceSolid(true); 179 fTG186cableLog -> SetVisAttributes(fTG186simpleCableVisAtt); 180 } 181 182 void BrachyDetectorConstructionTG186::CleanTG186() 183 { 184 185 delete fTG186simpleIridiumVisAtt; 186 fTG186simpleIridiumVisAtt = nullptr; 187 188 delete fTG186iridiumCorePhys; 189 fTG186iridiumCorePhys = nullptr; 190 191 delete fTG186iridiumCore; 192 fTG186iridiumCore = nullptr; 193 194 delete fTG186iridiumCoreLog; 195 fTG186iridiumCoreLog = nullptr ; 196 197 delete fTG186simpleCapsuleTipVisAtt; 198 fTG186simpleCapsuleTipVisAtt = nullptr; 199 200 delete fTG186capsuleTipPhys; 201 fTG186capsuleTipPhys = nullptr; 202 203 delete fTG186capsuleTip; 204 fTG186capsuleTip = nullptr; 205 206 delete fTG186capsuleTipLog; 207 fTG186capsuleTipLog = nullptr; 208 209 delete fTG186simpleCapsuleVisAtt; 210 fTG186simpleCapsuleVisAtt = nullptr; 211 212 delete fTG186capsulePhys; 213 fTG186capsulePhys = nullptr; 214 215 delete fTG186capsule; 216 fTG186capsule = nullptr; 217 218 delete fTG186capsuleLog; 219 fTG186capsuleLog = nullptr; 220 221 delete fTG186cable; 222 fTG186cable = nullptr; 223 224 delete fTG186cableLog; 225 fTG186cableLog = nullptr; 226 227 delete fTG186cablePhys; 228 fTG186cablePhys = nullptr; 229 230 delete fTG186simpleCableVisAtt; 231 fTG186simpleCableVisAtt = nullptr; 232 233 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 234 } 235