From 73dd28ece9b082a47118242a7ef894347f98dab2 Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Tue, 5 Nov 2024 15:12:46 -0500 Subject: [PATCH 01/32] Add merge matrix to configuration + initialization --- .../calorimetry/CalorimeterHitsMerger.cc | 26 +++++++++++++++++-- .../calorimetry/CalorimeterHitsMerger.h | 13 ++++++++++ .../calorimetry/CalorimeterHitsMergerConfig.h | 3 ++- .../CalorimeterHitsMerger_factory.h | 1 + 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index 0267d5f2bc..a8307411cf 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -12,16 +12,17 @@ #include #include -#include #include #include #include #include +#include // NEW #include #include #include #include #include +#include // NEW #include #include #include @@ -31,6 +32,7 @@ #include #include "algorithms/calorimetry/CalorimeterHitsMergerConfig.h" +#include "services/evaluator/EvaluatorSvc.h" // NEW namespace eicrecon { @@ -41,8 +43,8 @@ void CalorimeterHitsMerger::init() { return; } + id_desc = m_detector->readout(m_cfg.readout).idSpec(); try { - auto id_desc = m_detector->readout(m_cfg.readout).idSpec(); id_mask = 0; std::vector> ref_fields; for (size_t i = 0; i < m_cfg.fields.size(); ++i) { @@ -59,6 +61,26 @@ void CalorimeterHitsMerger::init() { } id_mask = ~id_mask; debug("ID mask in {:s}: {:#064b}", m_cfg.readout, id_mask); + + + // ------------------------------------------------------------------------ + // NEW + // ------------------------------------------------------------------------ + std::function hit_to_map = [this](const edm4eic::CalorimeterHit& hit) { + std::unordered_map params; + for (const auto& name_field : id_desc.fields()) { + params.emplace(name_field.first, name_field.second->value(hit.getCellID())); + trace("{} = {}", name_field.first, name_field.second->value(hit.getCellID()) ); + } + return params; + }; + + auto& svc = algorithms::ServiceSvc::instance(); + if (!m_cfg.mergeMatrix.empty()) { + make_mask = svc.service("EvaluatorSvc")->compile(m_cfg.mergeMatrix, hit_to_map); + } + // ------------------------------------------------------------------------ + } void CalorimeterHitsMerger::process( diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.h b/src/algorithms/calorimetry/CalorimeterHitsMerger.h index 763d9d199c..25319ca4bf 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.h +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.h @@ -11,11 +11,13 @@ #pragma once #include +#include // NEW #include #include #include #include #include +#include #include #include #include @@ -51,10 +53,21 @@ namespace eicrecon { private: uint64_t id_mask{0}, ref_mask{0}; + // -------------------------------------------------------------------------- + // NEW + // -------------------------------------------------------------------------- + /* TODO might not need this as a member... + */ + private: + std::function make_mask; + private: const dd4hep::Detector* m_detector{algorithms::GeoSvc::instance().detector()}; const dd4hep::rec::CellIDPositionConverter* m_converter{algorithms::GeoSvc::instance().cellIDPositionConverter()}; + private: + dd4hep::IDDescriptor id_desc; // NEW + }; } // namespace eicrecon diff --git a/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h b/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h index 9d5f92df6c..e166f002e4 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h +++ b/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h @@ -11,8 +11,9 @@ namespace eicrecon { struct CalorimeterHitsMergerConfig { std::string readout{""}; + std::string mergeMatrix{""}; std::vector fields{}; - std::vector refs{}; + std::vector refs{}; // TODO might need to evolve this to a vector of vectors... }; diff --git a/src/factories/calorimetry/CalorimeterHitsMerger_factory.h b/src/factories/calorimetry/CalorimeterHitsMerger_factory.h index 9f6aefcd1b..83e1bf18da 100644 --- a/src/factories/calorimetry/CalorimeterHitsMerger_factory.h +++ b/src/factories/calorimetry/CalorimeterHitsMerger_factory.h @@ -20,6 +20,7 @@ class CalorimeterHitsMerger_factory : public JOmniFactory m_hits_output {this}; ParameterRef m_readout {this, "readout", config().readout}; + ParameterRef m_mergeMatrix {this, "mergeMatrix", config().mergeMatrix}; ParameterRef> m_fields {this, "fields", config().fields}; ParameterRef> m_refs {this, "refs", config().refs}; From edf51743cb6f43213598b90b9a2bb18632b7e9b6 Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Tue, 5 Nov 2024 16:56:11 -0500 Subject: [PATCH 02/32] Add hit merger to BHCal plugin --- src/detectors/BHCAL/BHCAL.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/detectors/BHCAL/BHCAL.cc b/src/detectors/BHCAL/BHCAL.cc index 39871793fc..50dab2f7f6 100644 --- a/src/detectors/BHCAL/BHCAL.cc +++ b/src/detectors/BHCAL/BHCAL.cc @@ -12,6 +12,7 @@ #include "factories/calorimetry/CalorimeterClusterRecoCoG_factory.h" #include "factories/calorimetry/CalorimeterHitDigi_factory.h" #include "factories/calorimetry/CalorimeterHitReco_factory.h" +#include "factories/calorimetry/CalorimeterHitsMerger_factory.h" #include "factories/calorimetry/CalorimeterIslandCluster_factory.h" #include "factories/calorimetry/CalorimeterTruthClustering_factory.h" #include "factories/calorimetry/TrackClusterMergeSplitter_factory.h" @@ -179,5 +180,20 @@ extern "C" { app // TODO: Remove me once fixed ) ); + + // -------------------------------------------------------------------- + // NEW + // -------------------------------------------------------------------- + app->Add(new JOmniFactoryGeneratorT( + "HcalBarrelMergedHits", {"HcalBarrelRecHits"}, {"HcalBarrelMergedHits"}, + { + .readout = "HcalBarrelHits", + .fields = {"eta"}, + .refs = {1} + }, + app // TODO: Remove me once fixed + )); + + } } From 9d145b55bced9a37b66fde0d9f17c1d53bc3e293 Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Tue, 5 Nov 2024 18:44:26 -0500 Subject: [PATCH 03/32] Fill in merge-map-building using provided mappings --- .../calorimetry/CalorimeterHitsMerger.cc | 125 +++++++++++++----- .../calorimetry/CalorimeterHitsMerger.h | 21 ++- .../calorimetry/CalorimeterHitsMergerConfig.h | 2 +- .../CalorimeterHitsMerger_factory.h | 2 +- 4 files changed, 111 insertions(+), 39 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index a8307411cf..ef9ab873a2 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -43,41 +43,57 @@ void CalorimeterHitsMerger::init() { return; } - id_desc = m_detector->readout(m_cfg.readout).idSpec(); + // ------------------------------------------------------------------------ + // NEW + // ------------------------------------------------------------------------ + // initialize descriptor + decoders try { - id_mask = 0; - std::vector> ref_fields; - for (size_t i = 0; i < m_cfg.fields.size(); ++i) { - id_mask |= id_desc.field(m_cfg.fields[i])->mask(); - // use the provided id number to find ref cell, or use 0 - int ref = i < m_cfg.refs.size() ? m_cfg.refs[i] : 0; - ref_fields.emplace_back(m_cfg.fields[i], ref); - } - ref_mask = id_desc.encode(ref_fields); + id_desc = m_detector->readout(m_cfg.readout).idSpec(); + id_decoder = id_desc.decoder(); + for (const auto& field : m_cfg.fields) { + const short index = id_decoder->index(field); + } } catch (...) { - auto mess = fmt::format("Failed to load ID decoder for {}", m_cfg.readout); - warning(mess); + auto mess = fmt::format("Failed to load ID decoder for {}", m_cfg.readout); + warning(mess); // throw std::runtime_error(mess); } - id_mask = ~id_mask; - debug("ID mask in {:s}: {:#064b}", m_cfg.readout, id_mask); - - // ------------------------------------------------------------------------ - // NEW - // ------------------------------------------------------------------------ - std::function hit_to_map = [this](const edm4eic::CalorimeterHit& hit) { - std::unordered_map params; - for (const auto& name_field : id_desc.fields()) { - params.emplace(name_field.first, name_field.second->value(hit.getCellID())); - trace("{} = {}", name_field.first, name_field.second->value(hit.getCellID()) ); + // if field-by-field mappings provided, initialize functionals + if (m_cfg.mappings.empty()) { + id_mask = 0; + std::vector ref_fields; // NEW + for (size_t i = 0; i < m_cfg.fields.size(); ++i) { + id_mask |= id_desc.field(m_cfg.fields[i])->mask(); + // use the provided id number to find ref cell, or use 0 + int ref = i < m_cfg.refs.size() ? m_cfg.refs[i] : 0; + ref_fields.emplace_back(m_cfg.fields[i], ref); } - return params; - }; - - auto& svc = algorithms::ServiceSvc::instance(); - if (!m_cfg.mergeMatrix.empty()) { - make_mask = svc.service("EvaluatorSvc")->compile(m_cfg.mergeMatrix, hit_to_map); + ref_mask = id_desc.encode(ref_fields); + id_mask = ~id_mask; + debug("ID mask in {:s}: {:#064b}", m_cfg.readout, id_mask); + } else { + + // lambda to translate IDDescriptor fields into function parameters + std::function hit_to_map = [this](const edm4eic::CalorimeterHit& hit) { + std::unordered_map params; + for (const auto& name_field : id_desc.fields()) { + params.emplace(name_field.first, name_field.second->value(hit.getCellID())); + trace("{} = {}", name_field.first, name_field.second->value(hit.getCellID())); + } + return params; + }; + + // intialize functions + auto& svc = algorithms::ServiceSvc::instance(); + for (std::size_t iMap = 0; const auto& mapping : m_cfg.mappings) { + if (iMap < m_cfg.fields.size()) { + ref_maps.emplace_back( + svc.service("EvaluatorSvc")->compile(mapping, hit_to_map) + ); + } + ++iMap; + } // end loop over mappings } // ------------------------------------------------------------------------ @@ -90,14 +106,19 @@ void CalorimeterHitsMerger::process( const auto [in_hits] = input; auto [out_hits] = output; + // ------------------------------------------------------------------------ + // NEW + // ------------------------------------------------------------------------ // find the hits that belong to the same group (for merging) - std::unordered_map> merge_map; - std::size_t ix = 0; - for (const auto &h : *in_hits) { + MergeMap merge_map; + if (m_cfg.mappings.empty()) { + for (std::size_t ix = 0; const auto &h : *in_hits) { uint64_t id = h.getCellID() & id_mask; merge_map[id].push_back(ix); - ix++; + } + } else { + build_map_via_funcs(in_hits,merge_map); } // sort hits by energy from large to small @@ -162,4 +183,42 @@ void CalorimeterHitsMerger::process( debug("Size before = {}, after = {}", in_hits->size(), out_hits->size()); } +// -------------------------------------------------------------------------- +// NEW +// -------------------------------------------------------------------------- +void CalorimeterHitsMerger::build_map_via_funcs( + const edm4eic::CalorimeterHitCollection* in_hits, + MergeMap& merge_map +) const { + + std::vector ref_fields; + for (std::size_t iHit = 0; const auto& hit : *in_hits) { + + // make sure vector is clear + ref_indices.clear(); + for (std::size_t iField = 0; const auto& name_field : id_desc.fields()) { + + // if mapping provided for field, apply it + // otherwise just copy index + if (std::find(m_cfg.fields, name_field.first)){ + ref_fields.push_back( + {name_field.first, ref_maps[iField](hit)} + ); + } else { + ref_fields.push_back( + {name_field.first, id_decoder->get(hit.getCellID(), name_field.first)} + ); + } + ++iField; + } + const uint64_t ref_id = id_desc.encode(ref_fields); + + // add hit to appropriate group + merge_map[ref_id].push_back(iHit); + ++iHit + + } // end hit loop + +} // end 'build_map_via_funcs(edm4eic::CalorimeterHitsCollection*, MergeMap&)' + } // namespace eicrecon diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.h b/src/algorithms/calorimetry/CalorimeterHitsMerger.h index 25319ca4bf..92ae0c9d33 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.h +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.h @@ -10,6 +10,7 @@ #pragma once +#include #include #include // NEW #include @@ -21,12 +22,21 @@ #include #include #include +#include +#include #include "CalorimeterHitsMergerConfig.h" #include "algorithms/interfaces/WithPodConfig.h" namespace eicrecon { + // -------------------------------------------------------------------------- + // NEW + // -------------------------------------------------------------------------- + // aliases for convenience + using MergeMap = std::unordered_map>; + using RefField = std::pair; + using CalorimeterHitsMergerAlgorithm = algorithms::Algorithm< algorithms::Input< edm4eic::CalorimeterHitCollection @@ -56,17 +66,20 @@ namespace eicrecon { // -------------------------------------------------------------------------- // NEW // -------------------------------------------------------------------------- - /* TODO might not need this as a member... - */ private: - std::function make_mask; + std::vector> ref_maps; + dd4hep::IDDescriptor id_desc; + dd4hep::BitFieldCoder* id_decoder; private: const dd4hep::Detector* m_detector{algorithms::GeoSvc::instance().detector()}; const dd4hep::rec::CellIDPositionConverter* m_converter{algorithms::GeoSvc::instance().cellIDPositionConverter()}; + // -------------------------------------------------------------------------- + // NEW + // -------------------------------------------------------------------------- private: - dd4hep::IDDescriptor id_desc; // NEW + void build_map_via_funcs(const edm4eic::CalorimeterHitCollection* in_hits, MergeMap& merge_map) const; }; diff --git a/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h b/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h index e166f002e4..ac0be0f52f 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h +++ b/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h @@ -11,9 +11,9 @@ namespace eicrecon { struct CalorimeterHitsMergerConfig { std::string readout{""}; - std::string mergeMatrix{""}; std::vector fields{}; std::vector refs{}; // TODO might need to evolve this to a vector of vectors... + std::vector mappings{}; // TODO better name? }; diff --git a/src/factories/calorimetry/CalorimeterHitsMerger_factory.h b/src/factories/calorimetry/CalorimeterHitsMerger_factory.h index 83e1bf18da..4a50ce424c 100644 --- a/src/factories/calorimetry/CalorimeterHitsMerger_factory.h +++ b/src/factories/calorimetry/CalorimeterHitsMerger_factory.h @@ -20,9 +20,9 @@ class CalorimeterHitsMerger_factory : public JOmniFactory m_hits_output {this}; ParameterRef m_readout {this, "readout", config().readout}; - ParameterRef m_mergeMatrix {this, "mergeMatrix", config().mergeMatrix}; ParameterRef> m_fields {this, "fields", config().fields}; ParameterRef> m_refs {this, "refs", config().refs}; + ParameterRef> m_mappings {this, "mappings", config().mappings}; Service m_algorithmsInit {this}; From 54aa6b0a3bdd95c96b923c6b7b07130e9478e070 Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Tue, 5 Nov 2024 18:44:55 -0500 Subject: [PATCH 04/32] Add test case in the BHCal (merging towers-into-tiles) --- src/detectors/BHCAL/BHCAL.cc | 9 +++++++-- src/services/io/podio/JEventProcessorPODIO.cc | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/detectors/BHCAL/BHCAL.cc b/src/detectors/BHCAL/BHCAL.cc index 50dab2f7f6..9632c6cb2a 100644 --- a/src/detectors/BHCAL/BHCAL.cc +++ b/src/detectors/BHCAL/BHCAL.cc @@ -184,12 +184,17 @@ extern "C" { // -------------------------------------------------------------------- // NEW // -------------------------------------------------------------------- + /* TODO + * - work out how to update adjacency matrix based on provided mappings + * - tie matrix to mappings + * - factory for clustering merged hits + */ app->Add(new JOmniFactoryGeneratorT( "HcalBarrelMergedHits", {"HcalBarrelRecHits"}, {"HcalBarrelMergedHits"}, { .readout = "HcalBarrelHits", - .fields = {"eta"}, - .refs = {1} + .fields = {"phi"}, + .mappings = {"std::floor(phi/5)"} }, app // TODO: Remove me once fixed )); diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index 2575c326a9..e905b55824 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -294,6 +294,7 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "HcalBarrelClusterAssociations", "HcalBarrelSplitMergeClusters", "HcalBarrelSplitMergeClusterAssociations", + "HcalBarrelMergedHits", // NEW "B0ECalRawHits", "B0ECalRecHits", "B0ECalClusters", From 4e9f9010907557c80d9cf8e5ea0892cfb977330c Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Wed, 6 Nov 2024 11:47:05 -0500 Subject: [PATCH 05/32] Fix compile time errors --- src/algorithms/calorimetry/CalorimeterHitsMerger.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index ef9ab873a2..6cd5c759ea 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -195,12 +195,17 @@ void CalorimeterHitsMerger::build_map_via_funcs( for (std::size_t iHit = 0; const auto& hit : *in_hits) { // make sure vector is clear - ref_indices.clear(); + ref_fields.clear(); for (std::size_t iField = 0; const auto& name_field : id_desc.fields()) { + // check if field has associated mapping + const bool foundMapping = ( + std::find(m_cfg.fields.begin(), m_cfg.fields.end(), name_field.first) != m_cfg.fields.end() + ); + // if mapping provided for field, apply it // otherwise just copy index - if (std::find(m_cfg.fields, name_field.first)){ + if (foundMapping) { ref_fields.push_back( {name_field.first, ref_maps[iField](hit)} ); @@ -215,7 +220,7 @@ void CalorimeterHitsMerger::build_map_via_funcs( // add hit to appropriate group merge_map[ref_id].push_back(iHit); - ++iHit + ++iHit; } // end hit loop From 0155a7b3d654741e12e74399e010d6d10c587adc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 6 Nov 2024 16:59:32 +0000 Subject: [PATCH 06/32] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/CalorimeterHitsMerger.cc | 2 +- src/detectors/BHCAL/BHCAL.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index 6cd5c759ea..a118ae119f 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -198,7 +198,7 @@ void CalorimeterHitsMerger::build_map_via_funcs( ref_fields.clear(); for (std::size_t iField = 0; const auto& name_field : id_desc.fields()) { - // check if field has associated mapping + // check if field has associated mapping const bool foundMapping = ( std::find(m_cfg.fields.begin(), m_cfg.fields.end(), name_field.first) != m_cfg.fields.end() ); diff --git a/src/detectors/BHCAL/BHCAL.cc b/src/detectors/BHCAL/BHCAL.cc index 9632c6cb2a..dbab014be2 100644 --- a/src/detectors/BHCAL/BHCAL.cc +++ b/src/detectors/BHCAL/BHCAL.cc @@ -186,7 +186,7 @@ extern "C" { // -------------------------------------------------------------------- /* TODO * - work out how to update adjacency matrix based on provided mappings - * - tie matrix to mappings + * - tie matrix to mappings * - factory for clustering merged hits */ app->Add(new JOmniFactoryGeneratorT( From 903fe3e5ebc020456e28e0d1e5b5763233b5e41e Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Wed, 6 Nov 2024 13:25:04 -0500 Subject: [PATCH 07/32] Add debugging statements --- src/algorithms/calorimetry/CalorimeterHitsMerger.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index 6cd5c759ea..3ca672dee0 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -91,6 +91,7 @@ void CalorimeterHitsMerger::init() { ref_maps.emplace_back( svc.service("EvaluatorSvc")->compile(mapping, hit_to_map) ); + trace("Mapping for field {} = {}", m_cfg.fields.at(iMap), mapping); } ++iMap; } // end loop over mappings @@ -120,6 +121,7 @@ void CalorimeterHitsMerger::process( } else { build_map_via_funcs(in_hits,merge_map); } + debug("Merge map built: merging {} hits into {} merged hits", in_hits->size(), merge_map.size()); // sort hits by energy from large to small for (auto &it : merge_map) { From 19079b50272bb5b70d7753c9d0a9655d54442caa Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Wed, 6 Nov 2024 15:10:09 -0500 Subject: [PATCH 08/32] Fix seg fault by tying mappings to fields --- src/algorithms/calorimetry/CalorimeterHitsMerger.cc | 13 +++++++------ src/algorithms/calorimetry/CalorimeterHitsMerger.h | 4 +++- src/detectors/BHCAL/BHCAL.cc | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index 3fb78583a5..bb944a6103 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -59,7 +59,8 @@ void CalorimeterHitsMerger::init() { // throw std::runtime_error(mess); } - // if field-by-field mappings provided, initialize functionals + // if no field-by-field mappings provided, initialize relevant bitmasks + // otherwise intialize relevant functionals if (m_cfg.mappings.empty()) { id_mask = 0; std::vector ref_fields; // NEW @@ -84,13 +85,13 @@ void CalorimeterHitsMerger::init() { return params; }; + // intialize functions + // - NOTE this assumes provided fields are 1-to-1! auto& svc = algorithms::ServiceSvc::instance(); for (std::size_t iMap = 0; const auto& mapping : m_cfg.mappings) { if (iMap < m_cfg.fields.size()) { - ref_maps.emplace_back( - svc.service("EvaluatorSvc")->compile(mapping, hit_to_map) - ); + ref_maps[m_cfg.fields.at(iMap)] = svc.service("EvaluatorSvc")->compile(mapping, hit_to_map); trace("Mapping for field {} = {}", m_cfg.fields.at(iMap), mapping); } ++iMap; @@ -200,7 +201,7 @@ void CalorimeterHitsMerger::build_map_via_funcs( ref_fields.clear(); for (std::size_t iField = 0; const auto& name_field : id_desc.fields()) { - // check if field has associated mapping + // check if field has associated mapping const bool foundMapping = ( std::find(m_cfg.fields.begin(), m_cfg.fields.end(), name_field.first) != m_cfg.fields.end() ); @@ -209,7 +210,7 @@ void CalorimeterHitsMerger::build_map_via_funcs( // otherwise just copy index if (foundMapping) { ref_fields.push_back( - {name_field.first, ref_maps[iField](hit)} + {name_field.first, ref_maps[name_field.first](hit)} ); } else { ref_fields.push_back( diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.h b/src/algorithms/calorimetry/CalorimeterHitsMerger.h index 92ae0c9d33..8476c49278 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.h +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,7 @@ namespace eicrecon { // aliases for convenience using MergeMap = std::unordered_map>; using RefField = std::pair; + using MapFunc = std::function; using CalorimeterHitsMergerAlgorithm = algorithms::Algorithm< algorithms::Input< @@ -67,7 +69,7 @@ namespace eicrecon { // NEW // -------------------------------------------------------------------------- private: - std::vector> ref_maps; + mutable std::map ref_maps; dd4hep::IDDescriptor id_desc; dd4hep::BitFieldCoder* id_decoder; diff --git a/src/detectors/BHCAL/BHCAL.cc b/src/detectors/BHCAL/BHCAL.cc index dbab014be2..5774a6c1f1 100644 --- a/src/detectors/BHCAL/BHCAL.cc +++ b/src/detectors/BHCAL/BHCAL.cc @@ -186,8 +186,8 @@ extern "C" { // -------------------------------------------------------------------- /* TODO * - work out how to update adjacency matrix based on provided mappings - * - tie matrix to mappings - * - factory for clustering merged hits + * - tie matrix to mappings + * - add factory for clustering merged hits */ app->Add(new JOmniFactoryGeneratorT( "HcalBarrelMergedHits", {"HcalBarrelRecHits"}, {"HcalBarrelMergedHits"}, From 2930d2cf13859bebab36befcad03863256175b92 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 6 Nov 2024 20:10:22 +0000 Subject: [PATCH 09/32] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/CalorimeterHitsMerger.cc | 2 +- src/detectors/BHCAL/BHCAL.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index bb944a6103..15dcf2f984 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -201,7 +201,7 @@ void CalorimeterHitsMerger::build_map_via_funcs( ref_fields.clear(); for (std::size_t iField = 0; const auto& name_field : id_desc.fields()) { - // check if field has associated mapping + // check if field has associated mapping const bool foundMapping = ( std::find(m_cfg.fields.begin(), m_cfg.fields.end(), name_field.first) != m_cfg.fields.end() ); diff --git a/src/detectors/BHCAL/BHCAL.cc b/src/detectors/BHCAL/BHCAL.cc index 5774a6c1f1..72ae03f101 100644 --- a/src/detectors/BHCAL/BHCAL.cc +++ b/src/detectors/BHCAL/BHCAL.cc @@ -186,7 +186,7 @@ extern "C" { // -------------------------------------------------------------------- /* TODO * - work out how to update adjacency matrix based on provided mappings - * - tie matrix to mappings + * - tie matrix to mappings * - add factory for clustering merged hits */ app->Add(new JOmniFactoryGeneratorT( From 6586f07dd7f6a5a7ca654e533c49cef0e0c17d7f Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Thu, 7 Nov 2024 18:37:05 -0500 Subject: [PATCH 10/32] Implement expression workaround --- src/detectors/BHCAL/BHCAL.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detectors/BHCAL/BHCAL.cc b/src/detectors/BHCAL/BHCAL.cc index 5774a6c1f1..5f2fc0112c 100644 --- a/src/detectors/BHCAL/BHCAL.cc +++ b/src/detectors/BHCAL/BHCAL.cc @@ -194,7 +194,7 @@ extern "C" { { .readout = "HcalBarrelHits", .fields = {"phi"}, - .mappings = {"std::floor(phi/5)"} + .mappings = {"phi-(5*((phi/5)-floor(phi/5)))"} }, app // TODO: Remove me once fixed )); From b346c130aa42d5bab72e0c332f47d2dccc0233e5 Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Wed, 13 Nov 2024 18:26:25 -0500 Subject: [PATCH 11/32] Add helper methods to consistently make phi mapping + adjacency matrix --- src/detectors/BHCAL/BHCAL.cc | 66 ++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/src/detectors/BHCAL/BHCAL.cc b/src/detectors/BHCAL/BHCAL.cc index 251ae291e9..0284aff2dc 100644 --- a/src/detectors/BHCAL/BHCAL.cc +++ b/src/detectors/BHCAL/BHCAL.cc @@ -17,6 +17,60 @@ #include "factories/calorimetry/CalorimeterTruthClustering_factory.h" #include "factories/calorimetry/TrackClusterMergeSplitter_factory.h" +// TEST +#include + +// ---------------------------------------------------------------------------- +// Helper method to generate appropriate phi map +// ---------------------------------------------------------------------------- +std::string MakePhiMap(const std::size_t nMerge = 1) { + + // convert num to merge to string + const std::string sNum = std::to_string(nMerge); + + // construct mapping + std::string map = ""; + if (nMerge > 1) { + map = "phi-(" + sNum + "*((phi/" + sNum + ")-floor(phi/" + sNum + ")))"; + } else { + map = "phi"; + } + return map; + +} // end 'MakePhiMap(std::size_t)' + + + +// ---------------------------------------------------------------------------- +// Helper method to generate appropriate adjacency matrix +// ---------------------------------------------------------------------------- +std::string MakeAdjacencyMatrix(const std::size_t nMerge = 1) { + + // set up checks at wraparound + const std::string sMerge = std::to_string(nMerge); + const std::string wrapDef = "(abs(phi_1 - phi_2) == (320 - 1))"; + const std::string wrapMerge = "(abs(320 - abs(phi_1 - phi_2)) <= " + sMerge + ")"; + + // combine strings into horizontal adjacency conditions + const std::string phiAdjacent = "(abs(phi_1 - phi_2) == " + sMerge + ")"; + const std::string wrapAdjacent = nMerge > 1 ? wrapMerge : wrapDef; + + // put everything together + std::string matrix(""); + matrix += "("; + // check for vertically adjacent tiles + matrix += " ( (abs(eta_1 - eta_2) == 1) && (abs(phi_1 - phi_2) == 0) ) ||"; + // check for horizontally adjacent tiles + matrix += " ( (abs(eta_1 - eta_2) == 0) && " + phiAdjacent + " ) ||"; + // check for horizontally adjacent tiles at wraparound + matrix += " ( (abs(eta_1 - eta_2) == 0) && " + wrapAdjacent + " )"; + matrix += ") == 1"; + return matrix; + +} // end 'MakeAdjacencyMatrix(std::size_t)' + + + extern "C" { void InitPlugin(JApplication *app) { @@ -25,6 +79,15 @@ extern "C" { InitJANAPlugin(app); + // --------------------------------------------------------------------- + // no. of adjacent phi tiles to merge into a tower + // --------------------------------------------------------------------- + const std::size_t nPhiToMerge = 3; + + // TODO wire into main reconstruction flow + const std::string phiMap = MakePhiMap(nPhiToMerge); + const std::string adjMatrix = MakeAdjacencyMatrix(nPhiToMerge); + // Make sure digi and reco use the same value decltype(CalorimeterHitDigiConfig::capADC) HcalBarrel_capADC = 65536; //65536, 16bit ADC decltype(CalorimeterHitDigiConfig::dyRangeADC) HcalBarrel_dyRangeADC = 1.0 * dd4hep::GeV; @@ -185,7 +248,6 @@ extern "C" { // NEW // -------------------------------------------------------------------- /* TODO - * - work out how to update adjacency matrix based on provided mappings * - tie matrix to mappings * - add factory for clustering merged hits */ @@ -194,7 +256,7 @@ extern "C" { { .readout = "HcalBarrelHits", .fields = {"phi"}, - .mappings = {"phi-(5*((phi/5)-floor(phi/5)))"} + .mappings = {phiMap} }, app // TODO: Remove me once fixed )); From a6d8617bba61a8cbc5a41f2358aede2726ead6db Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Thu, 14 Nov 2024 12:08:36 -0500 Subject: [PATCH 12/32] Finish wiring in merged hits --- src/detectors/BHCAL/BHCAL.cc | 163 ++++++++++++++++------------------- 1 file changed, 74 insertions(+), 89 deletions(-) diff --git a/src/detectors/BHCAL/BHCAL.cc b/src/detectors/BHCAL/BHCAL.cc index 0284aff2dc..dc3686e278 100644 --- a/src/detectors/BHCAL/BHCAL.cc +++ b/src/detectors/BHCAL/BHCAL.cc @@ -17,57 +17,58 @@ #include "factories/calorimetry/CalorimeterTruthClustering_factory.h" #include "factories/calorimetry/TrackClusterMergeSplitter_factory.h" -// TEST -#include - -// ---------------------------------------------------------------------------- -// Helper method to generate appropriate phi map -// ---------------------------------------------------------------------------- -std::string MakePhiMap(const std::size_t nMerge = 1) { - - // convert num to merge to string - const std::string sNum = std::to_string(nMerge); - - // construct mapping - std::string map = ""; - if (nMerge > 1) { - map = "phi-(" + sNum + "*((phi/" + sNum + ")-floor(phi/" + sNum + ")))"; - } else { - map = "phi"; - } - return map; - -} // end 'MakePhiMap(std::size_t)' - - - -// ---------------------------------------------------------------------------- -// Helper method to generate appropriate adjacency matrix -// ---------------------------------------------------------------------------- -std::string MakeAdjacencyMatrix(const std::size_t nMerge = 1) { - - // set up checks at wraparound - const std::string sMerge = std::to_string(nMerge); - const std::string wrapDef = "(abs(phi_1 - phi_2) == (320 - 1))"; - const std::string wrapMerge = "(abs(320 - abs(phi_1 - phi_2)) <= " + sMerge + ")"; - - // combine strings into horizontal adjacency conditions - const std::string phiAdjacent = "(abs(phi_1 - phi_2) == " + sMerge + ")"; - const std::string wrapAdjacent = nMerge > 1 ? wrapMerge : wrapDef; - - // put everything together - std::string matrix(""); - matrix += "("; - // check for vertically adjacent tiles - matrix += " ( (abs(eta_1 - eta_2) == 1) && (abs(phi_1 - phi_2) == 0) ) ||"; - // check for horizontally adjacent tiles - matrix += " ( (abs(eta_1 - eta_2) == 0) && " + phiAdjacent + " ) ||"; - // check for horizontally adjacent tiles at wraparound - matrix += " ( (abs(eta_1 - eta_2) == 0) && " + wrapAdjacent + " )"; - matrix += ") == 1"; - return matrix; +namespace eicrecon { + + // -------------------------------------------------------------------------- + // Helper method to generate appropriate phi map + // -------------------------------------------------------------------------- + std::string MakePhiMap(const std::size_t nMerge = 1) { + + // convert num to merge to string + const std::string sNum = std::to_string(nMerge); + + // construct mapping + std::string map = ""; + if (nMerge > 1) { + map = "phi-(" + sNum + "*((phi/" + sNum + ")-floor(phi/" + sNum + ")))"; + } else { + map = "phi"; + } + return map; + + } // end 'MakePhiMap(std::size_t)' + + // -------------------------------------------------------------------------- + // Helper method to generate appropriate adjacency matrix + // -------------------------------------------------------------------------- + std::string MakeAdjacencyMatrix(const std::size_t nMerge = 1) { + + // set up checks at wraparound. + // magic constants: + // 320 - number of tiles per row + const std::string sMerge = std::to_string(nMerge); + const std::string wrapDef = "(abs(phi_1 - phi_2) == (320 - 1))"; + const std::string wrapMerge = "(abs(320 - abs(phi_1 - phi_2)) <= " + sMerge + ")"; + + // combine strings into horizontal adjacency conditions + const std::string phiAdjacent = "(abs(phi_1 - phi_2) == " + sMerge + ")"; + const std::string wrapAdjacent = nMerge > 1 ? wrapMerge : wrapDef; + + // put everything together + std::string matrix(""); + matrix += "("; + // check for vertically adjacent tiles + matrix += " ( (abs(eta_1 - eta_2) == 1) && (abs(phi_1 - phi_2) == 0) ) ||"; + // check for horizontally adjacent tiles + matrix += " ( (abs(eta_1 - eta_2) == 0) && " + phiAdjacent + " ) ||"; + // check for horizontally adjacent tiles at wraparound + matrix += " ( (abs(eta_1 - eta_2) == 0) && " + wrapAdjacent + " )"; + matrix += ") == 1"; + return matrix; + + } // end 'MakeAdjacencyMatrix(std::size_t)' -} // end 'MakeAdjacencyMatrix(std::size_t)' +} @@ -79,15 +80,6 @@ extern "C" { InitJANAPlugin(app); - // --------------------------------------------------------------------- - // no. of adjacent phi tiles to merge into a tower - // --------------------------------------------------------------------- - const std::size_t nPhiToMerge = 3; - - // TODO wire into main reconstruction flow - const std::string phiMap = MakePhiMap(nPhiToMerge); - const std::string adjMatrix = MakeAdjacencyMatrix(nPhiToMerge); - // Make sure digi and reco use the same value decltype(CalorimeterHitDigiConfig::capADC) HcalBarrel_capADC = 65536; //65536, 16bit ADC decltype(CalorimeterHitDigiConfig::dyRangeADC) HcalBarrel_dyRangeADC = 1.0 * dd4hep::GeV; @@ -95,17 +87,15 @@ extern "C" { decltype(CalorimeterHitDigiConfig::pedSigmaADC) HcalBarrel_pedSigmaADC = 2; decltype(CalorimeterHitDigiConfig::resolutionTDC) HcalBarrel_resolutionTDC = 1 * dd4hep::picosecond; - // Set default adjacency matrix. Magic constants: - // 320 - number of tiles per row - decltype(CalorimeterIslandClusterConfig::adjacencyMatrix) HcalBarrel_adjacencyMatrix = - "(" - // check for vertically adjacent tiles - " ( (abs(eta_1 - eta_2) == 1) && (abs(phi_1 - phi_2) == 0) ) ||" - // check for horizontally adjacent tiles - " ( (abs(eta_1 - eta_2) == 0) && (abs(phi_1 - phi_2) == 1) ) ||" - // check for horizontally adjacent tiles at wraparound - " ( (abs(eta_1 - eta_2) == 0) && (abs(phi_1 - phi_2) == (320 - 1)) )" - ") == 1"; + // --------------------------------------------------------------------- + // if needed, merge adjacent tiles into a tower and adjust maps/matrices + // --------------------------------------------------------------------- + const std::size_t nPhiToMerge = 1; + const std::string phiMap = MakePhiMap(nPhiToMerge); + const std::string adjMatrix = MakeAdjacencyMatrix(nPhiToMerge); + + // set matrix + decltype(CalorimeterIslandClusterConfig::adjacencyMatrix) HcalBarrel_adjacencyMatrix = adjMatrix; app->Add(new JOmniFactoryGeneratorT( "HcalBarrelRawHits", @@ -130,6 +120,7 @@ extern "C" { }, app // TODO: Remove me once fixed )); + app->Add(new JOmniFactoryGeneratorT( "HcalBarrelRecHits", {"HcalBarrelRawHits"}, {"HcalBarrelRecHits"}, { @@ -147,12 +138,24 @@ extern "C" { }, app // TODO: Remove me once fixed )); + + app->Add(new JOmniFactoryGeneratorT( + "HcalBarrelMergedHits", {"HcalBarrelRecHits"}, {"HcalBarrelMergedHits"}, + { + .readout = "HcalBarrelHits", + .fields = {"phi"}, + .mappings = {phiMap} + }, + app // TODO: Remove me once fixed + )); + app->Add(new JOmniFactoryGeneratorT( "HcalBarrelTruthProtoClusters", {"HcalBarrelRecHits", "HcalBarrelHits"}, {"HcalBarrelTruthProtoClusters"}, app // TODO: Remove me once fixed )); + app->Add(new JOmniFactoryGeneratorT( - "HcalBarrelIslandProtoClusters", {"HcalBarrelRecHits"}, {"HcalBarrelIslandProtoClusters"}, + "HcalBarrelIslandProtoClusters", {"HcalBarrelMergedHits"}, {"HcalBarrelIslandProtoClusters"}, { .adjacencyMatrix = HcalBarrel_adjacencyMatrix, .readout = "HcalBarrelHits", @@ -244,23 +247,5 @@ extern "C" { ) ); - // -------------------------------------------------------------------- - // NEW - // -------------------------------------------------------------------- - /* TODO - * - tie matrix to mappings - * - add factory for clustering merged hits - */ - app->Add(new JOmniFactoryGeneratorT( - "HcalBarrelMergedHits", {"HcalBarrelRecHits"}, {"HcalBarrelMergedHits"}, - { - .readout = "HcalBarrelHits", - .fields = {"phi"}, - .mappings = {phiMap} - }, - app // TODO: Remove me once fixed - )); - - } } From eba0c58b63b770ede462a01ba36c7719f963da63 Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Thu, 14 Nov 2024 12:12:51 -0500 Subject: [PATCH 13/32] Clean up WIP comments --- .../calorimetry/CalorimeterHitsMerger.cc | 20 +++++-------------- .../calorimetry/CalorimeterHitsMerger.h | 13 ++---------- .../calorimetry/CalorimeterHitsMergerConfig.h | 4 ++-- src/services/io/podio/JEventProcessorPODIO.cc | 2 +- 4 files changed, 10 insertions(+), 29 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index 15dcf2f984..c4ae370906 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -1,5 +1,5 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022 Chao Peng, Jihee Kim, Sylvester Joosten, Whitney Armstrong, Wouter Deconinck, David Lawrence +// Copyright (C) 2022 Chao Peng, Jihee Kim, Sylvester Joosten, Whitney Armstrong, Wouter Deconinck, David Lawrence, Derek Anderson /* * An algorithm to group readout hits from a calorimeter @@ -16,13 +16,13 @@ #include #include #include -#include // NEW +#include #include #include #include #include #include -#include // NEW +#include #include #include #include @@ -32,7 +32,7 @@ #include #include "algorithms/calorimetry/CalorimeterHitsMergerConfig.h" -#include "services/evaluator/EvaluatorSvc.h" // NEW +#include "services/evaluator/EvaluatorSvc.h" namespace eicrecon { @@ -43,9 +43,6 @@ void CalorimeterHitsMerger::init() { return; } - // ------------------------------------------------------------------------ - // NEW - // ------------------------------------------------------------------------ // initialize descriptor + decoders try { id_desc = m_detector->readout(m_cfg.readout).idSpec(); @@ -63,7 +60,7 @@ void CalorimeterHitsMerger::init() { // otherwise intialize relevant functionals if (m_cfg.mappings.empty()) { id_mask = 0; - std::vector ref_fields; // NEW + std::vector ref_fields; for (size_t i = 0; i < m_cfg.fields.size(); ++i) { id_mask |= id_desc.field(m_cfg.fields[i])->mask(); // use the provided id number to find ref cell, or use 0 @@ -97,7 +94,6 @@ void CalorimeterHitsMerger::init() { ++iMap; } // end loop over mappings } - // ------------------------------------------------------------------------ } @@ -108,9 +104,6 @@ void CalorimeterHitsMerger::process( const auto [in_hits] = input; auto [out_hits] = output; - // ------------------------------------------------------------------------ - // NEW - // ------------------------------------------------------------------------ // find the hits that belong to the same group (for merging) MergeMap merge_map; if (m_cfg.mappings.empty()) { @@ -186,9 +179,6 @@ void CalorimeterHitsMerger::process( debug("Size before = {}, after = {}", in_hits->size(), out_hits->size()); } -// -------------------------------------------------------------------------- -// NEW -// -------------------------------------------------------------------------- void CalorimeterHitsMerger::build_map_via_funcs( const edm4eic::CalorimeterHitCollection* in_hits, MergeMap& merge_map diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.h b/src/algorithms/calorimetry/CalorimeterHitsMerger.h index 8476c49278..f4cd61043d 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.h +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022 Chao Peng, Jihee Kim, Sylvester Joosten, Whitney Armstrong, Wouter Deconinck, David Lawrence +// Copyright (C) 2022 Chao Peng, Jihee Kim, Sylvester Joosten, Whitney Armstrong, Wouter Deconinck, David Lawrence, Derek Anderson /* * An algorithm to group readout hits from a calorimeter @@ -12,7 +12,7 @@ #include #include -#include // NEW +#include #include #include #include @@ -31,9 +31,6 @@ namespace eicrecon { - // -------------------------------------------------------------------------- - // NEW - // -------------------------------------------------------------------------- // aliases for convenience using MergeMap = std::unordered_map>; using RefField = std::pair; @@ -65,9 +62,6 @@ namespace eicrecon { private: uint64_t id_mask{0}, ref_mask{0}; - // -------------------------------------------------------------------------- - // NEW - // -------------------------------------------------------------------------- private: mutable std::map ref_maps; dd4hep::IDDescriptor id_desc; @@ -77,9 +71,6 @@ namespace eicrecon { const dd4hep::Detector* m_detector{algorithms::GeoSvc::instance().detector()}; const dd4hep::rec::CellIDPositionConverter* m_converter{algorithms::GeoSvc::instance().cellIDPositionConverter()}; - // -------------------------------------------------------------------------- - // NEW - // -------------------------------------------------------------------------- private: void build_map_via_funcs(const edm4eic::CalorimeterHitCollection* in_hits, MergeMap& merge_map) const; diff --git a/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h b/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h index ac0be0f52f..ccf59b43ba 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h +++ b/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h @@ -12,8 +12,8 @@ namespace eicrecon { std::string readout{""}; std::vector fields{}; - std::vector refs{}; // TODO might need to evolve this to a vector of vectors... - std::vector mappings{}; // TODO better name? + std::vector refs{}; + std::vector mappings{}; }; diff --git a/src/services/io/podio/JEventProcessorPODIO.cc b/src/services/io/podio/JEventProcessorPODIO.cc index e905b55824..1d6cbf5d4e 100644 --- a/src/services/io/podio/JEventProcessorPODIO.cc +++ b/src/services/io/podio/JEventProcessorPODIO.cc @@ -290,11 +290,11 @@ JEventProcessorPODIO::JEventProcessorPODIO() { "LFHCALSplitMergeClusterAssociations", "HcalBarrelRawHits", "HcalBarrelRecHits", + "HcalBarrelMergedHits", "HcalBarrelClusters", "HcalBarrelClusterAssociations", "HcalBarrelSplitMergeClusters", "HcalBarrelSplitMergeClusterAssociations", - "HcalBarrelMergedHits", // NEW "B0ECalRawHits", "B0ECalRecHits", "B0ECalClusters", From 174e38f02ee7bcb06c443de57011763c2f3a4f4d Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Thu, 14 Nov 2024 12:14:41 -0500 Subject: [PATCH 14/32] Remove spurious line break --- src/algorithms/calorimetry/CalorimeterHitsMerger.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index c4ae370906..117fd8bdcd 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -82,7 +82,6 @@ void CalorimeterHitsMerger::init() { return params; }; - // intialize functions // - NOTE this assumes provided fields are 1-to-1! auto& svc = algorithms::ServiceSvc::instance(); From 3b6e445e1d18ffb32dd3b7a145bebaa895790678 Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Thu, 19 Dec 2024 13:31:34 -0500 Subject: [PATCH 15/32] Move mapping/matrix makers upstream --- src/detectors/BHCAL/BHCAL.cc | 81 +++++++----------------------------- 1 file changed, 16 insertions(+), 65 deletions(-) diff --git a/src/detectors/BHCAL/BHCAL.cc b/src/detectors/BHCAL/BHCAL.cc index dc3686e278..6e3c7e1ff6 100644 --- a/src/detectors/BHCAL/BHCAL.cc +++ b/src/detectors/BHCAL/BHCAL.cc @@ -17,61 +17,6 @@ #include "factories/calorimetry/CalorimeterTruthClustering_factory.h" #include "factories/calorimetry/TrackClusterMergeSplitter_factory.h" -namespace eicrecon { - - // -------------------------------------------------------------------------- - // Helper method to generate appropriate phi map - // -------------------------------------------------------------------------- - std::string MakePhiMap(const std::size_t nMerge = 1) { - - // convert num to merge to string - const std::string sNum = std::to_string(nMerge); - - // construct mapping - std::string map = ""; - if (nMerge > 1) { - map = "phi-(" + sNum + "*((phi/" + sNum + ")-floor(phi/" + sNum + ")))"; - } else { - map = "phi"; - } - return map; - - } // end 'MakePhiMap(std::size_t)' - - // -------------------------------------------------------------------------- - // Helper method to generate appropriate adjacency matrix - // -------------------------------------------------------------------------- - std::string MakeAdjacencyMatrix(const std::size_t nMerge = 1) { - - // set up checks at wraparound. - // magic constants: - // 320 - number of tiles per row - const std::string sMerge = std::to_string(nMerge); - const std::string wrapDef = "(abs(phi_1 - phi_2) == (320 - 1))"; - const std::string wrapMerge = "(abs(320 - abs(phi_1 - phi_2)) <= " + sMerge + ")"; - - // combine strings into horizontal adjacency conditions - const std::string phiAdjacent = "(abs(phi_1 - phi_2) == " + sMerge + ")"; - const std::string wrapAdjacent = nMerge > 1 ? wrapMerge : wrapDef; - - // put everything together - std::string matrix(""); - matrix += "("; - // check for vertically adjacent tiles - matrix += " ( (abs(eta_1 - eta_2) == 1) && (abs(phi_1 - phi_2) == 0) ) ||"; - // check for horizontally adjacent tiles - matrix += " ( (abs(eta_1 - eta_2) == 0) && " + phiAdjacent + " ) ||"; - // check for horizontally adjacent tiles at wraparound - matrix += " ( (abs(eta_1 - eta_2) == 0) && " + wrapAdjacent + " )"; - matrix += ") == 1"; - return matrix; - - } // end 'MakeAdjacencyMatrix(std::size_t)' - -} - - - extern "C" { void InitPlugin(JApplication *app) { @@ -87,15 +32,17 @@ extern "C" { decltype(CalorimeterHitDigiConfig::pedSigmaADC) HcalBarrel_pedSigmaADC = 2; decltype(CalorimeterHitDigiConfig::resolutionTDC) HcalBarrel_resolutionTDC = 1 * dd4hep::picosecond; - // --------------------------------------------------------------------- - // if needed, merge adjacent tiles into a tower and adjust maps/matrices - // --------------------------------------------------------------------- - const std::size_t nPhiToMerge = 1; - const std::string phiMap = MakePhiMap(nPhiToMerge); - const std::string adjMatrix = MakeAdjacencyMatrix(nPhiToMerge); - - // set matrix - decltype(CalorimeterIslandClusterConfig::adjacencyMatrix) HcalBarrel_adjacencyMatrix = adjMatrix; + // Set default adjacency matrix. Magic constants: + // 320 - number of tiles per row + decltype(CalorimeterIslandClusterConfig::adjacencyMatrix) HcalBarrel_adjacencyMatrix = + "(" + // check for vertically adjacent tiles + " ( (abs(eta_1 - eta_2) == 1) && (abs(phi_1 - phi_2) == 0) ) ||" + // check for horizontally adjacent tiles + " ( (abs(eta_1 - eta_2) == 0) && (abs(phi_1 - phi_2) == 1) ) ||" + // check for horizontally adjacent tiles at wraparound + " ( (abs(eta_1 - eta_2) == 0) && (abs(phi_1 - phi_2) == (320 - 1)) )" + ") == 1"; app->Add(new JOmniFactoryGeneratorT( "HcalBarrelRawHits", @@ -139,12 +86,16 @@ extern "C" { app // TODO: Remove me once fixed )); + // -------------------------------------------------------------------- + // If needed, merge adjacent phi tiles into towers. By default, + // NO merging will be done. This can be changed at runtime. + // -------------------------------------------------------------------- app->Add(new JOmniFactoryGeneratorT( "HcalBarrelMergedHits", {"HcalBarrelRecHits"}, {"HcalBarrelMergedHits"}, { .readout = "HcalBarrelHits", .fields = {"phi"}, - .mappings = {phiMap} + .mappings = {"phi"} }, app // TODO: Remove me once fixed )); From b4511b4c12affe0ba35db7f608596cf4edbf3644 Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Mon, 30 Dec 2024 15:04:51 -0500 Subject: [PATCH 16/32] Make parameter names more descriptive --- src/algorithms/calorimetry/CalorimeterHitsMerger.cc | 12 ++++++------ .../calorimetry/CalorimeterHitsMergerConfig.h | 4 ++-- src/detectors/BHCAL/BHCAL.cc | 2 +- src/detectors/EHCAL/EHCAL.cc | 2 +- src/detectors/FHCAL/FHCAL.cc | 2 +- .../calorimetry/CalorimeterHitsMerger_factory.h | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index 117fd8bdcd..55c81f836b 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -56,15 +56,15 @@ void CalorimeterHitsMerger::init() { // throw std::runtime_error(mess); } - // if no field-by-field mappings provided, initialize relevant bitmasks + // if no field-by-field transformations provided, initialize relevant bitmasks // otherwise intialize relevant functionals - if (m_cfg.mappings.empty()) { + if (m_cfg.fieldTransformations.empty()) { id_mask = 0; std::vector ref_fields; for (size_t i = 0; i < m_cfg.fields.size(); ++i) { id_mask |= id_desc.field(m_cfg.fields[i])->mask(); // use the provided id number to find ref cell, or use 0 - int ref = i < m_cfg.refs.size() ? m_cfg.refs[i] : 0; + int ref = i < m_cfg.fieldRefs.size() ? m_cfg.fieldRefs[i] : 0; ref_fields.emplace_back(m_cfg.fields[i], ref); } ref_mask = id_desc.encode(ref_fields); @@ -85,13 +85,13 @@ void CalorimeterHitsMerger::init() { // intialize functions // - NOTE this assumes provided fields are 1-to-1! auto& svc = algorithms::ServiceSvc::instance(); - for (std::size_t iMap = 0; const auto& mapping : m_cfg.mappings) { + for (std::size_t iMap = 0; const auto& mapping : m_cfg.fieldTransformations) { if (iMap < m_cfg.fields.size()) { ref_maps[m_cfg.fields.at(iMap)] = svc.service("EvaluatorSvc")->compile(mapping, hit_to_map); trace("Mapping for field {} = {}", m_cfg.fields.at(iMap), mapping); } ++iMap; - } // end loop over mappings + } // end loop over fieldTransformations } } @@ -105,7 +105,7 @@ void CalorimeterHitsMerger::process( // find the hits that belong to the same group (for merging) MergeMap merge_map; - if (m_cfg.mappings.empty()) { + if (m_cfg.fieldTransformations.empty()) { for (std::size_t ix = 0; const auto &h : *in_hits) { uint64_t id = h.getCellID() & id_mask; merge_map[id].push_back(ix); diff --git a/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h b/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h index ccf59b43ba..3084a43e3d 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h +++ b/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h @@ -12,8 +12,8 @@ namespace eicrecon { std::string readout{""}; std::vector fields{}; - std::vector refs{}; - std::vector mappings{}; + std::vector fieldRefs{}; + std::vector fieldTransformations{}; }; diff --git a/src/detectors/BHCAL/BHCAL.cc b/src/detectors/BHCAL/BHCAL.cc index 6e3c7e1ff6..d5186bac43 100644 --- a/src/detectors/BHCAL/BHCAL.cc +++ b/src/detectors/BHCAL/BHCAL.cc @@ -95,7 +95,7 @@ extern "C" { { .readout = "HcalBarrelHits", .fields = {"phi"}, - .mappings = {"phi"} + .fieldTransformations = {"phi"} }, app // TODO: Remove me once fixed )); diff --git a/src/detectors/EHCAL/EHCAL.cc b/src/detectors/EHCAL/EHCAL.cc index 49e21f6beb..9ae6364c68 100644 --- a/src/detectors/EHCAL/EHCAL.cc +++ b/src/detectors/EHCAL/EHCAL.cc @@ -72,7 +72,7 @@ extern "C" { { .readout = "HcalEndcapNHits", .fields = {"layer", "slice"}, - .refs = {4, 0}, // place merged hits at ~1 interaction length deep + .fieldRefs = {4, 0}, // place merged hits at ~1 interaction length deep }, app // TODO: Remove me once fixed )); diff --git a/src/detectors/FHCAL/FHCAL.cc b/src/detectors/FHCAL/FHCAL.cc index 3f9f145528..17284b44fa 100644 --- a/src/detectors/FHCAL/FHCAL.cc +++ b/src/detectors/FHCAL/FHCAL.cc @@ -84,7 +84,7 @@ extern "C" { { .readout = "HcalEndcapPInsertHits", .fields = {"layer", "slice"}, - .refs = {1, 0}, + .fieldRefs = {1, 0}, }, app // TODO: Remove me once fixed )); diff --git a/src/factories/calorimetry/CalorimeterHitsMerger_factory.h b/src/factories/calorimetry/CalorimeterHitsMerger_factory.h index 4a50ce424c..f10f1eab31 100644 --- a/src/factories/calorimetry/CalorimeterHitsMerger_factory.h +++ b/src/factories/calorimetry/CalorimeterHitsMerger_factory.h @@ -21,8 +21,8 @@ class CalorimeterHitsMerger_factory : public JOmniFactory m_readout {this, "readout", config().readout}; ParameterRef> m_fields {this, "fields", config().fields}; - ParameterRef> m_refs {this, "refs", config().refs}; - ParameterRef> m_mappings {this, "mappings", config().mappings}; + ParameterRef> m_field_refs {this, "fieldRefs", config().refs}; + ParameterRef> m_field_transformations {this, "fieldTransormations", config().mappings}; Service m_algorithmsInit {this}; From 6976ee2fed1fd7bdfe29971d8883402414e453a6 Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Mon, 30 Dec 2024 15:34:15 -0500 Subject: [PATCH 17/32] Fix missed field renames --- .../calorimetry/CalorimeterHitsMerger.cc | 33 +++++++++++++++++++ .../CalorimeterHitsMerger_factory.h | 4 +-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index 55c81f836b..c3e8d87e5c 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -56,6 +56,8 @@ void CalorimeterHitsMerger::init() { // throw std::runtime_error(mess); } + +/* TO REMOVE // if no field-by-field transformations provided, initialize relevant bitmasks // otherwise intialize relevant functionals if (m_cfg.fieldTransformations.empty()) { @@ -93,6 +95,7 @@ void CalorimeterHitsMerger::init() { ++iMap; } // end loop over fieldTransformations } +*/ } @@ -183,6 +186,35 @@ void CalorimeterHitsMerger::build_map_via_funcs( MergeMap& merge_map ) const { + // throw error if field and transformation vectors + // are different sizes + if (m_cfg.fields.size() != m_fieldTransformations.size()) { + error( + "field and transformation vectors are different sizes ({} vs. {}). Vectors should be 1-to-1.", + m_cfg.fields.size(), + m_fieldTransformations.size() + ); + return; + } + + // loop over hits + std::vector ref_fields; + for (std::size_t iHit = 0; const auto& hit : *in_hits) { + + // loop through readout fields + for (std::size_t iField = 0; const auto& name_field : id_desc.fields()) { + + + + } // end field loop + + // add hit to appropriate group + merge_map[ref_id].push_back(iHit); + ++iHit; + + } // end hit loop + +/* TO REMOVE std::vector ref_fields; for (std::size_t iHit = 0; const auto& hit : *in_hits) { @@ -213,6 +245,7 @@ void CalorimeterHitsMerger::build_map_via_funcs( // add hit to appropriate group merge_map[ref_id].push_back(iHit); ++iHit; +*/ } // end hit loop diff --git a/src/factories/calorimetry/CalorimeterHitsMerger_factory.h b/src/factories/calorimetry/CalorimeterHitsMerger_factory.h index f10f1eab31..2ffe4a1776 100644 --- a/src/factories/calorimetry/CalorimeterHitsMerger_factory.h +++ b/src/factories/calorimetry/CalorimeterHitsMerger_factory.h @@ -21,8 +21,8 @@ class CalorimeterHitsMerger_factory : public JOmniFactory m_readout {this, "readout", config().readout}; ParameterRef> m_fields {this, "fields", config().fields}; - ParameterRef> m_field_refs {this, "fieldRefs", config().refs}; - ParameterRef> m_field_transformations {this, "fieldTransormations", config().mappings}; + ParameterRef> m_field_refs {this, "fieldRefs", config().fieldRefs}; + ParameterRef> m_field_transformations {this, "fieldTransormations", config().fieldTransformations}; Service m_algorithmsInit {this}; From 6af099258591736c9b0a4c54c86b0c0f41675b2a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 20:35:14 +0000 Subject: [PATCH 18/32] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/calorimetry/CalorimeterHitsMerger.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index c3e8d87e5c..c26eeabd85 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -187,7 +187,7 @@ void CalorimeterHitsMerger::build_map_via_funcs( ) const { // throw error if field and transformation vectors - // are different sizes + // are different sizes if (m_cfg.fields.size() != m_fieldTransformations.size()) { error( "field and transformation vectors are different sizes ({} vs. {}). Vectors should be 1-to-1.", From 073028234146b867bdad68d3823706b85c9519ac Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Mon, 30 Dec 2024 16:32:42 -0500 Subject: [PATCH 19/32] Store both reference masks and transformations in ref_map --- .../calorimetry/CalorimeterHitsMerger.cc | 123 ++++++++---------- 1 file changed, 54 insertions(+), 69 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index c3e8d87e5c..fffb963be7 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -43,6 +43,25 @@ void CalorimeterHitsMerger::init() { return; } + // check that input field, mask, and transformation vectors + // are the same length + if (m_cfg.fields.size() != m_cfg.fieldRefs.size()) { + error( + "Size of field and reference mask vectors are different ({} vs. {}).", + m_cfg.fields.size(), + m_cfg.fieldRefs.size() + ); + return; + } + if (m_cfg.fields.size() != m_cfg.fieldTransformations.size()) { + error( + "Size of field and transformation vectors are different ({} vs. {}).", + m_cfg.fields.size(), + m_cfg.fieldTransformations.size() + ); + return; + } + // initialize descriptor + decoders try { id_desc = m_detector->readout(m_cfg.readout).idSpec(); @@ -56,46 +75,42 @@ void CalorimeterHitsMerger::init() { // throw std::runtime_error(mess); } - -/* TO REMOVE - // if no field-by-field transformations provided, initialize relevant bitmasks - // otherwise intialize relevant functionals - if (m_cfg.fieldTransformations.empty()) { - id_mask = 0; - std::vector ref_fields; - for (size_t i = 0; i < m_cfg.fields.size(); ++i) { - id_mask |= id_desc.field(m_cfg.fields[i])->mask(); - // use the provided id number to find ref cell, or use 0 - int ref = i < m_cfg.fieldRefs.size() ? m_cfg.fieldRefs[i] : 0; - ref_fields.emplace_back(m_cfg.fields[i], ref); + // lambda to translate IDDescriptor fields into function parameters + std::function hit_transform = [this](const edm4eic::CalorimeterHit& hit) { + std::unordered_map params; + for (const auto& name_field : id_desc.fields()) { + params.emplace(name_field.first, name_field.second->value(hit.getCellID())); + trace("{} = {}", name_field.first, name_field.second->value(hit.getCellID())); } - ref_mask = id_desc.encode(ref_fields); - id_mask = ~id_mask; - debug("ID mask in {:s}: {:#064b}", m_cfg.readout, id_mask); - } else { - - // lambda to translate IDDescriptor fields into function parameters - std::function hit_to_map = [this](const edm4eic::CalorimeterHit& hit) { - std::unordered_map params; - for (const auto& name_field : id_desc.fields()) { - params.emplace(name_field.first, name_field.second->value(hit.getCellID())); - trace("{} = {}", name_field.first, name_field.second->value(hit.getCellID())); - } - return params; - }; - - // intialize functions - // - NOTE this assumes provided fields are 1-to-1! - auto& svc = algorithms::ServiceSvc::instance(); - for (std::size_t iMap = 0; const auto& mapping : m_cfg.fieldTransformations) { - if (iMap < m_cfg.fields.size()) { - ref_maps[m_cfg.fields.at(iMap)] = svc.service("EvaluatorSvc")->compile(mapping, hit_to_map); - trace("Mapping for field {} = {}", m_cfg.fields.at(iMap), mapping); - } - ++iMap; - } // end loop over fieldTransformations - } -*/ + return params; + }; + + // loop through provided readout fields + auto& svc = algorithms::ServiceSvc::instance(); + for (std::size_t iField = 0; std::string& field : m_cfg.fields) { + + // grab provided field reference masks + // and transformations + uint64_t field_mask = m_cfg.fieldRefs.at(iField); + std::string field_transfrom = m_cfg.fieldTransformations.at(iField); + + // grab name and value of provided field + auto name_field = id_desc.field(field); + + // set mask or transformation for each field + // - if no transformation provided, reference + // mask will be used + if (field_transform.empty()) { + ref_maps[field] = [field_mask, name_field](const edm4eic::CalorimterHit& hit) -> int { + return (name_field->value(hit.cellID()) & ~field_mask) | field_mask; + }; + trace("{}: using mask {:#064b}", field, field_mask); + } else { + ref_maps[field] = svc.service("EvaluatorSvc")->compile(field_transform, hit_transform); + trace("{}: using transformation '{}'", field, field_transform); + } + ++iField; + } // end field loop } @@ -186,35 +201,6 @@ void CalorimeterHitsMerger::build_map_via_funcs( MergeMap& merge_map ) const { - // throw error if field and transformation vectors - // are different sizes - if (m_cfg.fields.size() != m_fieldTransformations.size()) { - error( - "field and transformation vectors are different sizes ({} vs. {}). Vectors should be 1-to-1.", - m_cfg.fields.size(), - m_fieldTransformations.size() - ); - return; - } - - // loop over hits - std::vector ref_fields; - for (std::size_t iHit = 0; const auto& hit : *in_hits) { - - // loop through readout fields - for (std::size_t iField = 0; const auto& name_field : id_desc.fields()) { - - - - } // end field loop - - // add hit to appropriate group - merge_map[ref_id].push_back(iHit); - ++iHit; - - } // end hit loop - -/* TO REMOVE std::vector ref_fields; for (std::size_t iHit = 0; const auto& hit : *in_hits) { @@ -245,7 +231,6 @@ void CalorimeterHitsMerger::build_map_via_funcs( // add hit to appropriate group merge_map[ref_id].push_back(iHit); ++iHit; -*/ } // end hit loop From 34f194b81ca5e512f864932873c036b3bee95e59 Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Mon, 30 Dec 2024 17:12:38 -0500 Subject: [PATCH 20/32] Fix compiler errors --- src/algorithms/calorimetry/CalorimeterHitsMerger.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index fffb963be7..01f238df62 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -92,7 +92,7 @@ void CalorimeterHitsMerger::init() { // grab provided field reference masks // and transformations uint64_t field_mask = m_cfg.fieldRefs.at(iField); - std::string field_transfrom = m_cfg.fieldTransformations.at(iField); + std::string field_transform = m_cfg.fieldTransformations.at(iField); // grab name and value of provided field auto name_field = id_desc.field(field); @@ -101,8 +101,8 @@ void CalorimeterHitsMerger::init() { // - if no transformation provided, reference // mask will be used if (field_transform.empty()) { - ref_maps[field] = [field_mask, name_field](const edm4eic::CalorimterHit& hit) -> int { - return (name_field->value(hit.cellID()) & ~field_mask) | field_mask; + ref_maps[field] = [field_mask, name_field](const edm4eic::CalorimeterHit& hit) -> int { + return (name_field->value(hit.getCellID()) & ~field_mask) | field_mask; }; trace("{}: using mask {:#064b}", field, field_mask); } else { From 6c0bc835d7c0048e9ddb15d3adbd01ce949c1d53 Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Mon, 30 Dec 2024 17:37:53 -0500 Subject: [PATCH 21/32] Propagate merge map simplification to rest of algorithm --- .../calorimetry/CalorimeterHitsMerger.cc | 35 ++++++------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index 01f238df62..f9221a9654 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -123,15 +123,7 @@ void CalorimeterHitsMerger::process( // find the hits that belong to the same group (for merging) MergeMap merge_map; - if (m_cfg.fieldTransformations.empty()) { - for (std::size_t ix = 0; const auto &h : *in_hits) { - uint64_t id = h.getCellID() & id_mask; - merge_map[id].push_back(ix); - ix++; - } - } else { - build_map_via_funcs(in_hits,merge_map); - } + build_merge_map(in_hits, merge_map); debug("Merge map built: merging {} hits into {} merged hits", in_hits->size(), merge_map.size()); // sort hits by energy from large to small @@ -196,26 +188,19 @@ void CalorimeterHitsMerger::process( debug("Size before = {}, after = {}", in_hits->size(), out_hits->size()); } -void CalorimeterHitsMerger::build_map_via_funcs( - const edm4eic::CalorimeterHitCollection* in_hits, - MergeMap& merge_map -) const { +void CalorimeterHitsMerger::build_merge_map( + const edm4eic::CalorimeterHitCollection* in_hits, + MergeMap& merge_map) const { std::vector ref_fields; for (std::size_t iHit = 0; const auto& hit : *in_hits) { - // make sure vector is clear ref_fields.clear(); for (std::size_t iField = 0; const auto& name_field : id_desc.fields()) { - // check if field has associated mapping - const bool foundMapping = ( - std::find(m_cfg.fields.begin(), m_cfg.fields.end(), name_field.first) != m_cfg.fields.end() - ); - - // if mapping provided for field, apply it - // otherwise just copy index - if (foundMapping) { + // apply mapping to field if provided, + // otherwise copy value of field + if (ref_maps.count(name_field.first) > 0) { ref_fields.push_back( {name_field.first, ref_maps[name_field.first](hit)} ); @@ -226,14 +211,14 @@ void CalorimeterHitsMerger::build_map_via_funcs( } ++iField; } - const uint64_t ref_id = id_desc.encode(ref_fields); - // add hit to appropriate group + // encode new cell ID and add hit to m + const uint64_t ref_id = id_desc.encode(ref_fields); merge_map[ref_id].push_back(iHit); ++iHit; } // end hit loop -} // end 'build_map_via_funcs(edm4eic::CalorimeterHitsCollection*, MergeMap&)' +} // end 'build_merge_map(edm4eic::CalorimeterHitsCollection*, MergeMap&)' } // namespace eicrecon From 7735e6d8503a9e7838ec8800f8e5e3a6826ff73f Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Mon, 30 Dec 2024 17:44:11 -0500 Subject: [PATCH 22/32] Fix typo --- src/factories/calorimetry/CalorimeterHitsMerger_factory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/factories/calorimetry/CalorimeterHitsMerger_factory.h b/src/factories/calorimetry/CalorimeterHitsMerger_factory.h index 2ffe4a1776..053a6d5e56 100644 --- a/src/factories/calorimetry/CalorimeterHitsMerger_factory.h +++ b/src/factories/calorimetry/CalorimeterHitsMerger_factory.h @@ -22,7 +22,7 @@ class CalorimeterHitsMerger_factory : public JOmniFactory m_readout {this, "readout", config().readout}; ParameterRef> m_fields {this, "fields", config().fields}; ParameterRef> m_field_refs {this, "fieldRefs", config().fieldRefs}; - ParameterRef> m_field_transformations {this, "fieldTransormations", config().fieldTransformations}; + ParameterRef> m_field_transformations {this, "fieldTransformations", config().fieldTransformations}; Service m_algorithmsInit {this}; From 73202d4d207fcd4218c139bd7b994867a9877f66 Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Mon, 30 Dec 2024 17:49:41 -0500 Subject: [PATCH 23/32] Fix more typos --- src/algorithms/calorimetry/CalorimeterHitsMerger.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.h b/src/algorithms/calorimetry/CalorimeterHitsMerger.h index f4cd61043d..f68191dfca 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.h +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.h @@ -60,7 +60,7 @@ namespace eicrecon { void process(const Input&, const Output&) const final; private: - uint64_t id_mask{0}, ref_mask{0}; + uint64_t ref_mask{0}; private: mutable std::map ref_maps; @@ -72,7 +72,7 @@ namespace eicrecon { const dd4hep::rec::CellIDPositionConverter* m_converter{algorithms::GeoSvc::instance().cellIDPositionConverter()}; private: - void build_map_via_funcs(const edm4eic::CalorimeterHitCollection* in_hits, MergeMap& merge_map) const; + void build_merge_map(const edm4eic::CalorimeterHitCollection* in_hits, MergeMap& merge_map) const; }; From faf20b1d9ae8e2787223c55ef274ab01171ee1fa Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Mon, 30 Dec 2024 18:02:59 -0500 Subject: [PATCH 24/32] Propagate changes to plugins --- src/detectors/BHCAL/BHCAL.cc | 1 + src/detectors/EHCAL/EHCAL.cc | 1 + src/detectors/FHCAL/FHCAL.cc | 1 + 3 files changed, 3 insertions(+) diff --git a/src/detectors/BHCAL/BHCAL.cc b/src/detectors/BHCAL/BHCAL.cc index d5186bac43..457fc38680 100644 --- a/src/detectors/BHCAL/BHCAL.cc +++ b/src/detectors/BHCAL/BHCAL.cc @@ -95,6 +95,7 @@ extern "C" { { .readout = "HcalBarrelHits", .fields = {"phi"}, + .fieldRefs = {0}, .fieldTransformations = {"phi"} }, app // TODO: Remove me once fixed diff --git a/src/detectors/EHCAL/EHCAL.cc b/src/detectors/EHCAL/EHCAL.cc index 9ae6364c68..e8064d7c68 100644 --- a/src/detectors/EHCAL/EHCAL.cc +++ b/src/detectors/EHCAL/EHCAL.cc @@ -73,6 +73,7 @@ extern "C" { .readout = "HcalEndcapNHits", .fields = {"layer", "slice"}, .fieldRefs = {4, 0}, // place merged hits at ~1 interaction length deep + .fieldTransformations = {"", ""} // currently unused }, app // TODO: Remove me once fixed )); diff --git a/src/detectors/FHCAL/FHCAL.cc b/src/detectors/FHCAL/FHCAL.cc index 17284b44fa..965b8aaba1 100644 --- a/src/detectors/FHCAL/FHCAL.cc +++ b/src/detectors/FHCAL/FHCAL.cc @@ -85,6 +85,7 @@ extern "C" { .readout = "HcalEndcapPInsertHits", .fields = {"layer", "slice"}, .fieldRefs = {1, 0}, + .fieldTransformations = {"", ""} }, app // TODO: Remove me once fixed )); From 21307133f64813b41155b651355971cf325919ad Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Tue, 7 Jan 2025 14:41:02 -0500 Subject: [PATCH 25/32] Remove field refs --- .../calorimetry/CalorimeterHitsMerger.cc | 33 ++++--------------- .../calorimetry/CalorimeterHitsMergerConfig.h | 1 - src/detectors/EHCAL/EHCAL.cc | 3 +- src/detectors/FHCAL/FHCAL.cc | 3 +- .../CalorimeterHitsMerger_factory.h | 1 - 5 files changed, 8 insertions(+), 33 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index f9221a9654..7a522fbd62 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -43,16 +43,8 @@ void CalorimeterHitsMerger::init() { return; } - // check that input field, mask, and transformation vectors + // check that input field and transformation vectors // are the same length - if (m_cfg.fields.size() != m_cfg.fieldRefs.size()) { - error( - "Size of field and reference mask vectors are different ({} vs. {}).", - m_cfg.fields.size(), - m_cfg.fieldRefs.size() - ); - return; - } if (m_cfg.fields.size() != m_cfg.fieldTransformations.size()) { error( "Size of field and transformation vectors are different ({} vs. {}).", @@ -89,26 +81,13 @@ void CalorimeterHitsMerger::init() { auto& svc = algorithms::ServiceSvc::instance(); for (std::size_t iField = 0; std::string& field : m_cfg.fields) { - // grab provided field reference masks - // and transformations - uint64_t field_mask = m_cfg.fieldRefs.at(iField); + // grab provided transformation and field std::string field_transform = m_cfg.fieldTransformations.at(iField); - - // grab name and value of provided field auto name_field = id_desc.field(field); - // set mask or transformation for each field - // - if no transformation provided, reference - // mask will be used - if (field_transform.empty()) { - ref_maps[field] = [field_mask, name_field](const edm4eic::CalorimeterHit& hit) -> int { - return (name_field->value(hit.getCellID()) & ~field_mask) | field_mask; - }; - trace("{}: using mask {:#064b}", field, field_mask); - } else { - ref_maps[field] = svc.service("EvaluatorSvc")->compile(field_transform, hit_transform); - trace("{}: using transformation '{}'", field, field_transform); - } + // set transformation for each field + ref_maps[field] = svc.service("EvaluatorSvc")->compile(field_transform, hit_transform); + trace("{}: using transformation '{}'", field, field_transform); ++iField; } // end field loop @@ -212,7 +191,7 @@ void CalorimeterHitsMerger::build_merge_map( ++iField; } - // encode new cell ID and add hit to m + // encode new cell ID and add hit to map const uint64_t ref_id = id_desc.encode(ref_fields); merge_map[ref_id].push_back(iHit); ++iHit; diff --git a/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h b/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h index 3084a43e3d..fffe607bc9 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h +++ b/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h @@ -12,7 +12,6 @@ namespace eicrecon { std::string readout{""}; std::vector fields{}; - std::vector fieldRefs{}; std::vector fieldTransformations{}; }; diff --git a/src/detectors/EHCAL/EHCAL.cc b/src/detectors/EHCAL/EHCAL.cc index e8064d7c68..7458650337 100644 --- a/src/detectors/EHCAL/EHCAL.cc +++ b/src/detectors/EHCAL/EHCAL.cc @@ -72,8 +72,7 @@ extern "C" { { .readout = "HcalEndcapNHits", .fields = {"layer", "slice"}, - .fieldRefs = {4, 0}, // place merged hits at ~1 interaction length deep - .fieldTransformations = {"", ""} // currently unused + .fieldTransformations = {"4", "0"} }, app // TODO: Remove me once fixed )); diff --git a/src/detectors/FHCAL/FHCAL.cc b/src/detectors/FHCAL/FHCAL.cc index 965b8aaba1..1d0b6f3535 100644 --- a/src/detectors/FHCAL/FHCAL.cc +++ b/src/detectors/FHCAL/FHCAL.cc @@ -84,8 +84,7 @@ extern "C" { { .readout = "HcalEndcapPInsertHits", .fields = {"layer", "slice"}, - .fieldRefs = {1, 0}, - .fieldTransformations = {"", ""} + .fieldTransformations = {"1", "0"} }, app // TODO: Remove me once fixed )); diff --git a/src/factories/calorimetry/CalorimeterHitsMerger_factory.h b/src/factories/calorimetry/CalorimeterHitsMerger_factory.h index 053a6d5e56..2007d81889 100644 --- a/src/factories/calorimetry/CalorimeterHitsMerger_factory.h +++ b/src/factories/calorimetry/CalorimeterHitsMerger_factory.h @@ -21,7 +21,6 @@ class CalorimeterHitsMerger_factory : public JOmniFactory m_readout {this, "readout", config().readout}; ParameterRef> m_fields {this, "fields", config().fields}; - ParameterRef> m_field_refs {this, "fieldRefs", config().fieldRefs}; ParameterRef> m_field_transformations {this, "fieldTransformations", config().fieldTransformations}; Service m_algorithmsInit {this}; From 75bb4c56d06687a82acc5ffb60cfb1940e6bc758 Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Tue, 7 Jan 2025 15:27:48 -0500 Subject: [PATCH 26/32] Merge fields and transformation fields --- .../calorimetry/CalorimeterHitsMerger.cc | 32 ++++++++++++------- .../calorimetry/CalorimeterHitsMergerConfig.h | 1 - src/detectors/EHCAL/EHCAL.cc | 3 +- src/detectors/FHCAL/FHCAL.cc | 3 +- .../CalorimeterHitsMerger_factory.h | 1 - 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index 7a522fbd62..a92aeba02a 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -43,22 +43,32 @@ void CalorimeterHitsMerger::init() { return; } - // check that input field and transformation vectors - // are the same length - if (m_cfg.fields.size() != m_cfg.fieldTransformations.size()) { - error( - "Size of field and transformation vectors are different ({} vs. {}).", - m_cfg.fields.size(), - m_cfg.fieldTransformations.size() + // split parameters into vectors of fields + // and of transformations + std::vector fields; + std::vector transforms; + for (const std::string& field_transform : m_cfg.fieldTransformations) { + + const std::size_t isplit = field_transform.find_first_of(':'); + if (isplit == std::string::npos) { + warning("transform '{}' ill-formatted. Format is :.", field_transform); + } + + + fields.emplace_back( + field_transform.substr(0, isplit) + ); + transforms.emplace_back( + field_transform.substr(isplit + 1) ); - return; } + // initialize descriptor + decoders try { id_desc = m_detector->readout(m_cfg.readout).idSpec(); id_decoder = id_desc.decoder(); - for (const auto& field : m_cfg.fields) { + for (const std::string& field : fields) { const short index = id_decoder->index(field); } } catch (...) { @@ -79,10 +89,10 @@ void CalorimeterHitsMerger::init() { // loop through provided readout fields auto& svc = algorithms::ServiceSvc::instance(); - for (std::size_t iField = 0; std::string& field : m_cfg.fields) { + for (std::size_t iField = 0; std::string& field : fields) { // grab provided transformation and field - std::string field_transform = m_cfg.fieldTransformations.at(iField); + const std::string field_transform = transforms.at(iField); auto name_field = id_desc.field(field); // set transformation for each field diff --git a/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h b/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h index fffe607bc9..bb644b6eac 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h +++ b/src/algorithms/calorimetry/CalorimeterHitsMergerConfig.h @@ -11,7 +11,6 @@ namespace eicrecon { struct CalorimeterHitsMergerConfig { std::string readout{""}; - std::vector fields{}; std::vector fieldTransformations{}; }; diff --git a/src/detectors/EHCAL/EHCAL.cc b/src/detectors/EHCAL/EHCAL.cc index 7458650337..7d39c01472 100644 --- a/src/detectors/EHCAL/EHCAL.cc +++ b/src/detectors/EHCAL/EHCAL.cc @@ -71,8 +71,7 @@ extern "C" { "HcalEndcapNMergedHits", {"HcalEndcapNRecHits"}, {"HcalEndcapNMergedHits"}, { .readout = "HcalEndcapNHits", - .fields = {"layer", "slice"}, - .fieldTransformations = {"4", "0"} + .fieldTransformations = {"layer:4", "slice:0"} }, app // TODO: Remove me once fixed )); diff --git a/src/detectors/FHCAL/FHCAL.cc b/src/detectors/FHCAL/FHCAL.cc index 1d0b6f3535..ea1ab0c685 100644 --- a/src/detectors/FHCAL/FHCAL.cc +++ b/src/detectors/FHCAL/FHCAL.cc @@ -83,8 +83,7 @@ extern "C" { "HcalEndcapPInsertMergedHits", {"HcalEndcapPInsertRecHits"}, {"HcalEndcapPInsertMergedHits"}, { .readout = "HcalEndcapPInsertHits", - .fields = {"layer", "slice"}, - .fieldTransformations = {"1", "0"} + .fieldTransformations = {"layer:1", "layer:0"} }, app // TODO: Remove me once fixed )); diff --git a/src/factories/calorimetry/CalorimeterHitsMerger_factory.h b/src/factories/calorimetry/CalorimeterHitsMerger_factory.h index 2007d81889..7105376532 100644 --- a/src/factories/calorimetry/CalorimeterHitsMerger_factory.h +++ b/src/factories/calorimetry/CalorimeterHitsMerger_factory.h @@ -20,7 +20,6 @@ class CalorimeterHitsMerger_factory : public JOmniFactory m_hits_output {this}; ParameterRef m_readout {this, "readout", config().readout}; - ParameterRef> m_fields {this, "fields", config().fields}; ParameterRef> m_field_transformations {this, "fieldTransformations", config().fieldTransformations}; Service m_algorithmsInit {this}; From 07af3db3e571eb49c5979754a3bf6d90d5421351 Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Tue, 7 Jan 2025 15:39:48 -0500 Subject: [PATCH 27/32] Update BHCAL plugin --- src/detectors/BHCAL/BHCAL.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/detectors/BHCAL/BHCAL.cc b/src/detectors/BHCAL/BHCAL.cc index 457fc38680..1075c78af7 100644 --- a/src/detectors/BHCAL/BHCAL.cc +++ b/src/detectors/BHCAL/BHCAL.cc @@ -94,9 +94,7 @@ extern "C" { "HcalBarrelMergedHits", {"HcalBarrelRecHits"}, {"HcalBarrelMergedHits"}, { .readout = "HcalBarrelHits", - .fields = {"phi"}, - .fieldRefs = {0}, - .fieldTransformations = {"phi"} + .fieldTransformations = {"phi:phi"} }, app // TODO: Remove me once fixed )); From 01e99e3a5423f5f94b41c5c23c1ce3522a6a4979 Mon Sep 17 00:00:00 2001 From: ruse-traveler Date: Wed, 8 Jan 2025 10:25:04 -0500 Subject: [PATCH 28/32] Fix typo: slices not layers --- src/detectors/FHCAL/FHCAL.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detectors/FHCAL/FHCAL.cc b/src/detectors/FHCAL/FHCAL.cc index ea1ab0c685..36f7fb4797 100644 --- a/src/detectors/FHCAL/FHCAL.cc +++ b/src/detectors/FHCAL/FHCAL.cc @@ -83,7 +83,7 @@ extern "C" { "HcalEndcapPInsertMergedHits", {"HcalEndcapPInsertRecHits"}, {"HcalEndcapPInsertMergedHits"}, { .readout = "HcalEndcapPInsertHits", - .fieldTransformations = {"layer:1", "layer:0"} + .fieldTransformations = {"layer:1", "slice:0"} }, app // TODO: Remove me once fixed )); From ae5d8aa9236b5484333da57c17c787da7346ce0c Mon Sep 17 00:00:00 2001 From: Derek M Anderson Date: Wed, 8 Jan 2025 12:15:06 -0500 Subject: [PATCH 29/32] Update copyright dates Co-authored-by: Dmitry Kalinkin --- src/algorithms/calorimetry/CalorimeterHitsMerger.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index a92aeba02a..d756d2bdd9 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -1,5 +1,5 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022 Chao Peng, Jihee Kim, Sylvester Joosten, Whitney Armstrong, Wouter Deconinck, David Lawrence, Derek Anderson +// Copyright (C) 2022 - 2025 Chao Peng, Jihee Kim, Sylvester Joosten, Whitney Armstrong, Wouter Deconinck, David Lawrence, Derek Anderson /* * An algorithm to group readout hits from a calorimeter From 2a1a8de0627801d5ef245912ba0bae60844724d7 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Wed, 8 Jan 2025 13:26:33 -0500 Subject: [PATCH 30/32] Update src/algorithms/calorimetry/CalorimeterHitsMerger.h --- src/algorithms/calorimetry/CalorimeterHitsMerger.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.h b/src/algorithms/calorimetry/CalorimeterHitsMerger.h index f68191dfca..59f8575c37 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.h +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022 Chao Peng, Jihee Kim, Sylvester Joosten, Whitney Armstrong, Wouter Deconinck, David Lawrence, Derek Anderson +// Copyright (C) 2022 - 2025 Chao Peng, Jihee Kim, Sylvester Joosten, Whitney Armstrong, Wouter Deconinck, David Lawrence, Derek Anderson /* * An algorithm to group readout hits from a calorimeter From c7a0285168d135c7627a937b7bafd7e225e2d6e9 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Wed, 8 Jan 2025 15:28:29 -0500 Subject: [PATCH 31/32] Update src/detectors/BHCAL/BHCAL.cc --- src/detectors/BHCAL/BHCAL.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detectors/BHCAL/BHCAL.cc b/src/detectors/BHCAL/BHCAL.cc index 1075c78af7..f17e908d8d 100644 --- a/src/detectors/BHCAL/BHCAL.cc +++ b/src/detectors/BHCAL/BHCAL.cc @@ -105,7 +105,7 @@ extern "C" { )); app->Add(new JOmniFactoryGeneratorT( - "HcalBarrelIslandProtoClusters", {"HcalBarrelMergedHits"}, {"HcalBarrelIslandProtoClusters"}, + "HcalBarrelIslandProtoClusters", {"HcalBarrelRecHits"}, {"HcalBarrelIslandProtoClusters"}, { .adjacencyMatrix = HcalBarrel_adjacencyMatrix, .readout = "HcalBarrelHits", From ebc3547c97e5262da2047e7b2b38c639530efa2e Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Wed, 8 Jan 2025 17:25:18 -0500 Subject: [PATCH 32/32] IWYU --- src/algorithms/calorimetry/CalorimeterHitsMerger.cc | 3 +-- src/algorithms/calorimetry/CalorimeterHitsMerger.h | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc index d756d2bdd9..f43b75cce4 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.cc +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.cc @@ -16,13 +16,12 @@ #include #include #include -#include #include #include #include +#include #include #include -#include #include #include #include diff --git a/src/algorithms/calorimetry/CalorimeterHitsMerger.h b/src/algorithms/calorimetry/CalorimeterHitsMerger.h index 59f8575c37..4de553e4a8 100644 --- a/src/algorithms/calorimetry/CalorimeterHitsMerger.h +++ b/src/algorithms/calorimetry/CalorimeterHitsMerger.h @@ -10,20 +10,22 @@ #pragma once -#include #include #include #include +#include #include #include #include #include +#include #include #include #include #include #include #include +#include #include #include "CalorimeterHitsMergerConfig.h"