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