Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // This example is provided by the Geant4-DNA collaboration 27 // Any report or published results obtained using the Geant4-DNA software 28 // shall cite the following Geant4-DNA collaboration publication: 29 // Med. Phys. 37 (2010) 4692-4708 30 // J. Comput. Phys. 274 (2014) 841-882 31 // The Geant4-DNA web site is available at http://geant4-dna.org 32 // 33 // 34 /// \file DetectorConstruction.cc 35 /// \brief Implementation of the DetectorConstruction class 36 37 #include "DetectorConstruction.hh" 38 39 #include "DetectorMessenger.hh" 40 41 #include "G4ProductionCuts.hh" 42 #include "G4RunManager.hh" 43 #include "G4SystemOfUnits.hh" 44 45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 46 47 DetectorConstruction::DetectorConstruction() : G4VUserDetectorConstruction() 48 { 49 // create commands for interactive definition of the detector 50 fDetectorMessenger = new DetectorMessenger(this); 51 } 52 53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 54 55 DetectorConstruction::~DetectorConstruction() 56 { 57 delete fDetectorMessenger; 58 } 59 60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 61 62 G4VPhysicalVolume* DetectorConstruction::Construct() 63 64 { 65 DefineMaterials(); 66 return ConstructDetector(); 67 } 68 69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 70 71 void DetectorConstruction::DefineMaterials() 72 { 73 // Water is defined from NIST material database 74 G4NistManager* man = G4NistManager::Instance(); 75 G4Material* H2O = man->FindOrBuildMaterial("G4_WATER"); 76 77 // Default materials in setup. 78 fpWaterMaterial = H2O; 79 80 // needed variables 81 82 G4double z, a, density; 83 G4String name, symbol; 84 G4int nComponents, nAtoms; 85 86 a = 12.0107 * g / mole; 87 G4Element* elC = new G4Element(name = "Carbon", symbol = "C", z = 6., a); 88 89 a = 1.00794 * g / mole; 90 G4Element* elH = new G4Element(name = "Hydrogen", symbol = "H", z = 1., a); 91 92 a = 15.9994 * g / mole; 93 G4Element* elO = new G4Element(name = "Oxygen", symbol = "O", z = 8., a); 94 95 a = 14.0067 * g / mole; 96 G4Element* elN = new G4Element(name = "Nitrogen", symbol = "N", z = 7., a); 97 98 // Definition of Tetrahydrofurane (THF) 99 100 density = 1.346 * g / cm3; 101 102 fpTHFMaterial = new G4Material("THF", density, nComponents = 3); 103 fpTHFMaterial->AddElement(elC, nAtoms = 4); 104 fpTHFMaterial->AddElement(elH, nAtoms = 8); 105 fpTHFMaterial->AddElement(elO, nAtoms = 1); 106 107 // Definition of Nitrogen in nanodosimetry experiments 108 109 density = 0.34e-6 * g / cm3; 110 111 fpN2Material = new G4Material("N2", density, nComponents = 1); 112 fpN2Material->AddElement(elN, nAtoms = 2); 113 } 114 115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 116 117 G4VPhysicalVolume* DetectorConstruction::ConstructDetector() 118 { 119 G4double diameter; 120 G4double highz; 121 G4Material* targetMaterial; 122 G4Material* worldMaterial; 123 124 if (fGeomType == "dna") { 125 // nanometric geometry 126 fWorldSize = 20. * nm; 127 diameter = 2.3 * nm; 128 highz = 3.4 * nm; 129 targetMaterial = fpTHFMaterial; 130 worldMaterial = fpWaterMaterial; 131 } 132 else { 133 // macrometric geometry (experimental target in nanodosimetry) 134 fWorldSize = 2 * cm; 135 diameter = 1 * cm; 136 highz = 1 * cm; 137 ; 138 targetMaterial = fpN2Material; 139 worldMaterial = fpN2Material; 140 } 141 142 fpSolidWorld = new G4Box("World", // its name 143 fWorldSize / 2, fWorldSize / 2, fWorldSize / 2); // its size 144 145 fpLogicWorld = new G4LogicalVolume(fpSolidWorld, // its solid 146 worldMaterial, // its material 147 "World"); // its name 148 149 fpPhysiWorld = new G4PVPlacement(0, // no rotation 150 G4ThreeVector(), // at (0,0,0) 151 "World", // its name 152 fpLogicWorld, // its logical volume 153 0, // its mother volume 154 false, // no boolean operation 155 0); // copy number 156 157 G4Tubs* solidTarget = 158 new G4Tubs("Target", 0, diameter / 2., highz / 2., 0 * degree, 360 * degree); 159 160 G4LogicalVolume* logicTarget = new G4LogicalVolume(solidTarget, // its solid 161 targetMaterial, // its material 162 "Target"); // its name 163 164 new G4PVPlacement(0, // no rotation 165 G4ThreeVector(), // at (0,0,0) 166 "Target", // its name 167 logicTarget, // its logical volume 168 fpPhysiWorld, // its mother volume 169 false, // no boolean operation 170 0); // copy number 171 172 // Visualization attributes 173 G4VisAttributes* worldVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0)); 174 worldVisAtt->SetVisibility(true); 175 fpLogicWorld->SetVisAttributes(worldVisAtt); 176 177 G4VisAttributes* worldVisAtt1 = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0)); 178 worldVisAtt1->SetVisibility(true); 179 logicTarget->SetVisAttributes(worldVisAtt1); 180 181 return fpPhysiWorld; 182 } 183 184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 185 186 void DetectorConstruction::SetGeometry(const G4String& name) 187 { 188 fGeomType = name; 189 190 // tell RunManager about changes 191 G4RunManager::GetRunManager()->GeometryHasBeenModified(); 192 } 193