|
|
|||
File indexing completed on 2025-10-29 08:01:02
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 // 0034 // The Geant4-DNA web site is available at http://geant4-dna.org 0035 // 0036 /// \file DetectorConstruction.cc 0037 /// \brief Implementation of the DetectorConstruction class 0038 0039 #include "DetectorConstruction.hh" 0040 #include "DetectorMessenger.hh" 0041 #include "PhysicsList.hh" 0042 0043 #include "G4LogicalVolumeStore.hh" 0044 #include "G4NistManager.hh" 0045 #include "G4RunManager.hh" 0046 #include "G4SystemOfUnits.hh" 0047 #include "G4UserLimits.hh" 0048 0049 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 0050 0051 DetectorConstruction::DetectorConstruction(PhysicsList* ptr) 0052 : G4VUserDetectorConstruction(), 0053 fpWaterMaterial(nullptr), 0054 fLogicWorld(nullptr), 0055 fPhysiWorld(nullptr) 0056 { 0057 // Create commands for interactive definition of the detector 0058 fDetectorMessenger = new DetectorMessenger(this, ptr); 0059 0060 // Default values 0061 // 0062 // World size 0063 fWorldSize = 100 *um; 0064 // and material 0065 G4NistManager* man = G4NistManager::Instance(); 0066 G4Material* H2O = man->FindOrBuildMaterial("G4_WATER"); 0067 fpWaterMaterial = H2O; 0068 } 0069 0070 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 0071 0072 DetectorConstruction::~DetectorConstruction() 0073 { 0074 delete fDetectorMessenger; 0075 } 0076 0077 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 0078 0079 void DetectorConstruction::DefineMaterials() 0080 { 0081 // Water is defined from NIST material database 0082 G4NistManager* man = G4NistManager::Instance(); 0083 0084 G4Material* H2O = man->FindOrBuildMaterial("G4_WATER"); 0085 0086 /* 0087 If one wishes to test other density value for water material, 0088 one should use instead: 0089 G4Material * H2O = man->BuildMaterialWithNewDensity("G4_WATER_MODIFIED", 0090 "G4_WATER",1.100*g/cm3); 0091 0092 Note: any string for "G4_WATER_MODIFIED" parameter is accepted 0093 and "G4_WATER" parameter should not be changed 0094 Both materials are created and can be selected from dna.mac 0095 */ 0096 fpWaterMaterial = H2O; 0097 0098 // G4cout << "-> Density of water material (g/cm3)=" 0099 // << fpWaterMaterial->GetDensity()/(g/cm/cm/cm) << G4endl; 0100 0101 G4cout << *(G4Material::GetMaterialTable()) << G4endl; 0102 } 0103 0104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0105 0106 G4Material* 0107 DetectorConstruction::MaterialWithDensity(G4String name, G4double density) 0108 { 0109 // Water is defined from NIST material database 0110 G4NistManager* man = G4NistManager::Instance(); 0111 0112 G4Material * material = man->BuildMaterialWithNewDensity(name, 0113 "G4_WATER", density); 0114 0115 G4cout << "-> Density of water_modified material (g/cm3)=" 0116 << material->GetDensity()/(g/cm/cm/cm) << G4endl; 0117 0118 return material; 0119 } 0120 0121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 0122 0123 G4VPhysicalVolume* DetectorConstruction::Construct() 0124 { 0125 if (fPhysiWorld) { 0126 return fPhysiWorld; 0127 } 0128 0129 // World volume 0130 G4double worldSizeX = fWorldSize; 0131 G4double worldSizeY = worldSizeX; 0132 G4double worldSizeZ = worldSizeX; 0133 0134 G4Box* solidWorld = new G4Box("World", // its name 0135 worldSizeX / 2, worldSizeY / 2, worldSizeZ / 2); 0136 // its size 0137 0138 fLogicWorld = new G4LogicalVolume(solidWorld, // its solid 0139 fpWaterMaterial, // its material 0140 "World"); // its name 0141 0142 fPhysiWorld = new G4PVPlacement(0, // no rotation 0143 G4ThreeVector(), // at (0,0,0) 0144 "World", // its name 0145 fLogicWorld, // its logical volume 0146 0, // its mother volume 0147 false, // no boolean operation 0148 0); // copy number 0149 0150 // Visualization attributes - white 0151 G4VisAttributes* worldVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0)); 0152 worldVisAtt->SetVisibility(true); 0153 fLogicWorld->SetVisAttributes(worldVisAtt); 0154 0155 G4VisAttributes* worldVisAtt1 = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0)); 0156 worldVisAtt1->SetVisibility(true); 0157 0158 // Shows how to introduce a 20 eV tracking cut 0159 // logicWorld->SetUserLimits(new G4UserLimits(DBL_MAX,DBL_MAX,DBL_MAX,20*eV)); 0160 0161 return fPhysiWorld; 0162 } 0163 0164 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0165 0166 void DetectorConstruction::SetMaterial(const G4String& materialChoice) 0167 { 0168 // Search the material by its name 0169 G4Material* pttoMaterial = 0170 G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); 0171 0172 if (pttoMaterial) { 0173 fpWaterMaterial = pttoMaterial; 0174 if (fLogicWorld) { 0175 fLogicWorld->SetMaterial(fpWaterMaterial); 0176 } 0177 G4RunManager::GetRunManager()->GeometryHasBeenModified(); 0178 } 0179 } 0180 0181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0182 0183 void DetectorConstruction::SetSize(G4double value) 0184 { 0185 fWorldSize = value; 0186 G4RunManager::GetRunManager()->ReinitializeGeometry(); 0187 }
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|