File indexing completed on 2026-06-07 07:53:55
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 "G4PVPlacement.hh"
0038 #include "G4PhysicalConstants.hh"
0039 #include "G4PhysicalVolumeStore.hh"
0040 #include "G4SolidStore.hh"
0041 #include "G4SystemOfUnits.hh"
0042 #include "G4Tubs.hh"
0043 #include "G4UnitsTable.hh"
0044
0045
0046
0047 DetectorConstruction::DetectorConstruction()
0048 : fMaterial_World(0),
0049 fMaterial_Frame(0),
0050 fMaterial_ExitWindow(0),
0051 fMaterial_ScatterFoil(0),
0052 fMaterial_MonitorChbr(0),
0053 fMaterial_Bag(0),
0054 fMaterial_Gas(0),
0055 fMaterial_Ring(0),
0056 fPvol_World(0),
0057 fPvol_Frame(0),
0058 fDetectorMessenger(0)
0059 {
0060
0061 DefineMaterials();
0062
0063
0064 GeometryParameters();
0065
0066
0067 fDetectorMessenger = new DetectorMessenger(this);
0068 }
0069
0070
0071
0072 DetectorConstruction::~DetectorConstruction()
0073 {
0074 delete fDetectorMessenger;
0075 }
0076
0077
0078
0079 G4VPhysicalVolume* DetectorConstruction::Construct()
0080 {
0081 return ConstructVolumes();
0082 }
0083
0084
0085
0086 void DetectorConstruction::DefineMaterials()
0087 {
0088 G4double a, z, density;
0089 G4int ncomponents, natoms;
0090 G4double fractionmass;
0091 G4double temperature, pressure;
0092
0093
0094
0095 G4Element* H = new G4Element("Hydrogen", "H", z = 1, a = 1.0079 * g / mole);
0096 G4Element* He = new G4Element("Helium", "He", z = 2, a = 4.0026 * g / mole);
0097 G4Element* Be = new G4Element("Beryllium", "Be", z = 4, a = 9.1218 * g / mole);
0098 G4Element* C = new G4Element("Carbon", "C", z = 6, a = 12.0107 * g / mole);
0099 G4Element* N = new G4Element("Nitrogen", "N", z = 7, a = 14.0067 * g / mole);
0100 G4Element* O = new G4Element("Oxygen", "O", z = 8, a = 15.9994 * g / mole);
0101 G4Element* Al = new G4Element("Aluminium", "Al", z = 13, a = 26.9815 * g / mole);
0102 G4Element* Ar = new G4Element("Argon", "Ar", z = 18, a = 39.9480 * g / mole);
0103 G4Element* Ti = new G4Element("Titanium", "Ti", z = 22, a = 47.8670 * g / mole);
0104 G4Element* Va = new G4Element("Vanadium", "Va", z = 23, a = 50.9415 * g / mole);
0105 G4Element* Cu = new G4Element("Copper", "Cu", z = 29, a = 63.5460 * g / mole);
0106 G4Element* Ta = new G4Element("Tantalum", "Ta", z = 73, a = 180.9479 * g / mole);
0107 G4Element* Au = new G4Element("Gold", "Au", z = 79, a = 196.9666 * g / mole);
0108
0109
0110
0111 G4Material* Air = new G4Material("Air", density = 1.205 * mg / cm3, ncomponents = 4, kStateGas,
0112 293. * kelvin, 1. * atmosphere);
0113 Air->AddElement(C, fractionmass = 0.000124);
0114 Air->AddElement(N, fractionmass = 0.755267);
0115 Air->AddElement(O, fractionmass = 0.231782);
0116 Air->AddElement(Ar, fractionmass = 0.012827);
0117
0118
0119
0120 G4Material* Titanium = new G4Material("Titanium", density = 4.42 * g / cm3, ncomponents = 3);
0121 Titanium->AddElement(Ti, fractionmass = 0.90);
0122 Titanium->AddElement(Al, fractionmass = 0.06);
0123 Titanium->AddElement(Va, fractionmass = 0.04);
0124
0125
0126
0127 G4Material* Mylar = new G4Material("Mylar", density = 1.40 * g / cm3, ncomponents = 3);
0128 Mylar->AddElement(H, natoms = 4);
0129 Mylar->AddElement(C, natoms = 5);
0130 Mylar->AddElement(O, natoms = 2);
0131
0132
0133
0134 G4Material* Helium = new G4Material("Helium", density = 0.166 * mg / cm3, ncomponents = 1,
0135 kStateGas, 293. * kelvin, 1. * atmosphere);
0136 Helium->AddElement(He, fractionmass = 1.0);
0137
0138
0139
0140 G4Material* Aluminium = new G4Material("Aluminium", density = 2.7 * g / cm3, ncomponents = 1);
0141 Aluminium->AddElement(Al, fractionmass = 1.0);
0142
0143
0144
0145 G4Material* Beryllium = new G4Material("Beryllium", density = 1.85 * g / cm3, ncomponents = 1);
0146 Beryllium->AddElement(Be, fractionmass = 1.0);
0147
0148
0149
0150 G4Material* Graphite = new G4Material("Graphite", density = 2.18 * g / cm3, ncomponents = 1);
0151 Graphite->AddElement(C, fractionmass = 1.0);
0152
0153
0154
0155 G4Material* Copper = new G4Material("Copper", density = 8.92 * g / cm3, ncomponents = 1);
0156 Copper->AddElement(Cu, fractionmass = 1.0);
0157
0158
0159
0160 G4Material* Tantalum = new G4Material("Tantalum", density = 16.65 * g / cm3, ncomponents = 1);
0161 Tantalum->AddElement(Ta, fractionmass = 1.0);
0162
0163
0164
0165 G4Material* Gold = new G4Material("Gold", density = 19.30 * g / cm3, ncomponents = 1);
0166 Gold->AddElement(Au, fractionmass = 1.0);
0167
0168
0169
0170 density = universe_mean_density;
0171 pressure = 3.e-18 * pascal;
0172 temperature = 2.73 * kelvin;
0173 G4Material* Vacuum = new G4Material("Galactic", z = 1, a = 1.01 * g / mole, density, kStateGas,
0174 temperature, pressure);
0175
0176
0177
0178 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0179
0180
0181
0182 fMaterial_World = Vacuum;
0183 fMaterial_Frame = Air;
0184 fMaterial_ExitWindow = Titanium;
0185 fMaterial_ScatterFoil = fMaterial_Frame;
0186 fMaterial_MonitorChbr = Mylar;
0187 fMaterial_Bag = Mylar;
0188 fMaterial_Gas = Helium;
0189 fMaterial_Ring = Aluminium;
0190 }
0191
0192
0193
0194 void DetectorConstruction::GeometryParameters()
0195 {
0196 fZfront_ExitWindow = 0.0 * um;
0197 fThickness_ExitWindow = 41.2 * um;
0198
0199 fZfront_ScatterFoil = 2.65 * cm;
0200 fThickness_ScatterFoil = 0.0 * um;
0201
0202 fZfront_MonitorChbr = 50. * mm;
0203 fThickness_MonitorChbr = 112.7 * um;
0204
0205 fZfront_Bag = 64.975 * mm;
0206 fThickness_Bag = 110.0050 * cm;
0207
0208 fThickness_Gas = 110. * cm;
0209
0210 fThickness_Ring = 14. * mm;
0211 fInnerRadius_Ring = 20. * cm;
0212
0213 fZfront_Frame = 2.0 * um;
0214 fThickness_Frame = 118.2 * cm;
0215
0216 fThickness_World = fZfront_Frame + fThickness_Frame;
0217 fRadius_World = 23.3 * cm;
0218 }
0219
0220
0221
0222 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
0223 {
0224
0225
0226 G4GeometryManager::GetInstance()->OpenGeometry();
0227 G4PhysicalVolumeStore::GetInstance()->Clean();
0228 G4LogicalVolumeStore::GetInstance()->Clean();
0229 G4SolidStore::GetInstance()->Clean();
0230
0231
0232
0233 G4Tubs* svol_World = new G4Tubs("World",
0234 0 * cm, fRadius_World,
0235 0.5 * fThickness_World,
0236 0., twopi);
0237
0238 G4LogicalVolume* lvol_World = new G4LogicalVolume(svol_World,
0239 fMaterial_World,
0240 "World");
0241
0242 fPvol_World = new G4PVPlacement(0,
0243 G4ThreeVector(),
0244 lvol_World,
0245 "World",
0246 0,
0247 false,
0248 0);
0249
0250
0251
0252 G4Tubs* svol_Frame = new G4Tubs("Frame",
0253 0 * cm, fRadius_World,
0254 0.5 * fThickness_Frame,
0255 0., twopi);
0256
0257 G4LogicalVolume* lvol_Frame = new G4LogicalVolume(svol_Frame,
0258 fMaterial_Frame,
0259 "Frame");
0260
0261 G4double zpos = fZfront_Frame;
0262
0263 fPvol_Frame = new G4PVPlacement(0,
0264 G4ThreeVector(0, 0, zpos),
0265 lvol_Frame,
0266 "Frame",
0267 lvol_World,
0268 false,
0269 0);
0270
0271
0272
0273 G4Tubs* svol_ExitWindow = new G4Tubs("ExitWindow",
0274 0 * cm, fRadius_World,
0275 0.5 * fThickness_ExitWindow,
0276 0., twopi);
0277
0278 G4LogicalVolume* lvol_ExitWindow = new G4LogicalVolume(svol_ExitWindow,
0279 fMaterial_ExitWindow,
0280 "ExitWindow");
0281
0282 zpos = fZfront_ExitWindow + 0.5 * fThickness_ExitWindow - 0.5 * fThickness_Frame;
0283
0284 new G4PVPlacement(0,
0285 G4ThreeVector(0, 0, zpos),
0286 lvol_ExitWindow,
0287 "ExitWindow",
0288 lvol_Frame,
0289 false,
0290 0);
0291
0292
0293
0294 G4Tubs* svol_MonitorChbr = new G4Tubs("MonitorChbr",
0295 0 * cm, fRadius_World,
0296 0.5 * fThickness_MonitorChbr,
0297 0., twopi);
0298
0299 G4LogicalVolume* lvol_MonitorChbr = new G4LogicalVolume(svol_MonitorChbr,
0300 fMaterial_MonitorChbr,
0301 "MonitorChbr");
0302
0303 zpos = fZfront_MonitorChbr + 0.5 * fThickness_MonitorChbr - 0.5 * fThickness_Frame;
0304
0305 new G4PVPlacement(0,
0306 G4ThreeVector(0, 0, zpos),
0307 lvol_MonitorChbr,
0308 "MonitorChbr",
0309 lvol_Frame,
0310 false,
0311 0);
0312
0313
0314
0315 G4Tubs* svol_Bag = new G4Tubs("Bag",
0316 0 * cm, fRadius_World,
0317 0.5 * fThickness_Bag,
0318 0., twopi);
0319
0320 G4LogicalVolume* lvol_Bag = new G4LogicalVolume(svol_Bag,
0321 fMaterial_Bag,
0322 "Bag");
0323
0324 zpos = fZfront_Bag + 0.5 * fThickness_Bag - 0.5 * fThickness_Frame;
0325
0326 new G4PVPlacement(0,
0327 G4ThreeVector(0, 0, zpos),
0328 lvol_Bag,
0329 "Bag",
0330 lvol_Frame,
0331 false,
0332 0);
0333
0334
0335
0336 G4Tubs* svol_Gas = new G4Tubs("Gas",
0337 0 * cm, fRadius_World,
0338 0.5 * fThickness_Gas,
0339 0., twopi);
0340
0341 G4LogicalVolume* lvol_Gas = new G4LogicalVolume(svol_Gas,
0342 fMaterial_Gas,
0343 "Gas");
0344
0345 new G4PVPlacement(0,
0346 G4ThreeVector(),
0347 lvol_Gas,
0348 "Gas",
0349 lvol_Bag,
0350 false,
0351 0);
0352
0353
0354
0355 G4Tubs* svol_Ring = new G4Tubs("Ring",
0356 fInnerRadius_Ring, fRadius_World,
0357 0.5 * fThickness_Ring,
0358 0., twopi);
0359
0360 G4LogicalVolume* lvol_Ring = new G4LogicalVolume(svol_Ring,
0361 fMaterial_Ring,
0362 "Ring");
0363
0364 zpos = 0.5 * (fThickness_Gas - fThickness_Ring);
0365
0366 new G4PVPlacement(0,
0367 G4ThreeVector(0, 0, zpos),
0368 lvol_Ring,
0369 "Ring",
0370 lvol_Gas,
0371 false,
0372 1);
0373
0374 new G4PVPlacement(0,
0375 G4ThreeVector(0, 0, -zpos),
0376 lvol_Ring,
0377 "Ring",
0378 lvol_Gas,
0379 false,
0380 2);
0381
0382
0383
0384 if ((fMaterial_ScatterFoil != fMaterial_Frame) && (fThickness_ScatterFoil > 0.)) {
0385 G4Tubs* svol_ScatterFoil = new G4Tubs("ScatterFoil",
0386 0 * cm, fRadius_World,
0387 0.5 * fThickness_ScatterFoil,
0388 0., twopi);
0389
0390 G4LogicalVolume* lvol_ScatterFoil = new G4LogicalVolume(svol_ScatterFoil,
0391 fMaterial_ScatterFoil,
0392 "ScatterFoil");
0393
0394 zpos = fZfront_ScatterFoil + 0.5 * fThickness_ScatterFoil - 0.5 * fThickness_Frame;
0395
0396 new G4PVPlacement(0,
0397 G4ThreeVector(0, 0, zpos),
0398 lvol_ScatterFoil,
0399 "ScatterFoil",
0400 lvol_Frame,
0401 false,
0402 0);
0403 }
0404
0405 PrintGeometry();
0406
0407
0408
0409 return fPvol_World;
0410 }
0411
0412
0413
0414 void DetectorConstruction::PrintGeometry()
0415 {
0416
0417 std::ios::fmtflags mode = G4cout.flags();
0418 G4cout.setf(std::ios::fixed, std::ios::floatfield);
0419 G4int prec = G4cout.precision(6);
0420
0421 G4cout << "\n \t \t"
0422 << "Material \t"
0423 << "Z_front \t"
0424 << "Thickness \n";
0425
0426 G4cout << "\n ExitWindow \t" << fMaterial_ExitWindow->GetName() << "\t"
0427 << G4BestUnit(fZfront_ExitWindow, "Length") << "\t"
0428 << G4BestUnit(fThickness_ExitWindow, "Length");
0429
0430 if (fMaterial_ScatterFoil != fMaterial_Frame) {
0431 G4cout << "\n ScatterFoil \t" << fMaterial_ScatterFoil->GetName() << "\t"
0432 << "\t" << G4BestUnit(fZfront_ScatterFoil, "Length") << "\t"
0433 << G4BestUnit(fThickness_ScatterFoil, "Length");
0434 }
0435
0436 G4cout << "\n MonitorChbr \t" << fMaterial_MonitorChbr->GetName() << "\t"
0437 << "\t" << G4BestUnit(fZfront_MonitorChbr, "Length") << "\t"
0438 << G4BestUnit(fThickness_MonitorChbr, "Length");
0439
0440 G4double thickBagWindow = 0.5 * (fThickness_Bag - fThickness_Gas);
0441 G4double zfrontGas = fZfront_Bag + thickBagWindow;
0442 G4double zfrontBagWindow2 = zfrontGas + fThickness_Gas;
0443
0444 G4cout << "\n BagWindow1 \t" << fMaterial_Bag->GetName() << "\t"
0445 << "\t" << G4BestUnit(fZfront_Bag, "Length") << "\t"
0446 << G4BestUnit(thickBagWindow, "Length");
0447
0448 G4cout << "\n Gas \t" << fMaterial_Gas->GetName() << "\t"
0449 << "\t" << G4BestUnit(zfrontGas, "Length") << "\t" << G4BestUnit(fThickness_Gas, "Length");
0450
0451 G4cout << "\n BagWindow2 \t" << fMaterial_Bag->GetName() << "\t"
0452 << "\t" << G4BestUnit(zfrontBagWindow2, "Length") << "\t"
0453 << G4BestUnit(thickBagWindow, "Length");
0454
0455 G4cout << "\n ScoringPlane \t" << fMaterial_Frame->GetName() << "\t"
0456 << "\t" << G4BestUnit(fThickness_Frame, "Length") << "\n"
0457 << G4endl;
0458
0459
0460 G4cout.setf(mode, std::ios::floatfield);
0461 G4cout.precision(prec);
0462 }
0463
0464
0465
0466 void DetectorConstruction::SetMaterialScatter(G4String material)
0467 {
0468
0469 G4Material* pMaterial = G4Material::GetMaterial(material);
0470
0471 if (pMaterial) fMaterial_ScatterFoil = pMaterial;
0472 }
0473
0474
0475
0476 void DetectorConstruction::SetThicknessScatter(G4double val)
0477 {
0478 fThickness_ScatterFoil = val;
0479 }
0480
0481
0482
0483 #include "G4RunManager.hh"
0484
0485 void DetectorConstruction::UpdateGeometry()
0486 {
0487 G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
0488 }
0489
0490