File indexing completed on 2026-09-15 08:28:53
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 #include "DetectorConstruction.hh"
0030
0031 #include "DetectorMessenger.hh"
0032
0033 #include "G4Box.hh"
0034 #include "G4GeometryManager.hh"
0035 #include "G4LogicalVolume.hh"
0036 #include "G4LogicalVolumeStore.hh"
0037 #include "G4Material.hh"
0038 #include "G4NistManager.hh"
0039 #include "G4PVPlacement.hh"
0040 #include "G4PhysicalVolumeStore.hh"
0041 #include "G4RunManager.hh"
0042 #include "G4SolidStore.hh"
0043 #include "G4SystemOfUnits.hh"
0044 #include "G4UnitsTable.hh"
0045
0046
0047
0048 DetectorConstruction::DetectorConstruction()
0049 {
0050 fBoxSize = 1 * m;
0051 DefineMaterials();
0052 SetMaterial("Water_ts");
0053 fDetectorMessenger = new DetectorMessenger(this);
0054 }
0055
0056
0057
0058 DetectorConstruction::~DetectorConstruction()
0059 {
0060 delete fDetectorMessenger;
0061 }
0062
0063
0064
0065 G4VPhysicalVolume* DetectorConstruction::Construct()
0066 {
0067 return ConstructVolumes();
0068 }
0069
0070
0071
0072 void DetectorConstruction::DefineMaterials()
0073 {
0074
0075
0076
0077 G4int ncomponents, natoms;
0078
0079
0080 G4Element* H = new G4Element("TS_H_of_Water", "H", 1., 1.0079 * g / mole);
0081 G4Element* O = new G4Element("Oxygen", "O", 8., 16.00 * g / mole);
0082 G4Material* H2O = new G4Material("Water_ts", 1.000 * g / cm3, ncomponents = 2, kStateLiquid,
0083 593 * kelvin, 150 * bar);
0084 H2O->AddElement(H, natoms = 2);
0085 H2O->AddElement(O, natoms = 1);
0086 H2O->GetIonisation()->SetMeanExcitationEnergy(78.0 * eV);
0087
0088
0089 G4Isotope* H2 = new G4Isotope("H2", 1, 2);
0090 G4Element* D = new G4Element("TS_D_of_Heavy_Water", "D", 1);
0091 D->AddIsotope(H2, 100 * perCent);
0092 G4Material* D2O = new G4Material("HeavyWater", 1.11 * g / cm3, ncomponents = 2, kStateLiquid,
0093 293.15 * kelvin, 1 * atmosphere);
0094 D2O->AddElement(D, natoms = 2);
0095 D2O->AddElement(O, natoms = 1);
0096
0097
0098 G4Isotope* C12 = new G4Isotope("C12", 6, 12);
0099 G4Element* C = new G4Element("TS_C_of_Graphite", "C", ncomponents = 1);
0100 C->AddIsotope(C12, 100. * perCent);
0101 G4Material* graphite = new G4Material("graphite", 2.27 * g / cm3, ncomponents = 1, kStateSolid,
0102 293 * kelvin, 1 * atmosphere);
0103 graphite->AddElement(C, natoms = 1);
0104
0105
0106 }
0107
0108
0109
0110 G4Material* DetectorConstruction::MaterialWithSingleIsotope(G4String name, G4String symbol,
0111 G4double density, G4int Z, G4int A)
0112 {
0113
0114
0115 G4int ncomponents;
0116 G4double abundance, massfraction;
0117
0118 G4Isotope* isotope = new G4Isotope(symbol, Z, A);
0119
0120 G4Element* element = new G4Element(name, symbol, ncomponents = 1);
0121 element->AddIsotope(isotope, abundance = 100. * perCent);
0122
0123 G4Material* material = new G4Material(name, density, ncomponents = 1);
0124 material->AddElement(element, massfraction = 100. * perCent);
0125
0126 return material;
0127 }
0128
0129
0130
0131 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
0132 {
0133
0134 G4GeometryManager::GetInstance()->OpenGeometry();
0135 G4PhysicalVolumeStore::GetInstance()->Clean();
0136 G4LogicalVolumeStore::GetInstance()->Clean();
0137 G4SolidStore::GetInstance()->Clean();
0138
0139 G4Box* sBox = new G4Box("Container",
0140 fBoxSize / 2, fBoxSize / 2, fBoxSize / 2);
0141
0142 fLBox = new G4LogicalVolume(sBox,
0143 fMaterial,
0144 fMaterial->GetName());
0145
0146 fPBox = new G4PVPlacement(0,
0147 G4ThreeVector(),
0148 fLBox,
0149 fMaterial->GetName(),
0150 0,
0151 false,
0152 0);
0153
0154 PrintParameters();
0155
0156
0157
0158 return fPBox;
0159 }
0160
0161
0162
0163 void DetectorConstruction::PrintParameters()
0164 {
0165 G4cout << "\n The Box is " << G4BestUnit(fBoxSize, "Length") << " of " << fMaterial->GetName()
0166 << "\n \n"
0167 << fMaterial << G4endl;
0168 }
0169
0170
0171
0172 void DetectorConstruction::SetMaterial(G4String materialChoice)
0173 {
0174
0175 G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
0176
0177 if (pttoMaterial) {
0178 if (fMaterial != pttoMaterial) {
0179 fMaterial = pttoMaterial;
0180 if (fLBox) {
0181 fLBox->SetMaterial(pttoMaterial);
0182 }
0183 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0184 }
0185 }
0186 else {
0187 G4cout << "\n--> warning from DetectorConstruction::SetMaterial : " << materialChoice
0188 << " not found" << G4endl;
0189 }
0190 }
0191
0192
0193
0194 void DetectorConstruction::SetSize(G4double value)
0195 {
0196 fBoxSize = value;
0197 G4RunManager::GetRunManager()->ReinitializeGeometry();
0198 }
0199
0200