Skip to content

CaloMC: index CaloShowerROs once per event - #2142

Open
RobMina wants to merge 3 commits into
Mu2e:mainfrom
RobMina:digi-channel-index
Open

RobMina wants to merge 3 commits into
Mu2e:mainfrom
RobMina:digi-channel-index

Conversation

@RobMina

@RobMina RobMina commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What

CaloDigiMaker::fillROHits scanned every CaloShowerRO for each readout. This PR builds an index once per event: one pass collects the CaloShowerRO pointers of each readout in collection order, and fillROHits takes that list.

No random numbers are drawn in the lookup, and the order of the inputs is unchanged.

File: CaloMC/src/CaloDigiMaker_module.cc.

CRV half dropped

The original PR also indexed CrvPhotons in CrvSiPMChargeGenerator. That change conflicted with #2150 (ehrlich-uva, merged 2026-11-17), which reworked CRVResponse SiPM charge generation. The CRV half is removed; only the Calo indexing remains. Rebased/merged onto current main.

Validation

(From the original two-digitiser PR; Calo path unchanged by the CRV drop.)

The Calo output is bitwise identical to main. The reference was Offline main ca7b6580 (the CI build), with the same Production and mu2e-trig-config commits in both arms.

  • Mixed sample. Mix1BB digitisation of 2,000 CeMLeadingLog.MDC2025ap events with the four pileup streams and a fixed seed. Products dumped per event with PrintModule (including calo digis) are identical in all 2,000 events: 0.94M calo digis. TrigReport is identical.

Performance

Both arms ran on the same host, Mix1BB, 1,000 events per run, in two repeats alternating base and PR. Times are art TimeTracker means.

PR / main, repeat 1 repeat 2
CaloDigiMaker 0.450 0.454

Main's own repeat-to-repeat spread is 0.3-0.5 %.

CrvSiPMChargeGenerator builds the first CrvPhotons of each channel once per event instead of a linear search per channel; CaloDigiMaker collects the CaloShowerROs of each readout in one pass instead of scanning all of them per readout. Output bitwise identical; CaloDigiMaker 55 % and CrvSiPMCharges 14 % faster.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@FNALbuild

Copy link
Copy Markdown
Collaborator

Hi @RobMina,
You have proposed changes to files in these packages:

  • CaloMC
  • CRVResponse

which require these tests: build.

@Mu2e/write, @Mu2e/fnalbuild-users have access to CI actions on main.

⌛ The following tests have been triggered for a686153: build (Build queue - API unavailable)

About FNALbuild. Code review on Mu2e/Offline.

@FNALbuild

Copy link
Copy Markdown
Collaborator

☀️ The build tests passed at a686153.

Test Result Details
test with ✅ Command did not list any other PRs to include
merge ✅ Merged a686153 at 152833a
build (prof) ✅ Log file. Build time: 04 min 36 sec
ceSimReco ✅ Log file.
g4test_03MT ✅ Log file.
transportOnly ✅ Log file.
POT ✅ Log file.
g4study ✅ Log file.
cosmicSimReco ✅ Log file.
cosmicOffSpill ✅ Log file.
ceSteps ✅ Log file.
ceDigi ✅ Log file.
muDauSteps ✅ Log file.
ceMix ✅ Log file.
rootOverlaps ✅ Log file.
g4surfaceCheck ✅ Log file.
trigger ❓ Log file. Return Code 1.
check_cmake ✅ Log file.
FIXME, TODO ✅ TODO (0) FIXME (0) in 2 files
clang-tidy ➡️ 2 errors 26 warnings
whitespace check ✅ no whitespace errors found

N.B. These results were obtained from a build of this Pull Request at a686153 after being merged into the base branch at 152833a.

For more information, please check the job page here.
Build artifacts are deleted after 5 days. If this is not desired, select Keep this build forever on the job page.

@oksuzian oksuzian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review Summary — #2142

Reviewed at head a6861534dcc6d72bc4170f0c7d5ac162b9db99b6. First pass.

Decision

  • 🟢 approve. Both indexes reproduce the old searches exactly, and the output is bit-identical to main on every sample I ran: 10,000 off-spill cosmics, 1,000 on-spill CE events, and FNALbuild's ceMix and ceDigi. On CE events CaloDigiMaker takes about a third less time. FNALbuild build 3595 passed at this head, merged on main 152833a9. Its trigger row reads ":question: Return Code 1", but that comes from main, not from this PR (see Validation check). One optional small item (finding 1).

