Initialize TrkFilters members that FHiCL can leave unset - #1971
Open
oksuzian wants to merge 1 commit into
Open
Conversation
fhicl::OptionalAtom<T>::operator()(T&) assigns only when the key is present and leaves its target untouched otherwise. HelixCutsTool fills fifteen cut thresholds through that form with no in-class initializer and no entry in the constructor's initializer list, so omitting a key from a HelixFilter configuration makes checkHelix() compare against an indeterminate value instead of failing validation. Give each one an initializer chosen so that an unconfigured cut is a no-op, and initialize _myTracker to nullptr. _maxpT, which was never read, is removed rather than initialized. MultiHelixFilter never assigned _doHistograms from its own doHistograms parameter, so the switch that books the histograms in beginJob and fills them in filter() read an uninitialized bool and the configuration key had no effect. Initialize it from the configuration and default the _hists pointers to nullptr. No committed configuration changes behaviour: all twenty HelixFilter instances in mu2e-trig-config set all fifteen keys. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Collaborator
|
☀️ The build tests passed at b5d26c1.
N.B. These results were obtained from a build of this Pull Request at b5d26c1 after being merged into the base branch at c4b2bc6. For more information, please check the job page here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Two uninitialized-member reads in
TrkFilters, both sourced from FHiCL and neither caught by validation.fhicl::OptionalAtom<T>::operator()(T& value)assigns only when the key is present and leavesvalueuntouched otherwise (fhiclcpp/types/OptionalAtom.h:44-51).HelixFilter'sHelixCutsToolfills fifteen cut thresholds through that form —_hascc,_doHelicityCheck,_hel,_minnstrawhits,_minHitRatio,_minmom,_maxmom,_minpT,_maxchi2XY,_maxchi2PhiZ,_maxd0,_mind0,_maxlambda,_minlambda,_maxnloops,_minnloops— with no in-class initializer and no entry in the constructor's initializer list, and then reads every one of them in the cut chain. Omitting a key from a menu therefore produces a silently wrong trigger rather than a configuration error._slopeSigMin/_slopeSigMaxin the same struct already do it correctly, by keeping the boolean return in_useSlopeSigMin/_useSlopeSigMaxand guarding the comparison.MultiHelixFilterdeclares adoHistogramsparameter and a_doHistogramsmember but never assigns one from the other, sobeginJobandfilterdecide whether to book and fill histograms by reading an uninitialized bool, and the configuration key does nothing.Scope
Each threshold gets an in-class initializer chosen so that an unconfigured cut is a no-op,
_myTrackergetsnullptr,_doHistogramsis initialized from the configuration, and_histsdefaults to null pointers._maxpTis deleted rather than initialized — it is declared and never read anywhere in the file.No committed configuration changes behaviour. All twenty
HelixFilterinstances inmu2e-trig-config(trigTprFilters.fcl,trigAprFilters.fcl,trigCprFilters.fcl,trigMprFilters.fcl), after expanding their@table::references, set all fifteen keys;MultiHelixFilterhas no consumer in Offline, Production or mu2e-trig-config.Deliberately not in this PR
These came out of the same read-through and are each a separate topic:
fhicl::Atoms instead of initializedOptionalAtoms. That is the stronger fix — an omitted cut would fail validation instead of silently disabling itself — and every committed instance would still validate. Happy to do that instead if the maintainers prefer it; it is a schema change, so it did not belong in the same commit.prescaleUsingD0PhiandprescalerParare independent FHiCL entries, so enabling the flag without an amplitude leavesPhiPrescalingParamsat its default of zero,evalIPAPrescreturns 0, andNEvt % prescalerdivides by zero. The one live user setsamplitude: 6.2, whose minimum over phase is exactly 1.0, so nothing crashes today. The fix is anOptionalTableso the pair validates as a unit.HelixFilterconverts curvature to momentum with a bare3./10.and computes_bz0inbeginRunwithout ever reading it, whileMultiHelixFiltermultiplies by_bz0. The two modules disagree by a factor ofBz, and the live thresholds are tuned againstHelixFilter's current scale, so correcting it shifts every momentum cut in the menu.maxDt0timing cut is evaluated over the whole input collection rather than the helices that passed the selection. It is set in no committed configuration.beginJob/beginRunin both modules arevirtualwithoutoverride, which is what would have caught_histsnever being booked at compile time.Validation
Compile and test coverage from CI only — I have not run an art job. The change is behaviour-preserving for every committed configuration, as described above.