Skip to content

feat(geometry): add non-throwing readout API and producer-side reduced-geometry gating - #2783

Open
wdconinc wants to merge 5 commits into
mainfrom
nonthrowing-geometry-readout-api
Open

feat(geometry): add non-throwing readout API and producer-side reduced-geometry gating#2783
wdconinc wants to merge 5 commits into
mainfrom
nonthrowing-geometry-readout-api

Conversation

@wdconinc

@wdconinc wdconinc commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Briefly, what does this PR introduce? Please link to any relevant presentations or discussions.

This PR hardens geometry-dependent reconstruction in partial/reduced geometries while preserving strict failure behavior when desired.

It introduces:

  • Non-throwing geometry helpers in src/algorithms/interfaces/GeometryUtils.h:
    • hasReadout(...)
    • readoutIdSpec(...)
    • readoutSegmentation(...)
    • parseMissingReadoutPolicy(...) with MissingReadoutPolicy::{Disable, Throw}
  • A configurable missingReadoutPolicy knob (disable default, throw optional) on readout-dependent producer configs and factory parameters.
  • Producer-side handling for absent readouts in:
    • CalorimeterHitDigi
    • SimCalorimeterHitProcessor
    • CalorimeterIslandCluster
    • CalorimeterHitsMerger
    • MPGDTrackerDigi
    • MPGDHitReconstruction
    • LGADHitClustering
    • SiliconChargeSharing
    • PulseCombiner
    • FarDetectorTrackerCluster

Behavior:

  • missingReadoutPolicy=disable (default): log a clear warning and emit empty outputs for that producer.
  • missingReadoutPolicy=throw: raise a runtime error when the configured readout is absent.

Motivation:

  • Reduced geometries legitimately omit some subdetector readouts; previously this could surface as exceptions during upstream factory creation and cascade into downstream collection omissions.
  • This change distinguishes expected geometry absence from genuine algorithm failures and keeps optional-input semantics consistent.

Validation:

  • cmake --build build --target install -- -j8
  • ctest --test-dir build -V -R '^t_algorithms_test$'
  • Reduced-geometry smoke run (epic_craterlake_tracking_only, 2 events, CI gun flags):
    • default policy reproduced the local baseline omission set
    • missingReadoutPolicy=throw propagated missing-readout failures as expected

What is the urgency of this PR?

  • High (please describe reason below)
  • Medium
  • Low

