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