Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 /// \file medical/dna/range/src/DetectorConstr 27 /// \brief Implementation of the DetectorConst 28 // 29 // $Id: DetectorConstruction.cc 78723 2014-01- 30 // 31 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oo 33 34 #include "DetectorConstruction.hh" 35 36 #include "DetectorMessenger.hh" 37 38 #include "G4Colour.hh" 39 #include "G4GeometryManager.hh" 40 #include "G4LogicalVolume.hh" 41 #include "G4LogicalVolumeStore.hh" 42 #include "G4MultiFunctionalDetector.hh" 43 #include "G4NistManager.hh" 44 #include "G4PSDoseDeposit.hh" 45 #include "G4PSEnergyDeposit.hh" 46 #include "G4PVParameterised.hh" 47 #include "G4PVPlacement.hh" 48 #include "G4PVReplica.hh" 49 #include "G4PhysicalConstants.hh" 50 #include "G4PhysicalVolumeStore.hh" 51 #include "G4ProductionCuts.hh" 52 #include "G4RunManager.hh" 53 #include "G4SDManager.hh" 54 #include "G4SolidStore.hh" 55 #include "G4Sphere.hh" 56 #include "G4SubtractionSolid.hh" 57 #include "G4SystemOfUnits.hh" 58 #include "G4Tubs.hh" 59 #include "G4UnitsTable.hh" 60 #include "G4UserLimits.hh" 61 #include "G4VPhysicalVolume.hh" 62 #include "G4VPrimitiveScorer.hh" 63 #include "G4VSensitiveDetector.hh" 64 #include "G4VisAttributes.hh" 65 66 //....oooOO0OOooo........oooOO0OOooo........oo 67 68 DetectorConstruction::DetectorConstruction() 69 : G4VUserDetectorConstruction(), 70 fNPRadius(0), 71 fAbsRadius(0), 72 fNPMaterial(0), 73 fAbsMaterial(0), 74 pWorld(0), 75 fNP(0), 76 fAbs(0), 77 fDetectorMessenger(0), 78 fRegion(0) 79 { 80 // default tracking cut 81 fTrackingCut = 10.0 * eV; 82 83 // default parameter values 84 fNPRadius = 50 * nm; 85 fAbsRadius = 100000 * nm + fNPRadius; 86 87 fNreplicaR = 1000; 88 fNreplicaAzm = 360; 89 90 DefineMaterials(); 91 SetNPMaterial("G4_Au"); 92 SetAbsMaterial("G4_WATER"); 93 94 // create commands for interactive definitio 95 fDetectorMessenger = new DetectorMessenger(t 96 } 97 98 //....oooOO0OOooo........oooOO0OOooo........oo 99 100 DetectorConstruction::~DetectorConstruction() 101 { 102 delete fDetectorMessenger; 103 } 104 105 //....oooOO0OOooo........oooOO0OOooo........oo 106 107 G4VPhysicalVolume* DetectorConstruction::Const 108 { 109 return ConstructVolumes(); 110 } 111 112 //....oooOO0OOooo........oooOO0OOooo........oo 113 114 void DetectorConstruction::DefineMaterials() 115 { 116 G4NistManager* man = G4NistManager::Instance 117 118 man->FindOrBuildMaterial("G4_Au"); 119 man->FindOrBuildMaterial("G4_WATER"); 120 } 121 122 //....oooOO0OOooo........oooOO0OOooo........oo 123 124 G4VPhysicalVolume* DetectorConstruction::Const 125 { 126 const G4bool check_overlap = false; 127 G4GeometryManager::GetInstance()->OpenGeomet 128 G4PhysicalVolumeStore::GetInstance()->Clean( 129 G4LogicalVolumeStore::GetInstance()->Clean() 130 G4SolidStore::GetInstance()->Clean(); 131 132 // World ================================== 133 G4Material* Vacuum = new G4Material("Galacti 134 kStateGa 135 136 G4Sphere* sWorld = new G4Sphere("World", 0., 137 G4LogicalVolume* lWorld = new G4LogicalVolum 138 pWorld = new G4PVPlacement(0, G4ThreeVector( 139 140 // Spherical NanoParticle ================== 141 G4Sphere* sNP = new G4Sphere("NanoParticle", 142 143 fLogicalNP = new G4LogicalVolume(sNP, fNPMat 144 145 fNP = new G4PVPlacement(0, G4ThreeVector(), 146 check_overlap); 147 148 // Sampling Plane ========================== 149 150 // Spherical water absorber ---------------- 151 G4Sphere* sAbsorber0 = new G4Sphere("Absorbe 152 G4VSolid* sAbsorber = new G4SubtractionSolid 153 154 fLogicalAbs = new G4LogicalVolume(sAbsorber, 155 fAbs = 156 new G4PVPlacement(0, G4ThreeVector(), fLog 157 158 // Set Visualization Setting################ 159 G4VisAttributes* visWorld = new G4VisAttribu 160 G4VisAttributes* visNP = new G4VisAttributes 161 G4VisAttributes* visAbs = new G4VisAttribute 162 163 lWorld->SetVisAttributes(visWorld); 164 fLogicalNP->SetVisAttributes(visNP); 165 fLogicalAbs->SetVisAttributes(visAbs); 166 167 PrintParameters(); 168 169 G4double maxStep = fNPRadius / 2.; 170 fLogicalNP->SetUserLimits(new G4UserLimits(m 171 172 fRegion = new G4Region("NP"); 173 174 G4ProductionCuts* cuts = new G4ProductionCut 175 G4double defCut = 0.1 * nm; 176 cuts->SetProductionCut(defCut, "gamma"); 177 cuts->SetProductionCut(defCut, "e-"); 178 cuts->SetProductionCut(defCut, "e+"); 179 cuts->SetProductionCut(defCut, "proton"); 180 fRegion->SetProductionCuts(cuts); 181 fRegion->AddRootLogicalVolume(fLogicalNP); 182 183 return pWorld; 184 } 185 186 //....oooOO0OOooo........oooOO0OOooo........oo 187 188 void DetectorConstruction::PrintParameters() c 189 { 190 G4cout << "\n=============================== 191 G4cout << "---> The tracking cut to all part 192 << G4BestUnit(fTrackingCut, "Energy") 193 G4cout << "\n------------------------------- 194 G4cout << "---> The Nano-Particle is a spher 195 << " radius of " << fNPMaterial->GetN 196 << "\n \n" 197 << fNPMaterial << G4endl; 198 G4cout << "\n------------------------------- 199 G4cout << "---> The Absorber is a sphere of 200 << fAbsMaterial->GetName() << " made 201 << "\n \n" 202 << fAbsMaterial << G4endl; 203 G4cout << "\n=============================== 204 } 205 206 //....oooOO0OOooo........oooOO0OOooo........oo 207 208 void DetectorConstruction::SetTrackingCut(G4do 209 { 210 fTrackingCut = value; 211 G4RunManager::GetRunManager()->ReinitializeG 212 } 213 214 //....oooOO0OOooo........oooOO0OOooo........oo 215 216 void DetectorConstruction::SetAbsRadius(G4doub 217 { 218 fAbsRadius = value; 219 G4RunManager::GetRunManager()->ReinitializeG 220 } 221 222 void DetectorConstruction::SetNPRadius(G4doubl 223 { 224 fNPRadius = value; 225 G4RunManager::GetRunManager()->ReinitializeG 226 } 227 228 //....oooOO0OOooo........oooOO0OOooo........oo 229 // 230 void DetectorConstruction::SetAbsMaterial(G4St 231 { 232 G4Material* pttoMaterial = G4Material::GetMa 233 if (pttoMaterial) fAbsMaterial = pttoMateria 234 G4RunManager::GetRunManager()->PhysicsHasBee 235 } 236 237 void DetectorConstruction::SetNPMaterial(G4Str 238 { 239 G4Material* pttoMaterial = G4Material::GetMa 240 if (pttoMaterial) fNPMaterial = pttoMaterial 241 G4RunManager::GetRunManager()->PhysicsHasBee 242 } 243 244 //....oooOO0OOooo........oooOO0OOooo........oo 245 // 246 void DetectorConstruction::SetNReplicaR(G4int 247 { 248 fNreplicaR = value; 249 G4RunManager::GetRunManager()->ReinitializeG 250 } 251 void DetectorConstruction::SetNReplicaAzm(G4in 252 { 253 fNreplicaAzm = value; 254 G4RunManager::GetRunManager()->ReinitializeG 255 } 256