Skip to content

HEXPLIT: adjust timing cut to respect t0 - #2892

Open
veprbl wants to merge 8 commits into
mainfrom
pr/HEXPLIT_t0_cut
Open

HEXPLIT: adjust timing cut to respect t0#2892
veprbl wants to merge 8 commits into
mainfrom
pr/HEXPLIT_t0_cut

Conversation

@veprbl

@veprbl veprbl commented Aug 24, 2026

Copy link
Copy Markdown
Member

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

150 ns excess cut is relatively large for big chunk hadronic interactions, but we need to support case when t0 != 0, or this removes hits completely.

Related to #2081
Closes: #2802

What is the urgency of this PR?

  • High (please describe reason below)
    For meson structure group
  • Medium
  • Low

What kind of change does this PR introduce?

  • Bug fix (issue #__)
  • New feature (issue #__)
  • Optimization (issue #__)
  • Updated parameters, constants (issue #__)
  • 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.
    Old plugin:factory:tmax name is replaced by plugin:factory:max_time_to_truth_t0
  • This PR changes default behavior. Please describe changes below.
  • AI was used in preparing this PR. Please describe usage below.
    Claude

Copilot AI lite review requested due to automatic review settings August 24, 2026 19:21
@github-actions github-actions Bot added topic: calorimetry relates to calorimetry topic: far-forward Far forward reconstruction topic: forward labels Aug 24, 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 bug-fix updates HEXPLIT timing cuts to account for nonzero truth-particle production times.

Changes:

  • Adds optional MCParticles input and applies timing relative to truth t0.
  • Updates HEXPLIT configuration and ZDC/FHCAL wiring.
  • Adds timing-focused tests.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Reviewed changes and final comments
src/tests/algorithms_test/calorimetry_HEXPLIT.cc Adds truth fixtures and timing tests. Critical (1 vote): MutableMCParticle.h is unavailable; use MCParticle.h or the collection header.
src/factories/calorimetry/HEXPLIT_factory.h Wires optional truth input and the renamed timing parameter. Moderate (3 votes): Renaming tmax breaks existing configurations. Moderate (2 votes): The added input breaks existing one-tag InputTags overrides.
src/detectors/ZDC/ZDC.cc Enables truth timing input and updated HEXPLIT configuration.
src/detectors/FHCAL/FHCAL.cc Enables truth timing input and updated HEXPLIT configuration.
src/algorithms/calorimetry/HEXPLITConfig.h Renames the timing configuration field.
src/algorithms/calorimetry/HEXPLIT.h Extends the algorithm input interface and declares t0 helpers.
src/algorithms/calorimetry/HEXPLIT.cc Computes truth t0 and applies relative timing cuts. Critical (1 vote): Missing truth t0 removes the legacy absolute tmax rejection. Moderate (2 votes): Generator-level-only events lack a t0. Moderate (2 votes): Merged timeframes may use the wrong event’s primary time.
Suppressed comments (4)

src/algorithms/calorimetry/HEXPLIT.h:33

  • The algorithm input type now has two elements, but the constructor still advertises only {"inputHits"}. This leaves the new MC-particle input unnamed in the algorithm metadata (and can make input validation/introspection inconsistent); add a corresponding name such as mcParticles to the constructor's input-name list.
    algorithms::Algorithm<algorithms::Input<const edm4eic::CalorimeterHitCollection,
                                            std::optional<edm4hep::MCParticleCollection>>,

src/algorithms/calorimetry/HEXPLITConfig.h:12

  • Renaming the tmax field changes the exposed JANA parameter key from <factory>:tmax to <factory>:max_time_to_truth_t0. Existing user configurations and command lines that set tmax will no longer configure this cut, so this is a breaking API change; retain a compatibility alias/deprecation path or document the required migration and mark the breaking change.
  double max_time_to_truth_t0{325 * dd4hep::ns};

src/detectors/FHCAL/FHCAL.cc:89

  • JOmniFactory::PreInit requires the InputTags vector to contain exactly one name per registered input. Adding MCParticles here therefore makes existing HcalEndcapPInsertSubcellHits:InputTags overrides that contain only the old rec-hit tag fail during initialization, even though the new input is optional. Please preserve a legacy one-tag form or document this input-tag change as breaking.
      "HcalEndcapPInsertSubcellHits", {"HcalEndcapPInsertRecHits", "MCParticles"},
      {"HcalEndcapPInsertSubcellHits"},

src/detectors/ZDC/ZDC.cc:179

  • JOmniFactory::PreInit requires the InputTags vector to contain exactly one name per registered input. Adding MCParticles here therefore makes existing HcalFarForwardZDCSubcellHits:InputTags overrides that contain only the old rec-hit tag fail during initialization, even though the new input is optional. Please preserve a legacy one-tag form or document this input-tag change as breaking.
      "HcalFarForwardZDCSubcellHits", {"HcalFarForwardZDCRecHits", "MCParticles"},
      {"HcalFarForwardZDCSubcellHits"},

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/algorithms/calorimetry/HEXPLIT.cc Outdated
Comment thread src/algorithms/calorimetry/HEXPLIT.cc Outdated
Comment thread src/algorithms/calorimetry/HEXPLIT.cc Outdated
Comment thread src/factories/calorimetry/HEXPLIT_factory.h
Comment thread src/factories/calorimetry/HEXPLIT_factory.h Outdated
Comment thread src/tests/algorithms_test/calorimetry_HEXPLIT.cc Outdated
Copilot AI review requested due to automatic review settings August 24, 2026 19:42
@veprbl
veprbl force-pushed the pr/HEXPLIT_t0_cut branch from dd530f6 to 2ec128a Compare August 24, 2026 19:42

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 7 out of 7 changed files in this pull request and generated 3 comments.

Suppressed comments (3)

src/algorithms/calorimetry/HEXPLIT.cc:122

  • The added test only exercises the mchitlinks == nullptr fallback and never calls get_t0. The central new behavior—subtracting a non-zero primary time and applying max_time_to_truth_t0 when links are present—is therefore untested. Add a valid raw-hit/sim-hit/link/MCParticle setup with a non-zero t0 and assert both an in-window and an out-of-window hit.
    const auto t0 = nav.has_value() ? get_t0(hit, *nav) : std::nullopt;
    if (hit.getEnergy() < Emin || (t0.has_value() && (hit.getTime() - *t0) > max_dt)) {

src/algorithms/calorimetry/HEXPLIT.h:34

  • The Input tuple now contains both the reconstructed hits and an optional link collection, but the algorithm descriptor still supplies only {"inputHits"} to its constructor (line 41). This leaves the second input unnamed in the generic algorithm metadata/introspection; other multi-input algorithms enumerate every input (for example, CalorimeterTruthClustering.h:31). Add an inputHitLinks name for the new input.
using HEXPLITAlgorithm = algorithms::Algorithm<
    algorithms::Input<const edm4eic::CalorimeterHitCollection,
                      std::optional<edm4eic::MCRecoCalorimeterHitLinkCollection>>,
    algorithms::Output<edm4eic::CalorimeterHitCollection>>;

src/factories/calorimetry/HEXPLIT_factory.h:28

  • This renames the externally configurable JANA parameter from tmax to max_time_to_truth_t0. Existing command lines/configuration files that set ...:tmax will no longer affect HEXPLIT, so this is a breaking configuration change despite the PR description saying that no breaking changes are introduced. Please preserve a deprecated tmax alias (with a defined precedence) or document this as a breaking change.
  ParameterRef<double> m_max_time_to_truth_t0{this, "max_time_to_truth_t0",
                                              config().max_time_to_truth_t0};

Comment thread src/algorithms/calorimetry/HEXPLIT.cc Outdated
Comment thread src/algorithms/calorimetry/HEXPLIT.cc Outdated
Comment thread src/tests/algorithms_test/calorimetry_HEXPLIT.cc Outdated
Copilot AI review requested due to automatic review settings August 24, 2026 20:49

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 7 out of 7 changed files in this pull request and generated 3 comments.

Suppressed comments (1)

src/algorithms/calorimetry/HEXPLIT.cc:267

  • A raw hit can link to multiple simulation hits, and each simulation hit can contain multiple contributions. Breaking after the first contribution/link makes the selected primary time depend on link order rather than the time/energy policy used to form the reconstructed hit; a background link appearing first can therefore apply the wrong t0 and incorrectly reject or retain the hit. Select the contribution/simulation hit corresponding to the reconstructed time, or define a deterministic aggregation, and cover the multi-link case with a regression test.
    for (const auto& contrib : simhit.getContributions()) {
      t0 = get_primary(contrib).getTime();
      break;
    }
    break;

Comment thread src/algorithms/calorimetry/HEXPLIT.h
Comment thread src/tests/algorithms_test/calorimetry_HEXPLIT.cc
Comment on lines +96 to +100
edm4hep::MutableCaloHitContribution contrib;
contrib.setParticle(secondary);
contrib.setTime(hit_time_ns);
contrib.setEnergy(energy);
simhit.addToContributions(contrib);
@DraTeots

Copy link
Copy Markdown
Contributor

But... what happens if this timeout is fully removed? Are there analysis plots showing how bad everything is because of this?

Because again, in spirit of background meeting, if events might appear close to each other in time this cut will do the mess. Or it is seems so.

@veprbl

veprbl commented Aug 24, 2026

Copy link
Copy Markdown
Member Author

But... what happens if this timeout is fully removed? Are there analysis plots showing how bad everything is because of this?

Not much in ZDC, but there appears to be a slight energy cut in forward insert. I don't know why timescales are different.

edit: My testing was specifically on neutron benchmarks.

This PR applies the include-what-you-use fixes as suggested by
https://github.com/eic/EICrecon/actions/runs/32776133832.
Please merge this PR into the branch `pr/HEXPLIT_t0_cut`
to resolve failures in PR #2892.

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 24, 2026 23:08

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 7 out of 7 changed files in this pull request and generated no new comments.

Suppressed comments (3)

src/algorithms/calorimetry/HEXPLIT.cc:270

  • CalorimeterHitDigi can merge several SimCalorimeterHits into one raw hit and chooses the reconstructed timestamp from the most energetic linked sim hit (using its earliest contribution), but this loop always takes the first link and first contribution. For pileup/background cells, that t0 can belong to a different contributor than hit.getTime(), so a valid signal hit may be rejected—or a late hit retained—based on link order. Select the sim hit/contribution that determines the reconstructed timestamp, or explicitly combine all associated contributors according to the intended acceptance policy instead of stopping at the first one.
  for (const auto& [simhit, weight] : nav.getLinked(hit.getRawHit())) {
    for (const auto& contrib : simhit.getContributions()) {
      t0 = get_primary(contrib).getTime();
      break;
    }

src/algorithms/calorimetry/HEXPLIT.h:35

  • The Input alias now contains two collections, but the algorithm descriptor below still advertises only {"inputHits"}. This leaves HEXPLIT's declared interface inconsistent with its input tuple and makes the optional link input absent from metadata/introspection; the other multi-input algorithms in this tree provide one name per input. Add a name for the link collection.
                      std::optional<edm4eic::MCRecoCalorimeterHitLinkCollection>>,

src/tests/algorithms_test/calorimetry_HEXPLIT.cc:107

  • This contribution is a standalone mutable PODIO object and is never added to an edm4hep::CaloHitContributionCollection. addToContributions stores the object's (collectionID, index) relation, so simhit.getContributions() cannot resolve this object (or resolves an invalid ID); the timing tests can therefore pass without exercising get_t0(). Create the contribution in an owned contribution collection (kept alive in TruthChain) before adding it to the sim hit.
  edm4hep::MutableCaloHitContribution contrib;
  contrib.setParticle(secondary);
  contrib.setTime(hit_time_ns);
  contrib.setEnergy(energy);
  simhit.addToContributions(contrib);

Copilot AI review requested due to automatic review settings August 25, 2026 16:06

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 7 out of 7 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

src/tests/algorithms_test/calorimetry_HEXPLIT.cc:107

  • The contribution proxy is never inserted into an edm4hep::CaloHitContributionCollection; simhit.addToContributions therefore records an invalid relation. As a result getContributions() cannot reach secondary, so the linked timing tests do not provide a t0 and the two rejection cases will pass all 60 hits instead of exercising the new cut. Keep a contribution collection in TruthChain and create the contribution with create().
  edm4hep::MutableCaloHitContribution contrib;
  contrib.setParticle(secondary);
  contrib.setTime(hit_time_ns);
  contrib.setEnergy(energy);
  simhit.addToContributions(contrib);

Comment thread src/algorithms/calorimetry/HEXPLIT.cc
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: far-forward Far forward reconstruction topic: forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Background-merged events rejected by ZDC tmax cut (269 ns)

4 participants