Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // << 27 /// \file medical/GammaTherapy/src/DetectorCon 26 /// \file medical/GammaTherapy/src/DetectorConstruction.cc 28 /// \brief Implementation of the DetectorConst 27 /// \brief Implementation of the DetectorConstruction class 29 // 28 // 30 // 29 // 31 // ------------------------------------------- 30 // ------------------------------------------------------------- 32 // GEANT4 ibrem test 31 // GEANT4 ibrem test 33 // 32 // 34 // Authors: V.Grichine, V.Ivanchenko 33 // Authors: V.Grichine, V.Ivanchenko 35 // 34 // 36 // Modified: 35 // Modified: 37 // 36 // 38 // 18-02-03 V.Ivanchenko create 37 // 18-02-03 V.Ivanchenko create 39 // 38 // 40 // ------------------------------------------- 39 // ------------------------------------------------------------- 41 40 42 //....oooOO0OOooo........oooOO0OOooo........oo << 41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 43 //....oooOO0OOooo........oooOO0OOooo........oo << 42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 44 43 45 #include "DetectorConstruction.hh" 44 #include "DetectorConstruction.hh" 46 << 47 #include "CheckVolumeSD.hh" << 48 #include "DetectorMessenger.hh" 45 #include "DetectorMessenger.hh" 49 #include "PhantomSD.hh" 46 #include "PhantomSD.hh" 50 #include "TargetSD.hh" 47 #include "TargetSD.hh" >> 48 #include "CheckVolumeSD.hh" >> 49 #include "Histo.hh" 51 50 52 #include "G4Box.hh" 51 #include "G4Box.hh" 53 #include "G4Colour.hh" << 52 #include "G4Tubs.hh" 54 #include "G4GeometryManager.hh" << 55 #include "G4LogicalVolume.hh" 53 #include "G4LogicalVolume.hh" 56 #include "G4LogicalVolumeStore.hh" << 54 #include "G4VPhysicalVolume.hh" >> 55 #include "G4PVPlacement.hh" 57 #include "G4Material.hh" 56 #include "G4Material.hh" >> 57 #include "G4SDManager.hh" >> 58 #include "PhantomSD.hh" 58 #include "G4NistManager.hh" 59 #include "G4NistManager.hh" 59 #include "G4PVPlacement.hh" << 60 60 #include "G4PhysicalConstants.hh" << 61 #include "G4PhysicalVolumeStore.hh" 61 #include "G4PhysicalVolumeStore.hh" 62 #include "G4RunManager.hh" << 62 #include "G4LogicalVolumeStore.hh" 63 #include "G4SDManager.hh" << 64 #include "G4SolidStore.hh" 63 #include "G4SolidStore.hh" 65 #include "G4SystemOfUnits.hh" << 64 #include "G4RunManager.hh" 66 #include "G4Tubs.hh" << 65 67 #include "G4VPhysicalVolume.hh" << 68 #include "G4VisAttributes.hh" 66 #include "G4VisAttributes.hh" 69 #include "G4ios.hh" << 67 #include "G4Colour.hh" >> 68 70 #include "globals.hh" 69 #include "globals.hh" >> 70 #include "G4PhysicalConstants.hh" >> 71 #include "G4SystemOfUnits.hh" >> 72 #include "G4ios.hh" 71 73 72 //....oooOO0OOooo........oooOO0OOooo........oo << 74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 73 75 74 DetectorConstruction::DetectorConstruction() 76 DetectorConstruction::DetectorConstruction() 75 { 77 { 76 fLogicTarget1 = 0; 78 fLogicTarget1 = 0; 77 fLogicTarget2 = 0; 79 fLogicTarget2 = 0; 78 80 79 fMessenger = new DetectorMessenger(this); 81 fMessenger = new DetectorMessenger(this); 80 fVerbose = false; << 81 << 82 fNumZ = 60; << 83 fNumR = 80; << 84 82 85 fNumE = 200; << 83 fCheckSD = new CheckVolumeSD("checkSD"); 86 fMaxEnergy = 50.0 * MeV; << 84 (G4SDManager::GetSDMpointer())->AddNewDetector( fCheckSD ); 87 << 85 fPhantomSD = new PhantomSD("phantomSD"); 88 fDistanceVacuumTarget = 30. * mm, << 86 (G4SDManager::GetSDMpointer())->AddNewDetector( fPhantomSD ); 89 << 87 fTargetSD = new TargetSD("targetSD"); 90 fDelta = 0.001 * mm; << 88 (G4SDManager::GetSDMpointer())->AddNewDetector( fTargetSD ); 91 << 89 92 fTargetRadius = 100. * mm; << 90 fDistanceVacuumTarget = 30.*mm, 93 fTarget1Z = 9. * mm; << 91 94 fTarget2Z = 6. * mm; << 92 fDelta = 0.001*mm; 95 << 93 96 fGasVolumeRadius = 210. * mm; << 94 fTargetRadius = 100.*mm; 97 fGasVolumeZ = 690. * mm; << 95 fTarget1Z = 9.*mm; 98 fMylarVolumeZ = 0.02 * mm; << 96 fTarget2Z = 6.*mm; 99 << 97 100 fCheckVolumeZ = 0.1 * mm; << 98 fGasVolumeRadius = 210.*mm; 101 fCheckShiftZ = 200. * mm; << 99 fGasVolumeZ = 690.*mm; 102 << 100 fMylarVolumeZ = 0.02*mm; 103 fAbsorberRadius = 200. * mm; << 101 104 fPhantomRadius = 300. * mm; << 102 fCheckVolumeZ = 0.1*mm; 105 fPhantomZ = 300. * mm; << 103 fCheckShiftZ = 200.*mm; 106 << 104 107 fAirZ = 210. * mm; << 105 fAbsorberRadius = 200.*mm; 108 fAbsorberShiftZ = 70. * mm; << 106 fPhantomRadius = 300.*mm; 109 fWindowZ = 0.05 * mm; << 107 fPhantomZ = 300.*mm; >> 108 >> 109 fAirZ = 210.*mm; >> 110 fAbsorberShiftZ = 70.*mm; >> 111 fWindowZ = 0.05*mm; 110 112 111 G4NistManager* man = G4NistManager::Instance 113 G4NistManager* man = G4NistManager::Instance(); 112 // man->SetVerbose(1); << 114 //man->SetVerbose(1); 113 115 114 fTarget1Material = man->FindOrBuildMaterial( 116 fTarget1Material = man->FindOrBuildMaterial("G4_Be"); 115 fWindowMaterial = fTarget1Material; << 117 fWindowMaterial = fTarget1Material; 116 fTarget2Material = man->FindOrBuildMaterial( 118 fTarget2Material = man->FindOrBuildMaterial("G4_W"); 117 fLightMaterial = man->FindOrBuildMaterial("G << 119 fLightMaterial = man->FindOrBuildMaterial("G4_He"); 118 fAbsorberMaterial = man->FindOrBuildMaterial << 120 fAbsorberMaterial= man->FindOrBuildMaterial("G4_WATER"); 119 fWorldMaterial = man->FindOrBuildMaterial("G << 121 fWorldMaterial = man->FindOrBuildMaterial("G4_AIR"); 120 fMylar = man->FindOrBuildMaterial("G4_MYLAR" << 122 fMylar = man->FindOrBuildMaterial("G4_MYLAR"); 121 123 122 G4cout << *(G4Material::GetMaterialTable()) 124 G4cout << *(G4Material::GetMaterialTable()) << G4endl; 123 } 125 } 124 126 125 //....oooOO0OOooo........oooOO0OOooo........oo << 127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 126 128 127 DetectorConstruction::~DetectorConstruction() 129 DetectorConstruction::~DetectorConstruction() 128 { << 130 {} 129 delete fMessenger; << 130 } << 131 131 132 //....oooOO0OOooo........oooOO0OOooo........oo << 132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 133 133 134 void DetectorConstruction::InitialiseGeometryP 134 void DetectorConstruction::InitialiseGeometryParameters() 135 { 135 { 136 // Volumee sizes 136 // Volumee sizes 137 137 138 G4double factor = 1.2; 138 G4double factor = 1.2; 139 139 140 fWorldXY = factor * std::max(fPhantomRadius, << 140 fWorldXY = factor*std::max(fPhantomRadius,fGasVolumeRadius); 141 fAbsorberZ = fPhantomZ / fNumZ; << 141 G4double nz = (G4int)((Histo::GetPointer())->GetNumberDivZ()); 142 fGasVolumeZ = 1000. * mm - fAbsorberShiftZ - << 142 fAbsorberZ = fPhantomZ/nz; >> 143 fGasVolumeZ = 1000.*mm - fAbsorberShiftZ - fAirZ - fTarget1Z - fTarget2Z; 143 144 144 G4double ztot = fGasVolumeZ + fAirZ + fPhant << 145 G4double ztot = fGasVolumeZ + fAirZ + fPhantomZ + fDistanceVacuumTarget; 145 fTargetVolumeZ = fDistanceVacuumTarget + fTa 146 fTargetVolumeZ = fDistanceVacuumTarget + fTarget2Z + fTarget1Z + fDelta; 146 fWorldZ = factor * ztot * 0.5; << 147 fWorldZ = factor*ztot*0.5; 147 148 148 if (fCheckShiftZ < fDelta) { << 149 if(fCheckShiftZ < fDelta) { fCheckShiftZ = fDelta; } 149 fCheckShiftZ = fDelta; << 150 if(fCheckShiftZ > fAirZ - fCheckVolumeZ -fDelta) { 150 } << 151 fCheckShiftZ = fAirZ - fCheckVolumeZ -fDelta; 151 if (fCheckShiftZ > fAirZ - fCheckVolumeZ - f << 152 fCheckShiftZ = fAirZ - fCheckVolumeZ - fDe << 153 } 152 } 154 153 155 // Z position of volumes from upstream to do 154 // Z position of volumes from upstream to downstream 156 155 157 fWindowPosZ = -(ztot + fWindowZ) * 0.5; << 156 fWindowPosZ = -(ztot + fWindowZ)*0.5; 158 fGeneratorPosZ = fWindowPosZ - 0.5 * fWindow << 157 fGeneratorPosZ = fWindowPosZ - 0.5*fWindowZ - fDelta; 159 << 160 fTargetVolumePosZ = -0.5 * (ztot - fTargetVo << 161 fTarget1PosZ = -0.5 * (fTargetVolumeZ - fTar << 162 fTarget2PosZ = fTarget1PosZ + 0.5 * (fTarget << 163 158 164 fGasVolumePosZ = fTargetVolumePosZ + 0.5 * ( << 159 fTargetVolumePosZ= -0.5*(ztot - fTargetVolumeZ); 165 fCheckVolumePosZ = fGasVolumePosZ + 0.5 * (f << 160 fTarget1PosZ = -0.5*(fTargetVolumeZ - fTarget1Z) + fDistanceVacuumTarget; 166 fMylarPosZ = fGasVolumePosZ + 0.5 * (fGasVol << 161 fTarget2PosZ = fTarget1PosZ + 0.5*(fTarget2Z + fTarget1Z); >> 162 >> 163 fGasVolumePosZ = fTargetVolumePosZ + 0.5*(fTargetVolumeZ + fGasVolumeZ); >> 164 fCheckVolumePosZ = fGasVolumePosZ + 0.5*(fGasVolumeZ + fCheckVolumeZ) >> 165 + fCheckShiftZ; >> 166 fMylarPosZ = fGasVolumePosZ + 0.5*(fGasVolumeZ + fMylarVolumeZ) + fDelta; >> 167 >> 168 fPhantomPosZ = fGasVolumePosZ + 0.5*(fGasVolumeZ + fPhantomZ) + fAirZ; >> 169 fAbsorberPosZ = fAbsorberShiftZ - 0.5*(fPhantomZ - fAbsorberZ); >> 170 (Histo::GetPointer())->SetAbsorberZ(fPhantomZ); >> 171 (Histo::GetPointer())->SetAbsorberR(fAbsorberRadius); >> 172 (Histo::GetPointer())->SetScoreZ(fAbsorberShiftZ); >> 173 G4double shiftZPh = fPhantomPosZ-0.5*fPhantomZ; >> 174 fPhantomSD->SetShiftZ(shiftZPh); 167 175 168 fPhantomPosZ = fGasVolumePosZ + 0.5 * (fGasV << 176 G4cout << "===================================================" << G4endl; 169 fAbsorberPosZ = fAbsorberShiftZ - 0.5 * (fPh << 177 G4cout << "# GammaTherapy Geometry #" << G4endl; 170 << 178 G4cout << "===================================================" << G4endl; 171 fShiftZPh = fPhantomPosZ - 0.5 * fPhantomZ; << 179 G4cout << " World width= " << fWorldZ/mm << " mm " << G4endl; 172 << 180 G4cout << " Window width= " << fWindowZ/mm << " mm position = " 173 DumpGeometryParameters(); << 181 << fWindowPosZ/mm << " mm:" << G4endl; >> 182 G4cout << " TargetV width= " << fTargetVolumeZ/mm << " mm position = " >> 183 << fTargetVolumePosZ/mm << " mm:" << G4endl; >> 184 G4cout << " Target1 width= " << fTarget1Z/mm << " mm position = " >> 185 << fTarget1PosZ/mm << " mm:" << G4endl; >> 186 G4cout << " Target2 width= " << fTarget2Z/mm << " mm position = " >> 187 << fTarget2PosZ/mm << " mm:" << G4endl; >> 188 G4cout << " Gas width= " << fGasVolumeZ/mm << " mm position = " >> 189 << fGasVolumePosZ/mm << " mm:" << G4endl; >> 190 G4cout << " Mylar width= " << fMylarVolumeZ/mm << " mm position = " >> 191 << fMylarPosZ/mm << " mm:" << G4endl; >> 192 G4cout << " Check width= " << fCheckVolumeZ/mm << " mm position = " >> 193 << fCheckVolumePosZ/mm << " mm:" << G4endl; >> 194 G4cout << " Air width= " << fAirZ/mm << " mm " << G4endl; >> 195 G4cout << " Phantom width= " << fPhantomZ/mm << " mm position = " >> 196 << fPhantomPosZ/mm << " mm:" << G4endl; >> 197 G4cout << " Absorb width= " << fAbsorberZ/mm << " mm position = " >> 198 << fAbsorberPosZ/mm << " mm:" << G4endl; >> 199 G4cout << " Absorb shift= " << shiftZPh/mm << " mm " << G4endl; >> 200 G4cout << " Target1 " << fTarget1Material->GetName() << G4endl; >> 201 G4cout << " Target2 " << fTarget2Material->GetName() << G4endl; >> 202 G4cout << " Phantom " << fAbsorberMaterial->GetName() << G4endl; >> 203 G4cout << "===================================================" << G4endl; 174 } 204 } 175 205 176 //....oooOO0OOooo........oooOO0OOooo........oo << 206 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 177 207 178 G4VPhysicalVolume* DetectorConstruction::Const 208 G4VPhysicalVolume* DetectorConstruction::Construct() 179 { 209 { 180 InitialiseGeometryParameters(); << 210 // Cleanup old geometry 181 << 182 G4GeometryManager::GetInstance()->OpenGeomet << 183 G4PhysicalVolumeStore::GetInstance()->Clean( 211 G4PhysicalVolumeStore::GetInstance()->Clean(); 184 G4LogicalVolumeStore::GetInstance()->Clean() 212 G4LogicalVolumeStore::GetInstance()->Clean(); 185 G4SolidStore::GetInstance()->Clean(); 213 G4SolidStore::GetInstance()->Clean(); >> 214 >> 215 // >> 216 InitialiseGeometryParameters(); >> 217 186 // 218 // 187 // World 219 // World 188 // 220 // >> 221 G4VPhysicalVolume* pv; 189 222 190 G4Box* solidWorld = new G4Box("World", fWorl << 223 G4Box* solidWorld = new G4Box("World",fWorldXY,fWorldXY,fWorldZ); 191 G4LogicalVolume* logicWorld = new G4LogicalV << 224 G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, 192 G4VPhysicalVolume* physWorld = << 225 fWorldMaterial,"World"); 193 new G4PVPlacement(0, G4ThreeVector(), "Wor << 226 G4VPhysicalVolume* physWorld = new G4PVPlacement(0,G4ThreeVector(),"World", >> 227 logicWorld,0,false,0); 194 228 195 // Be Vacuum window 229 // Be Vacuum window 196 G4Tubs* solidWin = new G4Tubs("Window", 0., << 230 G4Tubs* solidWin = new G4Tubs("Window",0.,fTargetRadius*0.25,0.5*fWindowZ, 197 G4LogicalVolume* logicWin = new G4LogicalVol << 231 0.,twopi); 198 new G4PVPlacement(0, G4ThreeVector(0., 0., f << 232 G4LogicalVolume* logicWin = new G4LogicalVolume(solidWin, >> 233 fWindowMaterial,"Window"); >> 234 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fWindowPosZ),"Window",logicWin, >> 235 physWorld,false,0); 199 236 200 // Target Volume 237 // Target Volume 201 G4Tubs* solidTGVolume = << 238 G4Tubs* solidTGVolume = new G4Tubs("TargetVolume",0.,fTargetRadius, 202 new G4Tubs("TargetVolume", 0., fTargetRadi << 239 0.5*fTargetVolumeZ,0.,twopi); 203 G4LogicalVolume* logicTGVolume = << 240 G4LogicalVolume* logicTGVolume = new G4LogicalVolume(solidTGVolume, 204 new G4LogicalVolume(solidTGVolume, fLightM << 241 fLightMaterial, 205 new G4PVPlacement(0, G4ThreeVector(0., 0., f << 242 "TargetVolume"); 206 logicWorld, false, 0); << 243 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fTargetVolumePosZ), >> 244 logicTGVolume,"TargetVolume", >> 245 logicWorld,false,0); 207 246 208 // Target 1 247 // Target 1 209 G4Tubs* solidTarget1 = new G4Tubs("Target1", << 248 G4Tubs* solidTarget1 = new G4Tubs("Target1",0.,fTargetRadius*0.5, 210 fLogicTarget1 = new G4LogicalVolume(solidTar << 249 0.5*fTarget1Z,0.,twopi); 211 fTarget1 = new G4PVPlacement(0, G4ThreeVecto << 250 fLogicTarget1 = new G4LogicalVolume(solidTarget1,fTarget1Material,"Target1"); 212 logicTGVolume, << 251 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fTarget1PosZ), 213 // fLogicTarget1->SetSensitiveDetector(fTar << 252 fLogicTarget1,"Target1", >> 253 logicTGVolume,false,0); >> 254 (Histo::GetPointer())->SetTarget1(pv); >> 255 fLogicTarget1->SetSensitiveDetector(fTargetSD); 214 256 215 // Target 2 (for combined targets) 257 // Target 2 (for combined targets) 216 G4Tubs* solidTarget2 = new G4Tubs("Target2", << 258 G4Tubs* solidTarget2 = new G4Tubs("Target2",0.,fTargetRadius*0.5, 217 fLogicTarget2 = new G4LogicalVolume(solidTar << 259 0.5*fTarget2Z,0.,twopi); 218 fTarget2 = new G4PVPlacement(0, G4ThreeVecto << 260 fLogicTarget2 = new G4LogicalVolume(solidTarget2,fTarget2Material,"Target2"); 219 logicTGVolume, << 261 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fTarget2PosZ), >> 262 fLogicTarget2,"Target2", >> 263 logicTGVolume,false,0); 220 264 221 // fLogicTarget2->SetSensitiveDetector(fTar << 265 (Histo::GetPointer())->SetTarget2(pv); >> 266 fLogicTarget2->SetSensitiveDetector(fTargetSD); 222 267 223 // Gas Volume 268 // Gas Volume 224 G4Tubs* solidGasVolume = << 269 G4Tubs* solidGasVolume = new G4Tubs("GasVolume",0.,fGasVolumeRadius, 225 new G4Tubs("GasVolume", 0., fGasVolumeRadi << 270 0.5*fGasVolumeZ,0.,twopi); 226 G4LogicalVolume* logicGasVolume = << 271 G4LogicalVolume* logicGasVolume = new G4LogicalVolume(solidGasVolume, 227 new G4LogicalVolume(solidGasVolume, fLight << 272 fLightMaterial, 228 fGasVolume = new G4PVPlacement(0, G4ThreeVec << 273 "GasVolume"); 229 logicGasVolum << 274 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fGasVolumePosZ), >> 275 "GasVolume",logicGasVolume, >> 276 physWorld,false,0); >> 277 (Histo::GetPointer())->SetGasVolume(pv); 230 278 231 // Mylar window 279 // Mylar window 232 G4Tubs* sMylarVolume = new G4Tubs("Mylar", 0 << 280 G4Tubs* sMylarVolume = new G4Tubs("Mylar",0.,fGasVolumeRadius, 233 G4LogicalVolume* lMylarVolume = new G4Logica << 281 0.5*fMylarVolumeZ,0.,twopi); 234 new G4PVPlacement(0, G4ThreeVector(0., 0., f << 282 G4LogicalVolume* lMylarVolume = new G4LogicalVolume(sMylarVolume, 235 0); << 283 fMylar,"Mylar"); >> 284 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fMylarPosZ),"Mylar",lMylarVolume, >> 285 physWorld,false,0); 236 286 237 // Check Volume 287 // Check Volume 238 G4Tubs* solidCheckVolume = << 288 G4Tubs* solidCheckVolume = new G4Tubs("CheckVolume",0.,fGasVolumeRadius, 239 new G4Tubs("CheckVolume", 0., fGasVolumeRa << 289 0.5*fCheckVolumeZ,0.,twopi); 240 fLogicCheckVolume = new G4LogicalVolume(soli << 290 G4LogicalVolume* logicCheckVolume = new G4LogicalVolume(solidCheckVolume, 241 fCheckVolume = new G4PVPlacement(0, G4ThreeV << 291 fWorldMaterial, 242 fLogicCheck << 292 "CheckVolume"); 243 // logicCheckVolume->SetSensitiveDetector(f << 293 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fCheckVolumePosZ), >> 294 "CheckVolume",logicCheckVolume, >> 295 physWorld,false,0); >> 296 (Histo::GetPointer())->SetCheckVolume(pv); >> 297 logicCheckVolume->SetSensitiveDetector(fCheckSD); 244 298 245 // Phantom 299 // Phantom 246 G4Box* solidPhantom = new G4Box("Phantom", f << 300 G4Box* solidPhantom = new G4Box("Phantom",fPhantomRadius,fPhantomRadius, 247 G4LogicalVolume* logicPhantom = new G4Logica << 301 0.5*fPhantomZ); 248 G4VPhysicalVolume* physPhantom = new G4PVPla << 302 G4LogicalVolume* logicPhantom = new G4LogicalVolume(solidPhantom, 249 << 303 fAbsorberMaterial, 250 << 304 "Phantom"); 251 G4Tubs* solidPh = new G4Tubs("PhantomSD", 0. << 305 G4VPhysicalVolume* physPhantom = 252 fLogicPh = new G4LogicalVolume(solidPh, fAbs << 306 new G4PVPlacement(0, G4ThreeVector(0.,0.,fPhantomPosZ), 253 fPhantom = << 307 "Phantom",logicPhantom, 254 new G4PVPlacement(0, G4ThreeVector(0., 0., << 308 physWorld,false,0); 255 G4cout << "Phantom R= " << fAbsorberRadius < << 309 256 << 310 G4Tubs* solidPh = new G4Tubs("PhantomSD",0.,fAbsorberRadius, 257 // Sensitive Absorber << 311 0.5*fPhantomZ,0.,twopi); 258 G4double absWidth = 0.5 * fAbsorberZ; << 312 G4LogicalVolume* logicPh = new G4LogicalVolume(solidPh, 259 G4Tubs* solidAbsorber = new G4Tubs("Absorber << 313 fAbsorberMaterial,"PhantomSD"); 260 fLogicAbsorber = new G4LogicalVolume(solidAb << 314 G4VPhysicalVolume* physPh = new G4PVPlacement(0,G4ThreeVector(0.,0.,0.), 261 G4cout << "Absorber R= " << fAbsorberRadius << 315 "Phantom",logicPh, >> 316 physPhantom,false,0); >> 317 G4cout << "Phantom R= " << fAbsorberRadius << " dz= " << 0.5*fPhantomZ 262 << G4endl; 318 << G4endl; 263 319 264 new G4PVPlacement(0, G4ThreeVector(0., 0., f << 320 // Sensitive Absorber 265 false, 0); << 321 G4double absWidth = 0.5*fAbsorberZ; 266 << 322 G4Tubs* solidAbsorber = new G4Tubs("Absorber",0.,fAbsorberRadius,absWidth, 267 G4double stepR = fAbsorberRadius / (G4double << 323 0.,twopi); >> 324 G4LogicalVolume* logicAbsorber = new G4LogicalVolume(solidAbsorber, >> 325 fAbsorberMaterial, >> 326 "Absorber"); >> 327 G4cout << "Absorber R= " << fAbsorberRadius << " dz= " << absWidth >> 328 << " posZ= " << fAbsorberPosZ<< G4endl; >> 329 >> 330 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fAbsorberPosZ),"Absorber", >> 331 logicAbsorber,physPh,false,0); >> 332 (Histo::GetPointer())->SetPhantom(physPh); >> 333 G4int numR = (Histo::GetPointer())->GetNumberDivR(); >> 334 G4double stepR = fAbsorberRadius/(G4double)numR; 268 335 269 G4double r1 = 0.0; 336 G4double r1 = 0.0; 270 G4double r2 = 0.0; 337 G4double r2 = 0.0; 271 G4Tubs* solidRing; 338 G4Tubs* solidRing; >> 339 G4LogicalVolume* logicRing; 272 340 273 G4VisAttributes* VisAtt_ring = new G4VisAttr << 341 for(G4int k=0; k<numR; k++) { 274 for (G4int k = 0; k < fNumR; k++) { << 275 r2 = r1 + stepR; 342 r2 = r1 + stepR; 276 if (k == fNumR - 1) r2 = fAbsorberRadius; << 343 if(k == numR-1) r2 = fAbsorberRadius; 277 // G4cout << "New ring r1= " << r1 << " << 344 // G4cout << "New ring r1= " << r1 << " r2= " << r2 278 // << " dz= " << absWidth << G4endl; 345 // << " dz= " << absWidth << G4endl; 279 solidRing = new G4Tubs("Ring", r1, r2, abs << 346 solidRing = new G4Tubs("Ring",r1,r2,absWidth,0.,twopi); 280 G4LogicalVolume* logicRing = new G4Logical << 347 logicRing = new G4LogicalVolume(solidRing,fAbsorberMaterial,"Ring"); 281 // logicRing->SetSensitiveDetector(fPha << 348 logicRing->SetSensitiveDetector(fPhantomSD); 282 logicRing->SetVisAttributes(VisAtt_ring); << 349 logicRing->SetVisAttributes(G4VisAttributes::Invisible); 283 fLogicRing.push_back(logicRing); << 350 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,0.),logicRing,"Ring", 284 new G4PVPlacement(0, G4ThreeVector(0., 0., << 351 logicAbsorber,false,k); 285 r1 = r2; 352 r1 = r2; 286 } 353 } 287 << 354 // >> 355 // Sensitive Detectors: Absorber >> 356 // >> 357 logicPh->SetSensitiveDetector(fPhantomSD); >> 358 logicAbsorber->SetSensitiveDetector(fPhantomSD); 288 // 359 // 289 // Visualization attributes 360 // Visualization attributes 290 // 361 // 291 G4VisAttributes* VisAtt = 0; 362 G4VisAttributes* VisAtt = 0; 292 VisAtt = new G4VisAttributes(G4Colour(1.0, 1 << 363 VisAtt = new G4VisAttributes(G4Colour(1.0,1.0,1.0)); 293 VisAtt->SetVisibility(true); 364 VisAtt->SetVisibility(true); 294 fLogicAbsorber->SetVisAttributes(VisAtt); << 365 logicAbsorber->SetVisAttributes(VisAtt); 295 366 296 VisAtt = new G4VisAttributes(G4Colour(1.0, 1 << 367 VisAtt= new G4VisAttributes(G4Colour(1.0,1.0,2.0)); 297 VisAtt->SetVisibility(true); 368 VisAtt->SetVisibility(true); 298 logicPhantom->SetVisAttributes(VisAtt); 369 logicPhantom->SetVisAttributes(VisAtt); 299 370 300 VisAtt = new G4VisAttributes(G4Colour(1.0, 0 << 371 VisAtt= new G4VisAttributes(G4Colour(1.0,0.0,2.0)); 301 VisAtt->SetVisibility(true); 372 VisAtt->SetVisibility(true); 302 fLogicPh->SetVisAttributes(VisAtt); << 373 logicPh->SetVisAttributes(VisAtt); 303 374 304 VisAtt = new G4VisAttributes(G4Colour(1.0, 1 << 375 VisAtt= new G4VisAttributes(G4Colour(1.0,1.0,0.0)); 305 VisAtt->SetVisibility(true); 376 VisAtt->SetVisibility(true); 306 fLogicAbsorber->SetVisAttributes(VisAtt); << 377 logicAbsorber->SetVisAttributes(VisAtt); 307 378 308 VisAtt = new G4VisAttributes(G4Colour(0.1, 1 << 379 VisAtt= new G4VisAttributes(G4Colour(0.1,1.0,2.0)); 309 VisAtt->SetVisibility(true); 380 VisAtt->SetVisibility(true); 310 logicWorld->SetVisAttributes(VisAtt); 381 logicWorld->SetVisAttributes(VisAtt); 311 382 312 VisAtt = new G4VisAttributes(G4Colour(1.0, 1 << 383 VisAtt= new G4VisAttributes(G4Colour(1.0,1.0,0.0)); 313 VisAtt->SetVisibility(true); 384 VisAtt->SetVisibility(true); 314 logicGasVolume->SetVisAttributes(VisAtt); 385 logicGasVolume->SetVisAttributes(VisAtt); 315 386 316 VisAtt = new G4VisAttributes(G4Colour(0.0, 0 << 387 VisAtt= new G4VisAttributes(G4Colour(0.0,0.5,1.0)); 317 VisAtt->SetVisibility(true); 388 VisAtt->SetVisibility(true); 318 fLogicTarget1->SetVisAttributes(VisAtt); 389 fLogicTarget1->SetVisAttributes(VisAtt); 319 fLogicTarget2->SetVisAttributes(VisAtt); 390 fLogicTarget2->SetVisAttributes(VisAtt); 320 logicTGVolume->SetVisAttributes(VisAtt); 391 logicTGVolume->SetVisAttributes(VisAtt); 321 392 322 return physWorld; 393 return physWorld; 323 } 394 } 324 395 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 396 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 351 397 352 void DetectorConstruction::SetTarget1Material( 398 void DetectorConstruction::SetTarget1Material(const G4String& mat) 353 { 399 { 354 // search the material by its name 400 // search the material by its name 355 G4Material* pttoMaterial = G4NistManager::In << 401 G4Material* pttoMaterial = 356 if (!pttoMaterial) { << 402 G4NistManager::Instance()->FindOrBuildMaterial(mat, false); >> 403 if(!pttoMaterial) { 357 G4cout << "Material " << mat << " is not f 404 G4cout << "Material " << mat << " is not found out!" << G4endl; 358 } << 405 } else if (pttoMaterial != fTarget1Material) { 359 else if (pttoMaterial != fTarget1Material) { << 360 G4cout << "New target1 material " << mat < 406 G4cout << "New target1 material " << mat << G4endl; 361 if (fLogicTarget1) { << 407 if(fLogicTarget1) { fLogicTarget1->SetMaterial(fTarget1Material); } 362 fLogicTarget1->SetMaterial(fTarget1Mater << 363 } << 364 G4RunManager::GetRunManager()->PhysicsHasB 408 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 365 } 409 } 366 } 410 } 367 411 368 //....oooOO0OOooo........oooOO0OOooo........oo 412 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 369 413 370 void DetectorConstruction::SetTarget2Material( 414 void DetectorConstruction::SetTarget2Material(const G4String& mat) 371 { 415 { 372 // search the material by its name 416 // search the material by its name 373 G4Material* pttoMaterial = G4NistManager::In << 417 G4Material* pttoMaterial = >> 418 G4NistManager::Instance()->FindOrBuildMaterial(mat, false); 374 419 375 if (!pttoMaterial) { << 420 if(!pttoMaterial) { 376 G4cout << "Material " << mat << " is not f 421 G4cout << "Material " << mat << " is not found out!" << G4endl; 377 } << 422 } else if (pttoMaterial != fTarget2Material) { 378 else if (pttoMaterial != fTarget2Material) { << 379 fTarget2Material = pttoMaterial; 423 fTarget2Material = pttoMaterial; 380 G4cout << "New target2 material " << mat < 424 G4cout << "New target2 material " << mat << G4endl; 381 if (fLogicTarget2) { << 425 if(fLogicTarget2) { fLogicTarget2->SetMaterial(fTarget2Material); } 382 fLogicTarget2->SetMaterial(fTarget2Mater << 383 } << 384 G4RunManager::GetRunManager()->PhysicsHasB 426 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 385 } << 427 } 386 } 428 } 387 429 388 //....oooOO0OOooo........oooOO0OOooo........oo 430 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 389 431 390 void DetectorConstruction::DumpGeometryParamet << 432 void DetectorConstruction::UpdateGeometry() 391 { 433 { 392 G4cout << "================================= << 434 G4RunManager::GetRunManager()->GeometryHasBeenModified(); 393 G4cout << "# GammaTherapy Geometry << 394 G4cout << "================================= << 395 G4cout << " World width= " << fWorldZ / m << 396 G4cout << " Window width= " << fWindowZ / << 397 << " mm:" << G4endl; << 398 G4cout << " TargetV width= " << fTargetVolu << 399 << " mm position = " << fTargetVolum << 400 G4cout << " Target1 width= " << fTarget1Z / << 401 << " mm:" << 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 } 435 } >> 436 >> 437 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 421 438