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 publication: 29 // Med. Phys. 37 (2010) 4692-4708 29 // Med. Phys. 37 (2010) 4692-4708 30 // J. Comput. Phys. 274 (2014) 841-882 30 // J. Comput. Phys. 274 (2014) 841-882 31 // The Geant4-DNA web site is available at htt 31 // The Geant4-DNA web site is available at http://geant4-dna.org 32 // 32 // 33 // 33 // 34 /// \file DetectorConstruction.cc 34 /// \file DetectorConstruction.cc 35 /// \brief Implementation of the DetectorConst 35 /// \brief Implementation of the DetectorConstruction class 36 36 37 #include "DetectorConstruction.hh" 37 #include "DetectorConstruction.hh" 38 << 39 #include "DetectorMessenger.hh" 38 #include "DetectorMessenger.hh" 40 << 39 #include "G4SystemOfUnits.hh" 41 #include "G4ProductionCuts.hh" 40 #include "G4ProductionCuts.hh" 42 #include "G4RunManager.hh" 41 #include "G4RunManager.hh" 43 #include "G4SystemOfUnits.hh" << 44 42 45 //....oooOO0OOooo........oooOO0OOooo........oo 43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 46 44 47 DetectorConstruction::DetectorConstruction() : << 45 DetectorConstruction::DetectorConstruction() >> 46 : G4VUserDetectorConstruction() 48 { 47 { 49 // create commands for interactive definitio << 48 // create commands for interactive definition of the detector 50 fDetectorMessenger = new DetectorMessenger(t << 49 fDetectorMessenger = new DetectorMessenger(this); 51 } 50 } 52 51 >> 52 53 //....oooOO0OOooo........oooOO0OOooo........oo 53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 54 54 55 DetectorConstruction::~DetectorConstruction() 55 DetectorConstruction::~DetectorConstruction() 56 { 56 { 57 delete fDetectorMessenger; << 57 delete fDetectorMessenger; 58 } 58 } 59 59 60 //....oooOO0OOooo........oooOO0OOooo........oo 60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 61 61 62 G4VPhysicalVolume* DetectorConstruction::Const 62 G4VPhysicalVolume* DetectorConstruction::Construct() 63 63 64 { 64 { 65 DefineMaterials(); << 65 DefineMaterials(); 66 return ConstructDetector(); << 66 return ConstructDetector(); 67 } 67 } 68 68 69 //....oooOO0OOooo........oooOO0OOooo........oo 69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 70 70 71 void DetectorConstruction::DefineMaterials() 71 void DetectorConstruction::DefineMaterials() 72 { << 72 { 73 // Water is defined from NIST material datab << 73 // Water is defined from NIST material database 74 G4NistManager* man = G4NistManager::Instance << 74 G4NistManager * man = G4NistManager::Instance(); 75 G4Material* H2O = man->FindOrBuildMaterial(" << 75 G4Material * H2O = man->FindOrBuildMaterial("G4_WATER"); >> 76 >> 77 // Default materials in setup. >> 78 fpWaterMaterial = H2O; 76 79 77 // Default materials in setup. << 80 // needed variables 78 fpWaterMaterial = H2O; << 79 81 80 // needed variables << 82 G4double z, a, density; >> 83 G4String name, symbol; >> 84 G4int nComponents, nAtoms; 81 85 82 G4double z, a, density; << 83 G4String name, symbol; << 84 G4int nComponents, nAtoms; << 85 86 86 a = 12.0107 * g / mole; << 87 a = 12.0107*g/mole; 87 G4Element* elC = new G4Element(name = "Carbo << 88 G4Element* elC = new G4Element(name="Carbon", symbol="C", z=6., a); 88 89 89 a = 1.00794 * g / mole; << 90 a = 1.00794*g/mole; 90 G4Element* elH = new G4Element(name = "Hydro << 91 G4Element* elH = new G4Element(name="Hydrogen",symbol="H" , z=1., a); 91 92 92 a = 15.9994 * g / mole; << 93 a = 15.9994*g/mole; 93 G4Element* elO = new G4Element(name = "Oxyge << 94 G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a); 94 95 95 a = 14.0067 * g / mole; << 96 a = 14.0067*g/mole; 96 G4Element* elN = new G4Element(name = "Nitro << 97 G4Element* elN = new G4Element(name="Nitrogen" ,symbol="N" , z= 7., a); 97 98 98 // Definition of Tetrahydrofurane (THF) << 99 // Definition of Tetrahydrofurane (THF) 99 100 100 density = 1.346 * g / cm3; << 101 density=1.346*g/cm3; 101 102 102 fpTHFMaterial = new G4Material("THF", densit << 103 fpTHFMaterial = new G4Material("THF", density, nComponents=3); 103 fpTHFMaterial->AddElement(elC, nAtoms = 4); << 104 fpTHFMaterial->AddElement(elC, nAtoms=4); 104 fpTHFMaterial->AddElement(elH, nAtoms = 8); << 105 fpTHFMaterial->AddElement(elH, nAtoms=8); 105 fpTHFMaterial->AddElement(elO, nAtoms = 1); << 106 fpTHFMaterial->AddElement(elO, nAtoms=1); 106 107 107 // Definition of Nitrogen in nanodosimetry e << 108 // Definition of Nitrogen in nanodosimetry experiments 108 109 109 density = 0.34e-6 * g / cm3; << 110 density = 0.34e-6*g/cm3; 110 111 111 fpN2Material = new G4Material("N2", density, << 112 fpN2Material = new G4Material("N2", density, nComponents=1); 112 fpN2Material->AddElement(elN, nAtoms = 2); << 113 fpN2Material->AddElement(elN, nAtoms=2); 113 } 114 } 114 115 115 //....oooOO0OOooo........oooOO0OOooo........oo 116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 116 117 117 G4VPhysicalVolume* DetectorConstruction::Const 118 G4VPhysicalVolume* DetectorConstruction::ConstructDetector() 118 { 119 { 119 G4double diameter; << 120 G4double diameter; 120 G4double highz; << 121 G4double highz; 121 G4Material* targetMaterial; << 122 G4Material* targetMaterial; 122 G4Material* worldMaterial; << 123 G4Material* worldMaterial; 123 << 124 124 if (fGeomType == "dna") { << 125 if (fGeomType == "dna"){ 125 // nanometric geometry << 126 // nanometric geometry 126 fWorldSize = 20. * nm; << 127 fWorldSize = 20.*nm; 127 diameter = 2.3 * nm; << 128 diameter = 2.3*nm; 128 highz = 3.4 * nm; << 129 highz = 3.4*nm; 129 targetMaterial = fpTHFMaterial; << 130 targetMaterial = fpTHFMaterial; 130 worldMaterial = fpWaterMaterial; << 131 worldMaterial = fpWaterMaterial; 131 } << 132 } else { 132 else { << 133 // macrometric geometry (experimental target in nanodosimetry) 133 // macrometric geometry (experimental targ << 134 fWorldSize = 2*cm; 134 fWorldSize = 2 * cm; << 135 diameter = 1*cm; 135 diameter = 1 * cm; << 136 highz = 1*cm;; 136 highz = 1 * cm; << 137 targetMaterial = fpN2Material; 137 ; << 138 worldMaterial = fpN2Material; 138 targetMaterial = fpN2Material; << 139 } 139 worldMaterial = fpN2Material; << 140 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 = new G4Tubs("Target",0, diameter/2., highz/2., 0*degree, 360*degree); >> 158 >> 159 G4LogicalVolume* logicTarget = new G4LogicalVolume(solidTarget, //its solid >> 160 targetMaterial, //its material >> 161 "Target"); //its name >> 162 >> 163 new G4PVPlacement(0, //no rotation >> 164 G4ThreeVector(), //at (0,0,0) >> 165 "Target", //its name >> 166 logicTarget, //its logical volume >> 167 fpPhysiWorld, //its mother volume >> 168 false, //no boolean operation >> 169 0); //copy number >> 170 >> 171 // Visualization attributes >> 172 G4VisAttributes* worldVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0)); >> 173 worldVisAtt->SetVisibility(true); >> 174 fpLogicWorld->SetVisAttributes(worldVisAtt); >> 175 >> 176 G4VisAttributes* worldVisAtt1 = new G4VisAttributes(G4Colour(1.0,0.0,0.0)); >> 177 worldVisAtt1->SetVisibility(true); >> 178 logicTarget->SetVisAttributes(worldVisAtt1); >> 179 >> 180 return fpPhysiWorld; >> 181 } >> 182 >> 183 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 184 >> 185 void DetectorConstruction::SetGeometry(const G4String& name) >> 186 { >> 187 fGeomType = name; 141 188 142 fpSolidWorld = new G4Box("World", // its na << 189 // tell RunManager about changes 143 fWorldSize / 2, fWo << 190 G4RunManager::GetRunManager()->GeometryHasBeenModified(); 144 191 145 fpLogicWorld = new G4LogicalVolume(fpSolidWo << 192 } 146 worldMate << 147 "World"); << 148 << 149 fpPhysiWorld = new G4PVPlacement(0, // no r << 150 G4ThreeVect << 151 "World", / << 152 fpLogicWorl << 153 0, // its << 154 false, // << 155 0); // cop << 156 << 157 G4Tubs* solidTarget = << 158 new G4Tubs("Target", 0, diameter / 2., hig << 159 << 160 G4LogicalVolume* logicTarget = new G4Logical << 161 << 162 << 163 << 164 new G4PVPlacement(0, // no rotation << 165 G4ThreeVector(), // at (0 << 166 "Target", // its name << 167 logicTarget, // its logic << 168 fpPhysiWorld, // its moth << 169 false, // no boolean oper << 170 0); // copy number << 171 << 172 // Visualization attributes << 173 G4VisAttributes* worldVisAtt = new G4VisAttr << 174 worldVisAtt->SetVisibility(true); << 175 fpLogicWorld->SetVisAttributes(worldVisAtt); << 176 << 177 G4VisAttributes* worldVisAtt1 = new G4VisAtt << 178 worldVisAtt1->SetVisibility(true); << 179 logicTarget->SetVisAttributes(worldVisAtt1); << 180 << 181 return fpPhysiWorld; << 182 } << 183 << 184 //....oooOO0OOooo........oooOO0OOooo........oo << 185 << 186 void DetectorConstruction::SetGeometry(const G << 187 { << 188 fGeomType = name; << 189 << 190 // tell RunManager about changes << 191 G4RunManager::GetRunManager()->GeometryHasBe << 192 } << 193 193