File indexing completed on 2026-05-31 07:54:21
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 "G4GeometryManager.hh"
0034 #include "G4LogicalVolume.hh"
0035 #include "G4LogicalVolumeStore.hh"
0036 #include "G4Material.hh"
0037 #include "G4NistManager.hh"
0038 #include "G4PVPlacement.hh"
0039 #include "G4PhysicalConstants.hh"
0040 #include "G4PhysicalVolumeStore.hh"
0041 #include "G4SolidStore.hh"
0042 #include "G4SystemOfUnits.hh"
0043 #include "G4Tubs.hh"
0044 #include "G4UnitsTable.hh"
0045 #include "G4VPhysicalVolume.hh"
0046
0047
0048
0049 DetectorConstruction::DetectorConstruction() : fWall(nullptr), fCavity(nullptr)
0050 {
0051
0052 fCavityThickness = 2 * mm;
0053 fCavityRadius = 1 * cm;
0054
0055 fWallThickness = 5 * mm;
0056
0057 DefineMaterials();
0058 SetWallMaterial("G4_WATER");
0059 SetCavityMaterial("g4Water_gas");
0060
0061
0062 fDetectorMessenger = new DetectorMessenger(this);
0063 }
0064
0065
0066
0067 DetectorConstruction::~DetectorConstruction()
0068 {
0069 delete fDetectorMessenger;
0070 }
0071
0072
0073
0074 void DetectorConstruction::DefineMaterials()
0075 {
0076 G4double z, a;
0077
0078 G4Element* H = new G4Element("Hydrogen", "H", z = 1., a = 1.01 * g / mole);
0079 G4Element* O = new G4Element("Oxygen", "O", z = 8., a = 16.00 * g / mole);
0080
0081 G4Material* H2O = new G4Material("Water", 1.0 * g / cm3, 2);
0082 H2O->AddElement(H, 2);
0083 H2O->AddElement(O, 1);
0084 H2O->GetIonisation()->SetMeanExcitationEnergy(78.0 * eV);
0085
0086 G4Material* gas = new G4Material("Water_gas", 1.0 * mg / cm3, 2);
0087 gas->AddElement(H, 2);
0088 gas->AddElement(O, 1);
0089 gas->GetIonisation()->SetMeanExcitationEnergy(78.0 * eV);
0090
0091 new G4Material("Graphite", 6, 12.01 * g / mole, 2.265 * g / cm3);
0092 new G4Material("Graphite_gas", 6, 12.01 * g / mole, 2.265 * mg / cm3);
0093
0094 new G4Material("Aluminium", 13, 26.98 * g / mole, 2.700 * g / cm3);
0095 new G4Material("Aluminium_gas", 13, 26.98 * g / mole, 2.700 * mg / cm3);
0096
0097
0098
0099 G4NistManager* nist = G4NistManager::Instance();
0100
0101 nist->FindOrBuildMaterial("G4_WATER");
0102 nist->BuildMaterialWithNewDensity("g4Water_gas", "G4_WATER", 1.0 * mg / cm3);
0103
0104
0105 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0106 }
0107
0108
0109
0110 G4VPhysicalVolume* DetectorConstruction::Construct()
0111 {
0112 if (fWall) {
0113 return fWall;
0114 }
0115
0116
0117
0118 fTotalThickness = fCavityThickness + 2 * fWallThickness;
0119 fWallRadius = fCavityRadius + fWallThickness;
0120
0121 G4Tubs* sChamber = new G4Tubs("Chamber",
0122 0., fWallRadius, 0.5 * fTotalThickness, 0., twopi);
0123
0124 G4LogicalVolume* lChamber = new G4LogicalVolume(sChamber,
0125 fWallMaterial,
0126 "Chamber");
0127
0128 fWall = new G4PVPlacement(0,
0129 G4ThreeVector(),
0130 lChamber,
0131 "Wall",
0132 0,
0133 false,
0134 0);
0135
0136
0137
0138 G4Tubs* sCavity = new G4Tubs("Cavity", 0., fCavityRadius, 0.5 * fCavityThickness, 0., twopi);
0139
0140 G4LogicalVolume* lCavity = new G4LogicalVolume(sCavity,
0141 fCavityMaterial,
0142 "Cavity");
0143
0144 fCavity = new G4PVPlacement(0,
0145 G4ThreeVector(),
0146 lCavity,
0147 "Cavity",
0148 lChamber,
0149 false,
0150 1);
0151
0152 PrintParameters();
0153
0154
0155
0156
0157 return fWall;
0158 }
0159
0160
0161
0162 void DetectorConstruction::PrintParameters()
0163 {
0164 G4cout << "\n---------------------------------------------------------\n";
0165 G4cout << "---> The Wall is " << G4BestUnit(fWallThickness, "Length") << " of "
0166 << fWallMaterial->GetName() << " ( "
0167 << G4BestUnit(fWallMaterial->GetDensity(), "Volumic Mass") << " )\n";
0168 G4cout << " The Cavity is " << G4BestUnit(fCavityThickness, "Length") << " of "
0169 << fCavityMaterial->GetName() << " ( "
0170 << G4BestUnit(fCavityMaterial->GetDensity(), "Volumic Mass") << " )";
0171 G4cout << "\n---------------------------------------------------------\n";
0172 G4cout << G4endl;
0173 }
0174
0175
0176
0177 void DetectorConstruction::SetWallThickness(G4double value)
0178 {
0179 fWallThickness = value;
0180 }
0181
0182
0183
0184 void DetectorConstruction::SetWallMaterial(const G4String& materialChoice)
0185 {
0186
0187 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
0188 if (pttoMaterial) fWallMaterial = pttoMaterial;
0189 }
0190
0191
0192
0193 void DetectorConstruction::SetCavityThickness(G4double value)
0194 {
0195 fCavityThickness = value;
0196 }
0197
0198
0199
0200 void DetectorConstruction::SetCavityRadius(G4double value)
0201 {
0202 fCavityRadius = value;
0203 }
0204
0205
0206
0207 void DetectorConstruction::SetCavityMaterial(const G4String& materialChoice)
0208 {
0209
0210 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
0211 if (pttoMaterial) fCavityMaterial = pttoMaterial;
0212 }
0213
0214