Fix bugs and code quality issues found in CRVResponse review#1789
Fix bugs and code quality issues found in CRVResponse review#1789
Conversation
- Fix log10 -> log for exponential distribution in SiPM after-pulse timing - Fix operator precedence in findScintillatorCerenkovBinReverse - Fix Cherenkov photon interpolation (update prev on every iteration) - Fix double -> bool for NZS flag in CrvDigitizer - Remove dead static counters in MakeCrvPhotons - Fix swapped closing-brace comments in MakeCrvPhotons - Fix typo 'dublicate' -> 'duplicate' - Improve TFile error checking with IsZombie() Agent-Logs-Url: https://github.com/Mu2e/Offline/sessions/3fe2c6a5-2029-4a5b-9bd1-a38d758173b9 Co-authored-by: oksuzian <48927306+oksuzian@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Mu2e/Offline/sessions/3fe2c6a5-2029-4a5b-9bd1-a38d758173b9 Co-authored-by: oksuzian <48927306+oksuzian@users.noreply.github.com>
|
Hi @Copilot,
which require these tests: build. @Mu2e/fnalbuild-users, @Mu2e/write have access to CI actions on main. 📝 The author of this pull request is not a member of the Mu2e github organisation. |
|
@FNALbuild run build test |
|
⌛ The following tests have been triggered for 3dc2285: build (Build queue - API unavailable) |
|
All proposed changes can be accepted. Only point 3 will result in an insignificant change of the simulation results. Here are some additional comments.
|
ehrlich-uva
left a comment
There was a problem hiding this comment.
See my comments above.
|
☀️ The build tests passed at 3dc2285.
N.B. These results were obtained from a build of this Pull Request at 3dc2285 after being merged into the base branch at 5ec09f9. For more information, please check the job page here. |
Summary
Detailed code review of the CRVResponse module identified and fixed several bugs and code quality issues across 4 files.
Bug Fixes
1. Wrong logarithm base in SiPM after-pulse timing (
MakeCrvSiPMCharges.cc)The exponential distribution sampling for trap (after-pulse) times used
log10()instead oflog()(natural logarithm). The standard formula for exponential random variable generation isx = -lifetime * ln(U)where U is uniform(0,1). Usinglog10produced a mean oflifetime / ln(10) ≈ lifetime / 2.303, making after-pulse times ~2.3× shorter than intended by the physical lifetime parameters.2. Operator precedence bug in
findScintillatorCerenkovBinReverse(MakeCrvPhotons.cc)The expression
(bin / nBetaBins*nZBins) % nYBinsevaluated as((bin / nBetaBins) * nZBins) % nYBinsdue to left-to-right associativity of/and*, instead of the intended(bin / (nBetaBins*nZBins)) % nYBins. This affected the reverse bin lookup used in diagnostics.3. Cherenkov photon interpolation bug (
MakeCrvPhotons.cc)In
GetAverageNumberOfCerenkovPhotons, theprevBeta/prevNumberPhotonsvalues for linear interpolation were only updated on the first map iteration. For beta values beyond the second map entry, the function would incorrectly interpolate between the first entry and the matching entry, instead of between adjacent entries.4. Wrong type for NZS flag (
CrvDigitizer_module.cc)crvDigiMC.IsNZS()returnsboolbut was stored in adoublevariable.Code Quality Improvements
static int nPScintillation/nPCerenkovcounters and their associated commented-out print statement inMakeCrvPhotons.cc.MakeCrvPhotons::MakePhotons.CrvWaveformsGenerator_module.cc.TFileopen check from== NULL(which doesn't detect failed opens sincenewnever returns NULL) toIsZombie()inMakeCrvSiPMCharges.cc.