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 101905 2016-12-07 11:34:39Z gunter $ 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 84 82 fNumZ = 60; << 85 fCheckSD = new CheckVolumeSD("checkSD"); 83 fNumR = 80; << 86 (G4SDManager::GetSDMpointer())->AddNewDetector( fCheckSD ); 84 << 87 fPhantomSD = new PhantomSD("phantomSD"); 85 fNumE = 200; << 88 (G4SDManager::GetSDMpointer())->AddNewDetector( fPhantomSD ); 86 fMaxEnergy = 50.0 * MeV; << 89 fTargetSD = new TargetSD("targetSD"); 87 << 90 (G4SDManager::GetSDMpointer())->AddNewDetector( fTargetSD ); 88 fDistanceVacuumTarget = 30. * mm, << 91 89 << 92 fDistanceVacuumTarget = 30.*mm, 90 fDelta = 0.001 * mm; << 93 91 << 94 fDelta = 0.001*mm; 92 fTargetRadius = 100. * mm; << 95 93 fTarget1Z = 9. * mm; << 96 fTargetRadius = 100.*mm; 94 fTarget2Z = 6. * mm; << 97 fTarget1Z = 9.*mm; 95 << 98 fTarget2Z = 6.*mm; 96 fGasVolumeRadius = 210. * mm; << 99 97 fGasVolumeZ = 690. * mm; << 100 fGasVolumeRadius = 210.*mm; 98 fMylarVolumeZ = 0.02 * mm; << 101 fGasVolumeZ = 690.*mm; 99 << 102 fMylarVolumeZ = 0.02*mm; 100 fCheckVolumeZ = 0.1 * mm; << 103 101 fCheckShiftZ = 200. * mm; << 104 fCheckVolumeZ = 0.1*mm; 102 << 105 fCheckShiftZ = 200.*mm; 103 fAbsorberRadius = 200. * mm; << 106 104 fPhantomRadius = 300. * mm; << 107 fAbsorberRadius = 200.*mm; 105 fPhantomZ = 300. * mm; << 108 fPhantomRadius = 300.*mm; 106 << 109 fPhantomZ = 300.*mm; 107 fAirZ = 210. * mm; << 110 108 fAbsorberShiftZ = 70. * mm; << 111 fAirZ = 210.*mm; 109 fWindowZ = 0.05 * 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 << 164 fGasVolumePosZ = fTargetVolumePosZ + 0.5 * ( << 165 fCheckVolumePosZ = fGasVolumePosZ + 0.5 * (f << 166 fMylarPosZ = fGasVolumePosZ + 0.5 * (fGasVol << 167 << 168 fPhantomPosZ = fGasVolumePosZ + 0.5 * (fGasV << 169 fAbsorberPosZ = fAbsorberShiftZ - 0.5 * (fPh << 170 160 171 fShiftZPh = fPhantomPosZ - 0.5 * fPhantomZ; << 161 fTargetVolumePosZ= -0.5*(ztot - fTargetVolumeZ); >> 162 fTarget1PosZ = -0.5*(fTargetVolumeZ - fTarget1Z) + fDistanceVacuumTarget; >> 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); 172 177 173 DumpGeometryParameters(); << 178 G4cout << "===================================================" << G4endl; >> 179 G4cout << "# GammaTherapy Geometry #" << G4endl; >> 180 G4cout << "===================================================" << G4endl; >> 181 G4cout << " World width= " << fWorldZ/mm << " mm " << G4endl; >> 182 G4cout << " Window width= " << fWindowZ/mm << " mm position = " >> 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 InitialiseGeometryParameters(); 181 213 182 G4GeometryManager::GetInstance()->OpenGeomet << 183 G4PhysicalVolumeStore::GetInstance()->Clean( << 184 G4LogicalVolumeStore::GetInstance()->Clean() << 185 G4SolidStore::GetInstance()->Clean(); << 186 // 214 // 187 // World 215 // World 188 // 216 // >> 217 G4VPhysicalVolume* pv; 189 218 190 G4Box* solidWorld = new G4Box("World", fWorl << 219 G4Box* solidWorld = new G4Box("World",fWorldXY,fWorldXY,fWorldZ); 191 G4LogicalVolume* logicWorld = new G4LogicalV << 220 G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, 192 G4VPhysicalVolume* physWorld = << 221 fWorldMaterial,"World"); 193 new G4PVPlacement(0, G4ThreeVector(), "Wor << 222 G4VPhysicalVolume* physWorld = new G4PVPlacement(0,G4ThreeVector(),"World", >> 223 logicWorld,0,false,0); 194 224 195 // Be Vacuum window 225 // Be Vacuum window 196 G4Tubs* solidWin = new G4Tubs("Window", 0., << 226 G4Tubs* solidWin = new G4Tubs("Window",0.,fTargetRadius*0.25,0.5*fWindowZ, 197 G4LogicalVolume* logicWin = new G4LogicalVol << 227 0.,twopi); 198 new G4PVPlacement(0, G4ThreeVector(0., 0., f << 228 G4LogicalVolume* logicWin = new G4LogicalVolume(solidWin, >> 229 fWindowMaterial,"Window"); >> 230 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fWindowPosZ),"Window",logicWin, >> 231 physWorld,false,0); 199 232 200 // Target Volume 233 // Target Volume 201 G4Tubs* solidTGVolume = << 234 G4Tubs* solidTGVolume = new G4Tubs("TargetVolume",0.,fTargetRadius, 202 new G4Tubs("TargetVolume", 0., fTargetRadi << 235 0.5*fTargetVolumeZ,0.,twopi); 203 G4LogicalVolume* logicTGVolume = << 236 G4LogicalVolume* logicTGVolume = new G4LogicalVolume(solidTGVolume, 204 new G4LogicalVolume(solidTGVolume, fLightM << 237 fLightMaterial, 205 new G4PVPlacement(0, G4ThreeVector(0., 0., f << 238 "TargetVolume"); 206 logicWorld, false, 0); << 239 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fTargetVolumePosZ), >> 240 logicTGVolume,"TargetVolume", >> 241 logicWorld,false,0); 207 242 208 // Target 1 243 // Target 1 209 G4Tubs* solidTarget1 = new G4Tubs("Target1", << 244 G4Tubs* solidTarget1 = new G4Tubs("Target1",0.,fTargetRadius*0.5, 210 fLogicTarget1 = new G4LogicalVolume(solidTar << 245 0.5*fTarget1Z,0.,twopi); 211 fTarget1 = new G4PVPlacement(0, G4ThreeVecto << 246 fLogicTarget1 = new G4LogicalVolume(solidTarget1,fTarget1Material,"Target1"); 212 logicTGVolume, << 247 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fTarget1PosZ), 213 // fLogicTarget1->SetSensitiveDetector(fTar << 248 fLogicTarget1,"Target1", >> 249 logicTGVolume,false,0); >> 250 (Histo::GetPointer())->SetTarget1(pv); >> 251 fLogicTarget1->SetSensitiveDetector(fTargetSD); 214 252 215 // Target 2 (for combined targets) 253 // Target 2 (for combined targets) 216 G4Tubs* solidTarget2 = new G4Tubs("Target2", << 254 G4Tubs* solidTarget2 = new G4Tubs("Target2",0.,fTargetRadius*0.5, 217 fLogicTarget2 = new G4LogicalVolume(solidTar << 255 0.5*fTarget2Z,0.,twopi); 218 fTarget2 = new G4PVPlacement(0, G4ThreeVecto << 256 fLogicTarget2 = new G4LogicalVolume(solidTarget2,fTarget2Material,"Target2"); 219 logicTGVolume, << 257 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fTarget2PosZ), >> 258 fLogicTarget2,"Target2", >> 259 logicTGVolume,false,0); 220 260 221 // fLogicTarget2->SetSensitiveDetector(fTar << 261 (Histo::GetPointer())->SetTarget2(pv); >> 262 fLogicTarget2->SetSensitiveDetector(fTargetSD); 222 263 223 // Gas Volume 264 // Gas Volume 224 G4Tubs* solidGasVolume = << 265 G4Tubs* solidGasVolume = new G4Tubs("GasVolume",0.,fGasVolumeRadius, 225 new G4Tubs("GasVolume", 0., fGasVolumeRadi << 266 0.5*fGasVolumeZ,0.,twopi); 226 G4LogicalVolume* logicGasVolume = << 267 G4LogicalVolume* logicGasVolume = new G4LogicalVolume(solidGasVolume, 227 new G4LogicalVolume(solidGasVolume, fLight << 268 fLightMaterial, 228 fGasVolume = new G4PVPlacement(0, G4ThreeVec << 269 "GasVolume"); 229 logicGasVolum << 270 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fGasVolumePosZ), >> 271 "GasVolume",logicGasVolume, >> 272 physWorld,false,0); >> 273 (Histo::GetPointer())->SetGasVolume(pv); 230 274 231 // Mylar window 275 // Mylar window 232 G4Tubs* sMylarVolume = new G4Tubs("Mylar", 0 << 276 G4Tubs* sMylarVolume = new G4Tubs("Mylar",0.,fGasVolumeRadius, 233 G4LogicalVolume* lMylarVolume = new G4Logica << 277 0.5*fMylarVolumeZ,0.,twopi); 234 new G4PVPlacement(0, G4ThreeVector(0., 0., f << 278 G4LogicalVolume* lMylarVolume = new G4LogicalVolume(sMylarVolume, 235 0); << 279 fMylar,"Mylar"); >> 280 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fMylarPosZ),"Mylar",lMylarVolume, >> 281 physWorld,false,0); 236 282 237 // Check Volume 283 // Check Volume 238 G4Tubs* solidCheckVolume = << 284 G4Tubs* solidCheckVolume = new G4Tubs("CheckVolume",0.,fGasVolumeRadius, 239 new G4Tubs("CheckVolume", 0., fGasVolumeRa << 285 0.5*fCheckVolumeZ,0.,twopi); 240 fLogicCheckVolume = new G4LogicalVolume(soli << 286 G4LogicalVolume* logicCheckVolume = new G4LogicalVolume(solidCheckVolume, 241 fCheckVolume = new G4PVPlacement(0, G4ThreeV << 287 fWorldMaterial, 242 fLogicCheck << 288 "CheckVolume"); 243 // logicCheckVolume->SetSensitiveDetector(f << 289 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fCheckVolumePosZ), >> 290 "CheckVolume",logicCheckVolume, >> 291 physWorld,false,0); >> 292 (Histo::GetPointer())->SetCheckVolume(pv); >> 293 logicCheckVolume->SetSensitiveDetector(fCheckSD); 244 294 245 // Phantom 295 // Phantom 246 G4Box* solidPhantom = new G4Box("Phantom", f << 296 G4Box* solidPhantom = new G4Box("Phantom",fPhantomRadius,fPhantomRadius, 247 G4LogicalVolume* logicPhantom = new G4Logica << 297 0.5*fPhantomZ); 248 G4VPhysicalVolume* physPhantom = new G4PVPla << 298 G4LogicalVolume* logicPhantom = new G4LogicalVolume(solidPhantom, 249 << 299 fAbsorberMaterial, 250 << 300 "Phantom"); 251 G4Tubs* solidPh = new G4Tubs("PhantomSD", 0. << 301 G4VPhysicalVolume* physPhantom = 252 fLogicPh = new G4LogicalVolume(solidPh, fAbs << 302 new G4PVPlacement(0, G4ThreeVector(0.,0.,fPhantomPosZ), 253 fPhantom = << 303 "Phantom",logicPhantom, 254 new G4PVPlacement(0, G4ThreeVector(0., 0., << 304 physWorld,false,0); 255 G4cout << "Phantom R= " << fAbsorberRadius < << 305 256 << 306 G4Tubs* solidPh = new G4Tubs("PhantomSD",0.,fAbsorberRadius, 257 // Sensitive Absorber << 307 0.5*fPhantomZ,0.,twopi); 258 G4double absWidth = 0.5 * fAbsorberZ; << 308 G4LogicalVolume* logicPh = new G4LogicalVolume(solidPh, 259 G4Tubs* solidAbsorber = new G4Tubs("Absorber << 309 fAbsorberMaterial,"PhantomSD"); 260 fLogicAbsorber = new G4LogicalVolume(solidAb << 310 G4VPhysicalVolume* physPh = new G4PVPlacement(0,G4ThreeVector(0.,0.,0.), 261 G4cout << "Absorber R= " << fAbsorberRadius << 311 "Phantom",logicPh, >> 312 physPhantom,false,0); >> 313 G4cout << "Phantom R= " << fAbsorberRadius << " dz= " << 0.5*fPhantomZ 262 << G4endl; 314 << G4endl; 263 315 264 new G4PVPlacement(0, G4ThreeVector(0., 0., f << 316 // Sensitive Absorber 265 false, 0); << 317 G4double absWidth = 0.5*fAbsorberZ; 266 << 318 G4Tubs* solidAbsorber = new G4Tubs("Absorber",0.,fAbsorberRadius,absWidth, 267 G4double stepR = fAbsorberRadius / (G4double << 319 0.,twopi); >> 320 G4LogicalVolume* logicAbsorber = new G4LogicalVolume(solidAbsorber, >> 321 fAbsorberMaterial, >> 322 "Absorber"); >> 323 G4cout << "Absorber R= " << fAbsorberRadius << " dz= " << absWidth >> 324 << " posZ= " << fAbsorberPosZ<< G4endl; >> 325 >> 326 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,fAbsorberPosZ),"Absorber", >> 327 logicAbsorber,physPh,false,0); >> 328 (Histo::GetPointer())->SetPhantom(physPh); >> 329 G4int numR = (Histo::GetPointer())->GetNumberDivR(); >> 330 G4double stepR = fAbsorberRadius/(G4double)numR; 268 331 269 G4double r1 = 0.0; 332 G4double r1 = 0.0; 270 G4double r2 = 0.0; 333 G4double r2 = 0.0; 271 G4Tubs* solidRing; 334 G4Tubs* solidRing; >> 335 G4LogicalVolume* logicRing; 272 336 273 G4VisAttributes* VisAtt_ring = new G4VisAttr << 337 for(G4int k=0; k<numR; k++) { 274 for (G4int k = 0; k < fNumR; k++) { << 275 r2 = r1 + stepR; 338 r2 = r1 + stepR; 276 if (k == fNumR - 1) r2 = fAbsorberRadius; << 339 if(k == numR-1) r2 = fAbsorberRadius; 277 // G4cout << "New ring r1= " << r1 << " << 340 // G4cout << "New ring r1= " << r1 << " r2= " << r2 278 // << " dz= " << absWidth << G4endl; 341 // << " dz= " << absWidth << G4endl; 279 solidRing = new G4Tubs("Ring", r1, r2, abs << 342 solidRing = new G4Tubs("Ring",r1,r2,absWidth,0.,twopi); 280 G4LogicalVolume* logicRing = new G4Logical << 343 logicRing = new G4LogicalVolume(solidRing,fAbsorberMaterial,"Ring"); 281 // logicRing->SetSensitiveDetector(fPha << 344 logicRing->SetSensitiveDetector(fPhantomSD); 282 logicRing->SetVisAttributes(VisAtt_ring); << 345 logicRing->SetVisAttributes(G4VisAttributes::GetInvisible()); 283 fLogicRing.push_back(logicRing); << 346 pv = new G4PVPlacement(0,G4ThreeVector(0.,0.,0.),logicRing,"Ring", 284 new G4PVPlacement(0, G4ThreeVector(0., 0., << 347 logicAbsorber,false,k); 285 r1 = r2; 348 r1 = r2; 286 } 349 } 287 << 350 // >> 351 // Sensitive Detectors: Absorber >> 352 // >> 353 logicPh->SetSensitiveDetector(fPhantomSD); >> 354 logicAbsorber->SetSensitiveDetector(fPhantomSD); 288 // 355 // 289 // Visualization attributes 356 // Visualization attributes 290 // 357 // 291 G4VisAttributes* VisAtt = 0; 358 G4VisAttributes* VisAtt = 0; 292 VisAtt = new G4VisAttributes(G4Colour(1.0, 1 << 359 VisAtt = new G4VisAttributes(G4Colour(1.0,1.0,1.0)); 293 VisAtt->SetVisibility(true); 360 VisAtt->SetVisibility(true); 294 fLogicAbsorber->SetVisAttributes(VisAtt); << 361 logicAbsorber->SetVisAttributes(VisAtt); 295 362 296 VisAtt = new G4VisAttributes(G4Colour(1.0, 1 << 363 VisAtt= new G4VisAttributes(G4Colour(1.0,1.0,2.0)); 297 VisAtt->SetVisibility(true); 364 VisAtt->SetVisibility(true); 298 logicPhantom->SetVisAttributes(VisAtt); 365 logicPhantom->SetVisAttributes(VisAtt); 299 366 300 VisAtt = new G4VisAttributes(G4Colour(1.0, 0 << 367 VisAtt= new G4VisAttributes(G4Colour(1.0,0.0,2.0)); 301 VisAtt->SetVisibility(true); 368 VisAtt->SetVisibility(true); 302 fLogicPh->SetVisAttributes(VisAtt); << 369 logicPh->SetVisAttributes(VisAtt); 303 370 304 VisAtt = new G4VisAttributes(G4Colour(1.0, 1 << 371 VisAtt= new G4VisAttributes(G4Colour(1.0,1.0,0.0)); 305 VisAtt->SetVisibility(true); 372 VisAtt->SetVisibility(true); 306 fLogicAbsorber->SetVisAttributes(VisAtt); << 373 logicAbsorber->SetVisAttributes(VisAtt); 307 374 308 VisAtt = new G4VisAttributes(G4Colour(0.1, 1 << 375 VisAtt= new G4VisAttributes(G4Colour(0.1,1.0,2.0)); 309 VisAtt->SetVisibility(true); 376 VisAtt->SetVisibility(true); 310 logicWorld->SetVisAttributes(VisAtt); 377 logicWorld->SetVisAttributes(VisAtt); 311 378 312 VisAtt = new G4VisAttributes(G4Colour(1.0, 1 << 379 VisAtt= new G4VisAttributes(G4Colour(1.0,1.0,0.0)); 313 VisAtt->SetVisibility(true); 380 VisAtt->SetVisibility(true); 314 logicGasVolume->SetVisAttributes(VisAtt); 381 logicGasVolume->SetVisAttributes(VisAtt); 315 382 316 VisAtt = new G4VisAttributes(G4Colour(0.0, 0 << 383 VisAtt= new G4VisAttributes(G4Colour(0.0,0.5,1.0)); 317 VisAtt->SetVisibility(true); 384 VisAtt->SetVisibility(true); 318 fLogicTarget1->SetVisAttributes(VisAtt); 385 fLogicTarget1->SetVisAttributes(VisAtt); 319 fLogicTarget2->SetVisAttributes(VisAtt); 386 fLogicTarget2->SetVisAttributes(VisAtt); 320 logicTGVolume->SetVisAttributes(VisAtt); 387 logicTGVolume->SetVisAttributes(VisAtt); 321 388 322 return physWorld; 389 return physWorld; 323 } 390 } 324 391 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 392 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 351 393 352 void DetectorConstruction::SetTarget1Material( 394 void DetectorConstruction::SetTarget1Material(const G4String& mat) 353 { 395 { 354 // search the material by its name 396 // search the material by its name 355 G4Material* pttoMaterial = G4NistManager::In << 397 G4Material* pttoMaterial = 356 if (!pttoMaterial) { << 398 G4NistManager::Instance()->FindOrBuildMaterial(mat); >> 399 if(!pttoMaterial) { 357 G4cout << "Material " << mat << " is not f 400 G4cout << "Material " << mat << " is not found out!" << G4endl; 358 } << 401 } else if (pttoMaterial != fTarget1Material) { 359 else if (pttoMaterial != fTarget1Material) { << 360 G4cout << "New target1 material " << mat < 402 G4cout << "New target1 material " << mat << G4endl; 361 if (fLogicTarget1) { << 403 if(fLogicTarget1) { fLogicTarget1->SetMaterial(fTarget1Material); } 362 fLogicTarget1->SetMaterial(fTarget1Mater << 363 } << 364 G4RunManager::GetRunManager()->PhysicsHasB 404 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 365 } 405 } 366 } 406 } 367 407 368 //....oooOO0OOooo........oooOO0OOooo........oo 408 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 369 409 370 void DetectorConstruction::SetTarget2Material( 410 void DetectorConstruction::SetTarget2Material(const G4String& mat) 371 { 411 { 372 // search the material by its name 412 // search the material by its name 373 G4Material* pttoMaterial = G4NistManager::In << 413 G4Material* pttoMaterial = >> 414 G4NistManager::Instance()->FindOrBuildMaterial(mat); 374 415 375 if (!pttoMaterial) { << 416 if(!pttoMaterial) { 376 G4cout << "Material " << mat << " is not f 417 G4cout << "Material " << mat << " is not found out!" << G4endl; 377 } << 418 } else if (pttoMaterial != fTarget2Material) { 378 else if (pttoMaterial != fTarget2Material) { << 379 fTarget2Material = pttoMaterial; 419 fTarget2Material = pttoMaterial; 380 G4cout << "New target2 material " << mat < 420 G4cout << "New target2 material " << mat << G4endl; 381 if (fLogicTarget2) { << 421 if(fLogicTarget2) { fLogicTarget2->SetMaterial(fTarget2Material); } 382 fLogicTarget2->SetMaterial(fTarget2Mater << 383 } << 384 G4RunManager::GetRunManager()->PhysicsHasB 422 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 385 } << 423 } 386 } 424 } 387 425 388 //....oooOO0OOooo........oooOO0OOooo........oo 426 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 389 << 390 void DetectorConstruction::DumpGeometryParamet << 391 { << 392 G4cout << "================================= << 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 } << 421 427