File indexing completed on 2026-09-14 08:28:58
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 "ExGflash2DetectorConstruction.hh"
0036
0037 #include "ExGflash2SensitiveDetector.hh"
0038
0039
0040 #include "G4AutoDelete.hh"
0041 #include "G4Box.hh"
0042 #include "G4Colour.hh"
0043 #include "G4LogicalVolume.hh"
0044 #include "G4Material.hh"
0045 #include "G4NistManager.hh"
0046 #include "G4PVPlacement.hh"
0047 #include "G4SDManager.hh"
0048 #include "G4SystemOfUnits.hh"
0049 #include "G4ThreeVector.hh"
0050 #include "G4VPhysicalVolume.hh"
0051 #include "G4VisAttributes.hh"
0052 #include "globals.hh"
0053
0054
0055
0056 ExGflash2DetectorConstruction::ExGflash2DetectorConstruction()
0057 {
0058 G4cout << "ExGflash2DetectorConstruction::Detector constructor" << G4endl;
0059 }
0060
0061
0062
0063 ExGflash2DetectorConstruction::~ExGflash2DetectorConstruction() = default;
0064
0065
0066
0067 G4VPhysicalVolume* ExGflash2DetectorConstruction::Construct()
0068 {
0069
0070 G4cout << "Defining the materials" << G4endl;
0071
0072 G4NistManager* nistManager = G4NistManager::Instance();
0073
0074 G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
0075 G4Material* pbWO4 = nistManager->FindOrBuildMaterial("G4_PbWO4");
0076
0077
0078
0079
0080 G4double experimentalHall_x = 1000. * cm;
0081 G4double experimentalHall_y = 1000. * cm;
0082 G4double experimentalHall_z = 1000. * cm;
0083
0084 G4VSolid* experimentalHall_box = new G4Box("expHall_box",
0085 experimentalHall_x,
0086 experimentalHall_y,
0087 experimentalHall_z);
0088
0089 auto experimentalHallLog = new G4LogicalVolume(experimentalHall_box, air, "expHallLog",
0090 nullptr,
0091 nullptr,
0092 nullptr);
0093 G4VPhysicalVolume* experimentalHallPhys =
0094 new G4PVPlacement(nullptr,
0095 G4ThreeVector(),
0096 "expHall", experimentalHallLog, nullptr, false, 0);
0097
0098
0099
0100
0101
0102
0103 G4int nbOfCrystals = 10;
0104
0105
0106
0107
0108
0109
0110 G4double calo_xside = 31 * cm;
0111 G4double calo_yside = 31 * cm;
0112 G4double calo_zside = 24 * cm;
0113
0114 G4double crystalWidth = 3 * cm;
0115 G4double crystalLength = 24 * cm;
0116
0117 calo_xside = (crystalWidth * nbOfCrystals) + 1 * cm;
0118 calo_yside = (crystalWidth * nbOfCrystals) + 1 * cm;
0119 calo_zside = crystalLength;
0120
0121 auto calo_box = new G4Box("CMS calorimeter",
0122 calo_xside / 2.,
0123 calo_yside / 2., calo_zside / 2.);
0124 auto caloLog = new G4LogicalVolume(calo_box,
0125 air,
0126 "calo log",
0127 nullptr,
0128 nullptr,
0129 nullptr);
0130
0131 G4double xpos = 0.0;
0132 G4double ypos = 0.0;
0133 G4double zpos = 100.0 * cm;
0134 new G4PVPlacement(nullptr, G4ThreeVector(xpos, ypos, zpos), caloLog, "calorimeter",
0135 experimentalHallLog, false, 1);
0136
0137
0138 G4VSolid* crystal_box = new G4Box("Crystal",
0139 crystalWidth / 2, crystalWidth / 2, crystalLength / 2);
0140
0141 fCrystalLog = new G4LogicalVolume(crystal_box,
0142 pbWO4,
0143 "CrystalLog");
0144
0145 for (G4int i = 0; i < nbOfCrystals; i++) {
0146 for (G4int j = 0; j < nbOfCrystals; j++) {
0147 G4int n = i * 10 + j;
0148 G4ThreeVector crystalPos((i * crystalWidth) - 135, (j * crystalWidth) - 135, 0);
0149 fCrystalPhys[n] = new G4PVPlacement(nullptr,
0150 crystalPos,
0151 fCrystalLog,
0152 "crystal",
0153 caloLog, false, i);
0154 }
0155 }
0156 G4cout << "There are " << nbOfCrystals << " crystals per row in the calorimeter, so in total "
0157 << nbOfCrystals * nbOfCrystals << " crystals" << G4endl;
0158 G4cout << "They have width of " << crystalWidth / cm << " cm and a length of "
0159 << crystalLength / cm << " cm. The Material is " << pbWO4 << G4endl;
0160
0161 experimentalHallLog->SetVisAttributes(G4VisAttributes::GetInvisible());
0162 auto caloVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0163 auto crystalVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0));
0164 caloLog->SetVisAttributes(caloVisAtt);
0165 fCrystalLog->SetVisAttributes(crystalVisAtt);
0166
0167
0168
0169 return experimentalHallPhys;
0170 }
0171
0172
0173
0174 void ExGflash2DetectorConstruction::ConstructSDandField()
0175 {
0176
0177 G4SDManager* SDman = G4SDManager::GetSDMpointer();
0178 auto CaloSD = new ExGflash2SensitiveDetector("Calorimeter", this);
0179 SDman->AddNewDetector(CaloSD);
0180 fCrystalLog->SetSensitiveDetector(CaloSD);
0181
0182
0183 }
0184
0185