-
Notifications
You must be signed in to change notification settings - Fork 34
Implement Charged Candidate Maker (PFA1b) #2124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ruse-traveler
wants to merge
66
commits into
main
Choose a base branch
from
add-charged-candidate-maker-pfa-one
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 54 commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
c9d0fdf
Add skeletons of algorithm and factory
ruse-traveler 7236ad9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c052139
Merge branch 'main' into add-track-cluster-subtraction-pfa-one
ruse-traveler 4728ac1
Propagate upstream changes from development fork
ruse-traveler cfe67de
Merge branch 'add-track-cluster-subtraction-pfa-one' of github.com:ei…
ruse-traveler fb5a202
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d611fe6
Load particle plugin
ruse-traveler 21186d6
Use track PDGs for masses
ruse-traveler 703070e
Fix merge conflicts
ruse-traveler 0a4203a
Allow for checking zero against resolutions
ruse-traveler df5646d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] dcaed63
Write out all relevant collections
ruse-traveler 18176ea
Fix merge conflicts
ruse-traveler 7bf428c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c3a29ff
Merge branch 'main' into add-track-cluster-subtraction-pfa-one
ruse-traveler 5fc4ac4
Add particle category to global reconstruction
ruse-traveler e7c9fd9
Merge branch 'add-track-cluster-subtraction-pfa-one' of github.com:ei…
ruse-traveler 71d7bb6
Merge main
ruse-traveler 87204cb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 10867a3
Implement Track-Cluster Subtraction (PFA1) (fix: iwyu) (#2051)
wdconinc 3bbe27a
Remove PFTools
ruse-traveler 0ec864d
Make sure cmake finds plugin
ruse-traveler fa3fcb0
Use track-cluster matches until merge/splitter is updated
ruse-traveler 9c045ea
Make consistent with reco CMakeLists
ruse-traveler da828bb
Do light reformatting
ruse-traveler 298815f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 88539e1
Fix merge conflicts
ruse-traveler 7df36f3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] ea924e1
Merge branch 'main' into add-track-cluster-subtraction-pfa-one
ruse-traveler ff0a01b
Remove unused ChangeRun, make Process consistent with base class
ruse-traveler 9cdd2dc
Add outputs to defaults
ruse-traveler b9f4300
Clean up, add header guards
ruse-traveler f0cc650
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b1172a2
Implement Track-Cluster Subtraction (PFA1) (fix: iwyu) (#2087)
wdconinc 1623c19
Merge branch 'main' into add-track-cluster-subtraction-pfa-one
ruse-traveler 6412c91
Merge branch 'main' into add-track-cluster-subtraction-pfa-one
ruse-traveler 7147e15
Add FHCal insert
ruse-traveler 7e71e75
Make sure FHCal insert collections are in default output
ruse-traveler 6b0429d
Rename factories after primary output
ruse-traveler 429dd29
Remove WIP notes
ruse-traveler 05251ce
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e2c59e8
Add algorithm, factory, and generators
ruse-traveler a8040d9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b467b31
Remove edm4eic 8.X guards
ruse-traveler a80c881
Merge main
ruse-traveler d9350e7
Merge PFA1(a) branch
ruse-traveler e2fa5d2
Remove edm4eic 8.X guards
ruse-traveler 99325a7
Remove unnecessary comments
ruse-traveler 8464990
Add missing factory
ruse-traveler dbb370a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 06a2536
Fix typo in docstring
ruse-traveler cb56a96
Fix typo in docstring
ruse-traveler 0ba4a50
Merge branch 'add-track-cluster-subtraction-pfa-one' into add-charged…
ruse-traveler 82451e7
Implement Track-Cluster Subtraction (PFA1a) (fix: iwyu) (#2133)
wdconinc ed2fae1
Implement Charged Candidate Maker (PFA1b) (fix: iwyu) (#2134)
wdconinc eb4e239
Remove misplaced factory
ruse-traveler 4c8a98a
Temporarily add charged candidates to default output
ruse-traveler c027107
Merge branch 'main' into add-track-cluster-subtraction-pfa-one
ruse-traveler 3ef200c
Merge branch 'main' into add-charged-candidate-maker-pfa-one
ruse-traveler c9a0aa7
Merge PFA1a branch into PFA1b
ruse-traveler f208a51
Use track-cluster matches as PFA1b input
ruse-traveler 7deef73
Remove PFA1a code
ruse-traveler d517eb9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8f5d3a0
Fix typos in docstrings
ruse-traveler f4fc93d
Merge branch 'main' into add-charged-candidate-maker-pfa-one
ruse-traveler 49f2c03
Add log level/config application to factory init for consistency
ruse-traveler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| cmake_minimum_required(VERSION 3.16) | ||
|
|
||
| set(PLUGIN_NAME "algorithms_particle") | ||
|
|
||
| # Function creates ${PLUGIN_NAME}_plugin and ${PLUGIN_NAME}_library targets | ||
| # Setting default includes, libraries and installation paths | ||
| plugin_add(${PLUGIN_NAME} WITH_SHARED_LIBRARY WITHOUT_PLUGIN) | ||
|
|
||
| # The macro grabs sources as *.cc *.cpp *.c and headers as *.h *.hh *.hpp Then | ||
| # correctly sets sources for ${_name}_plugin and ${_name}_library targets Adds | ||
| # headers to the correct installation directory | ||
| plugin_glob_all(${PLUGIN_NAME}) | ||
|
|
||
| # Find dependencies | ||
| plugin_add_algorithms(${PLUGIN_NAME}) | ||
| plugin_add_dd4hep(${PLUGIN_NAME}) | ||
| plugin_add_event_model(${PLUGIN_NAME}) | ||
| plugin_add_eigen3(${PLUGIN_NAME}) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // SPDX-License-Identifier: LGPL-3.0-or-later | ||
| // Copyright (C) 2025 Derek Anderson | ||
|
|
||
| #include <edm4eic/Track.h> | ||
| #include <gsl/pointers> | ||
| #include <map> | ||
| #include <vector> | ||
|
|
||
| #include "ChargedCandidateMaker.h" | ||
|
|
||
| namespace eicrecon { | ||
|
|
||
| // ---------------------------------------------------------------------------- | ||
| //! Process inputs | ||
| // ---------------------------------------------------------------------------- | ||
| /*! Construct a candidate charged particle via the | ||
| * following algorithm. | ||
| * 1. Build map of tracks onto vectors of their | ||
| * matched tracks | ||
| * 2. For each track, create a Reconstructed | ||
| * Particle with track and cluster relations | ||
| * filled | ||
| */ | ||
| void ChargedCandidateMaker::process(const ChargedCandidateMaker::Input& input, | ||
| const ChargedCandidateMaker::Output& output) const { | ||
|
|
||
| // grab inputs/outputs | ||
| const auto [in_match] = input; | ||
| auto [out_particle] = output; | ||
|
|
||
| // exit if no matches in collection | ||
| if (in_match->size() == 0) { | ||
| debug("No track-cluster matches in collection"); | ||
| return; | ||
| } | ||
|
|
||
| MapToVecClust mapTrkToClust; | ||
| for (const auto& match : *in_match) { | ||
| mapTrkToClust[match.getTrack()].push_back(match.getCluster()); | ||
| } | ||
|
|
||
| for (const auto& [track, clusters] : mapTrkToClust) { | ||
| edm4eic::MutableReconstructedParticle particle = out_particle->create(); | ||
| particle.addToTracks(track); | ||
| for (const edm4eic::Cluster& cluster : clusters) { | ||
| particle.addToClusters(cluster); | ||
| } | ||
| } | ||
| } // end 'process(Input&, Output&)' | ||
| } // namespace eicrecon | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| // SPDX-License-Identifier: LGPL-3.0-or-later | ||
| // Copyright (C) 2025 Derek Anderson | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <algorithms/algorithm.h> | ||
| #include <edm4eic/ClusterCollection.h> | ||
| #include <edm4eic/ReconstructedParticleCollection.h> | ||
| #include <edm4eic/Track.h> | ||
| #include <edm4eic/TrackClusterMatchCollection.h> | ||
| #include <podio/ObjectID.h> | ||
| #include <map> | ||
| #include <string> | ||
| #include <string_view> | ||
| #include <vector> | ||
|
|
||
| #include "algorithms/interfaces/WithPodConfig.h" | ||
|
|
||
| namespace eicrecon { | ||
|
|
||
| // -------------------------------------------------------------------------- | ||
| //! Algorithm input/output | ||
| // -------------------------------------------------------------------------- | ||
| using ChargedCandidateMakerAlgorithm = | ||
| algorithms::Algorithm<algorithms::Input<edm4eic::TrackClusterMatchCollection>, | ||
| algorithms::Output<edm4eic::ReconstructedParticleCollection>>; | ||
|
|
||
| // ========================================================================== | ||
| //! Candidate Charged Particle Maker | ||
| // ========================================================================== | ||
| /*! An algorithm which takes a collection of clusters and their matched | ||
| * tracks, subtracts the sum of all tracks pointing to the cluster, | ||
| * and outputs the remnant clusters, expected clusters, and their matched | ||
| * tracks. | ||
| */ | ||
ruse-traveler marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| class ChargedCandidateMaker : public ChargedCandidateMakerAlgorithm, | ||
| public WithPodConfig<NoConfig> { | ||
|
|
||
| public: | ||
| // ------------------------------------------------------------------------ | ||
| //! Comparator struct for tracks | ||
| // ------------------------------------------------------------------------ | ||
| /*! Organizes tracks by their ObjectIDs in decreasing collection | ||
| * ID first, and by decreasing index second. | ||
| */ | ||
| struct CompareTrack { | ||
| bool operator()(const edm4eic::Track& lhs, const edm4eic::Track& rhs) const { | ||
| if (lhs.getObjectID().collectionID == rhs.getObjectID().collectionID) { | ||
| return (lhs.getObjectID().index < rhs.getObjectID().index); | ||
| } else { | ||
| return (lhs.getObjectID().collectionID < rhs.getObjectID().collectionID); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| ///! Alias for a map from a track to matched clusters | ||
| using MapToVecClust = std::map<edm4eic::Track, std::vector<edm4eic::Cluster>, CompareTrack>; | ||
|
|
||
| ///! Algorithm constructor | ||
| ChargedCandidateMaker(std::string_view name) | ||
| : ChargedCandidateMakerAlgorithm{name, | ||
| {"inputTrackClusterMatches"}, | ||
| {"outputChargedCandidateParticles"}, | ||
| "Forms candidate charged particles."} {} | ||
|
|
||
| // public method | ||
| void process(const Input&, const Output&) const final; | ||
|
|
||
| }; // end ChargedCandidateMaker | ||
|
|
||
| } // namespace eicrecon | ||
ruse-traveler marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // SPDX-License-Identifier: LGPL-3.0-or-later | ||
| // Copyright (C) 2025 Derek Anderson | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "extensions/jana/JOmniFactory.h" | ||
| #include "algorithms/particle/ChargedCandidateMaker.h" | ||
|
|
||
| namespace eicrecon { | ||
|
|
||
| class ChargedCandidateMaker_factory : public JOmniFactory<ChargedCandidateMaker_factory> { | ||
|
|
||
| public: | ||
| ///! alias for algorithm name | ||
| using AlgoT = eicrecon::ChargedCandidateMaker; | ||
|
|
||
| private: | ||
| // pointer to algorithm | ||
| std::unique_ptr<AlgoT> m_algo; | ||
|
|
||
| // input collection | ||
| PodioInput<edm4eic::TrackClusterMatch> m_track_cluster_match_input{this}; | ||
|
|
||
| // output collection | ||
| PodioOutput<edm4eic::ReconstructedParticle> m_charged_candidate_output{this}; | ||
|
|
||
| public: | ||
| ///! Configures algorithm | ||
| void Configure() { | ||
| m_algo = std::make_unique<AlgoT>(GetPrefix()); | ||
| m_algo->init(); | ||
| } | ||
|
|
||
| ///! Primary algorithm call | ||
| void Process(int32_t /*run_number*/, uint64_t /*event_number*/) { | ||
| m_algo->process({m_track_cluster_match_input()}, {m_charged_candidate_output().get()}); | ||
| } | ||
| }; // end ChargedCandidateMaker_factory | ||
|
|
||
| } // namespace eicrecon |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.