Skip to content

feat: cloner algorithm and factory#2384

Open
wdconinc wants to merge 6 commits into
mainfrom
cloner
Open

feat: cloner algorithm and factory#2384
wdconinc wants to merge 6 commits into
mainfrom
cloner

Conversation

@wdconinc

Copy link
Copy Markdown
Contributor

Briefly, what does this PR introduce?

This PR introduces a cloning meta algorithm and factory to turn subset collections into collections of objects. This is used here, in particular, to create a clone of the MCBeamElectrons and MCBeamProtons collections (subset collections to MCParticles), so those can be stored in a digitization step in #2380 without storing all truth of MCParticles.

What kind of change does this PR introduce?

  • Bug fix (issue #__)
  • New feature (issue: cloner meta algorithm)
  • Documentation update
  • Other: __

Please check if this PR fulfills the following:

  • Tests for the changes have been added
  • Documentation has been added / updated
  • Changes have been communicated to collaborators

Does this PR introduce breaking changes? What changes might users need to make to their code?

No.

Does this PR change default behavior?

No.

Copilot AI review requested due to automatic review settings January 31, 2026 22:26

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 adds a small “cloner” meta-algorithm and factory, and wires it into the beam plugin to materialize standalone copies of selected MC beam subset collections, enabling two-stage digitization workflows that don’t keep the full MCParticles truth.

Changes:

  • Introduces Cloner<T> meta algorithm to duplicate elements from an input collection into a new output collection.
  • Adds Cloner_factory<T> JANA omni-factory wrapper around Cloner<T>.
  • Updates src/global/beam/beam.cc to produce MCBeamElectronsCloned and MCBeamProtonsCloned collections from the existing beam subset collections.

Reviewed changes

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

File Description
src/global/beam/beam.cc Registers two Cloner_factory<edm4hep::MCParticle> instances to clone MCBeamElectrons and MCBeamProtons into standalone collections for two-stage workflows.
src/factories/meta/Cloner_factory.h Defines a generic JOmni-based factory that wires a single input PODIO collection into the Cloner<T> algorithm and exposes a single cloned output collection.
src/algorithms/meta/Cloner.h Implements the generic Cloner<T> algorithm that iterates an input collection and pushes obj.clone() into the output collection to break subset dependencies.

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

Comment thread src/factories/meta/Cloner_factory.h
Copilot AI review requested due to automatic review settings January 31, 2026 23:02

This comment was marked as resolved.

wdconinc pushed a commit that referenced this pull request Feb 1, 2026
This PR applies the include-what-you-use fixes as suggested by
https://github.com/eic/EICrecon/actions/runs/21552375295.
Please merge this PR into the branch `cloner`
to resolve failures in PR #2384.

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
wdconinc enabled auto-merge February 1, 2026 03:59
Copilot AI review requested due to automatic review settings February 1, 2026 04:02

This comment was marked as resolved.

@wdconinc

wdconinc commented Feb 1, 2026

Copy link
Copy Markdown
Contributor Author

No diffs.

@wdconinc
wdconinc requested review from a team and rahmans1 and removed request for a team February 1, 2026 16:58
@simonge

simonge commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

Commenting a bit of a longer conceptual view, rather than directly this purge of MC information (Thinking about #2385 and #2384). Should we be looking at storing the beam particles as Reconstructed Particles? Even after the metadata is available.

An algorithm would then take the vertex collection and the metadata on the beam settings to reconstruct a particle with an accurate covariance matrix. Which would be essential for the qError suggestion in eic/EDM4eic#93

@wdconinc

wdconinc commented Feb 1, 2026

Copy link
Copy Markdown
Contributor Author

Commenting a bit of a longer conceptual view, rather than directly this purge of MC information (Thinking about #2385 and #2384). Should we be looking at storing the beam particles as Reconstructed Particles? Even after the metadata is available.

An algorithm would then take the vertex collection and the metadata on the beam settings to reconstruct a particle with an accurate covariance matrix. Which would be essential for the qError suggestion in eic/EDM4eic#93

I think ultimately there will need to be some way of combining the metadata with primary vertex to get t0 and such, so that seems like a reasonable way forward. But I don't know how close we are to even starting that.

wdconinc pushed a commit that referenced this pull request Feb 14, 2026
This PR applies the include-what-you-use fixes as suggested by
https://github.com/eic/EICrecon/actions/runs/21552375295.
Please merge this PR into the branch `cloner`
to resolve failures in PR #2384.

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 Feb 15, 2026
This PR applies the include-what-you-use fixes as suggested by
https://github.com/eic/EICrecon/actions/runs/21552375295.
Please merge this PR into the branch `cloner`
to resolve failures in PR #2384.

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 February 15, 2026 18:41

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


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

Comment thread src/algorithms/meta/Cloner.h
Comment thread src/factories/meta/Cloner_factory.h
wdconinc and others added 5 commits July 21, 2026 16:28
This PR applies the include-what-you-use fixes as suggested by
https://github.com/eic/EICrecon/actions/runs/21552375295.
Please merge this PR into the branch `cloner`
to resolve failures in PR #2384.

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 21, 2026 21:28

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

Comment on lines +14 to +18
* This algorithm takes an input collection and creates an output collection
* containing cloned copies of those elements. This is primarily useful for
* subset collections (where elements point to objects in another collection)
* to create standalone collections that can be stored without the original.
*
Comment thread src/global/beam/beam.cc
Comment on lines +48 to +52
// Clone MCBeamElectrons and MCBeamProtons for two-stage workflows
// This allows storing just the beam particles without the full MCParticles collection
app->Add(new JOmniFactoryGeneratorT<Cloner_factory<edm4hep::MCParticle>>(
"MCBeamElectronsCloned", {"MCBeamElectrons"}, {"MCBeamElectronsCloned"}, app));
app->Add(new JOmniFactoryGeneratorT<Cloner_factory<edm4hep::MCParticle>>(
Comment thread src/global/beam/beam.cc
// Clone MCBeamElectrons and MCBeamProtons for two-stage workflows
// This allows storing just the beam particles without the full MCParticles collection
app->Add(new JOmniFactoryGeneratorT<Cloner_factory<edm4hep::MCParticle>>(
"MCBeamElectronsCloned", {"MCBeamElectrons"}, {"MCBeamElectronsCloned"}, app));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we come up with naming scheme for subset collections instead? How about MCBeamElectronsSubset?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do we care about the breakage that could introduce?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As far as I can imagine, no one knows how to work with subset collections without PODIO.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll append subset later

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

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

Comments suppressed due to low confidence (1)

src/algorithms/meta/Cloner.h:43

  • obj.clone() copies the object's relations as well. For relation-heavy types like edm4hep::MCParticle this means the cloned objects can still reference the original MCParticles collection (e.g. via parent/daughter relations), defeating the stated goal of being able to persist the cloned collection without persisting the original and likely triggering dangling-relation checks. The codebase explicitly avoids clone() for MCParticles for this reason (see src/algorithms/reco/UndoAfterBurner.cc where relationships are not cloned). Consider either (a) implementing an MCParticle-specific cloning path that copies only the value fields and clears/omits relations, or (b) extending this algorithm with an option to drop/rewire relations so outputs are self-contained when the source collection is not written.
    // Clone each element from input to output
    for (const auto& obj : *in_coll) {
      out_coll->push_back(obj.clone());
    }

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants