Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 /// \file persistency/gdml/G03/src/G03DetectorConstruction.cc 27 /// \brief Implementation of the G03DetectorConstruction class 28 // 29 // 30 // 31 // Class G03DetectorConstruction implementation 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........oooOO0OOooo........oooOO0OOooo...... 58 59 G03DetectorConstruction::G03DetectorConstruction() 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 G03DetectorMessenger(this); 75 76 fReader = new G03ColorReader; 77 fWriter = new G03ColorWriter; 78 fParser = new G4GDMLParser(fReader, fWriter); 79 } 80 81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 82 83 G03DetectorConstruction::~G03DetectorConstruction() 84 { 85 delete fDetectorMessenger; 86 delete fReader; 87 delete fWriter; 88 delete fParser; 89 } 90 91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 92 93 G4VPhysicalVolume* G03DetectorConstruction::Construct() 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 false. 102 // Disabling Schema validation for reading extended GDML file. 103 104 // Prints the material information 105 // 106 G4cout << *(G4Material::GetMaterialTable()) << G4endl; 107 108 // Giving World Physical Volume from GDML Parser 109 // 110 fWorldPhysVol = fParser->GetWorldVolume(); 111 112 if (fWritingChoice != 0) { 113 fParser->Write(fWriteFile, fWorldPhysVol, true, "./SimpleExtensionSchema/SimpleExtension.xsd"); 114 } 115 116 return fWorldPhysVol; 117 } 118 119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 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 = "Nitrogen", symbol = "N", z = 7., a); 134 135 a = 16.00 * g / mole; 136 G4Element* elO = new G4Element(name = "Oxygen", symbol = "O", z = 8., a); 137 138 a = 26.98 * g / mole; 139 G4Element* elAl = new G4Element(name = "Aluminum", symbol = "Al", z = 13., a); 140 141 // Print the Element information 142 // 143 G4cout << *(G4Element::GetElementTable()) << G4endl; 144 145 // Air 146 // 147 density = 1.29 * mg / cm3; 148 fAir = new G4Material(name = "Air", density, ncomponents = 2); 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", density, ncomponents = 1); 156 fAluminum->AddElement(elAl, fractionmass = 1.0); 157 158 // Lead 159 // 160 fPb = new G4Material("Lead", z = 82., a = 207.19 * g / mole, density = 11.35 * g / cm3); 161 162 // Xenon gas 163 // 164 fXenon = new G4Material("XenonGas", z = 54., a = 131.29 * g / mole, density = 5.458 * mg / cm3, 165 kStateGas, temperature = 293.15 * kelvin, pressure = 1 * atmosphere); 166 167 // Prints the material information 168 // 169 G4cout << *(G4Material::GetMaterialTable()) << G4endl; 170 } 171 172 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 173 174 void G03DetectorConstruction::SetReadFile(const G4String& fname) 175 { 176 fReadFile = fname; 177 fWritingChoice = 0; 178 } 179 180 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 181 182 void G03DetectorConstruction::SetWriteFile(const G4String& fname) 183 { 184 fWriteFile = fname; 185 fWritingChoice = 1; 186 } 187