Warning, file /geant4/examples/extended/persistency/gdml/G03/src/G03DetectorConstruction.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 #include "G03DetectorConstruction.hh"
0034
0035
0036
0037 #include "G4Material.hh"
0038 #include "G4VPhysicalVolume.hh"
0039 #include "globals.hh"
0040
0041
0042
0043 #include "G03DetectorMessenger.hh"
0044
0045
0046
0047 #include "G03ColorReader.hh"
0048
0049
0050
0051 #include "G03ColorWriter.hh"
0052
0053 #include "G4SystemOfUnits.hh"
0054
0055
0056
0057 G03DetectorConstruction::G03DetectorConstruction()
0058 : G4VUserDetectorConstruction(),
0059 fAir(0),
0060 fAluminum(0),
0061 fPb(0),
0062 fXenon(0),
0063 fReader(0),
0064 fWriter(0),
0065 fParser(0),
0066 fDetectorMessenger(0)
0067 {
0068 fReadFile = "color_extension.gdml";
0069 fWriteFile = "color_extension_test.gdml";
0070 fWritingChoice = 1;
0071
0072 fDetectorMessenger = new G03DetectorMessenger(this);
0073
0074 fReader = new G03ColorReader;
0075 fWriter = new G03ColorWriter;
0076 fParser = new G4GDMLParser(fReader, fWriter);
0077 }
0078
0079
0080
0081 G03DetectorConstruction::~G03DetectorConstruction()
0082 {
0083 delete fDetectorMessenger;
0084 delete fReader;
0085 delete fWriter;
0086 delete fParser;
0087 }
0088
0089
0090
0091 G4VPhysicalVolume* G03DetectorConstruction::Construct()
0092 {
0093
0094
0095 G4VPhysicalVolume* fWorldPhysVol;
0096
0097 fParser->Read(fReadFile, false);
0098
0099
0100
0101
0102
0103
0104 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0105
0106
0107
0108 fWorldPhysVol = fParser->GetWorldVolume();
0109
0110 if (fWritingChoice != 0) {
0111 fParser->Write(fWriteFile, fWorldPhysVol, true, "./SimpleExtensionSchema/SimpleExtension.xsd");
0112 }
0113
0114 return fWorldPhysVol;
0115 }
0116
0117
0118
0119 void G03DetectorConstruction::ListOfMaterials()
0120 {
0121 G4double a;
0122 G4double z;
0123 G4double density, temperature, pressure;
0124 G4double fractionmass;
0125 G4String name, symbol;
0126 G4int ncomponents;
0127
0128
0129
0130 a = 14.01 * g / mole;
0131 G4Element* elN = new G4Element(name = "Nitrogen", symbol = "N", z = 7., a);
0132
0133 a = 16.00 * g / mole;
0134 G4Element* elO = new G4Element(name = "Oxygen", symbol = "O", z = 8., a);
0135
0136 a = 26.98 * g / mole;
0137 G4Element* elAl = new G4Element(name = "Aluminum", symbol = "Al", z = 13., a);
0138
0139
0140
0141 G4cout << *(G4Element::GetElementTable()) << G4endl;
0142
0143
0144
0145 density = 1.29 * mg / cm3;
0146 fAir = new G4Material(name = "Air", density, ncomponents = 2);
0147 fAir->AddElement(elN, fractionmass = 0.7);
0148 fAir->AddElement(elO, fractionmass = 0.3);
0149
0150
0151
0152 density = 2.70 * g / cm3;
0153 fAluminum = new G4Material(name = "Aluminum", density, ncomponents = 1);
0154 fAluminum->AddElement(elAl, fractionmass = 1.0);
0155
0156
0157
0158 fPb = new G4Material("Lead", z = 82., a = 207.19 * g / mole, density = 11.35 * g / cm3);
0159
0160
0161
0162 fXenon = new G4Material("XenonGas", z = 54., a = 131.29 * g / mole, density = 5.458 * mg / cm3,
0163 kStateGas, temperature = 293.15 * kelvin, pressure = 1 * atmosphere);
0164
0165
0166
0167 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0168 }
0169
0170
0171
0172 void G03DetectorConstruction::SetReadFile(const G4String& fname)
0173 {
0174 fReadFile = fname;
0175 fWritingChoice = 0;
0176 }
0177
0178
0179
0180 void G03DetectorConstruction::SetWriteFile(const G4String& fname)
0181 {
0182 fWriteFile = fname;
0183 fWritingChoice = 1;
0184 }