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 // This example is provided by the Geant4-DNA 27 // Any report or published results obtained us 28 // shall cite the following Geant4-DNA collabo 29 // Med. Phys. 45 (2018) e722-e739 30 // Phys. Med. 31 (2015) 861-874 31 // Med. Phys. 37 (2010) 4692-4708 32 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 33 // 34 // The Geant4-DNA web site is available at htt 35 // 36 /// \file DetectorConstruction.cc 37 /// \brief Implementation of the DetectorConst 38 39 #include "DetectorConstruction.hh" 40 #include "DetectorMessenger.hh" 41 #include "PhysicsList.hh" 42 43 #include "G4LogicalVolumeStore.hh" 44 #include "G4NistManager.hh" 45 #include "G4RunManager.hh" 46 #include "G4SystemOfUnits.hh" 47 #include "G4UserLimits.hh" 48 49 //....oooOO0OOooo........oooOO0OOooo........oo 50 51 DetectorConstruction::DetectorConstruction(Phy 52 : G4VUserDetectorConstruction(), 53 fpWaterMaterial(nullptr), 54 fLogicWorld(nullptr), 55 fPhysiWorld(nullptr) 56 { 57 // Create commands for interactive definitio 58 fDetectorMessenger = new DetectorMessenger(t 59 60 // Default values 61 // 62 // World size 63 fWorldSize = 100 *um; 64 // and material 65 G4NistManager* man = G4NistManager::Instance 66 G4Material* H2O = man->FindOrBuildMaterial(" 67 fpWaterMaterial = H2O; 68 } 69 70 //....oooOO0OOooo........oooOO0OOooo........oo 71 72 DetectorConstruction::~DetectorConstruction() 73 { 74 delete fDetectorMessenger; 75 } 76 77 //....oooOO0OOooo........oooOO0OOooo........oo 78 79 void DetectorConstruction::DefineMaterials() 80 { 81 // Water is defined from NIST material datab 82 G4NistManager* man = G4NistManager::Instance 83 84 G4Material* H2O = man->FindOrBuildMaterial(" 85 86 /* 87 If one wishes to test other density value f 88 one should use instead: 89 G4Material * H2O = man->BuildMaterialWithNe 90 "G4_WATER",1.100*g/cm3); 91 92 Note: any string for "G4_WATER_MODIFIED" pa 93 and "G4_WATER" parameter should not be chan 94 Both materials are created and can be selec 95 */ 96 fpWaterMaterial = H2O; 97 98 // G4cout << "-> Density of water material ( 99 // << fpWaterMaterial->GetDensity()/(g/cm/c 100 101 G4cout << *(G4Material::GetMaterialTable()) 102 } 103 104 //....oooOO0OOooo........oooOO0OOooo........oo 105 106 G4Material* 107 DetectorConstruction::MaterialWithDensity(G4St 108 { 109 // Water is defined from NIST material datab 110 G4NistManager* man = G4NistManager::Instance 111 112 G4Material * material = man->BuildMaterialWi 113 "G4_WATER", density); 114 115 G4cout << "-> Density of water_modified mat 116 << material->GetDensity()/(g/cm/cm/cm) << 117 118 return material; 119 } 120 121 //....oooOO0OOooo........oooOO0OOooo........oo 122 123 G4VPhysicalVolume* DetectorConstruction::Const 124 { 125 if (fPhysiWorld) { 126 return fPhysiWorld; 127 } 128 129 // World volume 130 G4double worldSizeX = fWorldSize; 131 G4double worldSizeY = worldSizeX; 132 G4double worldSizeZ = worldSizeX; 133 134 G4Box* solidWorld = new G4Box("World", // i 135 worldSizeX / 2 136 // its size 137 138 fLogicWorld = new G4LogicalVolume(solidWorld 139 fpWaterMat 140 "World"); 141 142 fPhysiWorld = new G4PVPlacement(0, // no ro 143 G4ThreeVecto 144 "World", // 145 fLogicWorld, 146 0, // its m 147 false, // n 148 0); // copy 149 150 // Visualization attributes - white 151 G4VisAttributes* worldVisAtt = new G4VisAttr 152 worldVisAtt->SetVisibility(true); 153 fLogicWorld->SetVisAttributes(worldVisAtt); 154 155 G4VisAttributes* worldVisAtt1 = new G4VisAtt 156 worldVisAtt1->SetVisibility(true); 157 158 // Shows how to introduce a 20 eV tracking c 159 // logicWorld->SetUserLimits(new G4UserLimit 160 161 return fPhysiWorld; 162 } 163 164 //....oooOO0OOooo........oooOO0OOooo........oo 165 166 void DetectorConstruction::SetMaterial(const G 167 { 168 // Search the material by its name 169 G4Material* pttoMaterial = 170 G4NistManager::Instance()->FindOrBuildMate 171 172 if (pttoMaterial) { 173 fpWaterMaterial = pttoMaterial; 174 if (fLogicWorld) { 175 fLogicWorld->SetMaterial(fpWaterMaterial 176 } 177 G4RunManager::GetRunManager()->GeometryHas 178 } 179 } 180 181 //....oooOO0OOooo........oooOO0OOooo........oo 182 183 void DetectorConstruction::SetSize(G4double va 184 { 185 fWorldSize = value; 186 G4RunManager::GetRunManager()->ReinitializeG 187 } 188