File indexing completed on 2025-02-23 09:22:37
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
0034
0035 #include "G03DetectorConstruction.hh"
0036
0037
0038
0039 #include "G4Material.hh"
0040 #include "G4VPhysicalVolume.hh"
0041 #include "globals.hh"
0042
0043
0044
0045 #include "G03DetectorMessenger.hh"
0046
0047
0048
0049 #include "G03ColorReader.hh"
0050
0051
0052
0053 #include "G03ColorWriter.hh"
0054
0055 #include "G4SystemOfUnits.hh"
0056
0057
0058
0059 G03DetectorConstruction::G03DetectorConstruction()
0060 : G4VUserDetectorConstruction(),
0061 fAir(0),
0062 fAluminum(0),
0063 fPb(0),
0064 fXenon(0),
0065 fReader(0),
0066 fWriter(0),
0067 fParser(0),
0068 fDetectorMessenger(0)
0069 {
0070 fReadFile = "color_extension.gdml";
0071 fWriteFile = "color_extension_test.gdml";
0072 fWritingChoice = 1;
0073
0074 fDetectorMessenger = new G03DetectorMessenger(this);
0075
0076 fReader = new G03ColorReader;
0077 fWriter = new G03ColorWriter;
0078 fParser = new G4GDMLParser(fReader, fWriter);
0079 }
0080
0081
0082
0083 G03DetectorConstruction::~G03DetectorConstruction()
0084 {
0085 delete fDetectorMessenger;
0086 delete fReader;
0087 delete fWriter;
0088 delete fParser;
0089 }
0090
0091
0092
0093 G4VPhysicalVolume* G03DetectorConstruction::Construct()
0094 {
0095
0096
0097 G4VPhysicalVolume* fWorldPhysVol;
0098
0099 fParser->Read(fReadFile, false);
0100
0101
0102
0103
0104
0105
0106 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0107
0108
0109
0110 fWorldPhysVol = fParser->GetWorldVolume();
0111
0112 if (fWritingChoice != 0) {
0113 fParser->Write(fWriteFile, fWorldPhysVol, true, "./SimpleExtensionSchema/SimpleExtension.xsd");
0114 }
0115
0116 return fWorldPhysVol;
0117 }
0118
0119
0120
0121 void G03DetectorConstruction::ListOfMaterials()
0122 {
0123 G4double a;
0124 G4double z;
0125 G4double density, temperature, pressure;
0126 G4double fractionmass;
0127 G4String name, symbol;
0128 G4int ncomponents;
0129
0130
0131
0132 a = 14.01 * g / mole;
0133 G4Element* elN = new G4Element(name = "Nitrogen", symbol = "N", z = 7., a);
0134
0135 a = 16.00 * g / mole;
0136 G4Element* elO = new G4Element(name = "Oxygen", symbol = "O", z = 8., a);
0137
0138 a = 26.98 * g / mole;
0139 G4Element* elAl = new G4Element(name = "Aluminum", symbol = "Al", z = 13., a);
0140
0141
0142
0143 G4cout << *(G4Element::GetElementTable()) << G4endl;
0144
0145
0146
0147 density = 1.29 * mg / cm3;
0148 fAir = new G4Material(name = "Air", density, ncomponents = 2);
0149 fAir->AddElement(elN, fractionmass = 0.7);
0150 fAir->AddElement(elO, fractionmass = 0.3);
0151
0152
0153
0154 density = 2.70 * g / cm3;
0155 fAluminum = new G4Material(name = "Aluminum", density, ncomponents = 1);
0156 fAluminum->AddElement(elAl, fractionmass = 1.0);
0157
0158
0159
0160 fPb = new G4Material("Lead", z = 82., a = 207.19 * g / mole, density = 11.35 * g / cm3);
0161
0162
0163
0164 fXenon = new G4Material("XenonGas", z = 54., a = 131.29 * g / mole, density = 5.458 * mg / cm3,
0165 kStateGas, temperature = 293.15 * kelvin, pressure = 1 * atmosphere);
0166
0167
0168
0169 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0170 }
0171
0172
0173
0174 void G03DetectorConstruction::SetReadFile(const G4String& fname)
0175 {
0176 fReadFile = fname;
0177 fWritingChoice = 0;
0178 }
0179
0180
0181
0182 void G03DetectorConstruction::SetWriteFile(const G4String& fname)
0183 {
0184 fWriteFile = fname;
0185 fWritingChoice = 1;
0186 }