File indexing completed on 2026-03-28 07:50:29
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 "G4PhysicalConstants.hh"
0041 #include "G4PhysicalVolumeStore.hh"
0042 #include "G4RunManager.hh"
0043 #include "G4SolidStore.hh"
0044 #include "G4SystemOfUnits.hh"
0045 #include "G4Tubs.hh"
0046 #include "G4UnitsTable.hh"
0047
0048
0049
0050 DetectorConstruction::DetectorConstruction()
0051 {
0052 fAbsorRadius = 15 * mm;
0053 fAbsorLength = 60 * mm;
0054 fContainThickness = 2.4 * mm;
0055 DefineMaterials();
0056 SetAbsorMaterial("BeO");
0057 SetContainMaterial("Stainless-Steel");
0058 fDetectorMessenger = new DetectorMessenger(this);
0059 }
0060
0061
0062
0063 DetectorConstruction::~DetectorConstruction()
0064 {
0065 delete fDetectorMessenger;
0066 }
0067
0068
0069
0070 G4VPhysicalVolume* DetectorConstruction::Construct()
0071 {
0072 return ConstructVolumes();
0073 }
0074
0075
0076
0077 void DetectorConstruction::DefineMaterials()
0078 {
0079 G4int ncomponents, natoms;
0080
0081 G4Element* Be = new G4Element("Beryllium", "Be", 4., 9.01 * g / mole);
0082 G4Element* N = new G4Element("Nitrogen", "N", 7., 14.01 * g / mole);
0083 G4Element* O = new G4Element("Oxygen", "O", 8., 16.00 * g / mole);
0084 G4Element* Cr = new G4Element("Chromium", "Cr", 24., 51.99 * g / mole);
0085 G4Element* Fe = new G4Element("Iron", "Fe", 26., 55.84 * g / mole);
0086 G4Element* Ni = new G4Element("Nickel", "Ni", 28., 58.69 * g / mole);
0087
0088 G4Material* BeO = new G4Material("BeO", 3.05 * g / cm3, ncomponents = 2);
0089 BeO->AddElement(Be, natoms = 1);
0090 BeO->AddElement(O, natoms = 1);
0091
0092 G4Material* inox = new G4Material("Stainless-Steel", 8 * g / cm3, ncomponents = 3);
0093 inox->AddElement(Fe, 74 * perCent);
0094 inox->AddElement(Cr, 18 * perCent);
0095 inox->AddElement(Ni, 8 * perCent);
0096
0097 G4Material* Air = new G4Material("Air", 1.290 * mg / cm3, ncomponents = 2);
0098 Air->AddElement(N, 70. * perCent);
0099 Air->AddElement(O, 30. * perCent);
0100
0101 fWorldMaterial = Air;
0102
0103
0104 }
0105
0106
0107
0108 G4Material* DetectorConstruction::MaterialWithSingleIsotope(G4String name, G4String symbol,
0109 G4double density, G4int Z, G4int A)
0110 {
0111
0112
0113 G4int ncomponents;
0114 G4double abundance, massfraction;
0115
0116 G4Isotope* isotope = new G4Isotope(symbol, Z, A);
0117
0118 G4Element* element = new G4Element(name, symbol, ncomponents = 1);
0119 element->AddIsotope(isotope, abundance = 100. * perCent);
0120
0121 G4Material* material = new G4Material(name, density, ncomponents = 1);
0122 material->AddElement(element, massfraction = 100. * perCent);
0123
0124 return material;
0125 }
0126
0127
0128
0129 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
0130 {
0131
0132 G4GeometryManager::GetInstance()->OpenGeometry();
0133 G4PhysicalVolumeStore::GetInstance()->Clean();
0134 G4LogicalVolumeStore::GetInstance()->Clean();
0135 G4SolidStore::GetInstance()->Clean();
0136
0137
0138 G4double ContainRadius = fAbsorRadius + fContainThickness;
0139 G4double ContainLength = fAbsorLength + 2 * fContainThickness;
0140
0141 G4double WorldSizeXY = 2.4 * ContainRadius;
0142 G4double WorldSizeZ = 1.2 * ContainLength;
0143
0144
0145
0146 G4Box* sWorld = new G4Box("World",
0147 0.5 * WorldSizeXY, 0.5 * WorldSizeXY, 0.5 * WorldSizeZ);
0148
0149 G4LogicalVolume* lWorld = new G4LogicalVolume(sWorld,
0150 fWorldMaterial,
0151 "World");
0152
0153 fPWorld = new G4PVPlacement(0,
0154 G4ThreeVector(),
0155 lWorld,
0156 "World",
0157 0,
0158 false,
0159 0);
0160
0161
0162
0163 G4Tubs* sContain = new G4Tubs("Container",
0164 0., ContainRadius, 0.5 * ContainLength, 0., twopi);
0165
0166 fLContain = new G4LogicalVolume(sContain,
0167 fContainMaterial,
0168 fContainMaterial->GetName());
0169
0170 new G4PVPlacement(0,
0171 G4ThreeVector(),
0172 fLContain,
0173 fContainMaterial->GetName(),
0174 lWorld,
0175 false,
0176 0);
0177
0178
0179
0180 G4Tubs* sAbsor = new G4Tubs("Absorber",
0181 0., fAbsorRadius, 0.5 * fAbsorLength, 0., twopi);
0182
0183 fLAbsor = new G4LogicalVolume(sAbsor,
0184 fAbsorMaterial,
0185 fAbsorMaterial->GetName());
0186
0187 new G4PVPlacement(0,
0188 G4ThreeVector(),
0189 fLAbsor,
0190 fAbsorMaterial->GetName(),
0191 fLContain,
0192 false,
0193 0);
0194
0195 PrintParameters();
0196
0197
0198
0199 return fPWorld;
0200 }
0201
0202
0203
0204 void DetectorConstruction::PrintParameters()
0205 {
0206 G4cout << "\n The Absorber is a cylinder of " << fAbsorMaterial->GetName()
0207 << " radius = " << G4BestUnit(fAbsorRadius, "Length")
0208 << " length = " << G4BestUnit(fAbsorLength, "Length") << G4endl;
0209 G4cout << " The Container is a cylinder of " << fContainMaterial->GetName()
0210 << " thickness = " << G4BestUnit(fContainThickness, "Length") << G4endl;
0211
0212 G4cout << "\n" << fAbsorMaterial << G4endl;
0213 G4cout << "\n" << fContainMaterial << G4endl;
0214 }
0215
0216
0217
0218 void DetectorConstruction::SetAbsorMaterial(G4String materialChoice)
0219 {
0220
0221 G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
0222
0223 if (pttoMaterial) {
0224 fAbsorMaterial = pttoMaterial;
0225 if (fLAbsor) {
0226 fLAbsor->SetMaterial(fAbsorMaterial);
0227 }
0228 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0229 }
0230 else {
0231 G4cout << "\n--> warning from DetectorConstruction::SetAbsorMaterial : " << materialChoice
0232 << " not found" << G4endl;
0233 }
0234 }
0235
0236
0237
0238 void DetectorConstruction::SetContainMaterial(G4String materialChoice)
0239 {
0240
0241 G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
0242
0243 if (pttoMaterial) {
0244 fContainMaterial = pttoMaterial;
0245 if (fLContain) {
0246 fLContain->SetMaterial(fContainMaterial);
0247 }
0248 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0249 }
0250 else {
0251 G4cout << "\n--> warning from DetectorConstruction::SetContainMaterial : " << materialChoice
0252 << " not found" << G4endl;
0253 }
0254 }
0255
0256
0257
0258 void DetectorConstruction::SetAbsorRadius(G4double value)
0259 {
0260 fAbsorRadius = value;
0261 G4RunManager::GetRunManager()->ReinitializeGeometry();
0262 }
0263
0264
0265
0266 void DetectorConstruction::SetAbsorLength(G4double value)
0267 {
0268 fAbsorLength = value;
0269 G4RunManager::GetRunManager()->ReinitializeGeometry();
0270 }
0271
0272
0273
0274 void DetectorConstruction::SetContainThickness(G4double value)
0275 {
0276 fContainThickness = value;
0277 G4RunManager::GetRunManager()->ReinitializeGeometry();
0278 }
0279
0280