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