Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:17:11

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 /// \file XraySPODetectorConstruction.cc
0027 /// \brief Implementation of the DetectorConstruction class
0028 //
0029 // Authors: P.Dondero (paolo.dondero@cern.ch), R.Stanzani (ronny.stanzani@cern.ch)
0030 //
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0033 
0034 
0035 #include "XraySPODetectorConstruction.hh"
0036 #include "XraySPODetectorMessenger.hh"
0037 #include "G4NistManager.hh"
0038 #include "G4Material.hh"
0039 #include "G4LogicalVolume.hh"
0040 
0041 #include "G4PhysicalVolumeStore.hh"
0042 
0043 #include "G4PhysicalConstants.hh"
0044 #include "G4SystemOfUnits.hh"
0045 #include <iomanip>
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 XraySPODetectorConstruction::XraySPODetectorConstruction()
0050 : fDetectorMessenger(nullptr)
0051 {
0052   // materials
0053   DefineMaterials();
0054   fReadFile = "";
0055 
0056   // create commands for interactive definition of the calorimeter
0057   fDetectorMessenger = new XraySPODetectorMessenger(this);
0058 }
0059 
0060 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0061 
0062 G4VPhysicalVolume* XraySPODetectorConstruction::Construct()
0063 {
0064   return ConstructDetector();
0065 }
0066 
0067 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0068 
0069 void XraySPODetectorConstruction::DefineMaterials()
0070 {
0071   G4NistManager* man = G4NistManager::Instance();
0072 
0073   man->FindOrBuildMaterial("G4_Al");
0074   man->FindOrBuildMaterial("G4_Si");
0075   man->FindOrBuildMaterial("G4_Fe");
0076   man->FindOrBuildMaterial("G4_Cu");
0077   man->FindOrBuildMaterial("G4_Ge");
0078   man->FindOrBuildMaterial("G4_Mo");
0079   man->FindOrBuildMaterial("G4_Ta");
0080   man->FindOrBuildMaterial("G4_W");
0081   man->FindOrBuildMaterial("G4_Au");
0082   man->FindOrBuildMaterial("G4_Pb");
0083   man->FindOrBuildMaterial("G4_PbWO4");
0084   man->FindOrBuildMaterial("G4_SODIUM_IODIDE");
0085   man->FindOrBuildMaterial("G4_AIR");
0086   man->FindOrBuildMaterial("G4_WATER");
0087 
0088   G4Element* H = man->FindOrBuildElement("H");
0089   G4Element* O = man->FindOrBuildElement("O");
0090 
0091   G4Material* H2O = new G4Material("Water", 1.000*g/cm3, 2);
0092   H2O->AddElement(H, 2);
0093   H2O->AddElement(O, 1);
0094   H2O->GetIonisation()->SetMeanExcitationEnergy(78.0*eV);
0095 
0096   G4double density = universe_mean_density;    //from PhysicalConstants.h
0097   G4double pressure = 3.e-18*pascal;
0098   G4double temperature = 2.73*kelvin;
0099   G4Material* Galactic =  new G4Material("Galactic", 1., 1.008*g/mole, density, kStateGas, temperature, pressure);
0100 
0101   fDefaultMaterial = Galactic;
0102 }
0103 
0104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0105 
0106 
0107 void XraySPODetectorConstruction::SetReadFile(G4String &input_geometry)
0108 {
0109   fReadFile = std::move(input_geometry);
0110 }
0111 
0112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0113 
0114 G4VPhysicalVolume* XraySPODetectorConstruction::ConstructDetector()
0115 {
0116   if (fReadFile == "")
0117   {
0118     G4cout << "No geometry selected!" << G4endl;
0119   }
0120   else
0121   {
0122     auto *InnerRegion = new G4Region("InnerRegion");
0123     G4cout << "Build geometry from GDML file: " << fReadFile << G4endl;
0124     G4VPhysicalVolume* fWorldPhysVol;
0125     fParser.Read(fReadFile);
0126     fWorldPhysVol = fParser.GetWorldVolume();
0127     fWorld_log =  fWorldPhysVol->GetLogicalVolume();
0128     G4int num_volumes = 9;
0129     auto *inner_volumes = new G4String[num_volumes];
0130     inner_volumes[0] = "cone_1"; inner_volumes[1] = "cone_2"; inner_volumes[2] = "cone_3"; inner_volumes[3] = "cone_4";
0131     inner_volumes[4] = "cone_5"; inner_volumes[5] = "cone_6"; inner_volumes[6] = "cone_7"; inner_volumes[7] = "cone_8";
0132 
0133     G4cout << "Adding volumes to the InnerRegion" << G4endl;
0134     // Add volumes to the InnerRegion
0135     for (G4int j = 0; j <= num_volumes; j++)
0136     {
0137       for (G4int i = 0; i < (G4int)fWorld_log->GetNoDaughters(); i++)
0138       {
0139         if (fWorld_log->GetDaughter(i)->GetLogicalVolume()->GetName() == inner_volumes[j])
0140         {
0141           InnerRegion->AddRootLogicalVolume(fWorld_log->GetDaughter(i)->GetLogicalVolume());
0142           G4cout << "Added: " << fWorld_log->GetDaughter(i)->GetLogicalVolume()->GetName() << G4endl;
0143         }
0144       }
0145     }
0146     fPhysiWorld = fWorldPhysVol;
0147   }
0148   return fPhysiWorld;
0149 }
0150 
0151 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0152