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 // $Id$ 30 // 31 // 31 // Class G03DetectorConstruction implementatio 32 // Class G03DetectorConstruction implementation 32 // 33 // 33 // ------------------------------------------- 34 // ---------------------------------------------------------------------------- 34 35 35 #include "G03DetectorConstruction.hh" 36 #include "G03DetectorConstruction.hh" 36 37 37 // Geant4 includes 38 // Geant4 includes 38 // 39 // >> 40 #include "globals.hh" 39 #include "G4Material.hh" 41 #include "G4Material.hh" 40 #include "G4VPhysicalVolume.hh" 42 #include "G4VPhysicalVolume.hh" 41 #include "globals.hh" << 42 43 43 // Messenger 44 // Messenger 44 // 45 // 45 #include "G03DetectorMessenger.hh" 46 #include "G03DetectorMessenger.hh" 46 47 47 // Color extension include for reading 48 // Color extension include for reading 48 // 49 // 49 #include "G03ColorReader.hh" 50 #include "G03ColorReader.hh" 50 51 51 // Color extension include for writing 52 // Color extension include for writing 52 // 53 // 53 #include "G03ColorWriter.hh" 54 #include "G03ColorWriter.hh" 54 55 55 #include "G4SystemOfUnits.hh" 56 #include "G4SystemOfUnits.hh" 56 57 57 //....oooOO0OOooo........oooOO0OOooo........oo 58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 58 59 59 G03DetectorConstruction::G03DetectorConstructi 60 G03DetectorConstruction::G03DetectorConstruction() 60 : G4VUserDetectorConstruction(), << 61 : fAir(0), fAluminum(0), fPb(0), fXenon(0) 61 fAir(0), << 62 { 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"; 63 fReadFile = "color_extension.gdml"; 71 fWriteFile = "color_extension_test.gdml"; 64 fWriteFile = "color_extension_test.gdml"; 72 fWritingChoice = 1; 65 fWritingChoice = 1; 73 66 74 fDetectorMessenger = new G03DetectorMessenge << 67 fDetectorMessenger = new G03DetectorMessenger( this ); 75 68 76 fReader = new G03ColorReader; 69 fReader = new G03ColorReader; 77 fWriter = new G03ColorWriter; 70 fWriter = new G03ColorWriter; 78 fParser = new G4GDMLParser(fReader, fWriter) 71 fParser = new G4GDMLParser(fReader, fWriter); 79 } 72 } 80 73 81 //....oooOO0OOooo........oooOO0OOooo........oo 74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 82 75 83 G03DetectorConstruction::~G03DetectorConstruct 76 G03DetectorConstruction::~G03DetectorConstruction() 84 { 77 { 85 delete fDetectorMessenger; 78 delete fDetectorMessenger; 86 delete fReader; 79 delete fReader; 87 delete fWriter; 80 delete fWriter; 88 delete fParser; 81 delete fParser; 89 } 82 } 90 83 91 //....oooOO0OOooo........oooOO0OOooo........oo 84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 92 85 93 G4VPhysicalVolume* G03DetectorConstruction::Co 86 G4VPhysicalVolume* G03DetectorConstruction::Construct() 94 { << 87 { 95 // Reading of Geometry from GDML 88 // Reading of Geometry from GDML 96 89 97 G4VPhysicalVolume* fWorldPhysVol; 90 G4VPhysicalVolume* fWorldPhysVol; 98 91 99 fParser->Read(fReadFile, false); << 92 fParser->Read(fReadFile,false); 100 // << 93 // 101 // 2nd Boolean argument "Validate" set to fa << 94 // 2nd Boolean argument "Validate" set to false. 102 // Disabling Schema validation for reading e << 95 // Disabling Schema validation for reading extended GDML file. 103 << 96 104 // Prints the material information 97 // Prints the material information 105 // 98 // 106 G4cout << *(G4Material::GetMaterialTable()) << 99 G4cout << *(G4Material::GetMaterialTable() ) << G4endl; 107 100 108 // Giving World Physical Volume from GDML Pa 101 // Giving World Physical Volume from GDML Parser 109 // 102 // 110 fWorldPhysVol = fParser->GetWorldVolume(); << 103 fWorldPhysVol = fParser->GetWorldVolume(); 111 104 112 if (fWritingChoice != 0) { << 105 if(fWritingChoice!=0) 113 fParser->Write(fWriteFile, fWorldPhysVol, << 106 { >> 107 fParser->Write(fWriteFile, fWorldPhysVol, true, >> 108 "./SimpleExtensionSchema/SimpleExtension.xsd"); 114 } 109 } 115 << 110 116 return fWorldPhysVol; 111 return fWorldPhysVol; 117 } 112 } 118 113 119 //....oooOO0OOooo........oooOO0OOooo........oo 114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 120 115 121 void G03DetectorConstruction::ListOfMaterials( 116 void G03DetectorConstruction::ListOfMaterials() 122 { 117 { 123 G4double a; // atomic mass 118 G4double a; // atomic mass 124 G4double z; // atomic number 119 G4double z; // atomic number 125 G4double density, temperature, pressure; << 120 G4double density,temperature,pressure; 126 G4double fractionmass; 121 G4double fractionmass; 127 G4String name, symbol; 122 G4String name, symbol; 128 G4int ncomponents; 123 G4int ncomponents; 129 124 130 // Elements needed for the materials 125 // Elements needed for the materials 131 126 132 a = 14.01 * g / mole; << 127 a = 14.01*g/mole; 133 G4Element* elN = new G4Element(name = "Nitro << 128 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 129 >> 130 a = 16.00*g/mole; >> 131 G4Element* elO = new G4Element(name="Oxygen", symbol="O", z=8., a); >> 132 >> 133 a = 26.98*g/mole; >> 134 G4Element* elAl = new G4Element(name="Aluminum", symbol="Al", z=13., a); >> 135 141 // Print the Element information 136 // Print the Element information 142 // 137 // 143 G4cout << *(G4Element::GetElementTable()) << 138 G4cout << *(G4Element::GetElementTable()) << G4endl; 144 139 145 // Air 140 // Air 146 // 141 // 147 density = 1.29 * mg / cm3; << 142 density = 1.29*mg/cm3; 148 fAir = new G4Material(name = "Air", density, << 143 fAir = new G4Material(name="Air", density, ncomponents=2); 149 fAir->AddElement(elN, fractionmass = 0.7); << 144 fAir->AddElement(elN, fractionmass=0.7); 150 fAir->AddElement(elO, fractionmass = 0.3); << 145 fAir->AddElement(elO, fractionmass=0.3); 151 146 152 // Aluminum 147 // Aluminum 153 // 148 // 154 density = 2.70 * g / cm3; << 149 density = 2.70*g/cm3; 155 fAluminum = new G4Material(name = "Aluminum" << 150 fAluminum = new G4Material(name="Aluminum", density, ncomponents=1); 156 fAluminum->AddElement(elAl, fractionmass = 1 << 151 fAluminum->AddElement(elAl, fractionmass=1.0); 157 152 158 // Lead 153 // Lead 159 // 154 // 160 fPb = new G4Material("Lead", z = 82., a = 20 << 155 fPb = new G4Material("Lead", z=82., a= 207.19*g/mole, density= 11.35*g/cm3); 161 156 162 // Xenon gas 157 // Xenon gas 163 // 158 // 164 fXenon = new G4Material("XenonGas", z = 54., << 159 fXenon = new G4Material("XenonGas", z=54., a=131.29*g/mole, 165 kStateGas, temperatu << 160 density= 5.458*mg/cm3, kStateGas, >> 161 temperature= 293.15*kelvin, pressure= 1*atmosphere); 166 162 167 // Prints the material information 163 // Prints the material information 168 // 164 // 169 G4cout << *(G4Material::GetMaterialTable()) << 165 G4cout << *(G4Material::GetMaterialTable() ) << G4endl; 170 } 166 } 171 167 172 //....oooOO0OOooo........oooOO0OOooo........oo 168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 173 169 174 void G03DetectorConstruction::SetReadFile(cons << 170 void G03DetectorConstruction::SetReadFile( const G4String& fname ) 175 { 171 { 176 fReadFile = fname; << 172 fReadFile=fname; 177 fWritingChoice = 0; << 173 fWritingChoice=0; 178 } 174 } 179 175 180 //....oooOO0OOooo........oooOO0OOooo........oo 176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 181 177 182 void G03DetectorConstruction::SetWriteFile(con << 178 void G03DetectorConstruction::SetWriteFile( const G4String& fname ) 183 { 179 { 184 fWriteFile = fname; << 180 fWriteFile=fname; 185 fWritingChoice = 1; << 181 fWritingChoice=1; 186 } 182 } 187 183