Warning, file /geant4/examples/extended/field/field04/src/F04Materials.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #include "F04Materials.hh"
0032
0033 #include "G4SystemOfUnits.hh"
0034
0035
0036
0037 F04Materials::F04Materials()
0038 {
0039 fNistMan = G4NistManager::Instance();
0040
0041 fNistMan->SetVerbose(2);
0042
0043 CreateMaterials();
0044 }
0045
0046
0047
0048 F04Materials::~F04Materials()
0049 {
0050 delete fVacuum;
0051 delete fAir;
0052 delete fSci;
0053 delete fBeO;
0054 }
0055
0056
0057
0058 F04Materials* F04Materials::fInstance = nullptr;
0059
0060 F04Materials* F04Materials::GetInstance()
0061 {
0062 if (fInstance == nullptr) {
0063 fInstance = new F04Materials();
0064 }
0065 return fInstance;
0066 }
0067
0068
0069
0070 G4Material* F04Materials::GetMaterial(const G4String material)
0071 {
0072 G4Material* mat = fNistMan->FindOrBuildMaterial(material);
0073
0074 if (!mat) mat = G4Material::GetMaterial(material);
0075 if (!mat) {
0076 G4cout << material << "Not Found, Please Retry" << G4endl;
0077 }
0078
0079 return mat;
0080 }
0081
0082
0083
0084 void F04Materials::CreateMaterials()
0085 {
0086 G4double density;
0087 std::vector<G4int> natoms;
0088 std::vector<G4double> fractionMass;
0089 std::vector<G4String> elements;
0090
0091
0092
0093
0094
0095
0096 fVacuum = fNistMan->FindOrBuildMaterial("G4_Galactic");
0097
0098
0099
0100 fAir = fNistMan->FindOrBuildMaterial("G4_AIR");
0101
0102
0103
0104 fBeO = fNistMan->FindOrBuildMaterial("G4_BERYLLIUM_OXIDE");
0105
0106
0107
0108 elements.push_back("C");
0109 natoms.push_back(9);
0110 elements.push_back("H");
0111 natoms.push_back(10);
0112
0113 density = 1.032 * g / cm3;
0114 ;
0115
0116 fSci = fNistMan->ConstructNewMaterial("Scintillator", elements, natoms, density);
0117
0118 elements.clear();
0119 natoms.clear();
0120
0121 G4cout << G4endl << "The materials defined are: " << G4endl << G4endl;
0122
0123 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0124 }