Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 /// \file persistency/gdml/G03/src/G03Detector 27 /// \brief Implementation of the G03DetectorCo 28 // 29 // 30 // 31 // Class G03DetectorConstruction implementatio 32 // 33 // ------------------------------------------- 34 35 #include "G03DetectorConstruction.hh" 36 37 // Geant4 includes 38 // 39 #include "G4Material.hh" 40 #include "G4VPhysicalVolume.hh" 41 #include "globals.hh" 42 43 // Messenger 44 // 45 #include "G03DetectorMessenger.hh" 46 47 // Color extension include for reading 48 // 49 #include "G03ColorReader.hh" 50 51 // Color extension include for writing 52 // 53 #include "G03ColorWriter.hh" 54 55 #include "G4SystemOfUnits.hh" 56 57 //....oooOO0OOooo........oooOO0OOooo........oo 58 59 G03DetectorConstruction::G03DetectorConstructi 60 : G4VUserDetectorConstruction(), 61 fAir(0), 62 fAluminum(0), 63 fPb(0), 64 fXenon(0), 65 fReader(0), 66 fWriter(0), 67 fParser(0), 68 fDetectorMessenger(0) 69 { 70 fReadFile = "color_extension.gdml"; 71 fWriteFile = "color_extension_test.gdml"; 72 fWritingChoice = 1; 73 74 fDetectorMessenger = new G03DetectorMessenge 75 76 fReader = new G03ColorReader; 77 fWriter = new G03ColorWriter; 78 fParser = new G4GDMLParser(fReader, fWriter) 79 } 80 81 //....oooOO0OOooo........oooOO0OOooo........oo 82 83 G03DetectorConstruction::~G03DetectorConstruct 84 { 85 delete fDetectorMessenger; 86 delete fReader; 87 delete fWriter; 88 delete fParser; 89 } 90 91 //....oooOO0OOooo........oooOO0OOooo........oo 92 93 G4VPhysicalVolume* G03DetectorConstruction::Co 94 { 95 // Reading of Geometry from GDML 96 97 G4VPhysicalVolume* fWorldPhysVol; 98 99 fParser->Read(fReadFile, false); 100 // 101 // 2nd Boolean argument "Validate" set to fa 102 // Disabling Schema validation for reading e 103 104 // Prints the material information 105 // 106 G4cout << *(G4Material::GetMaterialTable()) 107 108 // Giving World Physical Volume from GDML Pa 109 // 110 fWorldPhysVol = fParser->GetWorldVolume(); 111 112 if (fWritingChoice != 0) { 113 fParser->Write(fWriteFile, fWorldPhysVol, 114 } 115 116 return fWorldPhysVol; 117 } 118 119 //....oooOO0OOooo........oooOO0OOooo........oo 120 121 void G03DetectorConstruction::ListOfMaterials( 122 { 123 G4double a; // atomic mass 124 G4double z; // atomic number 125 G4double density, temperature, pressure; 126 G4double fractionmass; 127 G4String name, symbol; 128 G4int ncomponents; 129 130 // Elements needed for the materials 131 132 a = 14.01 * g / mole; 133 G4Element* elN = new G4Element(name = "Nitro 134 135 a = 16.00 * g / mole; 136 G4Element* elO = new G4Element(name = "Oxyge 137 138 a = 26.98 * g / mole; 139 G4Element* elAl = new G4Element(name = "Alum 140 141 // Print the Element information 142 // 143 G4cout << *(G4Element::GetElementTable()) << 144 145 // Air 146 // 147 density = 1.29 * mg / cm3; 148 fAir = new G4Material(name = "Air", density, 149 fAir->AddElement(elN, fractionmass = 0.7); 150 fAir->AddElement(elO, fractionmass = 0.3); 151 152 // Aluminum 153 // 154 density = 2.70 * g / cm3; 155 fAluminum = new G4Material(name = "Aluminum" 156 fAluminum->AddElement(elAl, fractionmass = 1 157 158 // Lead 159 // 160 fPb = new G4Material("Lead", z = 82., a = 20 161 162 // Xenon gas 163 // 164 fXenon = new G4Material("XenonGas", z = 54., 165 kStateGas, temperatu 166 167 // Prints the material information 168 // 169 G4cout << *(G4Material::GetMaterialTable()) 170 } 171 172 //....oooOO0OOooo........oooOO0OOooo........oo 173 174 void G03DetectorConstruction::SetReadFile(cons 175 { 176 fReadFile = fname; 177 fWritingChoice = 0; 178 } 179 180 //....oooOO0OOooo........oooOO0OOooo........oo 181 182 void G03DetectorConstruction::SetWriteFile(con 183 { 184 fWriteFile = fname; 185 fWritingChoice = 1; 186 } 187