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