File indexing completed on 2025-01-31 09:22:22
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 #include "SiPMHit.hh"
0027
0028 #include <cstdlib>
0029
0030
0031
0032 SiPMHit::SiPMHit(G4String aVolumeName, G4int aCopyNumSensor,
0033 G4int aCopyNumCell)
0034 : fVolumeName(aVolumeName), fCopyNumCell(aCopyNumCell),
0035 fCopyNumSensor(aCopyNumSensor) {}
0036
0037
0038
0039 void SiPMHit::Digitise(const G4double aTimeWindow,
0040 const G4double aToaThreshold) {
0041
0042
0043 if (fEdep.empty()) {
0044 fIsValidHit = false;
0045 return;
0046 }
0047
0048 std::sort(fEdep.begin(), fEdep.end(),
0049 [](const std::pair<G4double, G4double> &left,
0050 const std::pair<G4double, G4double> &right) {
0051 return left.second < right.second;
0052 });
0053
0054 G4double firstHitTime = fEdep[0].second;
0055 fEdepDigi = 0;
0056 for (size_t i = 0; i < fEdep.size(); ++i) {
0057 if (aTimeWindow < 0 || fEdep[i].second < firstHitTime + aTimeWindow)
0058 fEdepDigi += fEdep[i].first;
0059 #ifdef DEBUG
0060 else
0061 std::cout << "Rejecting hit (" << fEdep[i].first << " keV) at time "
0062 << fEdep[i].second << "(start: " << firstHitTime << ")"
0063 << std::endl;
0064 #endif
0065 if ((fTimeOfArrival == -1) && (fEdepDigi > aToaThreshold))
0066 fTimeOfArrival = fEdep[i].second;
0067 }
0068 fIsValidHit = (fEdepDigi > 0);
0069
0070
0071 if (fEdepNonIonizing.empty())
0072 return;
0073
0074 std::sort(fEdepNonIonizing.begin(), fEdepNonIonizing.end(),
0075 [](const std::pair<G4double, G4double> &left,
0076 const std::pair<G4double, G4double> &right) {
0077 return left.second < right.second;
0078 });
0079
0080 fEdepNonIonizingDigi = 0;
0081 for (size_t i = 0; i < fEdepNonIonizing.size(); ++i) {
0082 if (aTimeWindow == -1 ||
0083 fEdepNonIonizing[i].second < firstHitTime + aTimeWindow)
0084 fEdepNonIonizingDigi += fEdepNonIonizing[i].first;
0085 }
0086 }