Repository navigation
TrackerMC: compute the straw response geometry once per cluster - #2143
Conversation
StrawElectronics::responseGeometry precomputes the reflection time and scale and the wire-distance interpolation of a cluster; linearResponse, maxResponseTime and maxLinearResponse take it, and the distance overloads call them with the same arithmetic. StrawCluster caches it per straw and StrawWaveform uses it. Output bitwise identical; makeSD about 20 % faster in Mix1BB digitisation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
☀️ The build tests passed at 685a483.
N.B. These results were obtained from a build of this Pull Request at 685a483 after being merged into the base branch at 152833a. For more information, please check the job page here. |
oksuzian
left a comment
There was a problem hiding this comment.
PR Review Summary — #2143
Reviewed at head 685a483b276f0467e99798e12be50d0c38b7f866. First pass.
Decision
- 🟢 approve. The per-cluster terms are computed with exactly the old arithmetic, and the tracker digitisation output is identical to
mainon four samples (15,916 straw digis with their waveforms and truth).makeSDtakes about 20% less time per event, as the description says. FNALbuild build 3596 passed at this head, apart from thetriggerrow, which shows the same warning on every build against currentmainand does not exercise this change (see Validation check). One optional simplification is below (finding 1).
Scope understood
StrawElectronics::responseGeometry(straw, distance)returns aResponseGeometry: the reflection time, the reflection scale, and the wire-distance interpolation index and weight.linearResponse,maxResponseTimeandmaxLinearResponseget overloads that take it. The distance overloads stay and now call the new ones.StrawCluster::responseGeometrycaches the result in twomutablemembers, keyed by straw id, and the six calls inStrawWaveform.ccuse it.
Findings
- ⚪ [S3] The cache could be filled once when the cluster is made, with no
mutablestate.- Evidence: in
StrawDigisFromStrawGasSteps, both waveforms of a sequence, including the cross-talk ones, are built with the sequence's own straw (createDigis,:585-586, called withstrawforselfand everyXTalkat:538,:550). So the key check inStrawCluster.hh:64only ever misses the first time. The primary clusters are made at:672, wherestrawele,strawandweq._wdistare all in hand, and the ghost copies (:794,:796) copy the cluster. - Computing the
ResponseGeometrythere, as a constructor argument, would remove the twomutablemembers and the key check, andStrawCluster.hhwould no longer need theTrackerConditionsandTrackerGeomincludes. A related sharp edge:ResponseGeometryis a public aggregate whose all-zero default (index 0, no reflection) is accepted bylinearResponsewithout complaint, andmaxResponseTime(…, distance)builds such a partial object internally. - This is a simplification and does not gate.
- Evidence: in
Checked, no action needed
- 🟢 Same arithmetic.
fillDistanceIntervalis the old loop and weight, line for line, including the clamp to_wPoints.size()-2and the extrapolating weight past the last point.responseGeometrycomputesstraw_length, the reflection time and the reflection scale with the old expressions, from the samefloat_wdistthe old calls received throughwireDistance().linearResponsethen formsindex_reflwith the same expression. - 🟢 The cache stays correct.
_rgeomStrawstarts invalid (StrawId()is0xFFFF,StrawId.hh:62), the result depends only on the straw and_wdist, which never changes after construction, and clusters live for one event, so aStrawElectronicschange between runs cannot leave a stale value.StrawDigisFromStrawGasStepsis a legacyart::EDProducer, so there is no concurrent access to themutablemembers. - 🟢 Other callers are unaffected.
StrawElectronicsMaker.cc:274(building the_tmax/_linmaxtables) and the diagnostic inStrawDigisFromStrawGasSteps_module.cc:1115still use the distance overloads, which give the same values. Nothing persistsTrackerMC::StrawCluster. - 🟢 Memory.
sizeof(StrawCluster)grows from 96 to 128 bytes. The peak RSS of my jobs did not change measurably (for example 893-902 MB onmainand 882-896 MB at this head in the timing runs below).
Validation check
-
Build/tests run: yes. A
muse buildof this head on the CI build of its merge base,mainca7b6580(p110), exited with status 0 and no warnings;mainran from that CI build. Each job ran in both arms with the same configuration and seeds, with aPrintModuledump of everyStrawDigi,StrawDigiADCWaveformandStrawDigiMC. All jobs exited with status 0, and every dump is identical:job events makeSDdigisFNALbuild ceDigi53 2,248 FNALbuild cosmicOffSpill400 5,984 FNALbuild ceMix53 2,472 ceMixwith 15 times the muon-stop pileup rate53 5,212 Digis and ADC samples are integers, so these compare exactly; the truth printout carries times to 0.01 ns.
-
Timing: the high-pileup job without the printer, three repeats with
mainand this head running side by side.makeSDmedian per event: 23.6, 24.4, 25.4 ms onmainand 18.8, 19.9, 19.4 ms at this head, a ratio of about 0.79. -
FNALbuild build 3596 (merged on
main152833a9, 16:33 UTC; checked 17:45 UTC): every test passed excepttrigger, which shows ":question: Return Code 1". Every build againstmainsinceca7b6580shows the same warning (mpr_TrkDe_80m70p_D0200445 → 414 against the reference), and thetriggerjob reads already-digitised files, so it does not run this code; itsTrigReportis identical to that of #2107, #2141 and #2142 on the samemain. -
Config contract check: not applicable, no fcl change.
-
Cross-repo consistency: pass.
Residual risk
- I did not run a full 1BB-intensity mixed sample; the description's Mix1BB comparison covers that.
Author follow-ups
- Optional: finding 1.
The primary constructor takes the StrawElectronics and the Straw and computes the ResponseGeometry from the cluster's own wire distance; responseGeometry() takes no arguments and the mutable cache and its straw-id check are removed. Output bitwise identical.
oksuzian
left a comment
There was a problem hiding this comment.
PR Review Summary — #2143
Reviewed at head 393ac9137d347f06e15907c0bfb5f583d9399e8a. Re-review of 685a483.
Decision
- 🟡 comment now, approve when green. The new commit computes the response geometry in the
StrawClusterconstructor, as the first pass suggested, and it gives the same inputs as before for every cluster. The tracker digitisation output is still identical tomainon the same four samples, andmakeSDis still about 25% faster. FNALbuild has not built this head yet. I will approve once it passes. The two notes below are optional and do not gate.
What changed since 685a483
- One commit,
393ac913, on top of the approved head. It is not a rebase, so the merge base is stillmainca7b6580. - The primary
StrawClusterconstructor now takes theStrawElectronicsand theStraw. It computes theResponseGeometryfrom the cluster's own_wdist(StrawCluster.cc:30).responseGeometry()takes no arguments (StrawCluster.hh:65), and the six calls inStrawWaveform.ccuse it. The module passesstraweleandstrawat its one construction site (StrawDigisFromStrawGasSteps_module.cc:672).
Prior findings
- 🟢 [was S3] Compute the response geometry when the cluster is made, with no
mutablestate — FIXED in 393ac91, verified.- The two
mutablemembers and the straw-id check are gone.git grepfinds nomutableinTrackerMCand no caller of the old two-argument accessor. - Every cluster gets the same inputs as on
main. The only primary construction is:672, wherestrawis_tracker->getStraw(sid)for the step's own straw (:627-629). The ghost copies (:794,:796) copy the cluster, so they keep its straw and_wdist. The waveform looks up its straw from the sequence's id (:535), andStrawClusterSequence::insertthrows for a cluster from another straw (StrawClusterSequence.cc:48-53). So the constructor's straw is always the waveform's straw. _rgeomis declared after_wdist(StrawCluster.hh:74,:80), so it is computed from the samefloatthatwireDistance()returned onmain.- The
TrackerGeominclude has left the header. TheTrackerConditionsinclude stays, which is right now that the header holds aResponseGeometryby value.
- The two
- 🟢 The "sharp edge" noted in the same finding is still there, but nothing reaches it.
ResponseGeometrystill defaults to all zeros, and the distance overloads ofmaxResponseTimeandmaxLinearResponsestill fill only the index and weight (StrawElectronics.cc:141-160). The struct comment now says so (StrawElectronics.hh:48). The only cluster with the zero default is a default-constructed one, andinsertrejects it because its type isunknown(StrawClusterSequence.cc:41-46). No action needed.
New findings
- ⚪ [S3] The cross-talk copy constructor would carry one straw's response terms to another straw.
StrawCluster(const StrawCluster&, StrawId const&, float)(StrawCluster.cc:33-38) changes_strawIdbut keeps_rgeom, whose reflection terms depend on the original straw's length. Nothing in Offline calls it, because cross-talk is applied throughXTalkin the waveform (StrawDigisFromStrawGasSteps_module.cc:537-551), so the output is not affected. Deleting it would remove the trap. - ⚪ [S3] The PR description still describes the first design. It says
StrawCluster::responseGeometry(strawele, straw)"caches the geometry per cluster, keyed by the straw id", and its file list leaves outStrawCluster.ccand the module. Please update it, since it becomes the record of the merge.
Validation check
-
Build/tests run: yes. A
muse buildof this head on the CI build of its merge base,mainca7b6580(p110), exited with status 0 and no warnings.mainran from that CI build. I reran the first pass's four jobs in both arms with the same configuration and seeds, with aPrintModuledump of everyStrawDigi,StrawDigiADCWaveformandStrawDigiMC. All jobs exited with status 0, and every dump is identical tomain. The head dumps are also identical to the first pass'smaindumps.job events makeSDdigisFNALbuild ceDigi53 2,248 FNALbuild cosmicOffSpill400 5,984 FNALbuild ceMix53 2,472 ceMixwith 15 times the muon-stop pileup rate53 5,212 -
Timing: the high-pileup job without the printer, three repeats with
mainand this head running side by side on the same host as the first pass.makeSDmedian per event: 12.6, 12.6, 12.8 ms onmainand 9.4, 9.4, 9.4 ms at this head, a ratio of 0.73 to 0.75. The absolute times are lower than in the first pass, so compare the ratio, which was about 0.79 then. -
Memory:
sizeof(StrawCluster)is 128 bytes, the same as at 685a483 (96 onmain). The removed 2-byte straw id fitted in padding. Peak RSS was 917-920 MB onmainand 911-913 MB at this head. -
FNALbuild: no build at this head. The
mu2e/buildteststatus has read "This test has not been triggered yet" since 01:21 UTC on 11 November (checked 03:34 UTC). The last FNALbuild result on this PR is build 3596, at 685a483. This head needs a CI run. -
Config contract check: not applicable, no fcl change.
-
Cross-repo consistency: pass. GitHub code search finds
TrackerMC/inc/StrawCluster.hhused only in Offline.
Residual risk
- No FNALbuild run at this head yet.
- I did not run a full 1BB-intensity mixed sample; the description's Mix1BB comparison covers the first commit.
Author follow-ups
- Update the PR description (finding 2).
- Optional: finding 1.
|
@FNALbuild run build test |
|
⌛ The following tests have been triggered for 393ac91: build (Build queue - API unavailable) |
|
☀️ The build tests passed at 393ac91.
N.B. These results were obtained from a build of this Pull Request at 393ac91 after being merged into the base branch at 30088f3. For more information, please check the job page here. |
oksuzian
left a comment
There was a problem hiding this comment.
PR Review Summary — #2143
Reviewed at head 393ac9137d347f06e15907c0bfb5f583d9399e8a. Follow-up to my comment review at the same head.
Decision
- 🟢 approve. FNALbuild build 3601 has now built this head, merged on
main30088f39, and every test passed: the prof build, all eleven validation jobs,rootOverlaps,g4surfaceCheck,trigger,check_cmakeand the whitespace check. The FIXME/TODO count and clang-tidy rows are informational; the one clang-tidy error is in cetlib'sLibraryManager.h, not in this PR. This is the approval my comment review promised once the build was green. The two optional notes from that review still stand and do not block.
|
Independent check on a different sample: Mix1BB digitization (Production
I had a similar change locally. Its extras on top of this one (tail sum, saturation once per waveform, skipping zero ADC samples) save only 2-7 ms/event, about 1-2% of the job, so I won't open a separate PR. I can send them as a small follow-up after this merges if useful. |
|
📝 The HEAD of |
What
StrawWaveformcallsStrawElectronics::linearResponse(andmaxResponseTime/maxLinearResponse) for every(waveform sample, cluster) pair. Each call recomputes terms that depend only on the cluster's wire distance and the
straw: the reflection time, the reflection scale (an
exp), and a linear scan of the wire-distance points for theinterpolation interval and weight.
This PR computes them once per cluster:
StrawElectronics::ResponseGeometryandresponseGeometry(straw, distance)hold and compute those terms.linearResponse,maxResponseTimeandmaxLinearResponseget overloads that take aResponseGeometry. Theexisting distance-based overloads now call them with the same arithmetic, so their results do not change.
StrawCluster::responseGeometry(strawele, straw)caches the geometry per cluster, keyed by the straw id.StrawWaveform.ccuse the cached geometry.Files:
TrackerConditions/inc/StrawElectronics.hh,TrackerConditions/src/StrawElectronics.cc,TrackerMC/inc/StrawCluster.hh,TrackerMC/src/StrawWaveform.cc.Validation
The output is bitwise identical to main.
ca7b6580(the CI build), with the same Production and mu2e-trig-config commits in botharms.
JobConfig/mixing/Mix.fcl+OneBB.fcl) of 2,000CeMLeadingLog.MDC2025apevents, with the fourMDC2025ac/adpileup streams and a fixed seed.PrintModule: straw digis, ADC waveforms, StrawDigiMC,calo and CRV digis, and the trigger reco built on them (combo hits, KalSeeds, calo clusters). All 2,000 events are
identical: 9.0M dump lines, 1.38M straw digis. TrigReport is identical.
calo clusters and CRV pulses are identical, and TrigReport is identical.
Performance
Both arms ran on the same host, 1,000 events per run, in two repeats alternating base and PR. Times are art
TimeTracker means.
makeSD(StrawDigisFromStrawGasSteps)Main's own repeat-to-repeat spread is 2 %.
makeSDis the most expensive module of the Mix1BB digitisation job, at86 of 297 ms/event on this host.
🤖 Generated with Claude Code