File indexing completed on 2025-01-31 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
0034
0035
0036
0037 #include <vector>
0038
0039 #include "GammaRayTelAnticoincidenceHit.hh"
0040 #include "GammaRayTelCalorimeterHit.hh"
0041 #include "GammaRayTelDigi.hh"
0042 #include "GammaRayTelDigitizer.hh"
0043 #include "GammaRayTelDigitizerMessenger.hh"
0044 #include "GammaRayTelTrackerHit.hh"
0045
0046 #include "G4DigiManager.hh"
0047 #include "G4Event.hh"
0048 #include "G4EventManager.hh"
0049 #include "G4ios.hh"
0050 #include "G4SDManager.hh"
0051 #include "G4SystemOfUnits.hh"
0052
0053
0054
0055 GammaRayTelDigitizer::GammaRayTelDigitizer(G4String name) : G4VDigitizerModule(name) {
0056 constexpr auto DIGIT_COLLECTION_NAME{"DigitsCollection"};
0057 collectionName.push_back(DIGIT_COLLECTION_NAME);
0058
0059
0060 digitizerMessenger = new GammaRayTelDigitizerMessenger(this);
0061 }
0062
0063
0064
0065 GammaRayTelDigitizer::~GammaRayTelDigitizer() {
0066 delete digitizerMessenger;
0067 }
0068
0069
0070
0071 void GammaRayTelDigitizer::Digitize() {
0072 digitsCollection = new GammaRayTelDigitsCollection("GammaRayTelDigitizer", "DigitsCollection");
0073
0074 auto *digitManager = G4DigiManager::GetDMpointer();
0075
0076 G4int trackerCollectionIdentifier{0};
0077 G4int calorimeterCollectionIdentifier{0};
0078 G4int anticoincidenceCollectionIdentifier{0};
0079
0080 totalEnergy = 0.;
0081
0082
0083
0084 trackerCollectionIdentifier = digitManager->GetHitsCollectionID("TrackerCollection");
0085 GammaRayTelTrackerHitsCollection *trackerCollection{nullptr};
0086 trackerCollection = (GammaRayTelTrackerHitsCollection*) (digitManager->GetHitsCollection(trackerCollectionIdentifier));
0087
0088
0089
0090 calorimeterCollectionIdentifier = digitManager->GetHitsCollectionID("CalorimeterCollection");
0091 GammaRayTelCalorimeterHitsCollection *calorimeterCollection{nullptr};
0092 calorimeterCollection = (GammaRayTelCalorimeterHitsCollection*) (digitManager->GetHitsCollection(calorimeterCollectionIdentifier));
0093
0094
0095
0096 anticoincidenceCollectionIdentifier = digitManager->GetHitsCollectionID("AnticoincidenceCollection");
0097 GammaRayTelAnticoincidenceHitsCollection *anticoincidenceCollection{nullptr};
0098 anticoincidenceCollection = (GammaRayTelAnticoincidenceHitsCollection*) (digitManager->GetHitsCollection(anticoincidenceCollectionIdentifier));
0099
0100 if (trackerCollection != nullptr) {
0101 G4int numberOfHits = trackerCollection->entries();
0102
0103 for (auto i = 0; i < numberOfHits; i++) {
0104 G4double depositedEnergy = (*trackerCollection)[i]->GetDepositedEnergy();
0105 G4int stripNumber = (*trackerCollection)[i]->GetStripNumber();
0106 G4int planeNumber = (*trackerCollection)[i]->GetSiliconPlaneNumber();
0107 G4int IsX = (*trackerCollection)[i]->GetPlaneType();
0108
0109
0110
0111 if (depositedEnergy > energyThreshold) {
0112 auto *digit = new GammaRayTelDigi();
0113 digit->SetPlaneNumber(planeNumber);
0114 digit->SetPlaneType(IsX);
0115 digit->SetStripNumber(stripNumber);
0116 digit->SetDigitType(0);
0117 digit->SetEnergy(0.);
0118 digitsCollection->insert(digit);
0119 }
0120 }
0121 }
0122
0123 if (calorimeterCollection != nullptr) {
0124 G4int numberOfHits = calorimeterCollection->entries();
0125
0126 for (auto i = 0; i < numberOfHits; i++) {
0127 totalEnergy += (*calorimeterCollection)[i]->GetCALDepositedEnergy();
0128 }
0129
0130
0131
0132 if (totalEnergy > 0.) {
0133 auto *digit = new GammaRayTelDigi();
0134 digit->SetPlaneNumber(0);
0135 digit->SetPlaneType(0);
0136 digit->SetStripNumber(0);
0137 digit->SetDigitType(1);
0138 digit->SetEnergy(totalEnergy);
0139 digitsCollection->insert(digit);
0140 }
0141 }
0142
0143 if (anticoincidenceCollection != nullptr) {
0144 G4int numberOfHits = anticoincidenceCollection->entries();
0145
0146 for (G4int i = 0; i < numberOfHits; i++) {
0147 auto energy = (*anticoincidenceCollection)[i]->GetEdepACD();
0148 auto type = (*anticoincidenceCollection)[i]->GetACDTileNumber();
0149
0150
0151
0152 if (energy > acdThreshold) {
0153 auto *digit = new GammaRayTelDigi();
0154 digit->SetPlaneNumber(0);
0155 digit->SetPlaneType(0);
0156 digit->SetStripNumber(type);
0157 digit->SetDigitType(2);
0158 digit->SetEnergy(energy);
0159 digitsCollection->insert(digit);
0160 }
0161 }
0162 }
0163
0164 if (trackerCollection != nullptr || anticoincidenceCollection != nullptr || calorimeterCollection != nullptr) {
0165 G4cout << "Number of digits in this event: " << digitsCollection->entries()
0166
0167
0168 << G4endl;
0169 }
0170
0171 StoreDigiCollection(digitsCollection);
0172
0173 G4int digitsCollectionIdentifier{-1};
0174 if (digitsCollectionIdentifier < 0) {
0175
0176 digitsCollectionIdentifier = digitManager->GetDigiCollectionID("GammaRayTelDigitizer/DigitsCollection");
0177 }
0178 }