// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // /// \file DetectorConstruction.cc /// \brief Implementation of the DetectorConstruction class // // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... #include "DetectorConstruction.hh" #include "DetectorMessenger.hh" #include "G4Material.hh" #include "G4NistManager.hh" #include "G4Box.hh" #include "G4LogicalVolume.hh" #include "G4PVPlacement.hh" #include "G4GeometryManager.hh" #include "G4PhysicalVolumeStore.hh" #include "G4LogicalVolumeStore.hh" #include "G4SolidStore.hh" #include "G4RunManager.hh" #include "G4UnitsTable.hh" #include "G4SystemOfUnits.hh" #include "G4Orb.hh" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction::DetectorConstruction() :G4VUserDetectorConstruction(), fPBox(0), fLBox(0), fMaterial(0), fDetectorMessenger(0) { fBoxSize = 1*m; DefineMaterials(); SetMaterial("Ice"); fDetectorMessenger = new DetectorMessenger(this); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... DetectorConstruction::~DetectorConstruction() { delete fDetectorMessenger;} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4VPhysicalVolume* DetectorConstruction::Construct() { return ConstructVolumes(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::DefineMaterials() { // specific element name for thermal neutronHP // (see G4ParticleHPThermalScatteringNames.cc) G4int ncomponents, natoms; // pressurized water G4Element* H = new G4Element("TS_H_of_Water" ,"H" , 1., 1.0079*g/mole); G4Element* O = new G4Element("Oxygen" ,"O" , 8., 16.00*g/mole); G4Material* H2O = new G4Material("Ice", 0.920*g/cm3, ncomponents=2, kStateLiquid, 233*kelvin, 70*bar); H2O->AddElement(H, natoms=2); H2O->AddElement(O, natoms=1); H2O->GetIonisation()->SetMeanExcitationEnergy(78.0*eV); // heavy water G4Isotope* H2 = new G4Isotope("H2",1,2); G4Element* D = new G4Element("TS_D_of_Heavy_Water", "D", 1); D->AddIsotope(H2, 100*perCent); G4Material* D2O = new G4Material("HeavyWater", 1.11*g/cm3, ncomponents=2, kStateLiquid, 293.15*kelvin, 1*atmosphere); D2O->AddElement(D, natoms=2); D2O->AddElement(O, natoms=1); // graphite G4Isotope* C12 = new G4Isotope("C12", 6, 12); G4Element* C = new G4Element("TS_C_of_Graphite","C", ncomponents=1); C->AddIsotope(C12, 100.*perCent); G4Material* graphite = new G4Material("graphite", 2.27*g/cm3, ncomponents=1, kStateSolid, 293*kelvin, 1*atmosphere); graphite->AddElement(C, natoms=1); ///G4cout << *(G4Material::GetMaterialTable()) << G4endl; std::vector energies = {1.25229244*eV, 1.27721959*eV, 1.30315925*eV, 1.33943009*eV, 1.39441187*eV, 1.42538787*eV, 1.48781745*eV, 1.5902439 *eV, 1.79822064*eV, 1.98351325*eV, 2.13770492*eV, 2.21137856*eV, 2.29943117*eV, 2.38489676*eV, 2.47696078*eV, 2.5764181 *eV, 2.62323167*eV, 2.68419655*eV, 2.81504178*eV, 2.94420976*eV, 3.10237913*eV, 3.24170008*eV, 3.43449448*eV, 3.62872531*eV, 3.95151515*eV}; /* std::vector rinds = {1.31, 1.31, 1.31, 1.31, 1.31, 1.31, 1.31, 1.31, 1.31, 1.31, 1.31, */ /* 1.31, 1.31, 1.31, 1.31, 1.31, 1.31, 1.31, 1.31, 1.31, 1.31, 1.31, */ /* 1.31, 1.31, 1.31}; */ std::vector rinds = {1.30715, 1.30712, 1.30721, 1.30796, 1.30919, 1.30951, 1.3094, 1.31046, 1.31167, 1.31407, 1.31416, 1.31611, 1.31645, 1.31623, 1.31782, 1.31873, 1.31869, 1.31926, 1.32073, 1.32091, 1.32332, 1.32352, 1.33049, 1.32666, 1.33159}; std::vector abslengths = { 1.0/5.86909891e-02*1e3, 1.0/8.37253830e-02*1e3, 1.0/1.29249411e-01*1e3, 1.0/1.54373030e-01*1e3 , 1.0/1.88055359e-01*1e3, 1.0/2.63026799e-01*1e3, 1.0/4.66199098e-01*1e3, 1.0/6.14570102e-01*1e3 , 1.0/2.39883292e+00*1e3, 1.0/5.94683261e+00*1e3, 1.0/1.16336042e+01*1e3, 1.0/2.18776162e+01*1e3 , 1.0/3.00014923e+01*1e3, 1.0/4.36515832e+01*1e3, 1.0/5.53168120e+01*1e3, 1.0/7.00993976e+01*1e3 , 1.0/7.58577575e+01*1e3, 1.0/8.20891416e+01*1e3, 1.0/7.73697919e+01*1e3, 1.0/7.58577575e+01*1e3 , 1.0/8.88324067e+01*1e3, 1.0/8.37253830e+01*1e3, 1.0/7.89119649e+01*1e3, 1.0/7.43752728e+01*1e3 ,1.0/6.47781546e+01*1e3}; G4cout << "Setting Materials!" << G4endl; G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); MPT->AddProperty("RINDEX", energies, rinds); MPT->AddProperty("ABSLENGTH",energies, abslengths); H2O->SetMaterialPropertiesTable(MPT); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4Material* DetectorConstruction::MaterialWithSingleIsotope( G4String name, G4String symbol, G4double density, G4int Z, G4int A) { // define a material from an isotope // G4int ncomponents; G4double abundance, massfraction; G4Isotope* isotope = new G4Isotope(symbol, Z, A); G4Element* element = new G4Element(name, symbol, ncomponents=1); element->AddIsotope(isotope, abundance= 100.*perCent); G4Material* material = new G4Material(name, density, ncomponents=1); material->AddElement(element, massfraction=100.*perCent); return material; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4VPhysicalVolume* DetectorConstruction::ConstructVolumes() { // Cleanup old geometry G4GeometryManager::GetInstance()->OpenGeometry(); G4PhysicalVolumeStore::GetInstance()->Clean(); G4LogicalVolumeStore::GetInstance()->Clean(); G4SolidStore::GetInstance()->Clean(); /* G4Box* */ /* sBox = new G4Box("Container", //its name */ /* fBoxSize/2,fBoxSize/2,fBoxSize/2); //its dimensions */ G4Orb* sBox = new G4Orb("Container", //its name fBoxSize/2); //its dimensions fLBox = new G4LogicalVolume(sBox, //its shape fMaterial, //its material fMaterial->GetName()); //its name fPBox = new G4PVPlacement(0, //no rotation G4ThreeVector(), //at (0,0,0) fLBox, //its logical volume fMaterial->GetName(), //its name 0, //its mother volume false, //no boolean operation 0); //copy number PrintParameters(); //always return the root volume // return fPBox; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::PrintParameters() { G4cout << "\n The Box is " << G4BestUnit(fBoxSize,"Length") << " of " << fMaterial->GetName() << "\n \n" << fMaterial << G4endl; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetMaterial(G4String materialChoice) { // search the material by its name G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); if (pttoMaterial) { if(fMaterial != pttoMaterial) { fMaterial = pttoMaterial; if(fLBox) { fLBox->SetMaterial(pttoMaterial); } G4RunManager::GetRunManager()->PhysicsHasBeenModified(); } } else { G4cout << "\n--> warning from DetectorConstruction::SetMaterial : " << materialChoice << " not found" << G4endl; } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void DetectorConstruction::SetSize(G4double value) { fBoxSize = value; G4RunManager::GetRunManager()->ReinitializeGeometry(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......