Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-03 07:52:22

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 F04Materials.cc
0027 /// \brief Implementation of the F04Materials class
0028 
0029 #include "F04Materials.hh"
0030 
0031 #include "G4SystemOfUnits.hh"
0032 
0033 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0034 
0035 F04Materials::F04Materials()
0036 {
0037   fNistMan = G4NistManager::Instance();
0038 
0039   fNistMan->SetVerbose(2);
0040 
0041   CreateMaterials();
0042 }
0043 
0044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0045 
0046 F04Materials::~F04Materials()
0047 {
0048   delete fVacuum;
0049   delete fAir;
0050   delete fSci;
0051   delete fBeO;
0052 }
0053 
0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0055 
0056 F04Materials* F04Materials::fInstance = nullptr;
0057 
0058 F04Materials* F04Materials::GetInstance()
0059 {
0060   if (fInstance == nullptr) {
0061     fInstance = new F04Materials();
0062   }
0063   return fInstance;
0064 }
0065 
0066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0067 
0068 G4Material* F04Materials::GetMaterial(const G4String material)
0069 {
0070   G4Material* mat = fNistMan->FindOrBuildMaterial(material);
0071 
0072   if (!mat) mat = G4Material::GetMaterial(material);
0073   if (!mat) {
0074     G4cout << material << "Not Found, Please Retry" << G4endl;
0075   }
0076 
0077   return mat;
0078 }
0079 
0080 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0081 
0082 void F04Materials::CreateMaterials()
0083 {
0084   G4double density;
0085   std::vector<G4int> natoms;
0086   std::vector<G4double> fractionMass;
0087   std::vector<G4String> elements;
0088 
0089   // Materials Definitions
0090   // =====================
0091 
0092   // Define Vacuum
0093 
0094   fVacuum = fNistMan->FindOrBuildMaterial("G4_Galactic");
0095 
0096   // Define Air
0097 
0098   fAir = fNistMan->FindOrBuildMaterial("G4_AIR");
0099 
0100   // Define BeO
0101 
0102   fBeO = fNistMan->FindOrBuildMaterial("G4_BERYLLIUM_OXIDE");
0103 
0104   // Define Scintillator
0105 
0106   elements.push_back("C");
0107   natoms.push_back(9);
0108   elements.push_back("H");
0109   natoms.push_back(10);
0110 
0111   density = 1.032 * g / cm3;
0112   ;
0113 
0114   fSci = fNistMan->ConstructNewMaterial("Scintillator", elements, natoms, density);
0115 
0116   elements.clear();
0117   natoms.clear();
0118 
0119   G4cout << G4endl << "The materials defined are: " << G4endl << G4endl;
0120 
0121   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0122 }