Scope understood

  • CrvSiPMChargeGenerator: one pass over CrvPhotons keeps the first collection of each channel (bar × 4 + SiPM, :200-207). The per-SiPM linear search becomes a lookup (:229-230).
  • CaloDigiMaker: one pass collects the CaloShowerROs of each readout in collection order (:194-198), and fillROHits loops over that list.

Findings

  1. ⚪ [S3] Small items, optional.
    • The new index loops drop inputs they cannot place, with no message:

      • a CrvPhotons whose SiPM number is outside 0-3, or whose bar index is past the geometry (CrvSiPMChargeGenerator_module.cc:204, :206);
      • a CaloShowerRO whose SiPMID is not below nWaveforms (CaloDigiMaker_module.cc:197).

      That is what main does too, since its searches could never match such an entry, so nothing changes. But these loops now see every input once, and a throw there would turn a corrupt input into an error rather than missing hits.

    • for (const auto& CaloShowerRO : CaloShowerROs) (:195) names the variable after its type, as the removed loop did. showerRO, as in fillROHits, would read better.

Checked, no action needed

  • 🟢 The index matches the old lookup.

    • Duplicate entries for one channel: the old search stopped at the first match, and the index keeps the first.
    • Entries the old search could never reach (SiPM outside 0-3, a bar not in the geometry) are skipped in both.
    • A readout with no CaloShowerRO still returns isEmpty, and one with only empty PETime lists is still non-empty.
    • Nothing draws random numbers, and the order inside each list is the collection order. So the random sequences and the output order are unchanged.
  • 🟢 Bit-identical to main.

    • Method: main is the CI build 152833a9. The PR is this head merged on 152833a9 together with #2145, with binomialArrivals: false (see my #2145 review). Each job dumped its products event by event with PrintModule, and the dumps were compared line by line.
    • Off-spill cosmics: Production digitize/OffSpill.fcl plus CRV reco, 10,000 CosmicCRYAll MDC2025ap events. CaloDigis, CrvDigis, both CrvDigiMCs, CrvRecoPulses and CrvCoincidenceClusters are identical in every event: 121k CRV digis and 154k pulses.
    • On-spill: digitize/OnSpill.fcl, 1,000 CeMLeadingLog MDC2025ba events. CaloDigis (10,338 digis with full waveforms) and StrawDigis (29,776) are identical.
    • FNALbuild's ceMix (with the muon-stop pileup) and ceDigi, 53 events each: calorimeter, CRV and all seven straw-digi collections are identical.
  • 🟢 Timing. main and this PR ran at the same time on the same node; TimeTracker means:

    main this PR
    CaloDigiMaker, CE (1,000 events) 0.84 ms 0.54 ms
    CrvSiPMCharges, cosmics (3,000) 1.17 ms 1.14 ms
    CrvSiPMCharges, CE 0.93 ms 0.90 ms
    full event, CE 23.6 ms 21.8 ms

    With few CrvPhotons collections per event the CRV gain is small. Your Mix1BB numbers, with heavier pileup, are larger.

