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 // This example is provided by the Geant4-DNA 26 // This example is provided by the Geant4-DNA collaboration 27 // Any report or published results obtained us << 27 // Any report or published results obtained using the Geant4-DNA software 28 // shall cite the following Geant4-DNA collabo 28 // shall cite the following Geant4-DNA collaboration publications: 29 // Med. Phys. 45 (2018) e722-e739 << 30 // Phys. Med. 31 (2015) 861-874 << 31 // Med. Phys. 37 (2010) 4692-4708 29 // Med. Phys. 37 (2010) 4692-4708 32 // Int. J. Model. Simul. Sci. Comput. 1 (2010) << 30 // Phys. Med. 31 (2015) 861-874 33 // << 34 // The Geant4-DNA web site is available at htt 31 // The Geant4-DNA web site is available at http://geant4-dna.org 35 // 32 // 36 /// \file medical/dna/svalue/src/DetectorConst 33 /// \file medical/dna/svalue/src/DetectorConstruction.cc 37 /// \brief Implementation of the DetectorConst 34 /// \brief Implementation of the DetectorConstruction class 38 35 39 #include "DetectorConstruction.hh" 36 #include "DetectorConstruction.hh" 40 << 41 #include "DetectorMessenger.hh" 37 #include "DetectorMessenger.hh" 42 38 43 #include "G4NistManager.hh" 39 #include "G4NistManager.hh" >> 40 #include "G4Sphere.hh" >> 41 #include "G4LogicalVolume.hh" >> 42 #include "G4VPhysicalVolume.hh" 44 #include "G4PVPlacement.hh" 43 #include "G4PVPlacement.hh" 45 #include "G4PhysicalConstants.hh" << 44 #include "G4PVReplica.hh" >> 45 >> 46 #include "G4GeometryManager.hh" >> 47 #include "G4PhysicalVolumeStore.hh" >> 48 #include "G4LogicalVolumeStore.hh" >> 49 #include "G4SolidStore.hh" 46 #include "G4RunManager.hh" 50 #include "G4RunManager.hh" 47 #include "G4Sphere.hh" << 51 48 #include "G4UnitsTable.hh" 52 #include "G4UnitsTable.hh" >> 53 #include "G4PhysicalConstants.hh" >> 54 #include "G4SystemOfUnits.hh" 49 #include "G4UserLimits.hh" 55 #include "G4UserLimits.hh" 50 56 51 //....oooOO0OOooo........oooOO0OOooo........oo 57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 52 58 53 DetectorConstruction::DetectorConstruction() : << 59 DetectorConstruction::DetectorConstruction() >> 60 : G4VUserDetectorConstruction() 54 { 61 { 55 // Default tracking cut << 62 //default tracking cut 56 << 63 fTrackingCut = 7.4*CLHEP::eV; 57 fTrackingCut = 7.4 * CLHEP::eV; << 64 58 << 65 // default parameter values 59 // Default parameter values << 66 fWorldRadius = 10*CLHEP::m; 60 << 67 fCytoThickness = 20*CLHEP::nm; 61 fWorldRadius = 10 * CLHEP::m; << 68 fNuclRadius = 10*CLHEP::nm; 62 fCytoThickness = 20 * CLHEP::nm; << 69 63 fNuclRadius = 10 * CLHEP::nm; << 64 << 65 DefineMaterials(); 70 DefineMaterials(); 66 71 67 // Create commands for interactive definitio << 72 // create commands for interactive definition of the detector 68 << 69 fDetectorMessenger = new DetectorMessenger(t 73 fDetectorMessenger = new DetectorMessenger(this); 70 } 74 } 71 75 72 //....oooOO0OOooo........oooOO0OOooo........oo 76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 73 77 74 DetectorConstruction::~DetectorConstruction() 78 DetectorConstruction::~DetectorConstruction() 75 { << 79 { 76 delete fDetectorMessenger; 80 delete fDetectorMessenger; 77 } 81 } 78 82 79 //....oooOO0OOooo........oooOO0OOooo........oo 83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 80 84 81 void DetectorConstruction::DefineMaterials() 85 void DetectorConstruction::DefineMaterials() 82 { << 86 { 83 G4NistManager* man = G4NistManager::Instance 87 G4NistManager* man = G4NistManager::Instance(); 84 << 88 85 fWorldMaterial = man->FindOrBuildMaterial("G 89 fWorldMaterial = man->FindOrBuildMaterial("G4_WATER"); 86 fCytoMaterial = fNuclMaterial = man->FindOrB 90 fCytoMaterial = fNuclMaterial = man->FindOrBuildMaterial("G4_WATER"); 87 } 91 } 88 92 89 //....oooOO0OOooo........oooOO0OOooo........oo 93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 90 << 94 91 G4VPhysicalVolume* DetectorConstruction::Const 95 G4VPhysicalVolume* DetectorConstruction::Construct() 92 { 96 { 93 if (fWorld) return fWorld; << 97 if(fWorld) return fWorld; 94 << 98 95 // Spherical world 99 // Spherical world 96 << 100 // 97 G4Sphere* sWorld = new G4Sphere("World", 0., << 101 G4Sphere* 98 << 102 sWorld = new G4Sphere("World", 99 fLogicalWorld = new G4LogicalVolume(sWorld, << 103 0., 100 << 104 1000*fNuclRadius, 101 fWorld = new G4PVPlacement(0, G4ThreeVector( << 105 0., >> 106 twopi, >> 107 0., >> 108 pi); >> 109 >> 110 fLogicalWorld = new G4LogicalVolume(sWorld, >> 111 fWorldMaterial, >> 112 "World"); >> 113 >> 114 fWorld = new G4PVPlacement(0, >> 115 G4ThreeVector(), >> 116 fLogicalWorld, >> 117 "World", >> 118 0, >> 119 false, >> 120 0); 102 121 103 // Spherical nucleus 122 // Spherical nucleus 104 << 123 // 105 G4Sphere* sNucl = new G4Sphere("Nucl", 0., f << 124 G4Sphere* 106 << 125 sNucl = new G4Sphere("Nucl", 107 fLogicalNucl = new G4LogicalVolume(sNucl, fN << 126 0., 108 << 127 fNuclRadius, 109 fNucl = new G4PVPlacement(0, G4ThreeVector() << 128 0., >> 129 twopi, >> 130 0., >> 131 pi); >> 132 >> 133 fLogicalNucl = new G4LogicalVolume(sNucl, >> 134 fNuclMaterial, >> 135 "Nucl"); >> 136 >> 137 fNucl = new G4PVPlacement(0, >> 138 G4ThreeVector(), >> 139 "Nucl", >> 140 fLogicalNucl, >> 141 fWorld, >> 142 false, >> 143 0); 110 144 111 // Spherical shell for cytoplasm 145 // Spherical shell for cytoplasm 112 << 113 G4Sphere* sCyto = << 114 new G4Sphere("Cyto", fNuclRadius, fNuclRad << 115 << 116 fLogicalCyto = new G4LogicalVolume(sCyto, fC << 117 << 118 fCyto = new G4PVPlacement(0, G4ThreeVector() << 119 // 146 // 120 << 147 G4Sphere* >> 148 sCyto = new G4Sphere("Cyto", >> 149 fNuclRadius, >> 150 fNuclRadius+fCytoThickness, >> 151 0., >> 152 twopi, >> 153 0., >> 154 pi); >> 155 >> 156 fLogicalCyto = new G4LogicalVolume(sCyto, >> 157 fCytoMaterial, >> 158 "Cyto"); >> 159 >> 160 fCyto = new G4PVPlacement(0, >> 161 G4ThreeVector(), >> 162 "Cyto", >> 163 fLogicalCyto, >> 164 fWorld, >> 165 false, >> 166 0); >> 167 // >> 168 121 PrintParameters(); 169 PrintParameters(); 122 << 170 123 // Tracking cut 171 // Tracking cut 124 << 125 fLogicalNucl->SetUserLimits(new G4UserLimits << 126 fLogicalCyto->SetUserLimits(new G4UserLimits << 127 fLogicalWorld->SetUserLimits(new G4UserLimit << 128 << 129 // 172 // >> 173 fLogicalNucl->SetUserLimits(new G4UserLimits(DBL_MAX,DBL_MAX,DBL_MAX, >> 174 fTrackingCut)); >> 175 fLogicalCyto->SetUserLimits(new G4UserLimits(DBL_MAX,DBL_MAX,DBL_MAX, >> 176 fTrackingCut)); >> 177 fLogicalWorld->SetUserLimits(new G4UserLimits(DBL_MAX,DBL_MAX,DBL_MAX, >> 178 fTrackingCut)); >> 179 >> 180 // >> 181 //always return the root volume >> 182 // 130 return fWorld; 183 return fWorld; 131 } 184 } 132 185 133 //....oooOO0OOooo........oooOO0OOooo........oo 186 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 134 187 135 void DetectorConstruction::PrintParameters() c 188 void DetectorConstruction::PrintParameters() const 136 { 189 { 137 G4cout << "\n------------------------------- 190 G4cout << "\n---------------------------------------------------------\n"; 138 G4cout << "---> The tracking cut is set to " << 191 G4cout << "---> The tracking cut is set to " 139 G4cout << "---> The World is a sphere of " < << 192 << G4BestUnit(fTrackingCut,"Energy") << G4endl; 140 << "radius of " << fWorldMaterial->Ge << 193 G4cout << "---> The World is a sphere of " 141 G4cout << "---> The Nucleus is a sphere of " << 194 << G4BestUnit(1000*fNuclRadius,"Length") << "radius of " 142 << fWorldMaterial->GetName() << " of << 195 << fWorldMaterial->GetName() << G4endl; 143 G4cout << "---> The Cytoplasm is a spherical << 196 G4cout << "---> The Nucleus is a sphere of " 144 << G4BestUnit(fCytoThickness, "Length << 197 << G4BestUnit(fNuclRadius,"Length") << "radius of " 145 << " of mass " << G4BestUnit(GetCytoM << 198 << fWorldMaterial->GetName() << " of mass " >> 199 << G4BestUnit(GetNuclMass(),"Mass") << G4endl; >> 200 G4cout << "---> The Cytoplasm is a spherical shell of thickness " >> 201 << G4BestUnit(fCytoThickness,"Length") << "of " >> 202 << fWorldMaterial->GetName() << " of mass " >> 203 << G4BestUnit(GetCytoMass(),"Mass") << G4endl; 146 G4cout << "\n------------------------------- 204 G4cout << "\n---------------------------------------------------------\n"; 147 } 205 } 148 206 149 //....oooOO0OOooo........oooOO0OOooo........oo 207 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 150 208 151 void DetectorConstruction::SetTrackingCut(G4do 209 void DetectorConstruction::SetTrackingCut(G4double value) 152 { 210 { 153 fTrackingCut = value; 211 fTrackingCut = value; 154 } 212 } 155 213 156 //....oooOO0OOooo........oooOO0OOooo........oo 214 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 157 215 158 void DetectorConstruction::SetNuclRadius(G4dou 216 void DetectorConstruction::SetNuclRadius(G4double value) 159 { 217 { 160 fNuclRadius = value; 218 fNuclRadius = value; 161 } 219 } 162 220 163 //....oooOO0OOooo........oooOO0OOooo........oo 221 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 164 222 165 void DetectorConstruction::SetCytoThickness(G4 223 void DetectorConstruction::SetCytoThickness(G4double value) 166 { 224 { 167 fCytoThickness = value; 225 fCytoThickness = value; 168 } 226 } 169 227 170 //....oooOO0OOooo........oooOO0OOooo........oo 228 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 171 229 172 void DetectorConstruction::SetWorldMaterial(co 230 void DetectorConstruction::SetWorldMaterial(const G4String& materialChoice) 173 { 231 { 174 // Search the material by its name << 232 // search the material by its name 175 G4Material* pttoMaterial = G4NistManager::In << 233 G4Material* pttoMaterial = >> 234 G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); 176 235 177 if (pttoMaterial && pttoMaterial != fWorldMa 236 if (pttoMaterial && pttoMaterial != fWorldMaterial) { 178 fWorldMaterial = pttoMaterial; 237 fWorldMaterial = pttoMaterial; 179 if (fLogicalWorld) fLogicalWorld->SetMater << 238 if(fLogicalWorld) fLogicalWorld->SetMaterial(pttoMaterial); 180 G4RunManager::GetRunManager()->PhysicsHasB 239 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 181 } 240 } 182 } 241 } 183 242 184 //....oooOO0OOooo........oooOO0OOooo........oo 243 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 185 244 186 void DetectorConstruction::SetCytoMaterial(con 245 void DetectorConstruction::SetCytoMaterial(const G4String& materialChoice) 187 { 246 { 188 // Search the material by its name << 247 // search the material by its name 189 G4Material* pttoMaterial = G4NistManager::In << 248 G4Material* pttoMaterial = >> 249 G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); 190 250 191 if (pttoMaterial && pttoMaterial != fCytoMat 251 if (pttoMaterial && pttoMaterial != fCytoMaterial) { 192 fCytoMaterial = pttoMaterial; 252 fCytoMaterial = pttoMaterial; 193 if (fLogicalCyto) fLogicalCyto->SetMateria << 253 if(fLogicalCyto) fLogicalCyto->SetMaterial(pttoMaterial); 194 G4RunManager::GetRunManager()->PhysicsHasB 254 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 195 } 255 } 196 } 256 } 197 257 198 //....oooOO0OOooo........oooOO0OOooo........oo 258 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 199 259 200 void DetectorConstruction::SetNuclMaterial(con 260 void DetectorConstruction::SetNuclMaterial(const G4String& materialChoice) 201 { 261 { 202 // Search the material by its name << 262 // search the material by its name 203 G4Material* pttoMaterial = G4NistManager::In << 263 G4Material* pttoMaterial = >> 264 G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); 204 265 205 if (pttoMaterial && pttoMaterial != fNuclMat 266 if (pttoMaterial && pttoMaterial != fNuclMaterial) { 206 fNuclMaterial = pttoMaterial; 267 fNuclMaterial = pttoMaterial; 207 if (fLogicalNucl) fLogicalNucl->SetMateria << 268 if(fLogicalNucl) fLogicalNucl->SetMaterial(pttoMaterial); 208 G4RunManager::GetRunManager()->PhysicsHasB 269 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 209 } 270 } 210 } 271 } >> 272 >> 273 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 211 274