What kind of change does this PR introduce?

  • Bug fix (issue: N/A)
  • New feature (issue: N/A)
  • Optimization (issue #__)
  • Updated parameters, constants (issue: N/A)
  • Updated documentation
  • other: __

Please check if any of the following apply

  • This PR requires changes to geometry (epic PR: __)
  • This PR requires changes to EDM4eic (EDM PR: __)
  • This PR introduces breaking changes. Please describe changes users need to make below.
  • This PR changes default behavior. Please describe changes below.
  • AI was used in preparing this PR. Please describe usage below.

Default-behavior change:

  • For the affected readout-dependent producers, when a configured readout is absent in the loaded geometry, the default behavior is now to disable that producer and emit empty outputs (missingReadoutPolicy=disable) instead of propagating a readout lookup exception.

AI usage:

  • Copilot CLI was used to implement/refactor the code changes, update tests, run local build/test/smoke validation commands, and draft this PR description.

Copilot AI lite review requested due to automatic review settings July 25, 2026 00:35
@github-actions github-actions Bot added topic: calorimetry relates to calorimetry topic: tracking Relates to tracking reconstruction topic: far-backward Reconstruction related to far backward detectors topic: infrastructure topic: digitization labels Jul 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves robustness when running EICrecon with reduced-geometry detector configurations by (1) introducing a non-throwing DD4hep readout lookup API and (2) gating multiple geometry-dependent producers so missing readouts disable the producer (with a single warning) instead of throwing during initialization.

Changes:

  • Added header-only eicrecon::geo helpers (hasReadout, readoutIdSpec, readoutSegmentation) to avoid DD4hep exceptions for absent readouts.
  • Updated multiple producers across calorimetry, digi, tracking, and far-detectors to detect missing readouts at init() time and early-return from process() when disabled.
  • Added Catch2 unit tests covering the new non-throwing geometry helper behavior.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/algorithms/interfaces/GeometryUtils.h Adds non-throwing readout presence/lookup helpers returning bool/std::optional.
src/tests/algorithms_test/interfaces_GeometryUtils.cc Adds unit tests validating helpers don’t throw on missing readouts.
src/tests/algorithms_test/CMakeLists.txt Registers the new GeometryUtils test in the algorithms test executable.
src/algorithms/tracking/MPGDHitReconstruction.h Adds m_readout_available gate.
src/algorithms/tracking/MPGDHitReconstruction.cc Disables algorithm on missing readout; early-returns in process().
src/algorithms/tracking/LGADHitClustering.h Adds m_readout_available gate.
src/algorithms/tracking/LGADHitClustering.cc Disables algorithm on missing readout; early-returns in process().
src/algorithms/fardetectors/FarDetectorTrackerCluster.h Adds m_readout_available gate.
src/algorithms/fardetectors/FarDetectorTrackerCluster.cc Disables algorithm on missing readout; early-returns in process().
src/algorithms/digi/SiliconChargeSharing.h Adds m_readout_available gate.
src/algorithms/digi/SiliconChargeSharing.cc Disables algorithm on missing readout; early-returns in process().
src/algorithms/digi/PulseCombiner.h Adds m_readout_available gate.
src/algorithms/digi/PulseCombiner.cc Disables algorithm on missing readout; early-returns in process(); clarifies init conditions.
src/algorithms/digi/MPGDTrackerDigi.h Adds m_readout_available gate.
src/algorithms/digi/MPGDTrackerDigi.cc Disables algorithm on missing readout; early-returns in process().
src/algorithms/calorimetry/SimCalorimeterHitProcessor.h Adds m_readout_available gate.
src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc Disables algorithm on missing readout; early-returns in process().
src/algorithms/calorimetry/CalorimeterIslandCluster.h Adds m_readout_available gate.
src/algorithms/calorimetry/CalorimeterIslandCluster.cc Disables algorithm on missing readout; early-returns in process().
src/algorithms/calorimetry/CalorimeterHitsMerger.h Adds m_readout_available gate.
src/algorithms/calorimetry/CalorimeterHitsMerger.cc Disables algorithm on missing/invalid decoder; early-returns in process().
src/algorithms/calorimetry/CalorimeterHitDigi.h Adds m_readout_available gate.
src/algorithms/calorimetry/CalorimeterHitDigi.cc Disables algorithm on missing readout; early-returns in process().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings July 25, 2026 00:52
wdconinc pushed a commit that referenced this pull request Jul 25, 2026
…d-geometry gating (fix: iwyu) (#2784)

This PR applies the include-what-you-use fixes as suggested by
https://github.com/eic/EICrecon/actions/runs/30136636279.
Please merge this PR into the branch `nonthrowing-geometry-readout-api`
to resolve failures in PR #2783.

Auto-generated by [create-pull-request][1]

[1]: https://github.com/peter-evans/create-pull-request

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 43 out of 43 changed files in this pull request and generated 1 comment.

Comment on lines +51 to +60
SECTION("present readout with a segmentation yields a valid segmentation") {
const auto segmentation = eicrecon::geo::readoutSegmentation(*detector, "MockTrackerHits");
REQUIRE(segmentation.has_value());
REQUIRE(segmentation->isValid());
}

SECTION("absent readout yields nullopt without throwing") {
REQUIRE_NOTHROW(eicrecon::geo::readoutSegmentation(*detector, "NonexistentHits"));
REQUIRE_FALSE(eicrecon::geo::readoutSegmentation(*detector, "NonexistentHits").has_value());
}
Copilot AI review requested due to automatic review settings July 25, 2026 00:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 43 out of 43 changed files in this pull request and generated 2 comments.

Comment on lines +151 to +159
const auto missing_readout_policy =
eicrecon::geo::parseMissingReadoutPolicy(m_cfg.missingReadoutPolicy);
if (m_cfg.readout.empty()) {
if ((!m_cfg.adjacencyMatrix.empty()) || (!m_cfg.peakNeighbourhoodMatrix.empty())) {
throw std::runtime_error(
"'readout' is not provided, it is needed to know the fields in readout ids");
}
} else {
if (!eicrecon::geo::hasReadout(*m_detector, m_cfg.readout)) {
Comment on lines 171 to +176
void LGADHitClustering::process(const LGADHitClustering::Input& input,
const LGADHitClustering::Output& output) const {
const auto [calibrated_hits] = input;
if (!m_readout_available) {
return;
}
wdconinc pushed a commit that referenced this pull request Jul 25, 2026
…d-geometry gating (fix: iwyu) (#2785)

This PR applies the include-what-you-use fixes as suggested by
https://github.com/eic/EICrecon/actions/runs/30137354767.
Please merge this PR into the branch `nonthrowing-geometry-readout-api`
to resolve failures in PR #2783.

Auto-generated by [create-pull-request][1]

[1]: https://github.com/peter-evans/create-pull-request

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 25, 2026 02:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 43 out of 43 changed files in this pull request and generated 1 comment.

Comment on lines 45 to +49
if (m_cfg.readout.empty()) {
error("readoutClass is not provided, it is needed to know the fields in readout ids");
m_readout_available = false;
return;
}
wdconinc pushed a commit that referenced this pull request Jul 27, 2026
…d-geometry gating (fix: iwyu) (#2784)

This PR applies the include-what-you-use fixes as suggested by
https://github.com/eic/EICrecon/actions/runs/30136636279.
Please merge this PR into the branch `nonthrowing-geometry-readout-api`
to resolve failures in PR #2783.

Auto-generated by [create-pull-request][1]

[1]: https://github.com/peter-evans/create-pull-request

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
wdconinc pushed a commit that referenced this pull request Jul 27, 2026
…d-geometry gating (fix: iwyu) (#2785)

This PR applies the include-what-you-use fixes as suggested by
https://github.com/eic/EICrecon/actions/runs/30137354767.
Please merge this PR into the branch `nonthrowing-geometry-readout-api`
to resolve failures in PR #2783.

Auto-generated by [create-pull-request][1]

[1]: https://github.com/peter-evans/create-pull-request

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 27, 2026 21:38
@wdconinc
wdconinc force-pushed the nonthrowing-geometry-readout-api branch from 3dbd240 to b3744d0 Compare July 27, 2026 21:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 43 out of 43 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/algorithms/calorimetry/CalorimeterHitsMerger.cc:49

  • When readout is empty, init() currently logs an error and silently disables the algorithm (m_readout_available = false). Unlike the other readout-dependent producers in this PR, this can mask a genuine configuration error and lead to missing outputs without failing the job. Consider throwing on an empty readout (the non-throwing behavior should be reserved for the case where a configured readout is absent from the loaded geometry).
  if (m_cfg.readout.empty()) {
    error("readoutClass is not provided, it is needed to know the fields in readout ids");
    m_readout_available = false;
    return;
  }

wdconinc and others added 5 commits August 12, 2026 13:38
Add eicrecon::geo::hasReadout / readoutIdSpec / readoutSegmentation in
src/algorithms/interfaces/GeometryUtils.h. These query DD4hep readouts
without throwing when a readout is absent (reporting absence via a bool or
an empty std::optional), so algorithms can gracefully disable
detector-specific code paths in reduced-geometry configurations instead of
letting DD4hep's throwing Detector::readout() propagate through the JANA2
dataflow. A thrown exception continues to mean a genuine failure.

The helpers are header-only and operate on a plain dd4hep::Detector, so
they are usable from both the framework-independent algorithms (via
algorithms::GeoSvc::instance().detector()) and from JANA services (via
DD4hep_service::detector()).

Adds a Catch2 unit test that exercises present and absent readouts against
the mock detector and verifies the helpers do not throw where the raw
DD4hep lookup does.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Implement Layer B by making geometry-dependent producers explicitly detect
absent readouts at init-time and disable themselves instead of throwing
through JANA's upstream producer path.

For each affected algorithm, init now checks
`eicrecon::geo::hasReadout(*detector, m_cfg.readout)` and, when absent,
logs a warning and sets a disable flag. process() then returns early,
emitting empty outputs.

This keeps JANA semantics intact: missing collections remain optional-input
behavior, while genuine algorithm failures still surface as exceptions.

Applied to:
- CalorimeterHitDigi
- SimCalorimeterHitProcessor
- CalorimeterIslandCluster
- CalorimeterHitsMerger
- MPGDTrackerDigi
- MPGDHitReconstruction
- LGADHitClustering
- SiliconChargeSharing
- PulseCombiner
- FarDetectorTrackerCluster

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add a configurable `missingReadoutPolicy` knob (`disable` or `throw`) to
the readout-dependent producer chain introduced in Layer B.

- Added policy parsing utilities in GeometryUtils:
  - MissingReadoutPolicy enum
  - parseMissingReadoutPolicy()
- Added `missingReadoutPolicy` to affected algorithm config structs with
  default `disable`.
- Exposed `missingReadoutPolicy` as JANA parameters in corresponding
  factories.
- Updated readout-gated algorithms so missing readouts now respect policy:
  - disable: warn once, disable producer, emit empty outputs
  - throw: raise runtime_error instead of disabling
- Extended GeometryUtils unit tests for policy parsing.

This keeps reduced-geometry default behavior stable while enabling strict
mode for configurations that must fail on missing readouts.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…d-geometry gating (fix: iwyu) (#2784)

This PR applies the include-what-you-use fixes as suggested by
https://github.com/eic/EICrecon/actions/runs/30136636279.
Please merge this PR into the branch `nonthrowing-geometry-readout-api`
to resolve failures in PR #2783.

Auto-generated by [create-pull-request][1]

[1]: https://github.com/peter-evans/create-pull-request

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…d-geometry gating (fix: iwyu) (#2785)

This PR applies the include-what-you-use fixes as suggested by
https://github.com/eic/EICrecon/actions/runs/30137354767.
Please merge this PR into the branch `nonthrowing-geometry-readout-api`
to resolve failures in PR #2783.

Auto-generated by [create-pull-request][1]

[1]: https://github.com/peter-evans/create-pull-request

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 12, 2026 18:38
@wdconinc
wdconinc force-pushed the nonthrowing-geometry-readout-api branch from b3744d0 to a37a113 Compare August 12, 2026 18:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 43 out of 43 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/factories/digi/PulseCombiner_factory.h:25

  • The config/parameter key for minimum_separation is spelled minimumSeperation (typo). This is user-facing (configurable via JANA parameters) and makes the knob harder to discover/remember. Consider correcting it to minimumSeparation (and optionally keeping the old spelling as a deprecated alias if backward compatibility is needed).

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

Labels

topic: calorimetry relates to calorimetry topic: digitization topic: far-backward Reconstruction related to far backward detectors topic: infrastructure topic: tracking Relates to tracking reconstruction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants