File indexing completed on 2025-02-23 09:22:36
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
0035 #include "G02DetectorConstruction.hh"
0036
0037
0038
0039 #include "G4GeometryManager.hh"
0040 #include "G4VisAttributes.hh"
0041 #include "globals.hh"
0042
0043
0044
0045 #include "G4Material.hh"
0046
0047
0048
0049 #include "G4Box.hh"
0050 #include "G4LogicalVolume.hh"
0051 #include "G4PVParameterised.hh"
0052 #include "G4PVPlacement.hh"
0053 #include "G4Tubs.hh"
0054 #include "G4VPhysicalVolume.hh"
0055
0056
0057
0058 #include "G4AffineTransform.hh"
0059 #include "G4DisplacedSolid.hh"
0060 #include "G4ReflectedSolid.hh"
0061 #include "G4ReflectionFactory.hh"
0062 #include "G4RotationMatrix.hh"
0063 #include "G4Transform3D.hh"
0064
0065
0066
0067 #include "G4AssemblyVolume.hh"
0068
0069
0070
0071 #include "G02ChamberParameterisation.hh"
0072
0073
0074
0075 #include "G02DetectorMessenger.hh"
0076
0077
0078
0079 #include "G4GDMLParser.hh"
0080 #include "G4PhysicalConstants.hh"
0081 #include "G4SystemOfUnits.hh"
0082
0083
0084
0085
0086
0087 G02DetectorConstruction::G02DetectorConstruction()
0088 : G4VUserDetectorConstruction(), fAir(0), fAluminum(0), fPb(0), fXenon(0), fDetectorMessenger(0)
0089 {
0090 fExpHall_x = 5. * m;
0091
0092 fReadFile = "test.gdml";
0093 fWriteFile = "wtest.gdml";
0094 fStepFile = "mbb";
0095 fWritingChoice = 1;
0096
0097 fDetectorMessenger = new G02DetectorMessenger(this);
0098 }
0099
0100
0101
0102
0103
0104 G02DetectorConstruction::~G02DetectorConstruction()
0105 {
0106 if (fDetectorMessenger) delete fDetectorMessenger;
0107 }
0108
0109
0110
0111
0112
0113 G4VPhysicalVolume* G02DetectorConstruction::Construct()
0114 {
0115
0116
0117 G4VPhysicalVolume* fWorldPhysVol;
0118
0119 if (fWritingChoice == 0) {
0120
0121
0122
0123
0124
0125
0126
0127
0128 fParser.Read(fReadFile);
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0139
0140
0141
0142 fWorldPhysVol = fParser.GetWorldVolume();
0143 }
0144 else if (fWritingChoice == 1) {
0145
0146
0147
0148 ListOfMaterials();
0149 fWorldPhysVol = ConstructDetector();
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182 fParser.Write(fWriteFile, fWorldPhysVol);
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197 }
0198 else
0199 {
0200
0201
0202 ListOfMaterials();
0203
0204
0205
0206 const G4double expHall_y = fExpHall_x / 50.;
0207 const G4double expHall_z = fExpHall_x / 50.;
0208
0209
0210
0211 G4Box* experimentalHallBox = new G4Box("ExpHallBox", fExpHall_x / 50., expHall_y, expHall_z);
0212 G4LogicalVolume* experimentalHallLV =
0213 new G4LogicalVolume(experimentalHallBox, fAir, "ExpHallLV");
0214 fWorldPhysVol = new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, 0.0), experimentalHallLV,
0215 "ExpHallPhys", 0, false, 0);
0216
0217
0218
0219 G4LogicalVolume* LogicalVolST = fParser.ParseST(fStepFile, fAir, fAluminum);
0220
0221
0222
0223 new G4PVPlacement(0, G4ThreeVector(10.0, 0.0, 0.0), LogicalVolST, "StepPhys",
0224 experimentalHallLV, false, 0);
0225 }
0226
0227
0228
0229 G4VisAttributes* BoxVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0230 fWorldPhysVol->GetLogicalVolume()->SetVisAttributes(BoxVisAtt);
0231
0232 return fWorldPhysVol;
0233 }
0234
0235
0236
0237
0238
0239 void G02DetectorConstruction::ListOfMaterials()
0240 {
0241 G4double a;
0242 G4double z;
0243 G4double density, temperature, pressure;
0244 G4double fractionmass;
0245 G4String name, symbol;
0246 G4int ncomponents;
0247
0248
0249
0250 a = 14.01 * g / mole;
0251 G4Element* elN = new G4Element(name = "Nitrogen", symbol = "N", z = 7., a);
0252
0253 a = 16.00 * g / mole;
0254 G4Element* elO = new G4Element(name = "Oxygen", symbol = "O", z = 8., a);
0255
0256 a = 26.98 * g / mole;
0257 G4Element* elAl = new G4Element(name = "Aluminum", symbol = "Al", z = 13., a);
0258
0259
0260
0261 G4cout << *(G4Element::GetElementTable()) << G4endl;
0262
0263
0264
0265 density = 1.29 * mg / cm3;
0266 fAir = new G4Material(name = "Air", density, ncomponents = 2);
0267 fAir->AddElement(elN, fractionmass = 0.7);
0268 fAir->AddElement(elO, fractionmass = 0.3);
0269
0270
0271
0272 density = 2.70 * g / cm3;
0273 fAluminum = new G4Material(name = "Aluminum", density, ncomponents = 1);
0274 fAluminum->AddElement(elAl, fractionmass = 1.0);
0275
0276
0277
0278 fPb = new G4Material("Lead", z = 82., a = 207.19 * g / mole, density = 11.35 * g / cm3);
0279
0280
0281
0282 fXenon = new G4Material("XenonGas", z = 54., a = 131.29 * g / mole, density = 5.458 * mg / cm3,
0283 kStateGas, temperature = 293.15 * kelvin, pressure = 1 * atmosphere);
0284
0285
0286
0287 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0288 }
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298 G4VPhysicalVolume* G02DetectorConstruction::ConstructDetector()
0299 {
0300
0301
0302 const G4double expHall_y = fExpHall_x;
0303 const G4double expHall_z = fExpHall_x;
0304
0305
0306
0307 G4Box* experimentalHallBox = new G4Box("ExpHallBox", fExpHall_x, expHall_y, expHall_z);
0308 G4LogicalVolume* experimentalHallLV = new G4LogicalVolume(experimentalHallBox, fAir, "ExpHallLV");
0309 G4PVPlacement* experimentalHallPhys = new G4PVPlacement(
0310 0, G4ThreeVector(0.0, 0.0, 0.0), experimentalHallLV, "ExpHallPhys", 0, false, 0);
0311
0312
0313
0314 const G4double det_x = fExpHall_x * 0.8;
0315 const G4double det_y = fExpHall_x * 0.7;
0316 const G4double det_z = det_y;
0317
0318
0319
0320 G4Box* detectorBox = new G4Box("detectorBox", det_x, det_y, det_z);
0321 G4LogicalVolume* detectorLV = new G4LogicalVolume(detectorBox, fAir, "detLV");
0322
0323 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, 0.0), detectorLV, "detPhys", experimentalHallLV,
0324 false, 0);
0325
0326
0327
0328 const G4double room_x = fExpHall_x / 20.;
0329 const G4double room_y = room_x;
0330 const G4double room_z = room_x;
0331
0332 G4Box* roomBox = new G4Box("roomBox", room_x, room_y, room_z);
0333 G4LogicalVolume* roomLV = new G4LogicalVolume(roomBox, fAir, "roomLV");
0334
0335 new G4PVPlacement(0, G4ThreeVector(fExpHall_x - room_x - 10., 0.0, 0.0), roomLV, "roomPhys",
0336 experimentalHallLV, false, 0);
0337
0338
0339
0340 const G4double bigL = fExpHall_x / 5. + 50.;
0341 G4LogicalVolume* subDetectorLV1 = ConstructSubDetector1();
0342
0343 new G4PVPlacement(0, G4ThreeVector(bigL, 0.0, 0.0), subDetectorLV1, "PhysSubDetector1",
0344 detectorLV, false, 0);
0345
0346
0347
0348
0349
0350
0351
0352 G4Translate3D translation(-bigL, 0., 0.);
0353 G4RotationMatrix* rotD3 = new G4RotationMatrix();
0354 G4Transform3D rotation = G4Rotate3D(*rotD3);
0355 G4ReflectX3D reflection;
0356 G4Transform3D transform = translation * rotation * reflection;
0357
0358
0359
0360 G4ReflectionFactory::Instance()->Place(transform, "reflSubDetector", subDetectorLV1, detectorLV,
0361 false, 0);
0362
0363
0364
0365 G4LogicalVolume* subDetectorLV3 = ConstructSubDetector2();
0366
0367 new G4PVPlacement(0, G4ThreeVector(0.0, bigL, 0.0), subDetectorLV3, "PhysSubDetectorFirst3",
0368 detectorLV, false, 0);
0369
0370
0371
0372 G4LogicalVolume* subDetectorLV4 = ConstructSubDetector2();
0373 G4LogicalVolume* subChamberLV = ConstructParametrisationChamber();
0374
0375 new G4PVPlacement(0, G4ThreeVector(0, 0.0, 0.0), subChamberLV, "AssemblyPhys", subDetectorLV4,
0376 false, 0);
0377
0378 new G4PVPlacement(0, G4ThreeVector(0.0, -bigL, 0.0), subDetectorLV4, "PhysSubDetectorSecond3",
0379 detectorLV, false, 0);
0380
0381 return experimentalHallPhys;
0382 }
0383
0384
0385
0386
0387
0388 G4LogicalVolume* G02DetectorConstruction::ConstructSubDetector1()
0389 {
0390 const G4double sub_x = fExpHall_x / 5.;
0391 const G4double sub_y = sub_x;
0392
0393
0394
0395 G4Tubs* subTub = new G4Tubs("subTub", 0., sub_x, sub_y, -90. * deg, 180 * deg);
0396 G4LogicalVolume* subTubLV = new G4LogicalVolume(subTub, fPb, "tubLV");
0397 G4LogicalVolume* AssemblyLV = ConstructAssembly();
0398
0399 new G4PVPlacement(0, G4ThreeVector(sub_x / 3, 0.0, 0.0), AssemblyLV, "AssemblyPhys", subTubLV,
0400 false, 0);
0401 return subTubLV;
0402 }
0403
0404
0405
0406
0407
0408 G4LogicalVolume* G02DetectorConstruction::ConstructSubDetector2()
0409 {
0410 const G4double sub_x = fExpHall_x / 10.;
0411 const G4double sub_y = sub_x * 2.;
0412 const G4double sub_z = sub_x;
0413
0414
0415
0416 G4Box* detHallBox = new G4Box("detHallBox", sub_x, sub_y, sub_z);
0417 G4LogicalVolume* detHallLV = new G4LogicalVolume(detHallBox, fAluminum, "detHallLV");
0418
0419 return detHallLV;
0420 }
0421
0422
0423
0424
0425
0426 G4LogicalVolume* G02DetectorConstruction::ConstructAssembly()
0427 {
0428 const G4double big_x = fExpHall_x / 17;
0429 const G4double big_y = big_x;
0430 const G4double big_z = big_x;
0431
0432
0433
0434 G4Box* OuterBox = new G4Box("OuterBox", big_x, big_y, big_z);
0435 G4LogicalVolume* OuterBoxLV = new G4LogicalVolume(OuterBox, fAir, "OuterBoxLV");
0436
0437 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, 0.0), OuterBoxLV, "OuterBoxPhys", 0, false, 0);
0438
0439
0440
0441 const G4double bigL = big_x / 2.5;
0442 const G4double medL = big_x / 8;
0443 const G4double smalL = big_x / 12;
0444
0445 G4Box* BigBox = new G4Box("BBox", bigL, bigL, bigL);
0446 G4LogicalVolume* BigBoxLV = new G4LogicalVolume(BigBox, fAluminum, "AlBigBoxLV");
0447 G4Box* MedBox = new G4Box("MBox", medL, medL, medL);
0448 G4LogicalVolume* MedBoxLV1 = new G4LogicalVolume(MedBox, fAluminum, "AlMedBoxLV1");
0449 G4Box* SmallBox = new G4Box("SBox", smalL, smalL, smalL);
0450 G4LogicalVolume* SmallBoxLV = new G4LogicalVolume(SmallBox, fAluminum, "AlSmaBoxLV");
0451
0452 const G4double bigPlace = bigL + 10.;
0453 const G4double medPlace = medL + 10.;
0454
0455 new G4PVPlacement(0, G4ThreeVector(bigPlace, 0.0, 0.0), BigBoxLV, "AlPhysBig", OuterBoxLV, false,
0456 0);
0457
0458
0459
0460 G4Tubs* BigTube = new G4Tubs("BTube", 0, smalL, smalL, -pi / 2., pi);
0461
0462
0463
0464 G4ReflectX3D Xreflection;
0465 G4Translate3D translation(-bigPlace, 0., 0.);
0466 G4Transform3D transform = Xreflection;
0467
0468 G4ReflectedSolid* ReflBig = new G4ReflectedSolid("Refll_Big", BigTube, transform);
0469 G4LogicalVolume* ReflBigLV = new G4LogicalVolume(ReflBig, fXenon, "ReflBigAl");
0470 new G4PVPlacement(0, G4ThreeVector(0., 0.0, 0.0), ReflBigLV, "AlPhysBigTube", SmallBoxLV, false,
0471 0);
0472
0473
0474
0475
0476
0477
0478 G4AssemblyVolume* assembly = new G4AssemblyVolume();
0479 G4RotationMatrix* rot = new G4RotationMatrix();
0480 G4ThreeVector posBig(-bigPlace, 0, 0);
0481 G4ThreeVector posBig0(bigPlace / 4, 0, 0);
0482 G4ThreeVector posMed(-medPlace, 0, 0);
0483 G4ThreeVector posMed0(medPlace, 0, 0);
0484 G4ThreeVector position(0., 0., 0.);
0485
0486
0487
0488 assembly->AddPlacedVolume(MedBoxLV1, posMed0, rot);
0489
0490
0491
0492 assembly->AddPlacedVolume(SmallBoxLV, posMed, rot);
0493
0494
0495
0496 assembly->MakeImprint(BigBoxLV, posBig0, rot, 0);
0497
0498
0499
0500
0501
0502 G4Translate3D translation1(-bigPlace, 0., 0.);
0503 G4RotationMatrix* rotD3 = new G4RotationMatrix();
0504 G4Transform3D rotation = G4Rotate3D(*rotD3);
0505 G4ReflectX3D reflection;
0506 G4Transform3D transform1 = translation1 * rotation * reflection;
0507
0508 assembly->MakeImprint(OuterBoxLV, transform1, 0, 0);
0509
0510 return OuterBoxLV;
0511 }
0512
0513
0514
0515
0516
0517 G4LogicalVolume* G02DetectorConstruction::ConstructParametrisationChamber()
0518 {
0519 const G4double chamber_x = fExpHall_x / 12.;
0520 const G4double chamber_y = chamber_x;
0521 const G4double chamber_z = chamber_x;
0522
0523
0524
0525 G4Box* paramChamberBox = new G4Box("ChamberBox", chamber_x, chamber_y, chamber_z);
0526 G4LogicalVolume* paramChamberLV = new G4LogicalVolume(paramChamberBox, fAir, "ChamberLV");
0527
0528
0529
0530 G4int NbOfChambers = 5;
0531 G4double ChamberWidth = 2 * cm;
0532 G4double ChamberSpacing = 8 * cm;
0533 G4double fTrackerLength = (NbOfChambers + 1) * ChamberSpacing;
0534 G4double trackerSize = 0.5 * fTrackerLength;
0535
0536
0537
0538
0539 G4Box* solidChamber = new G4Box("chamber", 10 * cm, 10 * cm, 1 * cm);
0540 G4LogicalVolume* logicChamber = new G4LogicalVolume(solidChamber, fAluminum, "Chamber", 0, 0, 0);
0541
0542 G4double firstPosition = -trackerSize + 0.5 * ChamberWidth;
0543 G4double firstLength = fTrackerLength / 10;
0544 G4double lastLength = fTrackerLength;
0545
0546 G4VPVParameterisation* chamberParam =
0547 new G02ChamberParameterisation(NbOfChambers,
0548 firstPosition,
0549 ChamberSpacing,
0550 ChamberWidth,
0551 firstLength,
0552 lastLength);
0553
0554 new G4PVParameterised("Chamber",
0555 logicChamber,
0556 paramChamberLV,
0557 kZAxis,
0558 NbOfChambers,
0559 chamberParam);
0560 return paramChamberLV;
0561 }
0562
0563
0564
0565
0566
0567 void G02DetectorConstruction::SetReadFile(const G4String& File)
0568 {
0569 fReadFile = File;
0570 fWritingChoice = 0;
0571 }
0572
0573
0574
0575
0576
0577 void G02DetectorConstruction::SetWriteFile(const G4String& File)
0578 {
0579 fWriteFile = File;
0580 fWritingChoice = 1;
0581 }
0582
0583
0584
0585
0586
0587 void G02DetectorConstruction::SetStepFile(const G4String& File)
0588 {
0589 fStepFile = File;
0590 fWritingChoice = 3;
0591 }