Validation check

  • Build/tests run: yes. A muse build of this head merged with #2145 on 152833a9 (p110) exited with status 0 and no warnings. All the jobs above exited with status 0.
  • FNALbuild build 3595 at this head, merged on 152833a9: every test passed except trigger, which reads ":question: Return Code 1". Its log shows one path off its reference: mpr_TrkDe_80m70p_D0200 passes 414 events against 445. Builds 3593 (#2107) and the ones for #2141 and #2143 show the same count on the same main. That reference has been stale since ca7b6580, and this PR touches no trigger code.
  • Config contract check: pass. No fcl or parameter changes.
  • Cross-repo consistency: pass. This PR merges cleanly with #2145, which also edits CRVResponse.

Residual risk

  • None found. The CRV index assumes bar indices run from 0 to the number of bars minus one, as CosmicRayShield builds them. The bit-identical cosmic run covers every bar that fired.

@oksuzian oksuzian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review Summary — #2142

Reviewed at head 0a9a6084991cfdad1553d9a585e8f49b7994e824. Re-review of a686153.

Decision

  • 🟡 comment now, approve when green. The new commit only renames the loop variable, as my nit suggested, and changes nothing else. FNALbuild has not built this head (no mu2e/buildtest result at 03:20 UTC), so I am requesting a build and will approve once it is green.

What changed since a686153

  • One commit, 0a9a608 "CaloDigiMaker: name the index loop variable showerRO" (CaloMC/src/CaloDigiMaker_module.cc, +3 −3). Not a rebase.

Prior findings (from my review at a6861534)

  • 🟢 [was ⚪ S3, second item] The loop variable named after its type. FIXED: for (const auto& showerRO : CaloShowerROs) (CaloDigiMaker_module.cc:195-197), the same name as in fillROHits (:268). The rename covers all three uses in the loop, and the body is otherwise unchanged.
  • ⚪ [S3, first item, open, optional] The index loops drop inputs they cannot place, with no message, as main does.

Validation check

  • Build/tests run: no. The change is a rename of a loop-local variable, checked by reading the diff. My bit-identity runs at a6861534 cover the behaviour.
  • Config contract check: not applicable.
  • Cross-repo consistency: pass.

@oksuzian

Copy link
Copy Markdown
Collaborator

@FNALbuild run build test

2 similar comments
@oksuzian

Copy link
Copy Markdown
Collaborator

@FNALbuild run build test

@RobMina

RobMina commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

@FNALbuild run build test

@FNALbuild

Copy link
Copy Markdown
Collaborator

⌛ The following tests have been triggered for 0a9a608: build (already triggered: build) (Build queue - API unavailable)

@FNALbuild

Copy link
Copy Markdown
Collaborator

☀️ The build tests passed at 0a9a608.

Test Result Details
test with ✅ Command did not list any other PRs to include
merge ✅ Merged 0a9a608 at 30088f3
build (prof) ✅ Log file. Build time: 09 min 25 sec
ceSimReco ✅ Log file.
g4test_03MT ✅ Log file.
transportOnly ✅ Log file.
POT ✅ Log file.
g4study ✅ Log file.
cosmicSimReco ✅ Log file.
cosmicOffSpill ✅ Log file.
ceSteps ✅ Log file.
ceDigi ✅ Log file.
muDauSteps ✅ Log file.
ceMix ✅ Log file.
rootOverlaps ✅ Log file.
g4surfaceCheck ✅ Log file.
trigger ❌ Log file. Return Code 2.
check_cmake ✅ Log file.
FIXME, TODO ✅ TODO (0) FIXME (0) in 2 files
clang-tidy ➡️ 2 errors 26 warnings
whitespace check ✅ no whitespace errors found

N.B. These results were obtained from a build of this Pull Request at 0a9a608 after being merged into the base branch at 30088f3.

For more information, please check the job page here.
Build artifacts are deleted after 5 days. If this is not desired, select Keep this build forever on the job page.

@oksuzian oksuzian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review Summary — #2142

Reviewed at head 0a9a6084991cfdad1553d9a585e8f49b7994e824. Follow-up to my comment review at the same head.

Decision

  • 🟢 approve. FNALbuild build 3603 has now built this head, merged on main 30088f39. The prof build, all eleven validation jobs, rootOverlaps, g4surfaceCheck, check_cmake and the whitespace check passed.
  • trigger shows "Return Code 2", but not because of this PR. Its log has exactly four messages, all from mu2e-trig-config#191's rename of apr_proton to apr_proton_p335/p250/p150, which merged before the reference log was regenerated. No path count differs from the reference.
  • Both clang-tidy errors are in cetlib's LibraryManager.h.
  • This is the approval my comment review promised once the build was green.

@RobMina

RobMina commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

I'm marking this as draft so that I can remove the CRV-related parts, which may conflict with #2150

@RobMina
RobMina marked this pull request as draft November 13, 2026 16:16
@FNALbuild

Copy link
Copy Markdown
Collaborator

📝 The HEAD of main has changed to 7024300. Tests are now out of date.

Mu2e#2150 already reworked CRVResponse SiPM charge generation. Keep only the
CaloDigiMaker once-per-event CaloShowerRO index from this PR.
@RobMina RobMina changed the title CRVResponse, CaloMC: index the input collections once per event CaloMC: index CaloShowerROs once per event Nov 20, 2026
@RobMina
RobMina marked this pull request as ready for review November 20, 2026 14:55
@RobMina

RobMina commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

@FNALbuild run build test

Merged current main and dropped the CrvSiPMChargeGenerator indexing (conflicts with #2150). Only CaloDigiMaker once-per-event index remains.

@oksuzian oksuzian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review Summary — #2142

Reviewed at head 21f3ce348b97edd44e53b02ba215cccb780dc6d1. Re-review of 0a9a608.

Decision

  • 🟡 comment now, approve when green. Thanks, Rob. Dropping the CRV half leaves exactly the calorimeter change I approved at 0a9a608, and CrvSiPMChargeGenerator is now the same as on main. FNALbuild has not built this head: your 14:55 UTC request had no reply from the bot at 16:55 UTC, and jenkins/ghprb is still pending. I will approve once it is green.

What changed since 0a9a608

  • One merge commit, 21f3ce3 "Merge main; drop CrvSiPMChargeGenerator indexing". The PR now changes only CaloMC/src/CaloDigiMaker_module.cc (+12 −8), and is up to date with main (785954ae).

The change, checked

  • 🟢 CaloDigiMaker_module.cc at this head is the same file as at 0a9a608 (git blob ced0708f at both heads). main has not changed that file since 2026-10-08, so the merge brings nothing new into it.
  • 🟢 CRVResponse/src/CrvSiPMChargeGenerator_module.cc at this head is the same as on main (blob f4f33862), so nothing of the CRV half is left to conflict with #2150.

Prior findings

  1. ⚪ [S3, open, optional] The index loop drops readouts it cannot place with no message, as main does: if (SiPMID < unsigned(nWaveforms)) (CaloDigiMaker_module.cc:197). Only the calorimeter loop is left of this item.

Validation check

  • Build/tests run: none. I compared the file blobs at both heads and on main. My bit-identity runs at a686153 cover this code.
  • Config contract check: not applicable.
  • Cross-repo consistency: pass.

Residual risk

  • None beyond the build.

@oksuzian

Copy link
Copy Markdown
Collaborator

@FNALbuild run build test

@FNALbuild

Copy link
Copy Markdown
Collaborator

⌛ The following tests have been triggered for 21f3ce3: build (already triggered: build) (Build queue - API unavailable)

@FNALbuild

Copy link
Copy Markdown
Collaborator

☀️ The build tests passed at 21f3ce3.

Test Result Details
test with ✅ Command did not list any other PRs to include
merge ✅ Merged 21f3ce3 at 785954a
build (prof) ✅ Log file. Build time: 18 min 54 sec
ceSimReco ✅ Log file.
g4test_03MT ✅ Log file.
transportOnly ✅ Log file.
POT ✅ Log file.
g4study ✅ Log file.
cosmicSimReco ✅ Log file.
cosmicOffSpill ✅ Log file.
ceSteps ✅ Log file.
ceDigi ✅ Log file.
muDauSteps ✅ Log file.
ceMix ✅ Log file.
rootOverlaps ✅ Log file.
g4surfaceCheck ✅ Log file.
trigger ❌ Log file. Return Code 2.
check_cmake ✅ Log file.
FIXME, TODO ✅ TODO (0) FIXME (0) in 1 files
clang-tidy ➡️ 1 errors 20 warnings
whitespace check ✅ no whitespace errors found

N.B. These results were obtained from a build of this Pull Request at 21f3ce3 after being merged into the base branch at 785954a.

For more information, please check the job page here.
Build artifacts are deleted after 5 days. If this is not desired, select Keep this build forever on the job page.

@oksuzian oksuzian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review Summary — #2142

Reviewed at head 21f3ce348b97edd44e53b02ba215cccb780dc6d1. Follow-up to my comment review at the same head.

Decision

  • 🟢 approve. FNALbuild build 3661 has built this head, merged on main 785954ae. The prof build, all eleven validation jobs, rootOverlaps, g4surfaceCheck, check_cmake and the whitespace check passed. This is the approval my comment review promised once the build was green.
  • trigger shows "Return Code 2", but not because of this PR. The log reports no path whose count differs from the reference; it fails only the timing check, on the scale factor. The CI scales the new time by the average time of LumiStreamPS, which is 8.48e-05 s in the reference log against 1.80e-05 s here, so the scale is 4.72. The reference average is set by one slow event: its maximum is 0.110 s and its median 1.32e-05 s, against a median of 1.62e-05 s here. The raw time per event is 0.0233 s against 0.0224 s. Offline#2193, #2191 and #2198 fail the same way.
  • clang-tidy's one error is in cetlib's LibraryManager.h. Its 20 warnings in CaloDigiMaker_module.cc are all on lines this PR does not change.

@RobMina

RobMina commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

@oksuzian this is ready to merge from my side: CLEAN at 21f3ce348, your approve at this head after FNALbuild build 3661, CaloDigiMaker only. I don't have merge rights on Mu2e/Offline — please merge when convenient.

@FNALbuild

Copy link
Copy Markdown
Collaborator

📝 The HEAD of main has changed to 0f6b4ad. Tests are now out of date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants