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