File indexing completed on 2025-12-17 09:28:48
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 "DetectorConstruction.hh"
0034
0035 #include "DetectorMessenger.hh"
0036
0037 #include "G4Box.hh"
0038 #include "G4GeometryManager.hh"
0039 #include "G4LogicalVolume.hh"
0040 #include "G4LogicalVolumeStore.hh"
0041 #include "G4Material.hh"
0042 #include "G4NistManager.hh"
0043 #include "G4PVPlacement.hh"
0044 #include "G4PhysicalConstants.hh"
0045 #include "G4PhysicalVolumeStore.hh"
0046 #include "G4RunManager.hh"
0047 #include "G4SolidStore.hh"
0048 #include "G4SystemOfUnits.hh"
0049 #include "G4UnitsTable.hh"
0050
0051
0052
0053 DetectorConstruction::DetectorConstruction()
0054 {
0055
0056 fAbsorThickness = 1 * cm;
0057 fAbsorSizeYZ = 1 * cm;
0058 fWorldSizeX = 1.2 * fAbsorThickness;
0059 fWorldSizeYZ = 1.2 * fAbsorSizeYZ;
0060
0061
0062 DefineMaterials();
0063 SetAbsorMaterial("G4_Co");
0064
0065
0066 fDetectorMessenger = new DetectorMessenger(this);
0067 }
0068
0069
0070
0071 DetectorConstruction::~DetectorConstruction()
0072 {
0073 delete fDetectorMessenger;
0074 }
0075
0076
0077
0078 G4VPhysicalVolume* DetectorConstruction::Construct()
0079 {
0080 return ConstructVolumes();
0081 }
0082
0083
0084
0085 void DetectorConstruction::DefineMaterials()
0086 {
0087
0088
0089
0090 G4int ncomponents, natoms;
0091
0092
0093 G4Element* H = new G4Element("TS_H_of_Water", "H", 1., 1.0079 * g / mole);
0094 G4Element* O = new G4Element("Oxygen", "O", 8., 16.00 * g / mole);
0095 G4Material* H2O = new G4Material("Water_ts", 1.000 * g / cm3, ncomponents = 2, kStateLiquid,
0096 593 * kelvin, 150 * bar);
0097 H2O->AddElement(H, natoms = 2);
0098 H2O->AddElement(O, natoms = 1);
0099 H2O->GetIonisation()->SetMeanExcitationEnergy(78.0 * eV);
0100
0101
0102 G4Isotope* H2 = new G4Isotope("H2", 1, 2);
0103 G4Element* D = new G4Element("TS_D_of_Heavy_Water", "D", 1);
0104 D->AddIsotope(H2, 100 * perCent);
0105 G4Material* D2O = new G4Material("HeavyWater", 1.11 * g / cm3, ncomponents = 2, kStateLiquid,
0106 293.15 * kelvin, 1 * atmosphere);
0107 D2O->AddElement(D, natoms = 2);
0108 D2O->AddElement(O, natoms = 1);
0109
0110
0111 G4Isotope* C12 = new G4Isotope("C12", 6, 12);
0112 G4Element* C = new G4Element("TS_C_of_Graphite", "C", ncomponents = 1);
0113 C->AddIsotope(C12, 100. * perCent);
0114 G4Material* graphite = new G4Material("graphite", 2.27 * g / cm3, ncomponents = 1, kStateSolid,
0115 293 * kelvin, 1 * atmosphere);
0116 graphite->AddElement(C, natoms = 1);
0117
0118
0119 fWorldMaterial = new G4Material("Galactic", 1, 1.01 * g / mole, universe_mean_density, kStateGas,
0120 2.73 * kelvin, 3.e-18 * pascal);
0121
0122
0123 }
0124
0125
0126
0127 G4Material* DetectorConstruction::MaterialWithSingleIsotope(G4String name, G4String symbol,
0128 G4double density, G4int Z, G4int A)
0129 {
0130
0131
0132 G4int ncomponents;
0133 G4double abundance, massfraction;
0134
0135 G4Isotope* isotope = new G4Isotope(symbol, Z, A);
0136
0137 G4Element* element = new G4Element(name, symbol, ncomponents = 1);
0138 element->AddIsotope(isotope, abundance = 100. * perCent);
0139
0140 G4Material* material = new G4Material(name, density, ncomponents = 1);
0141 material->AddElement(element, massfraction = 100. * perCent);
0142
0143 return material;
0144 }
0145
0146
0147
0148 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
0149 {
0150
0151 G4GeometryManager::GetInstance()->OpenGeometry();
0152 G4PhysicalVolumeStore::GetInstance()->Clean();
0153 G4LogicalVolumeStore::GetInstance()->Clean();
0154 G4SolidStore::GetInstance()->Clean();
0155
0156
0157
0158 fWorldSizeX = 1.2 * fAbsorThickness;
0159 fWorldSizeYZ = 1.2 * fAbsorSizeYZ;
0160
0161 G4Box* sWorld = new G4Box("World",
0162 fWorldSizeX / 2, fWorldSizeYZ / 2, fWorldSizeYZ / 2);
0163
0164 G4LogicalVolume* lWorld = new G4LogicalVolume(sWorld,
0165 fWorldMaterial,
0166 "World");
0167
0168 fWorldVolume = new G4PVPlacement(0,
0169 G4ThreeVector(),
0170 lWorld,
0171 "World",
0172 0,
0173 false,
0174 0);
0175
0176
0177
0178 G4Box* sAbsor = new G4Box("Absorber",
0179 fAbsorThickness / 2, fAbsorSizeYZ / 2, fAbsorSizeYZ / 2);
0180
0181 fLAbsor = new G4LogicalVolume(sAbsor,
0182 fAbsorMaterial,
0183 fAbsorMaterial->GetName());
0184
0185 new G4PVPlacement(0,
0186 G4ThreeVector(),
0187 fLAbsor,
0188 fAbsorMaterial->GetName(),
0189 lWorld,
0190 false,
0191 0);
0192
0193 PrintParameters();
0194
0195
0196
0197 return fWorldVolume;
0198 }
0199
0200
0201
0202 void DetectorConstruction::PrintParameters()
0203 {
0204 G4cout << "\n The Absorber is " << G4BestUnit(fAbsorThickness, "Length") << " of "
0205 << fAbsorMaterial->GetName() << "\n \n"
0206 << fAbsorMaterial << G4endl;
0207 }
0208
0209
0210
0211 void DetectorConstruction::SetAbsorMaterial(G4String materialChoice)
0212 {
0213
0214 G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
0215
0216 if (pttoMaterial) {
0217 fAbsorMaterial = pttoMaterial;
0218 if (fLAbsor) {
0219 fLAbsor->SetMaterial(fAbsorMaterial);
0220 }
0221 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0222 }
0223 else {
0224 G4cout << "\n--> warning from DetectorConstruction::SetMaterial : " << materialChoice
0225 << " not found" << G4endl;
0226 }
0227 }
0228
0229
0230
0231 void DetectorConstruction::SetAbsorThickness(G4double value)
0232 {
0233 fAbsorThickness = value;
0234 G4RunManager::GetRunManager()->ReinitializeGeometry();
0235 }
0236
0237
0238
0239 void DetectorConstruction::SetAbsorSizeYZ(G4double value)
0240 {
0241 fAbsorSizeYZ = value;
0242 G4RunManager::GetRunManager()->ReinitializeGeometry();
0243 }
0244
0245