File indexing completed on 2026-05-03 07:45:12
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 #include "ExGflash3ParallelWorld.hh"
0031
0032 #include "ExGflash3SensitiveDetector.hh"
0033
0034
0035 #include "G4AutoDelete.hh"
0036 #include "G4Box.hh"
0037 #include "G4Colour.hh"
0038 #include "G4LogicalVolume.hh"
0039 #include "G4Material.hh"
0040 #include "G4NistManager.hh"
0041 #include "G4PVPlacement.hh"
0042 #include "G4SDManager.hh"
0043 #include "G4SystemOfUnits.hh"
0044 #include "G4ThreeVector.hh"
0045 #include "G4VPhysicalVolume.hh"
0046 #include "G4VisAttributes.hh"
0047 #include "globals.hh"
0048
0049
0050
0051 ExGflash3ParallelWorld::ExGflash3ParallelWorld(G4String aWorldName)
0052 : G4VUserParallelWorld(aWorldName)
0053 {
0054 G4cout << "ExGflash3ParallelWorld::Parralel world constructor" << G4endl;
0055 }
0056
0057
0058
0059 ExGflash3ParallelWorld::~ExGflash3ParallelWorld() = default;
0060
0061
0062
0063 void ExGflash3ParallelWorld::Construct()
0064 {
0065
0066 G4Material* dummy = nullptr;
0067
0068
0069 auto ghostLogicalVolume = GetWorld()->GetLogicalVolume();
0070
0071
0072
0073 G4int nbOfCrystals = 10;
0074
0075
0076
0077
0078
0079
0080 G4double calo_xside = 31 * cm;
0081 G4double calo_yside = 31 * cm;
0082 G4double calo_zside = 24 * cm;
0083
0084 G4double crystalWidth = 3 * cm;
0085 G4double crystalLength = 24 * cm;
0086
0087 calo_xside = (crystalWidth * nbOfCrystals) + 1 * cm;
0088 calo_yside = (crystalWidth * nbOfCrystals) + 1 * cm;
0089 calo_zside = crystalLength;
0090
0091 auto calo_box = new G4Box("CMS calorimeter",
0092 calo_xside / 2.,
0093 calo_yside / 2., calo_zside / 2.);
0094 auto caloLog = new G4LogicalVolume(calo_box,
0095 dummy,
0096 "calo log",
0097 nullptr,
0098 nullptr,
0099 nullptr);
0100
0101 G4double xpos = 0.0;
0102 G4double ypos = 0.0;
0103 G4double zpos = 100.0 * cm;
0104 new G4PVPlacement(nullptr, G4ThreeVector(xpos, ypos, zpos), caloLog, "calorimeter",
0105 ghostLogicalVolume, false, 1);
0106
0107
0108 G4VSolid* crystal_box = new G4Box("Crystal",
0109 crystalWidth / 2, crystalWidth / 2, crystalLength / 2);
0110
0111 fCrystalLog = new G4LogicalVolume(crystal_box,
0112 dummy,
0113 "CrystalLog");
0114
0115 for (G4int i = 0; i < nbOfCrystals; i++) {
0116 for (G4int j = 0; j < nbOfCrystals; j++) {
0117 G4int n = i * 10 + j;
0118 G4ThreeVector crystalPos((i * crystalWidth) - 135, (j * crystalWidth) - 135, 0);
0119 fCrystalPhys[n] = new G4PVPlacement(nullptr,
0120 crystalPos,
0121 fCrystalLog,
0122 "crystal",
0123 caloLog, false, i);
0124 }
0125 }
0126 G4cout << "There are " << nbOfCrystals << " crystals per row in the calorimeter, so in total "
0127 << nbOfCrystals * nbOfCrystals << " crystals" << G4endl;
0128 G4cout << "They have width of " << crystalWidth / cm << " cm and a length of "
0129 << crystalLength / cm << " cm. " << G4endl;
0130
0131 auto caloVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0132 auto crystalVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0));
0133 caloLog->SetVisAttributes(caloVisAtt);
0134 fCrystalLog->SetVisAttributes(crystalVisAtt);
0135 }
0136
0137
0138
0139 void ExGflash3ParallelWorld::ConstructSD()
0140 {
0141
0142 G4SDManager* SDman = G4SDManager::GetSDMpointer();
0143 auto CaloSD = new ExGflash3SensitiveDetector("Calorimeter", this);
0144 SDman->AddNewDetector(CaloSD);
0145 fCrystalLog->SetSensitiveDetector(CaloSD);
0146 }
0147
0148