![]() |
|
|||
File indexing completed on 2025-02-23 09:21:56
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // This example is provided by the Geant4-DNA collaboration 0027 // Any report or published results obtained using the Geant4-DNA software 0028 // shall cite the following Geant4-DNA collaboration publications: 0029 // Med. Phys. 45, (2018) e722-e739 0030 // Phys. Med. 31 (2015) 861-874 0031 // Med. Phys. 37 (2010) 4692-4708 0032 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 157–178 0033 // The Geant4-DNA web site is available at http://geant4-dna.org 0034 // 0035 // 0036 /// \file DetectorConstruction.cc 0037 /// \brief Implementation of the DetectorConstruction class 0038 0039 #include "DetectorConstruction.hh" 0040 0041 #include "DetectorMessenger.hh" 0042 #include "PhysicsList.hh" 0043 0044 #include "G4LogicalVolume.hh" 0045 #include "G4RunManager.hh" 0046 #include "G4SystemOfUnits.hh" 0047 0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 0049 0050 DetectorConstruction::DetectorConstruction(PhysicsList* ptr) 0051 : G4VUserDetectorConstruction(), 0052 fpWaterMaterial(nullptr), 0053 fLogicWorld(nullptr), 0054 fPhysiWorld(nullptr) 0055 { 0056 fDetectorMessenger = new DetectorMessenger(this, ptr); 0057 } 0058 0059 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 0060 0061 DetectorConstruction::~DetectorConstruction() 0062 { 0063 delete fDetectorMessenger; 0064 } 0065 0066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 0067 0068 void DetectorConstruction::DefineMaterials() 0069 { 0070 // Water is defined from NIST material database 0071 G4NistManager* man = G4NistManager::Instance(); 0072 0073 G4Material* H2O = man->FindOrBuildMaterial("G4_WATER"); 0074 0075 /* 0076 If one wishes to test other density value for water material, 0077 one should use instead: 0078 G4Material * H2O = man->BuildMaterialWithNewDensity("G4_WATER_MODIFIED", 0079 "G4_WATER",1.100*g/cm3); 0080 0081 Note: any string for "G4_WATER_MODIFIED" parameter is accepted 0082 and "G4_WATER" parameter should not be changed 0083 Both materials are created and can be selected from dna.mac 0084 */ 0085 fpWaterMaterial = H2O; 0086 0087 // G4cout << "-> Density of water material (g/cm3)=" 0088 // << fpWaterMaterial->GetDensity()/(g/cm/cm/cm) << G4endl; 0089 0090 G4cout << *(G4Material::GetMaterialTable()) << G4endl; 0091 } 0092 0093 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 0094 0095 G4VPhysicalVolume* DetectorConstruction::Construct() 0096 { 0097 if (fPhysiWorld) { 0098 return fPhysiWorld; 0099 } 0100 DefineMaterials(); 0101 0102 // World volume 0103 0104 G4double worldSizeX = 10 * micrometer; 0105 G4double worldSizeY = worldSizeX; 0106 G4double worldSizeZ = worldSizeX; 0107 0108 G4Box* solidWorld = new G4Box("World", // its name 0109 worldSizeX / 2, worldSizeY / 2, worldSizeZ / 2); // its size 0110 0111 fLogicWorld = new G4LogicalVolume(solidWorld, // its solid 0112 fpWaterMaterial, // its material 0113 "World"); // its name 0114 0115 fPhysiWorld = new G4PVPlacement(0, // no rotation 0116 G4ThreeVector(), // at (0,0,0) 0117 "World", // its name 0118 fLogicWorld, // its logical volume 0119 0, // its mother volume 0120 false, // no boolean operation 0121 0); // copy number 0122 0123 // Target volume 0124 0125 G4Box* solidTarget = new G4Box("volumeTarget", // its name 0126 worldSizeX / 10, worldSizeY / 2, worldSizeZ / 2); // its size 0127 0128 fLogicTarget = new G4LogicalVolume(solidTarget, // its solid 0129 fpWaterMaterial, // its material 0130 "volumeTarget"); // its name 0131 0132 fPhysiTarget = new G4PVPlacement(0, // no rotation 0133 G4ThreeVector(), // at (0,0,0) 0134 "volumeTarget", // its name 0135 fLogicTarget, // its logical volume 0136 fPhysiWorld, // its mother volume 0137 false, // no boolean operation 0138 0); // copy number 0139 0140 // Target region 0141 0142 G4Region* targetRegion = new G4Region("regionTarget"); 0143 0144 // Cuts needed to allow combination of Physics 0145 // Default EM settings for fast simulation for e+, e-, gammas 0146 // 1 um proton cut avoids creation of very slow recoil ions 0147 G4ProductionCuts* cuts = new G4ProductionCuts(); 0148 cuts->SetProductionCut(0.7 * mm, "gamma"); 0149 cuts->SetProductionCut(0.7 * mm, "e-"); 0150 cuts->SetProductionCut(0.7 * mm, "e+"); 0151 cuts->SetProductionCut(1 * micrometer, "proton"); 0152 targetRegion->SetProductionCuts(cuts); 0153 0154 targetRegion->AddRootLogicalVolume(fLogicTarget); 0155 0156 // Visualization attributes - white 0157 G4VisAttributes* worldVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0)); 0158 worldVisAtt->SetVisibility(true); 0159 fLogicWorld->SetVisAttributes(worldVisAtt); 0160 0161 G4VisAttributes* targetVisAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0)); 0162 targetVisAtt->SetVisibility(true); 0163 fLogicTarget->SetVisAttributes(targetVisAtt); 0164 0165 return fPhysiWorld; 0166 } 0167 0168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0169 0170 void DetectorConstruction::SetMaterial(const G4String& materialChoice) 0171 { 0172 // Search the material by its name 0173 G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); 0174 0175 if (pttoMaterial) { 0176 fpWaterMaterial = pttoMaterial; 0177 if (fLogicWorld) { 0178 fLogicWorld->SetMaterial(fpWaterMaterial); 0179 } 0180 G4RunManager::GetRunManager()->GeometryHasBeenModified(); 0181 } 0182 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |