Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: avoid integer wraparound in CalorimeterHitDigi (#1557)
### Briefly, what does this PR introduce? In some configurations (EcalBarrelImagingRawHits), the pedestal mean (14 a.u.) and sigma (5 a.u.) are such that negative hit pedestal channel numbers are not uncommon in a simple Gaussian model. For low energy hits, this pushes the ADC value into negative double range, and conversion to unsigned long long results in integer wraparound. E.g. https://github.com/eic/EICrecon/actions/runs/10239218932/job/28324710737#step:9:6119. ``` Error: /home/runner/work/EICrecon/EICrecon/src/algorithms/calorimetry/CalorimeterHitDigi.cc:186:38: runtime error: implicit conversion from type 'long long' of value -2 (64-bit, signed) to type 'unsigned long long' changed the value to 18446744073709551614 (64-bit, unsigned) ``` This PR prevents the hit pedestal value from being negative. This PR does not address other reasons why we can get negative values, through intentionally incorrect user input (negative dynamic range). ### What kind of change does this PR introduce? - [x] Bug fix (issue: UBSan implicit-integer-sign-change in CalorimeterHitDigi) - [ ] New feature (issue #__) - [ ] Documentation update - [ ] Other: __ ### Please check if this PR fulfills the following: - [ ] Tests for the changes have been added - [ ] Documentation has been added / updated - [ ] Changes have been communicated to collaborators ### Does this PR introduce breaking changes? What changes might users need to make to their code? No. ### Does this PR change default behavior? No. --------- Co-authored-by: Dmitry Kalinkin <[email protected]>
- Loading branch information