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