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 // The Geant4-DNA web site is available at htt 34 // 35 // 36 /// \file DetectorConstruction.cc 37 /// \brief Implementation of the DetectorConst 38 39 #include "DetectorConstruction.hh" 40 41 #include "DetectorMessenger.hh" 42 #include "PhysicsList.hh" 43 44 #include "G4LogicalVolume.hh" 45 #include "G4RunManager.hh" 46 #include "G4SystemOfUnits.hh" 47 48 //....oooOO0OOooo........oooOO0OOooo........oo 49 50 DetectorConstruction::DetectorConstruction(Phy 51 : G4VUserDetectorConstruction(), 52 fpWaterMaterial(nullptr), 53 fLogicWorld(nullptr), 54 fPhysiWorld(nullptr) 55 { 56 fDetectorMessenger = new DetectorMessenger(t 57 } 58 59 //....oooOO0OOooo........oooOO0OOooo........oo 60 61 DetectorConstruction::~DetectorConstruction() 62 { 63 delete fDetectorMessenger; 64 } 65 66 //....oooOO0OOooo........oooOO0OOooo........oo 67 68 void DetectorConstruction::DefineMaterials() 69 { 70 // Water is defined from NIST material datab 71 G4NistManager* man = G4NistManager::Instance 72 73 G4Material* H2O = man->FindOrBuildMaterial(" 74 75 /* 76 If one wishes to test other density value f 77 one should use instead: 78 G4Material * H2O = man->BuildMaterialWithNe 79 "G4_WATER",1.100*g/cm3); 80 81 Note: any string for "G4_WATER_MODIFIED" pa 82 and "G4_WATER" parameter should not be chan 83 Both materials are created and can be selec 84 */ 85 fpWaterMaterial = H2O; 86 87 // G4cout << "-> Density of water material ( 88 // << fpWaterMaterial->GetDensity()/(g/cm/c 89 90 G4cout << *(G4Material::GetMaterialTable()) 91 } 92 93 //....oooOO0OOooo........oooOO0OOooo........oo 94 95 G4VPhysicalVolume* DetectorConstruction::Const 96 { 97 if (fPhysiWorld) { 98 return fPhysiWorld; 99 } 100 DefineMaterials(); 101 102 // World volume 103 104 G4double worldSizeX = 10 * micrometer; 105 G4double worldSizeY = worldSizeX; 106 G4double worldSizeZ = worldSizeX; 107 108 G4Box* solidWorld = new G4Box("World", // i 109 worldSizeX / 2 110 111 fLogicWorld = new G4LogicalVolume(solidWorld 112 fpWaterMat 113 "World"); 114 115 fPhysiWorld = new G4PVPlacement(0, // no ro 116 G4ThreeVecto 117 "World", // 118 fLogicWorld, 119 0, // its m 120 false, // n 121 0); // copy 122 123 // Target volume 124 125 G4Box* solidTarget = new G4Box("volumeTarget 126 worldSizeX / 127 128 fLogicTarget = new G4LogicalVolume(solidTarg 129 fpWaterMa 130 "volumeTa 131 132 fPhysiTarget = new G4PVPlacement(0, // no r 133 G4ThreeVect 134 "volumeTarg 135 fLogicTarge 136 fPhysiWorld 137 false, // 138 0); // cop 139 140 // Target region 141 142 G4Region* targetRegion = new G4Region("regio 143 144 // Cuts needed to allow combination of Physi 145 // Default EM settings for fast simulation f 146 // 1 um proton cut avoids creation of very s 147 G4ProductionCuts* cuts = new G4ProductionCut 148 cuts->SetProductionCut(0.7 * mm, "gamma"); 149 cuts->SetProductionCut(0.7 * mm, "e-"); 150 cuts->SetProductionCut(0.7 * mm, "e+"); 151 cuts->SetProductionCut(1 * micrometer, "prot 152 targetRegion->SetProductionCuts(cuts); 153 154 targetRegion->AddRootLogicalVolume(fLogicTar 155 156 // Visualization attributes - white 157 G4VisAttributes* worldVisAtt = new G4VisAttr 158 worldVisAtt->SetVisibility(true); 159 fLogicWorld->SetVisAttributes(worldVisAtt); 160 161 G4VisAttributes* targetVisAtt = new G4VisAtt 162 targetVisAtt->SetVisibility(true); 163 fLogicTarget->SetVisAttributes(targetVisAtt) 164 165 return fPhysiWorld; 166 } 167 168 //....oooOO0OOooo........oooOO0OOooo........oo 169 170 void DetectorConstruction::SetMaterial(const G 171 { 172 // Search the material by its name 173 G4Material* pttoMaterial = G4NistManager::In 174 175 if (pttoMaterial) { 176 fpWaterMaterial = pttoMaterial; 177 if (fLogicWorld) { 178 fLogicWorld->SetMaterial(fpWaterMaterial 179 } 180 G4RunManager::GetRunManager()->GeometryHas 181 } 182 } 183