From c4ccba8b613195e3ff5760647ffa140573814f02 Mon Sep 17 00:00:00 2001 From: Tristan Protzman Date: Mon, 9 Jun 2025 13:34:25 -0400 Subject: [PATCH 1/8] run cluster matchign for each calorimeter separately --- src/algorithms/reco/TrackClusterMatch.cc | 8 +-- src/algorithms/reco/TrackClusterMatchConfig.h | 1 + src/global/reco/reco.cc | 69 ++++++++++++++++--- 3 files changed, 64 insertions(+), 14 deletions(-) diff --git a/src/algorithms/reco/TrackClusterMatch.cc b/src/algorithms/reco/TrackClusterMatch.cc index 1d674de15d..fd8e59fb8b 100644 --- a/src/algorithms/reco/TrackClusterMatch.cc +++ b/src/algorithms/reco/TrackClusterMatch.cc @@ -47,13 +47,11 @@ void TrackClusterMatch::process(const TrackClusterMatch::Input& input, for (auto point : track.getPoints()) { // Check if the point is at the calorimeter // int id = m_detector->volumeManager().lookupDetector(cluster.getHits()[0].getCellID()).id(); // TODO: Find programmatic way to get detector cluster is from - uint32_t ecal_barrel_id = m_geo.detector()->constant("EcalBarrel_ID"); - uint32_t hcal_barrel_id = m_geo.detector()->constant("HcalBarrel_ID"); - bool is_ecal = point.system == ecal_barrel_id; - bool is_hcal = point.system == hcal_barrel_id; + uint32_t calo_id = m_geo.detector()->constant(m_cfg.calo_id); + bool is_calo = point.system == calo_id; bool is_surface = point.surface == 1; - if (!(is_ecal || is_hcal) || !is_surface) { + if (!is_calo || !is_surface) { trace("Skipping track point not at the calorimeter"); continue; } diff --git a/src/algorithms/reco/TrackClusterMatchConfig.h b/src/algorithms/reco/TrackClusterMatchConfig.h index 71f8874aad..8e793f28cb 100644 --- a/src/algorithms/reco/TrackClusterMatchConfig.h +++ b/src/algorithms/reco/TrackClusterMatchConfig.h @@ -9,5 +9,6 @@ namespace eicrecon { struct TrackClusterMatchConfig { double matching_distance = 0.5; + std::string calo_id = ""; }; } // namespace eicrecon diff --git a/src/global/reco/reco.cc b/src/global/reco/reco.cc index d24fdfc892..6c443bdc0e 100644 --- a/src/global/reco/reco.cc +++ b/src/global/reco/reco.cc @@ -183,18 +183,69 @@ void InitPlugin(JApplication* app) { }, app)); - app->Add(new JOmniFactoryGeneratorT>( - "BarrelClusters", - { - "HcalBarrelClusters", - "EcalBarrelClusters", - }, - {"BarrelClusters"}, app)); #if EDM4EIC_VERSION_MAJOR >= 8 + // Forward + app->Add(new JOmniFactoryGeneratorT( + "EcalEndcapPTrackClusterMatcher", + {"CalorimeterTrackProjections", "EcalEndcapPClusters"}, + {"EcalEndcapPTrackClusterMatches"}, + {.calo_id = "EcalEndcapP_ID"}, + app)); + + app->Add(new JOmniFactoryGeneratorT( + "EcalEndcapPInsertTrackClusterMatcher", + {"CalorimeterTrackProjections", "EcalEndcapPInsertClusters"}, + {"EcalEndcapPInsertTrackClusterMatches"}, + {.calo_id = "EcalEndcapPInsert_ID"}, + app)); + + app->Add(new JOmniFactoryGeneratorT( + "LFHCALTrackClusterMatcher", + {"CalorimeterTrackProjections", "LFHCALClusters"}, + {"LFHCALTrackClusterMatches"}, + {.calo_id = "LFHCAL_ID"}, + app)); + + app->Add(new JOmniFactoryGeneratorT( + "HcalEndcapPInsertClusterMatcher", + {"CalorimeterTrackProjections", "HcalEndcapPInsertClusters"}, + {"HcalEndcapPInsertClusterMatches"}, + {.calo_id = "HcalEndcapPInsert_ID"}, + app)); + + + // Barrel + app->Add(new JOmniFactoryGeneratorT( + "EcalBarrelTrackClusterMatcher", + {"CalorimeterTrackProjections", "EcalBarrelClusters"}, + {"EcalBarrelTrackClusterMatches"}, + {.calo_id = "EcalBarrel_ID"}, + app)); + + app->Add(new JOmniFactoryGeneratorT( + "HcalBarrelTrackClusterMatcher", + {"CalorimeterTrackProjections", "HcalBarrelClusters"}, + {"HcalBarrelTrackClusterMatches"}, + {.calo_id = "HcalBarrel_ID"}, + app)); + + // Backward + app->Add(new JOmniFactoryGeneratorT( + "EcalEndcapNBarrelTrackClusterMatcher", + {"CalorimeterTrackProjections", "EcalEndcapNClusters"}, + {"EcalEndcapNTrackClusterMatches"}, + {.calo_id = "EcalEndcapN_ID"}, + app)); + app->Add(new JOmniFactoryGeneratorT( - "TrackClusterMatcher", {"CalorimeterTrackProjections", "BarrelClusters"}, - {"TrackClusterMatches"}, {}, app)); + "HcalEndcapNBarrelTrackClusterMatcher", + {"CalorimeterTrackProjections", "HcalEndcapNClusters"}, + {"HcalEndcapNTrackClusterMatches"}, + {.calo_id = "HcalEndcapN_ID"}, + app)); + + #endif // EDM4EIC_VERSION_MAJOR >= 8 app->Add(new JOmniFactoryGeneratorT( From 4aa2b0d310f52a399ee37fce31481fad000e42ef Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Jun 2025 17:37:37 +0000 Subject: [PATCH 2/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/reco/TrackClusterMatch.cc | 4 +- src/algorithms/reco/TrackClusterMatchConfig.h | 2 +- src/global/reco/reco.cc | 51 +++++-------------- 3 files changed, 17 insertions(+), 40 deletions(-) diff --git a/src/algorithms/reco/TrackClusterMatch.cc b/src/algorithms/reco/TrackClusterMatch.cc index fd8e59fb8b..a51d25a566 100644 --- a/src/algorithms/reco/TrackClusterMatch.cc +++ b/src/algorithms/reco/TrackClusterMatch.cc @@ -48,8 +48,8 @@ void TrackClusterMatch::process(const TrackClusterMatch::Input& input, // Check if the point is at the calorimeter // int id = m_detector->volumeManager().lookupDetector(cluster.getHits()[0].getCellID()).id(); // TODO: Find programmatic way to get detector cluster is from uint32_t calo_id = m_geo.detector()->constant(m_cfg.calo_id); - bool is_calo = point.system == calo_id; - bool is_surface = point.surface == 1; + bool is_calo = point.system == calo_id; + bool is_surface = point.surface == 1; if (!is_calo || !is_surface) { trace("Skipping track point not at the calorimeter"); diff --git a/src/algorithms/reco/TrackClusterMatchConfig.h b/src/algorithms/reco/TrackClusterMatchConfig.h index 8e793f28cb..3d139cacf9 100644 --- a/src/algorithms/reco/TrackClusterMatchConfig.h +++ b/src/algorithms/reco/TrackClusterMatchConfig.h @@ -9,6 +9,6 @@ namespace eicrecon { struct TrackClusterMatchConfig { double matching_distance = 0.5; - std::string calo_id = ""; + std::string calo_id = ""; }; } // namespace eicrecon diff --git a/src/global/reco/reco.cc b/src/global/reco/reco.cc index 6c443bdc0e..3f294c4f1d 100644 --- a/src/global/reco/reco.cc +++ b/src/global/reco/reco.cc @@ -183,68 +183,45 @@ void InitPlugin(JApplication* app) { }, app)); - #if EDM4EIC_VERSION_MAJOR >= 8 // Forward app->Add(new JOmniFactoryGeneratorT( - "EcalEndcapPTrackClusterMatcher", - {"CalorimeterTrackProjections", "EcalEndcapPClusters"}, - {"EcalEndcapPTrackClusterMatches"}, - {.calo_id = "EcalEndcapP_ID"}, - app)); + "EcalEndcapPTrackClusterMatcher", {"CalorimeterTrackProjections", "EcalEndcapPClusters"}, + {"EcalEndcapPTrackClusterMatches"}, {.calo_id = "EcalEndcapP_ID"}, app)); app->Add(new JOmniFactoryGeneratorT( "EcalEndcapPInsertTrackClusterMatcher", {"CalorimeterTrackProjections", "EcalEndcapPInsertClusters"}, - {"EcalEndcapPInsertTrackClusterMatches"}, - {.calo_id = "EcalEndcapPInsert_ID"}, - app)); + {"EcalEndcapPInsertTrackClusterMatches"}, {.calo_id = "EcalEndcapPInsert_ID"}, app)); app->Add(new JOmniFactoryGeneratorT( - "LFHCALTrackClusterMatcher", - {"CalorimeterTrackProjections", "LFHCALClusters"}, - {"LFHCALTrackClusterMatches"}, - {.calo_id = "LFHCAL_ID"}, - app)); + "LFHCALTrackClusterMatcher", {"CalorimeterTrackProjections", "LFHCALClusters"}, + {"LFHCALTrackClusterMatches"}, {.calo_id = "LFHCAL_ID"}, app)); app->Add(new JOmniFactoryGeneratorT( "HcalEndcapPInsertClusterMatcher", {"CalorimeterTrackProjections", "HcalEndcapPInsertClusters"}, - {"HcalEndcapPInsertClusterMatches"}, - {.calo_id = "HcalEndcapPInsert_ID"}, - app)); - + {"HcalEndcapPInsertClusterMatches"}, {.calo_id = "HcalEndcapPInsert_ID"}, app)); // Barrel app->Add(new JOmniFactoryGeneratorT( - "EcalBarrelTrackClusterMatcher", - {"CalorimeterTrackProjections", "EcalBarrelClusters"}, - {"EcalBarrelTrackClusterMatches"}, - {.calo_id = "EcalBarrel_ID"}, - app)); + "EcalBarrelTrackClusterMatcher", {"CalorimeterTrackProjections", "EcalBarrelClusters"}, + {"EcalBarrelTrackClusterMatches"}, {.calo_id = "EcalBarrel_ID"}, app)); app->Add(new JOmniFactoryGeneratorT( - "HcalBarrelTrackClusterMatcher", - {"CalorimeterTrackProjections", "HcalBarrelClusters"}, - {"HcalBarrelTrackClusterMatches"}, - {.calo_id = "HcalBarrel_ID"}, - app)); + "HcalBarrelTrackClusterMatcher", {"CalorimeterTrackProjections", "HcalBarrelClusters"}, + {"HcalBarrelTrackClusterMatches"}, {.calo_id = "HcalBarrel_ID"}, app)); // Backward app->Add(new JOmniFactoryGeneratorT( "EcalEndcapNBarrelTrackClusterMatcher", - {"CalorimeterTrackProjections", "EcalEndcapNClusters"}, - {"EcalEndcapNTrackClusterMatches"}, - {.calo_id = "EcalEndcapN_ID"}, - app)); + {"CalorimeterTrackProjections", "EcalEndcapNClusters"}, {"EcalEndcapNTrackClusterMatches"}, + {.calo_id = "EcalEndcapN_ID"}, app)); app->Add(new JOmniFactoryGeneratorT( "HcalEndcapNBarrelTrackClusterMatcher", - {"CalorimeterTrackProjections", "HcalEndcapNClusters"}, - {"HcalEndcapNTrackClusterMatches"}, - {.calo_id = "HcalEndcapN_ID"}, - app)); - + {"CalorimeterTrackProjections", "HcalEndcapNClusters"}, {"HcalEndcapNTrackClusterMatches"}, + {.calo_id = "HcalEndcapN_ID"}, app)); #endif // EDM4EIC_VERSION_MAJOR >= 8 From e34ddcd381566c0dd9be14246afbe4b1695a8221 Mon Sep 17 00:00:00 2001 From: Tristan Protzman Date: Mon, 9 Jun 2025 13:59:19 -0400 Subject: [PATCH 3/8] validate configuration --- src/algorithms/reco/TrackClusterMatch.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/algorithms/reco/TrackClusterMatch.cc b/src/algorithms/reco/TrackClusterMatch.cc index a51d25a566..2d562a39c2 100644 --- a/src/algorithms/reco/TrackClusterMatch.cc +++ b/src/algorithms/reco/TrackClusterMatch.cc @@ -27,6 +27,15 @@ void TrackClusterMatch::process(const TrackClusterMatch::Input& input, auto [matched_particles] = output; trace("We have {} tracks and {} clusters", tracks->size(), clusters->size()); + // Validate the configuration + if (m_cfg.matching_distance <= 0) { + throw std::runtime_error( + fmt::format("Invalid matching distance: {}", m_cfg.matching_distance)); + } + if (m_cfg.calo_id.empty()) { + throw std::runtime_error("Calorimeter ID must be set in the configuration"); + } + std::set used_tracks; // Loop across each cluster, and find the cloeset projected track for (auto cluster : *clusters) { From fa5cda60a8409d4ff2c1cfbc1e5f4eca68215dfc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Jun 2025 17:59:32 +0000 Subject: [PATCH 4/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/reco/TrackClusterMatch.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/algorithms/reco/TrackClusterMatch.cc b/src/algorithms/reco/TrackClusterMatch.cc index 2d562a39c2..b65b118b6a 100644 --- a/src/algorithms/reco/TrackClusterMatch.cc +++ b/src/algorithms/reco/TrackClusterMatch.cc @@ -29,8 +29,7 @@ void TrackClusterMatch::process(const TrackClusterMatch::Input& input, // Validate the configuration if (m_cfg.matching_distance <= 0) { - throw std::runtime_error( - fmt::format("Invalid matching distance: {}", m_cfg.matching_distance)); + throw std::runtime_error(fmt::format("Invalid matching distance: {}", m_cfg.matching_distance)); } if (m_cfg.calo_id.empty()) { throw std::runtime_error("Calorimeter ID must be set in the configuration"); From defddad9852e7d67c097867c89cd1ecda4865eb3 Mon Sep 17 00:00:00 2001 From: Tristan Protzman Date: Mon, 30 Jun 2025 16:05:59 -0400 Subject: [PATCH 5/8] save each match collection by default --- src/global/reco/reco.cc | 2 +- src/services/io/podio/JEventProcessorPODIO.cc | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/global/reco/reco.cc b/src/global/reco/reco.cc index 3f294c4f1d..c88dba145c 100644 --- a/src/global/reco/reco.cc +++ b/src/global/reco/reco.cc @@ -201,7 +201,7 @@ void InitPlugin(JApplication* app) { app->Add(new JOmniFactoryGeneratorT( "HcalEndcapPInsertClusterMatcher", {"CalorimeterTrackProjections", "HcalEndcapPInsertClusters"}, - {"HcalEndcapPInsertClusterMatches"}, {.calo_id = "HcalEndcapPInsert_ID"}, app)); + {"HcalEndcapPInsertTrackClusterMatches"}, {.calo_id = "HcalEndcapPInsert_ID"}, app)); // Barrel app->Add(new JOmniFactoryGeneratorT( diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index aa28194b80..99a5bc17c2 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -380,7 +380,14 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "HcalFarForwardZDCRawHitAssociations", #endif #if EDM4EIC_VERSION_MAJOR >= 8 - "TrackClusterMatches", + "EcalEndcapPTrackClusterMatches", + "EcalEndcapPInsertTrackClusterMatches", + "LFHCALTrackClusterMatches", + "HcalEndcapPInsertClusterMatches", + "EcalBarrelTrackClusterMatches", + "HcalBarrelTrackClusterMatches", + "EcalEndcapNTrackClusterMatches", + "HcalEndcapNTrackClusterMatches", #endif }; From 3818632c196155f7526d8d709e53b8fdb04bf140 Mon Sep 17 00:00:00 2001 From: Tristan Protzman Date: Mon, 30 Jun 2025 16:23:57 -0400 Subject: [PATCH 6/8] apply iwyu --- src/algorithms/reco/TrackClusterMatch.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/algorithms/reco/TrackClusterMatch.cc b/src/algorithms/reco/TrackClusterMatch.cc index b65b118b6a..9b8d5e02a4 100644 --- a/src/algorithms/reco/TrackClusterMatch.cc +++ b/src/algorithms/reco/TrackClusterMatch.cc @@ -1,13 +1,14 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // Copyright (C) 2025 Tristan Protzman -#include #include // Needs edm4eic::TrackClusterMatch #include +#include +#include #include #include -#include #include +#include #include #if EDM4EIC_VERSION_MAJOR >= 8 From cec667f6b974a2c994b5206ff978eed755bfcc4b Mon Sep 17 00:00:00 2001 From: Tristan Protzman Date: Tue, 1 Jul 2025 15:08:00 -0400 Subject: [PATCH 7/8] remove EcalEndcapPInsert track cluster matching --- src/global/reco/reco.cc | 5 ----- src/services/io/podio/JEventProcessorPODIO.cc | 1 - 2 files changed, 6 deletions(-) diff --git a/src/global/reco/reco.cc b/src/global/reco/reco.cc index c88dba145c..d1157d0184 100644 --- a/src/global/reco/reco.cc +++ b/src/global/reco/reco.cc @@ -189,11 +189,6 @@ void InitPlugin(JApplication* app) { "EcalEndcapPTrackClusterMatcher", {"CalorimeterTrackProjections", "EcalEndcapPClusters"}, {"EcalEndcapPTrackClusterMatches"}, {.calo_id = "EcalEndcapP_ID"}, app)); - app->Add(new JOmniFactoryGeneratorT( - "EcalEndcapPInsertTrackClusterMatcher", - {"CalorimeterTrackProjections", "EcalEndcapPInsertClusters"}, - {"EcalEndcapPInsertTrackClusterMatches"}, {.calo_id = "EcalEndcapPInsert_ID"}, app)); - app->Add(new JOmniFactoryGeneratorT( "LFHCALTrackClusterMatcher", {"CalorimeterTrackProjections", "LFHCALClusters"}, {"LFHCALTrackClusterMatches"}, {.calo_id = "LFHCAL_ID"}, app)); diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index 99a5bc17c2..47b6fd5415 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -381,7 +381,6 @@ JEventProcessorPODIO::JEventProcessorPODIO() { #endif #if EDM4EIC_VERSION_MAJOR >= 8 "EcalEndcapPTrackClusterMatches", - "EcalEndcapPInsertTrackClusterMatches", "LFHCALTrackClusterMatches", "HcalEndcapPInsertClusterMatches", "EcalBarrelTrackClusterMatches", From 22f8cd57e7ddd9c93ea31adcabfc1a034bcc861e Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Tue, 1 Jul 2025 18:01:01 -0400 Subject: [PATCH 8/8] reco.cc: convention is to name factory according to its "primary" output --- src/global/reco/reco.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/global/reco/reco.cc b/src/global/reco/reco.cc index d1157d0184..4e75c56c95 100644 --- a/src/global/reco/reco.cc +++ b/src/global/reco/reco.cc @@ -186,35 +186,35 @@ void InitPlugin(JApplication* app) { #if EDM4EIC_VERSION_MAJOR >= 8 // Forward app->Add(new JOmniFactoryGeneratorT( - "EcalEndcapPTrackClusterMatcher", {"CalorimeterTrackProjections", "EcalEndcapPClusters"}, + "EcalEndcapPTrackClusterMatches", {"CalorimeterTrackProjections", "EcalEndcapPClusters"}, {"EcalEndcapPTrackClusterMatches"}, {.calo_id = "EcalEndcapP_ID"}, app)); app->Add(new JOmniFactoryGeneratorT( - "LFHCALTrackClusterMatcher", {"CalorimeterTrackProjections", "LFHCALClusters"}, + "LFHCALTrackClusterMatches", {"CalorimeterTrackProjections", "LFHCALClusters"}, {"LFHCALTrackClusterMatches"}, {.calo_id = "LFHCAL_ID"}, app)); app->Add(new JOmniFactoryGeneratorT( - "HcalEndcapPInsertClusterMatcher", + "HcalEndcapPInsertClusterMatches", {"CalorimeterTrackProjections", "HcalEndcapPInsertClusters"}, {"HcalEndcapPInsertTrackClusterMatches"}, {.calo_id = "HcalEndcapPInsert_ID"}, app)); // Barrel app->Add(new JOmniFactoryGeneratorT( - "EcalBarrelTrackClusterMatcher", {"CalorimeterTrackProjections", "EcalBarrelClusters"}, + "EcalBarrelTrackClusterMatches", {"CalorimeterTrackProjections", "EcalBarrelClusters"}, {"EcalBarrelTrackClusterMatches"}, {.calo_id = "EcalBarrel_ID"}, app)); app->Add(new JOmniFactoryGeneratorT( - "HcalBarrelTrackClusterMatcher", {"CalorimeterTrackProjections", "HcalBarrelClusters"}, + "HcalBarrelTrackClusterMatches", {"CalorimeterTrackProjections", "HcalBarrelClusters"}, {"HcalBarrelTrackClusterMatches"}, {.calo_id = "HcalBarrel_ID"}, app)); // Backward app->Add(new JOmniFactoryGeneratorT( - "EcalEndcapNBarrelTrackClusterMatcher", + "EcalEndcapNBarrelTrackClusterMatches", {"CalorimeterTrackProjections", "EcalEndcapNClusters"}, {"EcalEndcapNTrackClusterMatches"}, {.calo_id = "EcalEndcapN_ID"}, app)); app->Add(new JOmniFactoryGeneratorT( - "HcalEndcapNBarrelTrackClusterMatcher", + "HcalEndcapNBarrelTrackClusterMatches", {"CalorimeterTrackProjections", "HcalEndcapNClusters"}, {"HcalEndcapNTrackClusterMatches"}, {.calo_id = "HcalEndcapN_ID"}, app));