Skip to content

Commit dfe9e30

Browse files
mfasDashahor02
authored andcommitted
[EMCAL-610] Fix handling of the time sample
The digitizer creates time samples however it stores them in ns. The time needs to be converted to sample ID dividing by the length of the time sample.
1 parent 00ddc3a commit dfe9e30

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎Detectors/EMCAL/simulation/src/RawWriter.cxx‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// granted to it by virtue of its status as an Intergovernmental Organization
99
// or submit itself to any jurisdiction.
1010

11+
#include "FairLogger.h"
12+
1113
#include <fmt/core.h>
1214
#include <gsl/span>
1315
#include <TSystem.h>
@@ -102,7 +104,15 @@ bool RawWriter::processNextTrigger()
102104
} else {
103105
bunchDigits = &(towerdata->second.mDigits);
104106
}
105-
(*bunchDigits)[int(dig.getTimeStamp())] = &dig;
107+
// Get time sample of the digit:
108+
// Digitizer stores the time sample in ns, needs to be converted to time sample dividing
109+
// by the length of the time sample
110+
auto timesample = int(dig.getTimeStamp() / emcal::constants::EMCAL_TIMESAMPLE);
111+
if (timesample >= mNADCSamples) {
112+
LOG(ERROR) << "Digit time sample " << timesample << " outside range [0," << mNADCSamples << "]";
113+
continue;
114+
}
115+
(*bunchDigits)[timesample] = &dig;
106116
}
107117
}
108118

0 commit comments

Comments
 (0)