From 4ee39c7bf3df61cb55d7b14652ac9b9fd4bc4d07 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Sauvan Date: Thu, 25 Apr 2024 10:37:53 +0200 Subject: [PATCH] Cleaning Stage1 / Layer1 Producers / Processors / Algos structure and config (#104) * WIP: cleaning Stage1/Layer1 structure and config * fix compilation issue with layer 1 emulator algo * apply code-format * update documentation --- L1Trigger/L1THGCal/README.md | 12 +- .../L1THGCal/interface/HGCalAlgoWrapperBase.h | 6 +- .../L1THGCal/interface/HGCalProcessorBase.h | 7 +- .../backend/HGCalBackendLayer1Processor.h | 24 ---- .../HGCalBackendLayer1ProcessorTruncation.h | 24 ++++ .../HGCalBackendLayer1ProcessorTruncationFw.h | 26 +++++ .../backend/HGCalBackendStage1Processor.h | 25 ---- ...tionImpl.h => HGCalLayer1TruncationImpl.h} | 8 +- .../backend/HGCalStage1TruncationConfig_SA.h | 72 ------------ .../backend/HGCalStage1TruncationImpl_SA.h | 43 ------- ...lStage1SortingAlg_SA.h => BatcherSorter.h} | 12 +- ...g_SA.h => HGCalLayer1TruncationFwConfig.h} | 22 ++-- ...mpl_SA.h => HGCalLayer1TruncationFwImpl.h} | 22 ++-- .../plugins/HGCalBackendLayer1Producer.cc | 26 ++++- .../plugins/HGCalBackendStage1Producer.cc | 96 --------------- .../backend/HGCalBackendLayer1Processor.cc | 32 ----- ...HGCalBackendLayer1Processor2DClustering.cc | 10 +- .../HGCalBackendLayer1ProcessorTruncation.cc | 24 ++++ ...HGCalBackendLayer1ProcessorTruncationFw.cc | 33 ++++++ .../backend/HGCalBackendStage1Processor.cc | 27 ----- ...per.cc => HGCalLayer1TruncationWrapper.cc} | 38 +++--- L1Trigger/L1THGCal/python/customLayer1.py | 19 +++ .../L1THGCal/python/customNewProcessors.py | 17 --- .../L1THGCal/python/hgcalBackEndLayer1_cff.py | 1 - .../L1THGCal/python/hgcalBackEndLayer2_cff.py | 1 - .../python/hgcalTriggerPrimitivesNew_cff.py | 35 ------ .../l1tHGCalBackEndLayer1Producer_cfi.py | 26 ++--- .../l1tHGCalBackEndLayer2Producer_cfi.py | 6 - .../L1THGCal/src/HGCalAlgoWrapperBase.cc | 2 +- L1Trigger/L1THGCal/src/HGCalProcessorBase.cc | 2 - ...onImpl.cc => HGCalLayer1TruncationImpl.cc} | 22 ++-- .../backend/HGCalStage1TruncationImpl_SA.cc | 109 ------------------ ...tage1SortingAlg_SA.cc => BatcherSorter.cc} | 12 +- ...l_SA.cc => HGCalLayer1TruncationFwImpl.cc} | 42 +++++-- .../HGCalBackendStage1ParameterExtractor.cc | 4 +- .../L1THGCalUtilities/python/clustering2d.py | 15 --- .../python/clustering2d_v2.py | 23 ---- .../L1THGCalUtilities/python/customNtuples.py | 7 +- L1Trigger/L1THGCalUtilities/python/layer1.py | 41 +++++++ .../test/testHGCalL1T_multialgo_V16_cfg.py | 14 +-- .../testHGCalL1T_stage1Truncation_V11_cfg.py | 13 +-- .../testHGCalL1T_stage1Truncation_V16_cfg.py | 13 +-- 42 files changed, 337 insertions(+), 676 deletions(-) delete mode 100644 L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1Processor.h create mode 100644 L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1ProcessorTruncation.h create mode 100644 L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1ProcessorTruncationFw.h delete mode 100644 L1Trigger/L1THGCal/interface/backend/HGCalBackendStage1Processor.h rename L1Trigger/L1THGCal/interface/backend/{HGCalStage1TruncationImpl.h => HGCalLayer1TruncationImpl.h} (84%) delete mode 100644 L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationConfig_SA.h delete mode 100644 L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationImpl_SA.h rename L1Trigger/L1THGCal/interface/backend_emulator/{HGCalStage1SortingAlg_SA.h => BatcherSorter.h} (88%) rename L1Trigger/L1THGCal/interface/backend_emulator/{HGCalStage1TruncationConfig_SA.h => HGCalLayer1TruncationFwConfig.h} (74%) rename L1Trigger/L1THGCal/interface/backend_emulator/{HGCalStage1TruncationImpl_SA.h => HGCalLayer1TruncationFwImpl.h} (69%) delete mode 100644 L1Trigger/L1THGCal/plugins/HGCalBackendStage1Producer.cc delete mode 100644 L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1Processor.cc create mode 100644 L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1ProcessorTruncation.cc create mode 100644 L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1ProcessorTruncationFw.cc delete mode 100644 L1Trigger/L1THGCal/plugins/backend/HGCalBackendStage1Processor.cc rename L1Trigger/L1THGCal/plugins/backend/{HGCalStage1TruncationWrapper.cc => HGCalLayer1TruncationWrapper.cc} (80%) create mode 100644 L1Trigger/L1THGCal/python/customLayer1.py delete mode 100644 L1Trigger/L1THGCal/python/hgcalTriggerPrimitivesNew_cff.py rename L1Trigger/L1THGCal/src/backend/{HGCalStage1TruncationImpl.cc => HGCalLayer1TruncationImpl.cc} (83%) delete mode 100644 L1Trigger/L1THGCal/src/backend/HGCalStage1TruncationImpl_SA.cc rename L1Trigger/L1THGCal/src/backend_emulator/{HGCalStage1SortingAlg_SA.cc => BatcherSorter.cc} (93%) rename L1Trigger/L1THGCal/src/backend_emulator/{HGCalStage1TruncationImpl_SA.cc => HGCalLayer1TruncationFwImpl.cc} (70%) delete mode 100644 L1Trigger/L1THGCalUtilities/python/clustering2d_v2.py create mode 100644 L1Trigger/L1THGCalUtilities/python/layer1.py diff --git a/L1Trigger/L1THGCal/README.md b/L1Trigger/L1THGCal/README.md index 1947f3902db8a..fe3dd67c88867 100644 --- a/L1Trigger/L1THGCal/README.md +++ b/L1Trigger/L1THGCal/README.md @@ -18,7 +18,7 @@ The HGCAL TPG simulation is split in a chain of producers, called from the [`hgc - `HGCalVFEProducer`: HGCROC trigger path simulation (defined in [`l1tHGCalVFEProducer_cfi.py`](python/l1tHGCalVFEProducer_cfi.py)) - `HGCalConcentratorProducer`: ECON-T simulation (defined in [`l1tHGCalConcentratorProducer_cfi.py`](python/l1tHGCalConcentratorProducer_cfi.py)) - Back-end producers - - `HGCalBackendLayer1Producer` and `HGCalBackendStage1Producer`: trigger cell path in the back-end Stage 1, the `Stage1` version is the latest version meant to be used with emulators (defined in [`l1tHGCalBackEndLayer1Producer_cfi.py`](python/l1tHGCalBackEndLayer1Producer_cfi.py)) + - `HGCalBackendLayer1Producer`: trigger cell path in the back-end Stage 1 (defined in [`l1tHGCalBackEndLayer1Producer_cfi.py`](python/l1tHGCalBackEndLayer1Producer_cfi.py)) - `HGCalBackendLayer2Producer`: clustering in the back-end Stage 2 (defined in [`l1tHGCalBackEndLayer2Producer_cfi.py`](python/l1tHGCalBackEndLayer2Producer_cfi.py)) - `HGCalTowerMapProducer`: towers in the back-end Stage 1 (defined in [`l1tHGCalTowerMapProducer_cfi.py`](python/l1tHGCalTowerMapProducer_cfi.py)) - `HGCalTowerProducer`: towers in the back-end Stage 2 (defined in [`l1tHGCalTowerProducer_cfi.py`](python/l1tHGCalTowerProducer_cfi.py)) @@ -57,7 +57,7 @@ flowchart TB tower -- Towers --> l1t click hgcroc href "https://github.com/cms-sw/cmssw/blob/master/L1Trigger/L1THGCal/plugins/HGCalVFEProducer.cc" "click to display Producer source" click econ href "https://github.com/cms-sw/cmssw/blob/master/L1Trigger/L1THGCal/plugins/HGCalConcentratorProducer.cc" "click to display Producer source" - click stage1 href "https://github.com/cms-sw/cmssw/blob/master/L1Trigger/L1THGCal/plugins/HGCalBackendStage1Producer.cc" "click to display Producer source" + click stage1 href "https://github.com/cms-sw/cmssw/blob/master/L1Trigger/L1THGCal/plugins/HGCalBackendLayer1Producer.cc" "click to display Producer source" click stage2 href "https://github.com/cms-sw/cmssw/blob/master/L1Trigger/L1THGCal/plugins/HGCalBackendLayer2Producer.cc" "click to display Producer source" click towermap href "https://github.com/cms-sw/cmssw/blob/master/L1Trigger/L1THGCal/plugins/HGCalTowerMapProducer.cc" "click to display Producer source" click tower href "https://github.com/cms-sw/cmssw/blob/master/L1Trigger/L1THGCal/plugins/HGCalTowerProducer.cc" "click to display Producer source" @@ -107,7 +107,7 @@ classDiagram Algorithm implementations emulating dedicating firmware blocks are written in such a way that they can be executed in a standalone fashion outside CMSSW, for cross-validation with their firmware counterpart. Therefore they are integrated within CMSSW by the mean of wrapper classes that are translating data and configurations between the CMSSW world and the standalone emulator world. -Algorithm implementations are configured by the mean of dedicated configuration objects built in the wrapper class. The wrapper class also perform the conversion of the input data from CMSSW data formats to standalone data formats, and convert back the output data from standalone data formats to CMSSW data formats. +Algorithm implementations are configured by the mean of dedicated configuration objects built in the wrapper class. The wrapper class also performs the conversion of the input data from CMSSW data formats to standalone data formats, and convert back the output data from standalone data formats to CMSSW data formats. This wrapping structure is illustrated in the diagram below. @@ -180,12 +180,12 @@ Deprecated Stage 1 algorithms, which are layer-by-layer 2D clustering algorithm The different Stage 1 processing versions are implemented in: - [`plugins/backend/HGCalBackendLayer1Processor2DClustering.cc`](plugins/backend/HGCalBackendLayer1Processor2DClustering.cc): original implementations of the 2D layer clusterings and pass-through -- [`plugins/backend/HGCalBackendLayer1Processor.cc`](plugins/backend/HGCalBackendLayer1Processor.cc): first implementation of Stage 1 trigger cell truncation -- [`plugins/backend/HGCalBackendStage1Processor.cc`](plugins/backend/HGCalBackendStage1Processor.cc): latest Stage 1 processor calling the 2022 Stage 1 emulator +- [`plugins/backend/HGCalBackendLayer1ProcessorTruncation.cc`](plugins/backend/HGCalBackendLayer1ProcessorTruncation.cc): first implementation of Stage 1 trigger cell truncation +- [`plugins/backend/HGCalBackendLayer1ProcessorTruncationFw.cc`](plugins/backend/HGCalBackendLayer1ProcessorTruncationFw.cc): latest Stage 1 processor calling the 2022 Stage 1 emulator And actual implementations of the algorithms are stored in [`src/backend`](src/backend). These processors are configured from [`python/l1tHGCalBackEndLayer1Producer_cfi.py`](python/l1tHGCalBackEndLayer1Producer_cfi.py). Customization functions are available in - [`python/customClustering.py`](python/customClustering.py): old 2D layer clustering customization -- [`python/customNewProcessors.py`](python/customNewProcessors.py): contains Stage 1 truncation and emulator customization +- [`python/customLayer1.py`](python/customLayer1.py): contains Stage 1 truncation and emulator customization #### Stage 2 clustering The Stage 2 is responsible of building the final 3D clusters, initially from 2D layer clusters and now directly from trigger cells. The default Stage 2 clustering algorithm is the so-called `HistoMax`, which refers to the way the cluster building is seeded. diff --git a/L1Trigger/L1THGCal/interface/HGCalAlgoWrapperBase.h b/L1Trigger/L1THGCal/interface/HGCalAlgoWrapperBase.h index 4ffca6c91b00e..2d73948b04630 100644 --- a/L1Trigger/L1THGCal/interface/HGCalAlgoWrapperBase.h +++ b/L1Trigger/L1THGCal/interface/HGCalAlgoWrapperBase.h @@ -29,7 +29,7 @@ typedef HGCalAlgoWrapperBaseT>, std::vector>, std::tuple> - HGCalStage1TruncationWrapperBase; + HGCalLayer1TruncationWrapperBase; #include "FWCore/PluginManager/interface/PluginFactory.h" typedef edmplugin::PluginFactory @@ -37,7 +37,7 @@ typedef edmplugin::PluginFactory HGCalTowerMapsWrapperBaseFactory; typedef edmplugin::PluginFactory HGCalStage2FilteringWrapperBaseFactory; -typedef edmplugin::PluginFactory - HGCalStage1TruncationWrapperBaseFactory; +typedef edmplugin::PluginFactory + HGCalLayer1TruncationWrapperBaseFactory; #endif diff --git a/L1Trigger/L1THGCal/interface/HGCalProcessorBase.h b/L1Trigger/L1THGCal/interface/HGCalProcessorBase.h index 3b94a3990abdb..1c8f0d9969ffc 100644 --- a/L1Trigger/L1THGCal/interface/HGCalProcessorBase.h +++ b/L1Trigger/L1THGCal/interface/HGCalProcessorBase.h @@ -21,11 +21,9 @@ typedef HGCalProcessorBaseT, l1t::HGCalTriggerSumsBxCollection, l1t::HGCalConcentratorDataBxCollection>> HGCalConcentratorProcessorBase; -typedef HGCalProcessorBaseT, l1t::HGCalClusterBxCollection> - HGCalBackendLayer1ProcessorBase; typedef HGCalProcessorBaseT>>, - std::vector>> - HGCalBackendStage1ProcessorBase; + l1t::HGCalClusterBxCollection> + HGCalBackendLayer1ProcessorBase; typedef HGCalProcessorBaseT, std::pair> HGCalBackendLayer2ProcessorBase; @@ -40,7 +38,6 @@ typedef HGCalProcessorBaseT< typedef edmplugin::PluginFactory HGCalVFEProcessorBaseFactory; typedef edmplugin::PluginFactory HGCalConcentratorFactory; typedef edmplugin::PluginFactory HGCalBackendLayer1Factory; -typedef edmplugin::PluginFactory HGCalBackendStage1Factory; typedef edmplugin::PluginFactory HGCalBackendLayer2Factory; typedef edmplugin::PluginFactory HGCalTowerMapFactory; typedef edmplugin::PluginFactory HGCalTowerFactory; diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1Processor.h b/L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1Processor.h deleted file mode 100644 index a978061c02146..0000000000000 --- a/L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1Processor.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef __L1Trigger_L1THGCal_HGCalBackendLayer1Processor_h__ -#define __L1Trigger_L1THGCal_HGCalBackendLayer1Processor_h__ - -#include "L1Trigger/L1THGCal/interface/HGCalProcessorBase.h" - -#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h" -#include "DataFormats/L1THGCal/interface/HGCalCluster.h" - -#include "L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationImpl.h" -#include "L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h" - -class HGCalBackendLayer1Processor : public HGCalBackendLayer1ProcessorBase { -public: - HGCalBackendLayer1Processor(const edm::ParameterSet& conf); - - void run(const edm::Handle& collHandle, - l1t::HGCalClusterBxCollection& collCluster2D) override; - -private: - std::unique_ptr clusteringDummy_; - std::unique_ptr truncation_; -}; - -#endif diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1ProcessorTruncation.h b/L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1ProcessorTruncation.h new file mode 100644 index 0000000000000..6b66639e834a6 --- /dev/null +++ b/L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1ProcessorTruncation.h @@ -0,0 +1,24 @@ +#ifndef __L1Trigger_L1THGCal_HGCalBackendLayer1ProcessorTruncation_h__ +#define __L1Trigger_L1THGCal_HGCalBackendLayer1ProcessorTruncation_h__ + +#include "L1Trigger/L1THGCal/interface/HGCalProcessorBase.h" + +#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h" +#include "DataFormats/L1THGCal/interface/HGCalCluster.h" + +#include "L1Trigger/L1THGCal/interface/backend/HGCalLayer1TruncationImpl.h" +#include "L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h" + +class HGCalBackendLayer1ProcessorTruncation : public HGCalBackendLayer1ProcessorBase { +public: + HGCalBackendLayer1ProcessorTruncation(const edm::ParameterSet& conf); + + void run(const std::pair>>& fpga_id_tcs, + l1t::HGCalClusterBxCollection& clusters) override; + +private: + std::unique_ptr clusteringDummy_; + std::unique_ptr truncation_; +}; + +#endif diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1ProcessorTruncationFw.h b/L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1ProcessorTruncationFw.h new file mode 100644 index 0000000000000..ddebba5fb4729 --- /dev/null +++ b/L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1ProcessorTruncationFw.h @@ -0,0 +1,26 @@ +#ifndef __L1Trigger_L1THGCal_HGCalBackendLayer1ProcessorTruncationFw_h__ +#define __L1Trigger_L1THGCal_HGCalBackendLayer1ProcessorTruncationFw_h__ + +#include "L1Trigger/L1THGCal/interface/HGCalProcessorBase.h" +#include "L1Trigger/L1THGCal/interface/HGCalAlgoWrapperBase.h" + +#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h" +#include "DataFormats/L1THGCal/interface/HGCalCluster.h" + +#include "L1Trigger/L1THGCal/interface/backend_emulator/HGCalLayer1TruncationFwImpl.h" +#include "L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h" + +class HGCalBackendLayer1ProcessorTruncationFw : public HGCalBackendLayer1ProcessorBase { +public: + HGCalBackendLayer1ProcessorTruncationFw(const edm::ParameterSet& conf); + + void run(const std::pair>>& fpga_id_tcs, + l1t::HGCalClusterBxCollection& clusters) override; + +private: + std::unique_ptr clusteringDummy_; + std::unique_ptr truncationWrapper_; + const edm::ParameterSet conf_; +}; + +#endif diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalBackendStage1Processor.h b/L1Trigger/L1THGCal/interface/backend/HGCalBackendStage1Processor.h deleted file mode 100644 index b2ead8f2eb087..0000000000000 --- a/L1Trigger/L1THGCal/interface/backend/HGCalBackendStage1Processor.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __L1Trigger_L1THGCal_HGCalBackendStage1Processor_h__ -#define __L1Trigger_L1THGCal_HGCalBackendStage1Processor_h__ - -#include "L1Trigger/L1THGCal/interface/HGCalProcessorBase.h" -#include "L1Trigger/L1THGCal/interface/HGCalAlgoWrapperBase.h" - -#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h" -#include "DataFormats/L1THGCal/interface/HGCalCluster.h" - -#include "L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationImpl.h" -#include "L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h" - -class HGCalBackendStage1Processor : public HGCalBackendStage1ProcessorBase { -public: - HGCalBackendStage1Processor(const edm::ParameterSet& conf); - - void run(const std::pair>>& fpga_id_tcs, - std::vector>& truncated_tcs) override; - -private: - std::unique_ptr truncationWrapper_; - const edm::ParameterSet conf_; -}; - -#endif diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalLayer1TruncationImpl.h similarity index 84% rename from L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationImpl.h rename to L1Trigger/L1THGCal/interface/backend/HGCalLayer1TruncationImpl.h index 9b0ad6f759bbf..1022b82f1289f 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalLayer1TruncationImpl.h @@ -1,5 +1,5 @@ -#ifndef __L1Trigger_L1THGCal_HGCalStage1TruncationImpl_h__ -#define __L1Trigger_L1THGCal_HGCalStage1TruncationImpl_h__ +#ifndef __L1Trigger_L1THGCal_HGCalLayer1TruncationImpl_h__ +#define __L1Trigger_L1THGCal_HGCalLayer1TruncationImpl_h__ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h" @@ -7,9 +7,9 @@ #include -class HGCalStage1TruncationImpl { +class HGCalLayer1TruncationImpl { public: - HGCalStage1TruncationImpl(const edm::ParameterSet& conf); + HGCalLayer1TruncationImpl(const edm::ParameterSet& conf); void setGeometry(const HGCalTriggerGeometryBase* const geom) { triggerTools_.setGeometry(geom); } diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationConfig_SA.h b/L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationConfig_SA.h deleted file mode 100644 index 646b18c77aec3..0000000000000 --- a/L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationConfig_SA.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef __L1Trigger_L1THGCal_HGCalStage1TruncationConfig_SA_h__ -#define __L1Trigger_L1THGCal_HGCalStage1TruncationConfig_SA_h__ - -#include -#include // uint32_t - -namespace l1thgcfirmwareDUMMY { - - class Stage1TruncationConfig { - public: - Stage1TruncationConfig(const bool do_truncate, - const double roz_min, - const double roz_max, - const unsigned roz_bins, - const std::vector& max_tcs_per_bins, - const std::vector& phi_edges) - : do_truncate_(do_truncate), - roz_min_(roz_min), - roz_max_(roz_max), - roz_bins_(roz_bins), - max_tcs_per_bins_(max_tcs_per_bins), - phi_edges_(phi_edges) {} - - void setParameters(const bool do_truncate, - const double roz_min, - const double roz_max, - const unsigned roz_bins, - const std::vector& max_tcs_per_bins, - const std::vector& phi_edges) { - do_truncate_ = do_truncate; - roz_min_ = roz_min; - roz_max_ = roz_max; - roz_bins_ = roz_bins; - max_tcs_per_bins_ = max_tcs_per_bins; - phi_edges_ = phi_edges; - } - - void setParameters(const Stage1TruncationConfig& newConfig) { - setParameters(newConfig.doTruncate(), - newConfig.rozMin(), - newConfig.rozMax(), - newConfig.rozBins(), - newConfig.maxTcsPerBin(), - newConfig.phiEdges()); - } - - void setSector120(const unsigned sector) { sector120_ = sector; } - void setFPGAID(const uint32_t fpga_id) { fpga_id_ = fpga_id; } - - bool doTruncate() const { return do_truncate_; } - double rozMin() const { return roz_min_; } - double rozMax() const { return roz_max_; } - unsigned rozBins() const { return roz_bins_; } - const std::vector& maxTcsPerBin() const { return max_tcs_per_bins_; } - const std::vector& phiEdges() const { return phi_edges_; } - unsigned phiSector() const { return sector120_; } - uint32_t fpgaID() const { return fpga_id_; } - - private: - bool do_truncate_; - double roz_min_; - double roz_max_; - unsigned roz_bins_; - std::vector max_tcs_per_bins_; - std::vector phi_edges_; - unsigned sector120_; - uint32_t fpga_id_; - }; - -} // namespace l1thgcfirmwareDUMMY - -#endif diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationImpl_SA.h b/L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationImpl_SA.h deleted file mode 100644 index 5feb22b6b86de..0000000000000 --- a/L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationImpl_SA.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef __L1Trigger_L1THGCal_HGCalStage1TruncationImpl_h__ -#define __L1Trigger_L1THGCal_HGCalStage1TruncationImpl_h__ - -#include "L1Trigger/L1THGCal/interface/backend/HGCalTriggerCell_SA.h" -#include "L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationConfig_SA.h" - -#include -#include // uint32_t, unsigned -#include // std::unordered_map -#include // std::sort - -class HGCalStage1TruncationImplSA { -public: - HGCalStage1TruncationImplSA() = default; - ~HGCalStage1TruncationImplSA() = default; - - void runAlgorithm() const; - - unsigned run(const l1thgcfirmwareDUMMY::HGCalTriggerCellSACollection& tcs_in, - const l1thgcfirmwareDUMMY::Stage1TruncationConfig& theConf, - l1thgcfirmwareDUMMY::HGCalTriggerCellSACollection& tcs_out) const; - - int phiBin(unsigned roverzbin, double phi, const std::vector& phiedges) const; - double rotatedphi(double x, double y, double z, int sector) const; - unsigned rozBin(double roverz, double rozmin, double rozmax, unsigned rozbins) const; - -private: - static constexpr unsigned offset_roz_ = 1; - static constexpr unsigned mask_roz_ = 0x3f; // 6 bits, max 64 bins - static constexpr unsigned mask_phi_ = 1; - - bool do_truncate_; - double roz_min_ = 0.; - double roz_max_ = 0.; - unsigned roz_bins_ = 42; - std::vector max_tcs_per_bin_; - std::vector phi_edges_; - - uint32_t packBin(unsigned roverzbin, unsigned phibin) const; - void unpackBin(unsigned packedbin, unsigned& roverzbin, unsigned& phibin) const; -}; - -#endif diff --git a/L1Trigger/L1THGCal/interface/backend_emulator/HGCalStage1SortingAlg_SA.h b/L1Trigger/L1THGCal/interface/backend_emulator/BatcherSorter.h similarity index 88% rename from L1Trigger/L1THGCal/interface/backend_emulator/HGCalStage1SortingAlg_SA.h rename to L1Trigger/L1THGCal/interface/backend_emulator/BatcherSorter.h index 1e146d917cb9a..5a535c2e578ab 100644 --- a/L1Trigger/L1THGCal/interface/backend_emulator/HGCalStage1SortingAlg_SA.h +++ b/L1Trigger/L1THGCal/interface/backend_emulator/BatcherSorter.h @@ -1,5 +1,5 @@ -#ifndef __L1Trigger_L1THGCal_HGCalStage1SortingAlg_SA_h__ -#define __L1Trigger_L1THGCal_HGCalStage1SortingAlg_SA_h__ +#ifndef __L1Trigger_L1THGCal_BatcherSorter_h__ +#define __L1Trigger_L1THGCal_BatcherSorter_h__ #include #include @@ -21,11 +21,11 @@ typedef std::vector adress_t; // Address Pointer for sorter & namespace l1thgcfirmware { - class HGCalStage1SortingAlg_SA { + class BatcherSorter { public: - HGCalStage1SortingAlg_SA(); + BatcherSorter(); - HGCalStage1SortingAlg_SA(const unsigned NTCin, const unsigned NTCout) : N(NTCin), M(NTCout) { + BatcherSorter(const unsigned NTCin, const unsigned NTCout) : N(NTCin), M(NTCout) { unsigned ns = NTCin / 4; unsigned nma = (NTCout < (NTCin / 4)) ? 2 * NTCout : NTCin / 2; unsigned nmb = (NTCout < nma) ? 2 * NTCout : 2 * nma; @@ -34,7 +34,7 @@ namespace l1thgcfirmware { setNMB(nmb); } - ~HGCalStage1SortingAlg_SA() {} + ~BatcherSorter() {} //Generates the sorting network void sorting(const datain_t& arr_input, dataout_t& arr_output, adressout_t& arr_adresses) const; diff --git a/L1Trigger/L1THGCal/interface/backend_emulator/HGCalStage1TruncationConfig_SA.h b/L1Trigger/L1THGCal/interface/backend_emulator/HGCalLayer1TruncationFwConfig.h similarity index 74% rename from L1Trigger/L1THGCal/interface/backend_emulator/HGCalStage1TruncationConfig_SA.h rename to L1Trigger/L1THGCal/interface/backend_emulator/HGCalLayer1TruncationFwConfig.h index dad3b3817fa4f..abc5124bc7e96 100644 --- a/L1Trigger/L1THGCal/interface/backend_emulator/HGCalStage1TruncationConfig_SA.h +++ b/L1Trigger/L1THGCal/interface/backend_emulator/HGCalLayer1TruncationFwConfig.h @@ -1,21 +1,21 @@ -#ifndef __L1Trigger_L1THGCal_HGCalStage1TruncationConfig_SA_h__ -#define __L1Trigger_L1THGCal_HGCalStage1TruncationConfig_SA_h__ +#ifndef __L1Trigger_L1THGCal_HGCalLayer1TruncationFwConfig_h__ +#define __L1Trigger_L1THGCal_HGCalLayer1TruncationFwConfig_h__ #include #include // uint32_t namespace l1thgcfirmware { - class Stage1TruncationConfig { + class HGCalLayer1TruncationFwConfig { public: - Stage1TruncationConfig() {} + HGCalLayer1TruncationFwConfig() {} - Stage1TruncationConfig(const bool do_truncate, - const double roz_min, - const double roz_max, - const unsigned roz_bins, - const std::vector& max_tcs_per_bins, - const std::vector& phi_edges) + HGCalLayer1TruncationFwConfig(const bool do_truncate, + const double roz_min, + const double roz_max, + const unsigned roz_bins, + const std::vector& max_tcs_per_bins, + const std::vector& phi_edges) : do_truncate_(do_truncate), roz_min_(roz_min), roz_max_(roz_max), @@ -37,7 +37,7 @@ namespace l1thgcfirmware { phi_edges_ = phi_edges; } - void setParameters(const Stage1TruncationConfig& newConfig) { + void setParameters(const HGCalLayer1TruncationFwConfig& newConfig) { setParameters(newConfig.doTruncate(), newConfig.rozMin(), newConfig.rozMax(), diff --git a/L1Trigger/L1THGCal/interface/backend_emulator/HGCalStage1TruncationImpl_SA.h b/L1Trigger/L1THGCal/interface/backend_emulator/HGCalLayer1TruncationFwImpl.h similarity index 69% rename from L1Trigger/L1THGCal/interface/backend_emulator/HGCalStage1TruncationImpl_SA.h rename to L1Trigger/L1THGCal/interface/backend_emulator/HGCalLayer1TruncationFwImpl.h index 41229e2a31219..d72df48254d50 100644 --- a/L1Trigger/L1THGCal/interface/backend_emulator/HGCalStage1TruncationImpl_SA.h +++ b/L1Trigger/L1THGCal/interface/backend_emulator/HGCalLayer1TruncationFwImpl.h @@ -1,9 +1,9 @@ -#ifndef __L1Trigger_L1THGCal_HGCalStage1TruncationImpl_SA_h__ -#define __L1Trigger_L1THGCal_HGCalStage1TruncationImpl_SA_h__ +#ifndef __L1Trigger_L1THGCal_HGCalLayer1TruncationFwImpl_h__ +#define __L1Trigger_L1THGCal_HGCalLayer1TruncationFwImpl_h__ #include "L1Trigger/L1THGCal/interface/backend_emulator/HGCalTriggerCell_SA.h" -#include "L1Trigger/L1THGCal/interface/backend_emulator/HGCalStage1TruncationConfig_SA.h" -#include "L1Trigger/L1THGCal/interface/backend_emulator/HGCalStage1SortingAlg_SA.h" +#include "L1Trigger/L1THGCal/interface/backend_emulator/HGCalLayer1TruncationFwConfig.h" +#include "L1Trigger/L1THGCal/interface/backend_emulator/BatcherSorter.h" #include #include // uint32_t, unsigned @@ -11,17 +11,21 @@ namespace l1thgcfirmware { - class HGCalStage1TruncationImplSA { + class HGCalLayer1TruncationFwImpl { public: - HGCalStage1TruncationImplSA(); - ~HGCalStage1TruncationImplSA() {} + HGCalLayer1TruncationFwImpl(); + ~HGCalLayer1TruncationFwImpl() {} void runAlgorithm() const; unsigned run(const l1thgcfirmware::HGCalTriggerCellSACollection& tcs_in, - const l1thgcfirmware::Stage1TruncationConfig& theConf, + const l1thgcfirmware::HGCalLayer1TruncationFwConfig& theConf, l1thgcfirmware::HGCalTriggerCellSACollection& tcs_out) const; + int phiBin(unsigned roverzbin, double phi, const std::vector& phiedges) const; + double rotatedphi(double x, double y, double z, unsigned sector) const; + unsigned rozBin(double roverz, double rozmin, double rozmax, unsigned rozbins) const; + private: static constexpr unsigned offset_roz_ = 1; static constexpr unsigned mask_roz_ = 0x3f; // 6 bits, max 64 bins @@ -36,8 +40,6 @@ namespace l1thgcfirmware { uint32_t packBin(unsigned roverzbin, unsigned phibin) const; void unpackBin(unsigned packedbin, unsigned& roverzbin, unsigned& phibin) const; - int phiBin(unsigned roverzbin, double phi, const std::vector& phiedges) const; - double rotatedphi(double x, double y, double z, unsigned sector) const; double rotatedphi(double phi, unsigned sector) const; unsigned smallerMultOfFourGreaterThan(unsigned n) const; diff --git a/L1Trigger/L1THGCal/plugins/HGCalBackendLayer1Producer.cc b/L1Trigger/L1THGCal/plugins/HGCalBackendLayer1Producer.cc index 50a07dbd136e5..266f97b01f66d 100644 --- a/L1Trigger/L1THGCal/plugins/HGCalBackendLayer1Producer.cc +++ b/L1Trigger/L1THGCal/plugins/HGCalBackendLayer1Producer.cc @@ -10,6 +10,7 @@ #include "DataFormats/HGCDigi/interface/HGCDigiCollections.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" +#include "DataFormats/ForwardDetId/interface/HGCalTriggerBackendDetId.h" #include "L1Trigger/L1THGCal/interface/HGCalProcessorBase.h" @@ -32,13 +33,15 @@ class HGCalBackendLayer1Producer : public edm::stream::EDProducer<> { edm::ESGetToken triggerGeomToken_; std::unique_ptr backendProcess_; + bool bypass_be_mapping_ = false; }; DEFINE_FWK_MODULE(HGCalBackendLayer1Producer); HGCalBackendLayer1Producer::HGCalBackendLayer1Producer(const edm::ParameterSet& conf) : input_cell_(consumes(conf.getParameter("InputTriggerCells"))), - triggerGeomToken_(esConsumes()) { + triggerGeomToken_(esConsumes()), + bypass_be_mapping_(conf.getParameter("BypassBackendMapping")) { //setup Backend parameters const edm::ParameterSet& beParamConfig = conf.getParameterSet("ProcessorParameters"); const std::string& beProcessorName = beParamConfig.getParameter("ProcessorName"); @@ -59,8 +62,25 @@ void HGCalBackendLayer1Producer::produce(edm::Event& e, const edm::EventSetup& e // Input collections edm::Handle trigCellBxColl; - e.getByToken(input_cell_, trigCellBxColl); - backendProcess_->run(trigCellBxColl, *be_cluster_output); + + // Split trigger cell collection per FPGA + std::unordered_map>> tcs_per_fpga; + + for (unsigned i = 0; i < trigCellBxColl->size(); ++i) { + edm::Ptr tc_ptr(trigCellBxColl, i); + uint32_t fpga = 0; // null detid + if (!bypass_be_mapping_) { + uint32_t module = triggerGeometry_->getModuleFromTriggerCell(tc_ptr->detId()); + fpga = triggerGeometry_->getStage1FpgaFromModule(module); + } + // if bypass_be_mapping, TCs from the entire detector will be put in a single collection + tcs_per_fpga[fpga].push_back(tc_ptr); + } + + for (auto& fpga_tcs : tcs_per_fpga) { + backendProcess_->run(fpga_tcs, *be_cluster_output); + } + e.put(std::move(be_cluster_output), backendProcess_->name()); } diff --git a/L1Trigger/L1THGCal/plugins/HGCalBackendStage1Producer.cc b/L1Trigger/L1THGCal/plugins/HGCalBackendStage1Producer.cc deleted file mode 100644 index 496a2ca2ca810..0000000000000 --- a/L1Trigger/L1THGCal/plugins/HGCalBackendStage1Producer.cc +++ /dev/null @@ -1,96 +0,0 @@ -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Utilities/interface/ESGetToken.h" - -#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h" -#include "DataFormats/L1THGCal/interface/HGCalTriggerSums.h" -#include "DataFormats/HGCDigi/interface/HGCDigiCollections.h" -#include "Geometry/Records/interface/CaloGeometryRecord.h" -#include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" - -#include "L1Trigger/L1THGCal/interface/HGCalProcessorBase.h" - -#include "DataFormats/L1THGCal/interface/HGCalCluster.h" - -#include "L1Trigger/L1THGCal/interface/backend/HGCalClusteringDummyImpl.h" -#include "L1Trigger/L1THGCal/interface/HGCalProcessorBase.h" - -#include - -class HGCalBackendStage1Producer : public edm::stream::EDProducer<> { -public: - HGCalBackendStage1Producer(const edm::ParameterSet&); - ~HGCalBackendStage1Producer() override = default; - - void beginRun(const edm::Run&, const edm::EventSetup&) override; - void produce(edm::Event&, const edm::EventSetup&) override; - -private: - // inputs - const edm::EDGetToken input_cell_; - edm::ESHandle triggerGeometry_; - const edm::ESGetToken triggerGeomToken_; - - std::unique_ptr backendProcess_; - - std::unique_ptr clusteringDummy_; -}; - -DEFINE_FWK_MODULE(HGCalBackendStage1Producer); - -HGCalBackendStage1Producer::HGCalBackendStage1Producer(const edm::ParameterSet& conf) - : input_cell_(consumes(conf.getParameter("InputTriggerCells"))), - triggerGeomToken_(esConsumes()) { - //setup Backend parameters - const edm::ParameterSet& beParamConfig = conf.getParameterSet("ProcessorParameters"); - const std::string& beProcessorName = beParamConfig.getParameter("ProcessorName"); - - clusteringDummy_ = std::make_unique(conf.getParameterSet("C2d_parameters")); - - backendProcess_ = std::unique_ptr{ - HGCalBackendStage1Factory::get()->create(beProcessorName, beParamConfig)}; - - produces(backendProcess_->name()); -} - -void HGCalBackendStage1Producer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) { - triggerGeometry_ = es.getHandle(triggerGeomToken_); - backendProcess_->setGeometry(triggerGeometry_.product()); - if (clusteringDummy_) - clusteringDummy_->setGeometry(triggerGeometry_.product()); -} - -void HGCalBackendStage1Producer::produce(edm::Event& e, const edm::EventSetup& es) { - // Output collections - auto be_cluster_output = std::make_unique(); - - // Input collections - edm::Handle trigCellBxColl; - - // Split trigger cell collection per FPGA - e.getByToken(input_cell_, trigCellBxColl); - - std::unordered_map>> tcs_per_fpga; - - for (unsigned i = 0; i < trigCellBxColl->size(); ++i) { - edm::Ptr tc_ptr(trigCellBxColl, i); - uint32_t module = triggerGeometry_->getModuleFromTriggerCell(tc_ptr->detId()); - uint32_t fpga = triggerGeometry_->getStage1FpgaFromModule(module); - tcs_per_fpga[fpga].push_back(tc_ptr); - } - - // Apply truncation per FPGA - std::vector> truncated_tcs; - - for (auto& fpga_tcs : tcs_per_fpga) { - backendProcess_->run(fpga_tcs, truncated_tcs); - } - - // Merge truncated tc collections - clusteringDummy_->clusterizeDummy(truncated_tcs, *be_cluster_output); - - e.put(std::move(be_cluster_output), backendProcess_->name()); -} diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1Processor.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1Processor.cc deleted file mode 100644 index c43cbd278968e..0000000000000 --- a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1Processor.cc +++ /dev/null @@ -1,32 +0,0 @@ -#include "L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1Processor.h" - -DEFINE_EDM_PLUGIN(HGCalBackendLayer1Factory, HGCalBackendLayer1Processor, "HGCalBackendLayer1Processor"); - -HGCalBackendLayer1Processor::HGCalBackendLayer1Processor(const edm::ParameterSet& conf) - : HGCalBackendLayer1ProcessorBase(conf) { - clusteringDummy_ = std::make_unique(conf.getParameterSet("C2d_parameters")); - truncation_ = std::make_unique(conf.getParameterSet("truncation_parameters")); -} - -void HGCalBackendLayer1Processor::run(const edm::Handle& collHandle, - l1t::HGCalClusterBxCollection& collCluster2D) { - if (clusteringDummy_) - clusteringDummy_->setGeometry(geometry()); - if (truncation_) - truncation_->setGeometry(geometry()); - - std::unordered_map>> tcs_per_fpga; - - for (unsigned i = 0; i < collHandle->size(); ++i) { - edm::Ptr tc_ptr(collHandle, i); - uint32_t module = geometry()->getModuleFromTriggerCell(tc_ptr->detId()); - uint32_t fpga = geometry()->getStage1FpgaFromModule(module); - tcs_per_fpga[fpga].push_back(tc_ptr); - } - - std::vector> truncated_tcs; - for (auto& fpga_tcs : tcs_per_fpga) { - truncation_->run(fpga_tcs.first, fpga_tcs.second, truncated_tcs); - } - clusteringDummy_->clusterizeDummy(truncated_tcs, collCluster2D); -} diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1Processor2DClustering.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1Processor2DClustering.cc index 36271c9d422a8..0083520c1af7a 100644 --- a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1Processor2DClustering.cc +++ b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1Processor2DClustering.cc @@ -28,19 +28,15 @@ class HGCalBackendLayer1Processor2DClustering : public HGCalBackendLayer1Process } } - void run(const edm::Handle& collHandle, + void run(const std::pair>>& fpga_id_tcs, l1t::HGCalClusterBxCollection& collCluster2D) override { if (clustering_) clustering_->setGeometry(geometry()); if (clusteringDummy_) clusteringDummy_->setGeometry(geometry()); - /* create a persistent vector of pointers to the trigger-cells */ - std::vector> triggerCellsPtrs; - for (unsigned i = 0; i < collHandle->size(); ++i) { - edm::Ptr ptr(collHandle, i); - triggerCellsPtrs.push_back(ptr); - } + // copy TC collection for sorting + std::vector> triggerCellsPtrs = fpga_id_tcs.second; std::sort(triggerCellsPtrs.begin(), triggerCellsPtrs.end(), diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1ProcessorTruncation.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1ProcessorTruncation.cc new file mode 100644 index 0000000000000..fc6efed7c2a0e --- /dev/null +++ b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1ProcessorTruncation.cc @@ -0,0 +1,24 @@ +#include "L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1ProcessorTruncation.h" + +DEFINE_EDM_PLUGIN(HGCalBackendLayer1Factory, + HGCalBackendLayer1ProcessorTruncation, + "HGCalBackendLayer1ProcessorTruncation"); + +HGCalBackendLayer1ProcessorTruncation::HGCalBackendLayer1ProcessorTruncation(const edm::ParameterSet& conf) + : HGCalBackendLayer1ProcessorBase(conf) { + clusteringDummy_ = std::make_unique(conf.getParameterSet("clustering_dummy_parameters")); + truncation_ = std::make_unique(conf.getParameterSet("truncation_parameters")); +} + +void HGCalBackendLayer1ProcessorTruncation::run( + const std::pair>>& fpga_id_tcs, + l1t::HGCalClusterBxCollection& clusters) { + if (clusteringDummy_) + clusteringDummy_->setGeometry(geometry()); + if (truncation_) + truncation_->setGeometry(geometry()); + + std::vector> truncated_tcs; + truncation_->run(fpga_id_tcs.first, fpga_id_tcs.second, truncated_tcs); + clusteringDummy_->clusterizeDummy(truncated_tcs, clusters); +} diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1ProcessorTruncationFw.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1ProcessorTruncationFw.cc new file mode 100644 index 0000000000000..c10d21d2898c7 --- /dev/null +++ b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendLayer1ProcessorTruncationFw.cc @@ -0,0 +1,33 @@ +#include "L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1ProcessorTruncationFw.h" +#include "DataFormats/ForwardDetId/interface/HGCalTriggerBackendDetId.h" + +DEFINE_EDM_PLUGIN(HGCalBackendLayer1Factory, + HGCalBackendLayer1ProcessorTruncationFw, + "HGCalBackendLayer1ProcessorTruncationFw"); + +HGCalBackendLayer1ProcessorTruncationFw::HGCalBackendLayer1ProcessorTruncationFw(const edm::ParameterSet& conf) + : HGCalBackendLayer1ProcessorBase(conf), conf_(conf) { + const edm::ParameterSet& truncationParamConfig = conf.getParameterSet("truncation_parameters"); + const std::string& truncationWrapperName = truncationParamConfig.getParameter("AlgoName"); + + clusteringDummy_ = std::make_unique(conf.getParameterSet("clustering_dummy_parameters")); + truncationWrapper_ = std::unique_ptr{ + HGCalLayer1TruncationWrapperBaseFactory::get()->create(truncationWrapperName, truncationParamConfig)}; +} + +void HGCalBackendLayer1ProcessorTruncationFw::run( + const std::pair>>& fpga_id_tcs, + l1t::HGCalClusterBxCollection& clusters) { + const unsigned sector120 = HGCalTriggerBackendDetId(fpga_id_tcs.first).sector(); + const uint32_t fpga_id = fpga_id_tcs.first; + + // Configuration + clusteringDummy_->setGeometry(geometry()); + const std::tuple configuration{ + geometry(), sector120, fpga_id}; + truncationWrapper_->configure(configuration); + + std::vector> truncated_tcs; + truncationWrapper_->process(fpga_id_tcs.second, truncated_tcs); + clusteringDummy_->clusterizeDummy(truncated_tcs, clusters); +} diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendStage1Processor.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalBackendStage1Processor.cc deleted file mode 100644 index ff16815380624..0000000000000 --- a/L1Trigger/L1THGCal/plugins/backend/HGCalBackendStage1Processor.cc +++ /dev/null @@ -1,27 +0,0 @@ -#include "L1Trigger/L1THGCal/interface/backend/HGCalBackendStage1Processor.h" -#include "DataFormats/ForwardDetId/interface/HGCalTriggerBackendDetId.h" - -DEFINE_EDM_PLUGIN(HGCalBackendStage1Factory, HGCalBackendStage1Processor, "HGCalBackendStage1Processor"); - -HGCalBackendStage1Processor::HGCalBackendStage1Processor(const edm::ParameterSet& conf) - : HGCalBackendStage1ProcessorBase(conf), conf_(conf) { - const edm::ParameterSet& truncationParamConfig = conf.getParameterSet("truncation_parameters"); - const std::string& truncationWrapperName = truncationParamConfig.getParameter("AlgoName"); - - truncationWrapper_ = std::unique_ptr{ - HGCalStage1TruncationWrapperBaseFactory::get()->create(truncationWrapperName, truncationParamConfig)}; -} - -void HGCalBackendStage1Processor::run( - const std::pair>>& fpga_id_tcs, - std::vector>& truncated_tcs) { - const unsigned sector120 = HGCalTriggerBackendDetId(fpga_id_tcs.first).sector(); - const uint32_t fpga_id = fpga_id_tcs.first; - - // Configuration - const std::tuple configuration{ - geometry(), sector120, fpga_id}; - truncationWrapper_->configure(configuration); - - truncationWrapper_->process(fpga_id_tcs.second, truncated_tcs); -} diff --git a/L1Trigger/L1THGCal/plugins/backend/HGCalStage1TruncationWrapper.cc b/L1Trigger/L1THGCal/plugins/backend/HGCalLayer1TruncationWrapper.cc similarity index 80% rename from L1Trigger/L1THGCal/plugins/backend/HGCalStage1TruncationWrapper.cc rename to L1Trigger/L1THGCal/plugins/backend/HGCalLayer1TruncationWrapper.cc index 9c58c7bb113c4..f6ae43add7c70 100644 --- a/L1Trigger/L1THGCal/plugins/backend/HGCalStage1TruncationWrapper.cc +++ b/L1Trigger/L1THGCal/plugins/backend/HGCalLayer1TruncationWrapper.cc @@ -2,15 +2,15 @@ #include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h" #include "L1Trigger/L1THGCal/interface/backend_emulator/HGCalTriggerCell_SA.h" -#include "L1Trigger/L1THGCal/interface/backend_emulator/HGCalStage1TruncationImpl_SA.h" -#include "L1Trigger/L1THGCal/interface/backend_emulator/HGCalStage1TruncationConfig_SA.h" +#include "L1Trigger/L1THGCal/interface/backend_emulator/HGCalLayer1TruncationFwImpl.h" +#include "L1Trigger/L1THGCal/interface/backend_emulator/HGCalLayer1TruncationFwConfig.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" -class HGCalStage1TruncationWrapper : public HGCalStage1TruncationWrapperBase { +class HGCalLayer1TruncationWrapper : public HGCalLayer1TruncationWrapperBase { public: - HGCalStage1TruncationWrapper(const edm::ParameterSet& conf); - ~HGCalStage1TruncationWrapper() override = default; + HGCalLayer1TruncationWrapper(const edm::ParameterSet& conf); + ~HGCalLayer1TruncationWrapper() override = default; void configure( const std::tuple& configuration) override; @@ -32,15 +32,15 @@ class HGCalStage1TruncationWrapper : public HGCalStage1TruncationWrapperBase { unsigned rozBin(double roverz, double rozmin, double rozmax, unsigned rozbins) const; HGCalTriggerTools triggerTools_; - l1thgcfirmware::HGCalStage1TruncationImplSA theAlgo_; - l1thgcfirmware::Stage1TruncationConfig theConfiguration_; + l1thgcfirmware::HGCalLayer1TruncationFwImpl theAlgo_; + l1thgcfirmware::HGCalLayer1TruncationFwConfig theConfiguration_; // Scale factor for quantities sent to emulator to keep floating point precision. Value is arbitrary and could be set to relevant value. const unsigned int FWfactor_ = 10000; }; -HGCalStage1TruncationWrapper::HGCalStage1TruncationWrapper(const edm::ParameterSet& conf) - : HGCalStage1TruncationWrapperBase(conf), +HGCalLayer1TruncationWrapper::HGCalLayer1TruncationWrapper(const edm::ParameterSet& conf) + : HGCalLayer1TruncationWrapperBase(conf), theAlgo_(), theConfiguration_(conf.getParameter("doTruncation"), conf.getParameter("rozMin"), @@ -49,7 +49,7 @@ HGCalStage1TruncationWrapper::HGCalStage1TruncationWrapper(const edm::ParameterS conf.getParameter>("maxTcsPerBin"), conf.getParameter>("phiSectorEdges")) {} -void HGCalStage1TruncationWrapper::convertCMSSWInputs(const std::vector>& fpga_tcs, +void HGCalLayer1TruncationWrapper::convertCMSSWInputs(const std::vector>& fpga_tcs, l1thgcfirmware::HGCalTriggerCellSACollection& fpga_tcs_SA) const { fpga_tcs_SA.clear(); fpga_tcs_SA.reserve(fpga_tcs.size()); @@ -72,7 +72,7 @@ void HGCalStage1TruncationWrapper::convertCMSSWInputs(const std::vector>& fpga_tcs_original, std::vector>& fpga_tcs_trunc) const { @@ -83,7 +83,7 @@ void HGCalStage1TruncationWrapper::convertAlgorithmOutputs( } } -void HGCalStage1TruncationWrapper::process(const std::vector>& fpga_tcs, +void HGCalLayer1TruncationWrapper::process(const std::vector>& fpga_tcs, std::vector>& tcs_out) const { l1thgcfirmware::HGCalTriggerCellSACollection fpga_tcs_SA; convertCMSSWInputs(fpga_tcs, fpga_tcs_SA); @@ -92,12 +92,12 @@ void HGCalStage1TruncationWrapper::process(const std::vector& configuration) { setGeometry(std::get<0>(configuration)); @@ -105,7 +105,7 @@ void HGCalStage1TruncationWrapper::configure( theConfiguration_.setFPGAID(std::get<2>(configuration)); }; -double HGCalStage1TruncationWrapper::rotatedphi(double phi, unsigned sector) const { +double HGCalLayer1TruncationWrapper::rotatedphi(double phi, unsigned sector) const { if (sector == 1) { if (phi < M_PI and phi > 0) phi = phi - (2. * M_PI / 3.); @@ -117,7 +117,7 @@ double HGCalStage1TruncationWrapper::rotatedphi(double phi, unsigned sector) con return phi; } -unsigned HGCalStage1TruncationWrapper::rozBin(double roverz, double rozmin, double rozmax, unsigned rozbins) const { +unsigned HGCalLayer1TruncationWrapper::rozBin(double roverz, double rozmin, double rozmax, unsigned rozbins) const { constexpr double margin = 1.001; double roz_bin_size = (rozbins > 0 ? (rozmax - rozmin) * margin / double(rozbins) : 0.); unsigned roverzbin = 0; @@ -129,6 +129,6 @@ unsigned HGCalStage1TruncationWrapper::rozBin(double roverz, double rozmin, doub return roverzbin; } -DEFINE_EDM_PLUGIN(HGCalStage1TruncationWrapperBaseFactory, - HGCalStage1TruncationWrapper, - "HGCalStage1TruncationWrapper"); +DEFINE_EDM_PLUGIN(HGCalLayer1TruncationWrapperBaseFactory, + HGCalLayer1TruncationWrapper, + "HGCalLayer1TruncationWrapper"); diff --git a/L1Trigger/L1THGCal/python/customLayer1.py b/L1Trigger/L1THGCal/python/customLayer1.py new file mode 100644 index 0000000000000..400bae16c01a3 --- /dev/null +++ b/L1Trigger/L1THGCal/python/customLayer1.py @@ -0,0 +1,19 @@ +import FWCore.ParameterSet.Config as cms +from L1Trigger.L1THGCal.l1tHGCalBackEndLayer1Producer_cfi import layer1truncation_proc, layer1truncationfw_proc, truncation_params, truncationfw_params + +def custom_layer1_truncation(process): + parameters = layer1truncation_proc.clone() + process.l1tHGCalBackEndLayer1Producer.ProcessorParameters = parameters + process.l1tHGCalBackEndLayer1Producer.BypassBackendMapping = cms.bool(False) + process.l1tHGCalBackEndLayer2Producer.InputCluster = cms.InputTag('l1tHGCalBackEndLayer1Producer:HGCalBackendLayer1ProcessorTruncation') + process.l1tHGCalTowerProducer.InputTriggerCells = cms.InputTag('l1tHGCalBackEndLayer1Producer:HGCalBackendLayer1ProcessorTruncation') + return process + +def custom_layer1_truncationfw(process): + parameters = layer1truncationfw_proc.clone() + process.l1tHGCalBackEndLayer1Producer.ProcessorParameters = parameters + process.l1tHGCalBackEndLayer1Producer.BypassBackendMapping = cms.bool(False) + process.l1tHGCalBackEndLayer2Producer.InputCluster = cms.InputTag('l1tHGCalBackEndLayer1Producer:HGCalBackendLayer1ProcessorTruncationFw') + process.l1tHGCalTowerProducer.InputTriggerCells = cms.InputTag('l1tHGCalBackEndLayer1Producer:HGCalBackendLayer1ProcessorTruncationFw') + return process + diff --git a/L1Trigger/L1THGCal/python/customNewProcessors.py b/L1Trigger/L1THGCal/python/customNewProcessors.py index 4b7c7ad81145b..aba0a28b733df 100644 --- a/L1Trigger/L1THGCal/python/customNewProcessors.py +++ b/L1Trigger/L1THGCal/python/customNewProcessors.py @@ -1,23 +1,6 @@ import FWCore.ParameterSet.Config as cms -from L1Trigger.L1THGCal.l1tHGCalBackEndLayer1Producer_cfi import layer1truncation_proc -from L1Trigger.L1THGCal.l1tHGCalBackEndLayer1Producer_cfi import stage1truncation_proc -from L1Trigger.L1THGCal.l1tHGCalBackEndLayer1Producer_cfi import truncation_params from L1Trigger.L1THGCal.hgcalBackendLayer2_fwClustering_cfi import layer2ClusteringFw_Params -def custom_layer1_truncation(process): - parameters = layer1truncation_proc.clone() - process.l1tHGCalBackEndLayer1Producer.ProcessorParameters = parameters - process.l1tHGCalBackEndLayer2Producer.InputCluster = cms.InputTag('l1tHGCalBackEndLayer1Producer:HGCalBackendLayer1Processor') - process.l1tHGCalTowerProducer.InputTriggerCells = cms.InputTag('l1tHGCalBackEndLayer1Producer:HGCalBackendLayer1Processor') - return process - -def custom_stage1_truncation(process): - parameters = stage1truncation_proc.clone() - process.l1tHGCalBackEndLayer1Producer.ProcessorParameters = parameters - process.l1tHGCalBackEndLayer2Producer.InputCluster = cms.InputTag('l1tHGCalBackEndStage1Producer:HGCalBackendStage1Processor') - process.l1tHGCalTowerProducer.InputTriggerCells = cms.InputTag('l1tHGCalBackEndStage1Producer:HGCalBackendStage1Processor') - return process - def custom_clustering_standalone(process): process.l1tHGCalBackEndLayer2Producer.ProcessorParameters.ProcessorName = cms.string('HGCalBackendLayer2Processor3DClusteringSA') process.l1tHGCalBackEndLayer2Producer.ProcessorParameters.DistributionParameters = truncation_params diff --git a/L1Trigger/L1THGCal/python/hgcalBackEndLayer1_cff.py b/L1Trigger/L1THGCal/python/hgcalBackEndLayer1_cff.py index e6b07179c3a21..ee0697e1cd3ef 100644 --- a/L1Trigger/L1THGCal/python/hgcalBackEndLayer1_cff.py +++ b/L1Trigger/L1THGCal/python/hgcalBackEndLayer1_cff.py @@ -5,6 +5,5 @@ L1THGCalBackEndLayer1 = cms.Task(l1tHGCalBackEndLayer1Producer) -L1THGCalBackEndStage1 = cms.Task(l1tHGCalBackEndStage1Producer) L1THGCalBackEndLayer1HFNose = cms.Task(l1tHGCalBackEndLayer1ProducerHFNose) diff --git a/L1Trigger/L1THGCal/python/hgcalBackEndLayer2_cff.py b/L1Trigger/L1THGCal/python/hgcalBackEndLayer2_cff.py index 39376706ea420..6d59043882ffd 100644 --- a/L1Trigger/L1THGCal/python/hgcalBackEndLayer2_cff.py +++ b/L1Trigger/L1THGCal/python/hgcalBackEndLayer2_cff.py @@ -5,6 +5,5 @@ L1THGCalBackEndLayer2 = cms.Task(l1tHGCalBackEndLayer2Producer) -L1THGCalBackEndStage2 = cms.Task(l1tHGCalBackEndStage2Producer) L1THGCalBackEndLayer2HFNose = cms.Task(l1tHGCalBackEndLayer2ProducerHFNose) diff --git a/L1Trigger/L1THGCal/python/hgcalTriggerPrimitivesNew_cff.py b/L1Trigger/L1THGCal/python/hgcalTriggerPrimitivesNew_cff.py deleted file mode 100644 index 4f69ed4d22d27..0000000000000 --- a/L1Trigger/L1THGCal/python/hgcalTriggerPrimitivesNew_cff.py +++ /dev/null @@ -1,35 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from L1Trigger.L1THGCal.l1tHGCalTriggerGeometryESProducer_cfi import * -from L1Trigger.L1THGCal.hgcalVFE_cff import * -from L1Trigger.L1THGCal.hgcalConcentrator_cff import * -from L1Trigger.L1THGCal.hgcalBackEndLayer1_cff import * -from L1Trigger.L1THGCal.hgcalBackEndLayer2_cff import * -from L1Trigger.L1THGCal.hgcalTowerMap_cff import * -from L1Trigger.L1THGCal.hgcalTower_cff import * - -L1THGCalTriggerPrimitivesTask = cms.Task(L1THGCalVFE, L1THGCalConcentrator, L1THGCalBackEndStage1, L1THGCalBackEndStage2, L1THGCalTowerMap, L1THGCalTower) -L1THGCalTriggerPrimitives = cms.Sequence(L1THGCalTriggerPrimitivesTask) - -_hfnose_hgcalTriggerPrimitivesTask = L1THGCalTriggerPrimitivesTask.copy() -_hfnose_hgcalTriggerPrimitivesTask.add(L1THFnoseVFE, L1THGCalConcentratorHFNose, L1THGCalBackEndLayer1HFNose, L1THGCalBackEndLayer2HFNose, L1THGCalTowerMapHFNose, L1THGCalTowerHFNose) - -from Configuration.Eras.Modifier_phase2_hfnose_cff import phase2_hfnose -phase2_hfnose.toReplaceWith( - L1THGCalTriggerPrimitivesTask, _hfnose_hgcalTriggerPrimitivesTask ) - -from Configuration.Eras.Modifier_phase2_hgcalV10_cff import phase2_hgcalV10 -from Configuration.Eras.Modifier_phase2_hgcalV11_cff import phase2_hgcalV11 -from L1Trigger.L1THGCal.customTriggerGeometry import custom_geometry_V10, custom_geometry_V11_Imp3 -from L1Trigger.L1THGCal.customCalibration import custom_cluster_calibration_global -modifyHgcalTriggerPrimitivesWithV10Geometry_ = (phase2_hgcalV10 & ~phase2_hgcalV11).makeProcessModifier(custom_geometry_V10) -modifyHgcalTriggerPrimitivesWithV11Geometry_ = phase2_hgcalV11.makeProcessModifier(custom_geometry_V11_Imp3) - -from Configuration.ProcessModifiers.convertHGCalDigisSim_cff import convertHGCalDigisSim -# can't declare a producer version of simHGCalUnsuppressedDigis in the normal flow of things, -# because it's already an EDAlias elsewhere -def _fakeHGCalDigiAlias(process): - from EventFilter.HGCalRawToDigi.HGCDigiConverter_cfi import HGCDigiConverter as _HGCDigiConverter - process.simHGCalUnsuppressedDigis = _HGCDigiConverter.clone() - process.L1THGCalTriggerPrimitivesTask.add(process.simHGCalUnsuppressedDigis) -doFakeHGCalDigiAlias = convertHGCalDigisSim.makeProcessModifier(_fakeHGCalDigiAlias) diff --git a/L1Trigger/L1THGCal/python/l1tHGCalBackEndLayer1Producer_cfi.py b/L1Trigger/L1THGCal/python/l1tHGCalBackEndLayer1Producer_cfi.py index 1bef6460c6ae8..32a1a89642de0 100644 --- a/L1Trigger/L1THGCal/python/l1tHGCalBackEndLayer1Producer_cfi.py +++ b/L1Trigger/L1THGCal/python/l1tHGCalBackEndLayer1Producer_cfi.py @@ -76,7 +76,7 @@ doTruncation=cms.bool(True) ) -truncation_paramsSA = cms.PSet(AlgoName=cms.string('HGCalStage1TruncationWrapper'), +truncationfw_params = cms.PSet(AlgoName=cms.string('HGCalLayer1TruncationWrapper'), rozMin=cms.double(0.07587128), rozMax=cms.double(0.55508006), rozBins=cms.uint32(42), @@ -86,29 +86,25 @@ ) -layer1truncation_proc = cms.PSet(ProcessorName = cms.string('HGCalBackendLayer1Processor'), - C2d_parameters = dummy_C2d_params.clone(), - truncation_parameters = truncation_params.clone() +layer1truncation_proc = cms.PSet(ProcessorName = cms.string('HGCalBackendLayer1ProcessorTruncation'), + truncation_parameters = truncation_params.clone(), + clustering_dummy_parameters = dummy_C2d_params.clone() ) -stage1truncation_proc = cms.PSet(ProcessorName = cms.string('HGCalBackendStage1Processor'), - truncation_parameters = truncation_paramsSA.clone() + +layer1truncationfw_proc = cms.PSet(ProcessorName = cms.string('HGCalBackendLayer1ProcessorTruncationFw'), + truncation_parameters = truncationfw_params.clone(), + clustering_dummy_parameters = dummy_C2d_params.clone() ) -be_proc = cms.PSet(ProcessorName = cms.string('HGCalBackendLayer1Processor2DClustering'), +clustering2d_proc = cms.PSet(ProcessorName = cms.string('HGCalBackendLayer1Processor2DClustering'), C2d_parameters = dummy_C2d_params.clone() ) l1tHGCalBackEndLayer1Producer = cms.EDProducer( "HGCalBackendLayer1Producer", InputTriggerCells = cms.InputTag('l1tHGCalConcentratorProducer:HGCalConcentratorProcessorSelection'), - ProcessorParameters = be_proc.clone() - ) - -l1tHGCalBackEndStage1Producer = cms.EDProducer( - "HGCalBackendStage1Producer", - InputTriggerCells = cms.InputTag('l1tHGCalConcentratorProducer:HGCalConcentratorProcessorSelection'), - C2d_parameters = dummy_C2d_params.clone(), - ProcessorParameters = stage1truncation_proc.clone() + BypassBackendMapping = cms.bool(True), + ProcessorParameters = clustering2d_proc.clone() ) l1tHGCalBackEndLayer1ProducerHFNose = l1tHGCalBackEndLayer1Producer.clone( diff --git a/L1Trigger/L1THGCal/python/l1tHGCalBackEndLayer2Producer_cfi.py b/L1Trigger/L1THGCal/python/l1tHGCalBackEndLayer2Producer_cfi.py index 26875eaee3815..a1a480aff73c2 100644 --- a/L1Trigger/L1THGCal/python/l1tHGCalBackEndLayer2Producer_cfi.py +++ b/L1Trigger/L1THGCal/python/l1tHGCalBackEndLayer2Producer_cfi.py @@ -172,12 +172,6 @@ ProcessorParameters = be_proc.clone() ) -l1tHGCalBackEndStage2Producer = cms.EDProducer( - "HGCalBackendLayer2Producer", - InputCluster = cms.InputTag('l1tHGCalBackEndStage1Producer:HGCalBackendStage1Processor'), - ProcessorParameters = be_proc.clone() - ) - l1tHGCalBackEndLayer2ProducerHFNose = l1tHGCalBackEndLayer2Producer.clone( InputCluster = cms.InputTag('l1tHGCalBackEndLayer1ProducerHFNose:HGCalBackendLayer1Processor2DClustering'), ProcessorParameters = dict( diff --git a/L1Trigger/L1THGCal/src/HGCalAlgoWrapperBase.cc b/L1Trigger/L1THGCal/src/HGCalAlgoWrapperBase.cc index f983c24dd043d..547ad057550f6 100644 --- a/L1Trigger/L1THGCal/src/HGCalAlgoWrapperBase.cc +++ b/L1Trigger/L1THGCal/src/HGCalAlgoWrapperBase.cc @@ -6,4 +6,4 @@ EDM_REGISTER_PLUGINFACTORY(HGCalTowerMapsWrapperBaseFactory, "HGCalTowerMapsWrap EDM_REGISTER_PLUGINFACTORY(HGCalStage2FilteringWrapperBaseFactory, "HGCalStage2FilteringWrapperBaseFactory"); -EDM_REGISTER_PLUGINFACTORY(HGCalStage1TruncationWrapperBaseFactory, "HGCalStage1TruncationWrapperBaseFactory"); +EDM_REGISTER_PLUGINFACTORY(HGCalLayer1TruncationWrapperBaseFactory, "HGCalLayer1TruncationWrapperBaseFactory"); diff --git a/L1Trigger/L1THGCal/src/HGCalProcessorBase.cc b/L1Trigger/L1THGCal/src/HGCalProcessorBase.cc index 5fd811eac034d..c5ca76a2e0525 100644 --- a/L1Trigger/L1THGCal/src/HGCalProcessorBase.cc +++ b/L1Trigger/L1THGCal/src/HGCalProcessorBase.cc @@ -6,8 +6,6 @@ EDM_REGISTER_PLUGINFACTORY(HGCalConcentratorFactory, "HGCalConcentratorFactory") EDM_REGISTER_PLUGINFACTORY(HGCalBackendLayer1Factory, "HGCalBackendLayer1Factory"); -EDM_REGISTER_PLUGINFACTORY(HGCalBackendStage1Factory, "HGCalBackendStage1Factory"); - EDM_REGISTER_PLUGINFACTORY(HGCalBackendLayer2Factory, "HGCalBackendLayer2Factory"); EDM_REGISTER_PLUGINFACTORY(HGCalTowerMapFactory, "HGCalTowerMapFactory"); diff --git a/L1Trigger/L1THGCal/src/backend/HGCalStage1TruncationImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalLayer1TruncationImpl.cc similarity index 83% rename from L1Trigger/L1THGCal/src/backend/HGCalStage1TruncationImpl.cc rename to L1Trigger/L1THGCal/src/backend/HGCalLayer1TruncationImpl.cc index d0b730c2d4b8e..b779b5f3a150f 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalStage1TruncationImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalLayer1TruncationImpl.cc @@ -1,8 +1,8 @@ -#include "L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationImpl.h" +#include "L1Trigger/L1THGCal/interface/backend/HGCalLayer1TruncationImpl.h" #include "DataFormats/ForwardDetId/interface/HGCalTriggerBackendDetId.h" #include -HGCalStage1TruncationImpl::HGCalStage1TruncationImpl(const edm::ParameterSet& conf) +HGCalLayer1TruncationImpl::HGCalLayer1TruncationImpl(const edm::ParameterSet& conf) : do_truncate_(conf.getParameter("doTruncation")), roz_min_(conf.getParameter("rozMin")), roz_max_(conf.getParameter("rozMax")), @@ -10,15 +10,15 @@ HGCalStage1TruncationImpl::HGCalStage1TruncationImpl(const edm::ParameterSet& co max_tcs_per_bin_(conf.getParameter>("maxTcsPerBin")), phi_edges_(conf.getParameter>("phiSectorEdges")) { if (max_tcs_per_bin_.size() != roz_bins_) - throw cms::Exception("HGCalStage1TruncationImpl::BadConfig") << "Inconsistent sizes of maxTcsPerBin and rozBins"; + throw cms::Exception("HGCalLayer1TruncationImpl::BadConfig") << "Inconsistent sizes of maxTcsPerBin and rozBins"; if (phi_edges_.size() != roz_bins_) - throw cms::Exception("HGCalStage1TruncationImpl::BadConfig") << "Inconsistent sizes of phiSectorEdges and rozBins"; + throw cms::Exception("HGCalLayer1TruncationImpl::BadConfig") << "Inconsistent sizes of phiSectorEdges and rozBins"; constexpr double margin = 1.001; roz_bin_size_ = (roz_bins_ > 0 ? (roz_max_ - roz_min_) * margin / double(roz_bins_) : 0.); } -void HGCalStage1TruncationImpl::run(uint32_t fpga_id, +void HGCalLayer1TruncationImpl::run(uint32_t fpga_id, const std::vector>& tcs_in, std::vector>& tcs_out) { unsigned sector120 = HGCalTriggerBackendDetId(fpga_id).sector(); @@ -54,7 +54,7 @@ void HGCalStage1TruncationImpl::run(uint32_t fpga_id, unsigned phibin = 0; unpackBin(bin_tcs.first, roverzbin, phibin); if (roverzbin >= max_tcs_per_bin_.size()) - throw cms::Exception("HGCalStage1TruncationImpl::OutOfRange") + throw cms::Exception("HGCalLayer1TruncationImpl::OutOfRange") << "roverzbin index " << roverzbin << "out of range"; unsigned max_tc = max_tcs_per_bin_[roverzbin]; if (do_truncate_ && bin_tcs.second.size() > max_tc) { @@ -66,29 +66,29 @@ void HGCalStage1TruncationImpl::run(uint32_t fpga_id, } } -unsigned HGCalStage1TruncationImpl::packBin(unsigned roverzbin, unsigned phibin) const { +unsigned HGCalLayer1TruncationImpl::packBin(unsigned roverzbin, unsigned phibin) const { unsigned packed_bin = 0; packed_bin |= ((roverzbin & mask_roz_) << offset_roz_); packed_bin |= (phibin & mask_phi_); return packed_bin; } -void HGCalStage1TruncationImpl::unpackBin(unsigned packedbin, unsigned& roverzbin, unsigned& phibin) const { +void HGCalLayer1TruncationImpl::unpackBin(unsigned packedbin, unsigned& roverzbin, unsigned& phibin) const { roverzbin = ((packedbin >> offset_roz_) & mask_roz_); phibin = (packedbin & mask_phi_); } -unsigned HGCalStage1TruncationImpl::phiBin(unsigned roverzbin, double phi) const { +unsigned HGCalLayer1TruncationImpl::phiBin(unsigned roverzbin, double phi) const { unsigned phi_bin = 0; if (roverzbin >= phi_edges_.size()) - throw cms::Exception("HGCalStage1TruncationImpl::OutOfRange") << "roverzbin index " << roverzbin << "out of range"; + throw cms::Exception("HGCalLayer1TruncationImpl::OutOfRange") << "roverzbin index " << roverzbin << "out of range"; double phi_edge = phi_edges_[roverzbin]; if (phi > phi_edge) phi_bin = 1; return phi_bin; } -double HGCalStage1TruncationImpl::rotatedphi(double x, double y, double z, int sector) const { +double HGCalLayer1TruncationImpl::rotatedphi(double x, double y, double z, int sector) const { if (z > 0) x = -x; double phi = std::atan2(y, x); diff --git a/L1Trigger/L1THGCal/src/backend/HGCalStage1TruncationImpl_SA.cc b/L1Trigger/L1THGCal/src/backend/HGCalStage1TruncationImpl_SA.cc deleted file mode 100644 index 5cf179f7ed799..0000000000000 --- a/L1Trigger/L1THGCal/src/backend/HGCalStage1TruncationImpl_SA.cc +++ /dev/null @@ -1,109 +0,0 @@ -#include "L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationImpl_SA.h" -#include - -unsigned HGCalStage1TruncationImplSA::run(const l1thgcfirmwareDUMMY::HGCalTriggerCellSACollection& tcs_in, - const l1thgcfirmwareDUMMY::Stage1TruncationConfig& theConf, - l1thgcfirmwareDUMMY::HGCalTriggerCellSACollection& tcs_out) const { - unsigned sector120 = theConf.phiSector(); - std::unordered_map tcs_per_bin; - - // configuation: - bool do_truncate = theConf.doTruncate(); - double rozmin = theConf.rozMin(); - double rozmax = theConf.rozMax(); - unsigned rozbins = theConf.rozBins(); - const std::vector& maxtcsperbin = theConf.maxTcsPerBin(); - const std::vector& phiedges = theConf.phiEdges(); - - // group TCs per (r/z, phi) bins - for (const auto& tc : tcs_in) { - double x = tc.x(); - double y = tc.y(); - double z = tc.z(); - double roverz = std::sqrt(x * x + y * y) / std::abs(z); - unsigned roverzbin = rozBin(roverz, rozmin, rozmax, rozbins); - - double phi = rotatedphi(x, y, z, sector120); - int phibin = phiBin(roverzbin, phi, phiedges); - if (phibin < 0) - return 1; - unsigned packed_bin = packBin(roverzbin, phibin); - - tcs_per_bin[packed_bin].push_back(tc); - } - // apply sorting and trunction in each (r/z, phi) bin - for (auto& bin_tcs : tcs_per_bin) { - std::sort(bin_tcs.second.begin(), - bin_tcs.second.end(), - [](const l1thgcfirmwareDUMMY::HGCalTriggerCell& a, - const l1thgcfirmwareDUMMY::HGCalTriggerCell& b) -> bool { return a.mipPt() > b.mipPt(); }); - - unsigned roverzbin = 0; - unsigned phibin = 0; - unpackBin(bin_tcs.first, roverzbin, phibin); - if (roverzbin >= maxtcsperbin.size()) - return 1; - - unsigned max_tc = maxtcsperbin[roverzbin]; - if (do_truncate && bin_tcs.second.size() > max_tc) { - bin_tcs.second.resize(max_tc); - } - - for (const auto& tc : bin_tcs.second) { - tcs_out.push_back(tc); - } - } - - return 0; -} - -unsigned HGCalStage1TruncationImplSA::packBin(unsigned roverzbin, unsigned phibin) const { - unsigned packed_bin = 0; - packed_bin |= ((roverzbin & mask_roz_) << offset_roz_); - packed_bin |= (phibin & mask_phi_); - return packed_bin; -} - -void HGCalStage1TruncationImplSA::unpackBin(unsigned packedbin, unsigned& roverzbin, unsigned& phibin) const { - roverzbin = ((packedbin >> offset_roz_) & mask_roz_); - phibin = (packedbin & mask_phi_); -} - -int HGCalStage1TruncationImplSA::phiBin(unsigned roverzbin, double phi, const std::vector& phiedges) const { - int phi_bin = 0; - if (roverzbin >= phiedges.size()) - return -1; - double phi_edge = phiedges[roverzbin]; - if (phi > phi_edge) - phi_bin = 1; - return phi_bin; -} - -double HGCalStage1TruncationImplSA::rotatedphi(double x, double y, double z, int sector) const { - if (z > 0) - x = -x; - double phi = std::atan2(y, x); - - if (sector == 1) { - if (phi < M_PI and phi > 0) - phi = phi - (2. * M_PI / 3.); - else - phi = phi + (4. * M_PI / 3.); - } else if (sector == 2) { - phi = phi + (2. * M_PI / 3.); - } - return phi; -} - -unsigned HGCalStage1TruncationImplSA::rozBin(double roverz, double rozmin, double rozmax, unsigned rozbins) const { - constexpr double margin = 1.001; - double roz_bin_size = (rozbins > 0 ? (rozmax - rozmin) * margin / double(rozbins) : 0.); - unsigned roverzbin = 0; - if (roz_bin_size > 0.) { - roverz -= rozmin; - roverz = std::clamp(roverz, 0., rozmax - rozmin); - roverzbin = unsigned(roverz / roz_bin_size); - } - - return roverzbin; -} diff --git a/L1Trigger/L1THGCal/src/backend_emulator/HGCalStage1SortingAlg_SA.cc b/L1Trigger/L1THGCal/src/backend_emulator/BatcherSorter.cc similarity index 93% rename from L1Trigger/L1THGCal/src/backend_emulator/HGCalStage1SortingAlg_SA.cc rename to L1Trigger/L1THGCal/src/backend_emulator/BatcherSorter.cc index c084000c63e16..cda288b6a2d58 100644 --- a/L1Trigger/L1THGCal/src/backend_emulator/HGCalStage1SortingAlg_SA.cc +++ b/L1Trigger/L1THGCal/src/backend_emulator/BatcherSorter.cc @@ -8,7 +8,7 @@ // Universite Paris-Saclay //************************************************************************************************/ -#include "L1Trigger/L1THGCal/interface/backend_emulator/HGCalStage1SortingAlg_SA.h" +#include "L1Trigger/L1THGCal/interface/backend_emulator/BatcherSorter.h" #include @@ -23,9 +23,7 @@ using namespace l1thgcfirmware; // @param arr_adresses - list of adresses of elements selected (output). Address goes from 0 to N // //-------------------------------------------------------------------------------------------------/ -void HGCalStage1SortingAlg_SA::sorting(const datain_t& arr_input, - dataout_t& arr_output, - adressout_t& arr_adresses) const { +void BatcherSorter::sorting(const datain_t& arr_input, dataout_t& arr_output, adressout_t& arr_adresses) const { //Variables declaration datasorter_t arr_tmp(NS); datamerger_t arr_tmp_so(NMA), arr_tmp_so1(NMA), arr_tmp_so2(NMA); @@ -117,7 +115,7 @@ void HGCalStage1SortingAlg_SA::sorting(const datain_t& arr_input, // The Art Of Computer Programming, D. Knuth - Sorting and Searching (2nd edition Volume 3), 1998, page 111 //-------------------------------------------------------------------------------------------------/ -void HGCalStage1SortingAlg_SA::sorter(data_to_sort_t& list_sorter, adress_t& list_adresses) const { +void BatcherSorter::sorter(data_to_sort_t& list_sorter, adress_t& list_adresses) const { unsigned tmp_data, tmp_adress; unsigned i, p, q, r, d, constant_bound; datasorter_t list_sorter_tmp(NS); @@ -173,7 +171,7 @@ void HGCalStage1SortingAlg_SA::sorter(data_to_sort_t& list_sorter, adress_t& lis // The Art Of Computer Programming, D. Knuth - Sorting and Searching (2nd edition Volume 3), 1998, page 111 // //-------------------------------------------------------------------------------------------------/ -void HGCalStage1SortingAlg_SA::merger(const unsigned& NM, data_to_merge_t& list_merger, adress_t& list_adresses) const { +void BatcherSorter::merger(const unsigned& NM, data_to_merge_t& list_merger, adress_t& list_adresses) const { unsigned tmp, tmp_adress; unsigned i, p, q, r, d; datamerger_t list_merger_tmp(NM); @@ -227,7 +225,7 @@ void HGCalStage1SortingAlg_SA::merger(const unsigned& NM, data_to_merge_t& list_ // Equivalent to res=ceil(log(i)/log(2)) // //-------------------------------------------------------------------------------------------------/ -unsigned HGCalStage1SortingAlg_SA::log2_rounded(unsigned i) const { +unsigned BatcherSorter::log2_rounded(unsigned i) const { unsigned res = 0; unsigned tmp = i; diff --git a/L1Trigger/L1THGCal/src/backend_emulator/HGCalStage1TruncationImpl_SA.cc b/L1Trigger/L1THGCal/src/backend_emulator/HGCalLayer1TruncationFwImpl.cc similarity index 70% rename from L1Trigger/L1THGCal/src/backend_emulator/HGCalStage1TruncationImpl_SA.cc rename to L1Trigger/L1THGCal/src/backend_emulator/HGCalLayer1TruncationFwImpl.cc index ffd07070950dd..7a80bf04ef76a 100644 --- a/L1Trigger/L1THGCal/src/backend_emulator/HGCalStage1TruncationImpl_SA.cc +++ b/L1Trigger/L1THGCal/src/backend_emulator/HGCalLayer1TruncationFwImpl.cc @@ -1,13 +1,13 @@ -#include "L1Trigger/L1THGCal/interface/backend_emulator/HGCalStage1TruncationImpl_SA.h" +#include "L1Trigger/L1THGCal/interface/backend_emulator/HGCalLayer1TruncationFwImpl.h" #include -#include +#include using namespace l1thgcfirmware; -HGCalStage1TruncationImplSA::HGCalStage1TruncationImplSA() {} +HGCalLayer1TruncationFwImpl::HGCalLayer1TruncationFwImpl() {} -unsigned HGCalStage1TruncationImplSA::run(const l1thgcfirmware::HGCalTriggerCellSACollection& tcs_in, - const l1thgcfirmware::Stage1TruncationConfig& theConf, +unsigned HGCalLayer1TruncationFwImpl::run(const l1thgcfirmware::HGCalTriggerCellSACollection& tcs_in, + const l1thgcfirmware::HGCalLayer1TruncationFwConfig& theConf, l1thgcfirmware::HGCalTriggerCellSACollection& tcs_out) const { std::unordered_map> tcs_per_bin; @@ -35,7 +35,7 @@ unsigned HGCalStage1TruncationImplSA::run(const l1thgcfirmware::HGCalTriggerCell smallerMultOfFourGreaterThan(maxtcsperbin[roverzbin])); const unsigned ntcout = (do_truncate ? maxtcsperbin[roverzbin] : bin_tcs.second.size()); - l1thgcfirmware::HGCalStage1SortingAlg_SA tcSorter(ntcin, ntcout); + l1thgcfirmware::BatcherSorter tcSorter(ntcin, ntcout); std::vector theTCsIn_mipt(ntcin); std::vector theTCsOut_mipt(ntcout); @@ -67,19 +67,19 @@ unsigned HGCalStage1TruncationImplSA::run(const l1thgcfirmware::HGCalTriggerCell return 0; } -uint32_t HGCalStage1TruncationImplSA::packBin(unsigned roverzbin, unsigned phibin) const { +uint32_t HGCalLayer1TruncationFwImpl::packBin(unsigned roverzbin, unsigned phibin) const { unsigned packed_bin = 0; packed_bin |= ((roverzbin & mask_roz_) << offset_roz_); packed_bin |= (phibin & mask_phi_); return packed_bin; } -void HGCalStage1TruncationImplSA::unpackBin(unsigned packedbin, unsigned& roverzbin, unsigned& phibin) const { +void HGCalLayer1TruncationFwImpl::unpackBin(unsigned packedbin, unsigned& roverzbin, unsigned& phibin) const { roverzbin = ((packedbin >> offset_roz_) & mask_roz_); phibin = (packedbin & mask_phi_); } -int HGCalStage1TruncationImplSA::phiBin(unsigned roverzbin, double phi, const std::vector& phiedges) const { +int HGCalLayer1TruncationFwImpl::phiBin(unsigned roverzbin, double phi, const std::vector& phiedges) const { unsigned phi_bin = 0; if (roverzbin >= phiedges.size()) return -1; @@ -89,7 +89,7 @@ int HGCalStage1TruncationImplSA::phiBin(unsigned roverzbin, double phi, const st return phi_bin; } -double HGCalStage1TruncationImplSA::rotatedphi(double phi, unsigned sector) const { +double HGCalLayer1TruncationFwImpl::rotatedphi(double phi, unsigned sector) const { if (sector == 1) { if (phi < M_PI and phi > 0) phi = phi - (2. * M_PI / 3.); @@ -101,7 +101,27 @@ double HGCalStage1TruncationImplSA::rotatedphi(double phi, unsigned sector) cons return phi; } -unsigned HGCalStage1TruncationImplSA::smallerMultOfFourGreaterThan(unsigned N) const { +double HGCalLayer1TruncationFwImpl::rotatedphi(double x, double y, double z, unsigned sector) const { + if (z > 0) + x = -x; + double phi = std::atan2(y, x); + return this->rotatedphi(phi, sector); +} + +unsigned HGCalLayer1TruncationFwImpl::rozBin(double roverz, double rozmin, double rozmax, unsigned rozbins) const { + constexpr double margin = 1.001; + double roz_bin_size = (rozbins > 0 ? (rozmax - rozmin) * margin / double(rozbins) : 0.); + unsigned roverzbin = 0; + if (roz_bin_size > 0.) { + roverz -= rozmin; + roverz = std::clamp(roverz, 0., rozmax - rozmin); + roverzbin = unsigned(roverz / roz_bin_size); + } + + return roverzbin; +} + +unsigned HGCalLayer1TruncationFwImpl::smallerMultOfFourGreaterThan(unsigned N) const { unsigned remnant = (N + 4) % 4; if (remnant == 0) return N; diff --git a/L1Trigger/L1THGCal/test/HGCalBackendStage1ParameterExtractor.cc b/L1Trigger/L1THGCal/test/HGCalBackendStage1ParameterExtractor.cc index 06e742702b60b..7a801b89e1179 100644 --- a/L1Trigger/L1THGCal/test/HGCalBackendStage1ParameterExtractor.cc +++ b/L1Trigger/L1THGCal/test/HGCalBackendStage1ParameterExtractor.cc @@ -20,7 +20,7 @@ #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h" #include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h" -#include "L1Trigger/L1THGCal/interface/backend/HGCalStage1TruncationImpl_SA.h" +#include "L1Trigger/L1THGCal/interface/backend_emulator/HGCalLayer1TruncationFwImpl.h" #include using json = nlohmann::ordered_json; // using ordered_json for readability @@ -47,7 +47,7 @@ class HGCalBackendStage1ParameterExtractor : public edm::stream::EDAnalyzer<> { edm::ESHandle triggerGeometry_; edm::ESGetToken triggerGeomToken_; - HGCalStage1TruncationImplSA theAlgo_; + l1thgcfirmware::HGCalLayer1TruncationFwImpl theAlgo_; // Metadata std::string detector_version_; diff --git a/L1Trigger/L1THGCalUtilities/python/clustering2d.py b/L1Trigger/L1THGCalUtilities/python/clustering2d.py index 374b51c132c38..62f5c352503fe 100644 --- a/L1Trigger/L1THGCalUtilities/python/clustering2d.py +++ b/L1Trigger/L1THGCalUtilities/python/clustering2d.py @@ -68,18 +68,3 @@ def __call__(self, process, inputs): return producer -class RozBinTruncation(object): - def __init__(self, - maxTcsPerBin=truncation_params.maxTcsPerBin): - self.processor = layer1truncation_proc.clone( - truncation_parameters=truncation_params.clone( - maxTcsPerBin=maxTcsPerBin - ) - ) - - def __call__(self, process, inputs): - producer = process.l1tHGCalBackEndLayer1Producer.clone( - InputTriggerCells = cms.InputTag(inputs), - ProcessorParameters = self.processor - ) - return producer diff --git a/L1Trigger/L1THGCalUtilities/python/clustering2d_v2.py b/L1Trigger/L1THGCalUtilities/python/clustering2d_v2.py deleted file mode 100644 index 2f38bed6308be..0000000000000 --- a/L1Trigger/L1THGCalUtilities/python/clustering2d_v2.py +++ /dev/null @@ -1,23 +0,0 @@ -import FWCore.ParameterSet.Config as cms -from L1Trigger.L1THGCal.l1tHGCalBackEndLayer1Producer_cfi import dummy_C2d_params, \ - stage1truncation_proc, \ - truncation_params - -class RozBinTruncation(object): - def __init__(self, - maxTcsPerBin=truncation_params.maxTcsPerBin, - doTruncation=truncation_params.doTruncation): - self.processor = stage1truncation_proc.clone( - truncation_parameters=truncation_params.clone( - maxTcsPerBin=maxTcsPerBin, - doTruncation=doTruncation - ) - ) - - def __call__(self,process,inputs): - producer = process.l1tHGCalBackEndStage1Producer.clone( - InputTriggerCells = cms.InputTag(inputs), - C2d_parameters = dummy_C2d_params.clone(), - ProcessorParameters = self.processor - ) - return producer diff --git a/L1Trigger/L1THGCalUtilities/python/customNtuples.py b/L1Trigger/L1THGCalUtilities/python/customNtuples.py index 8416b4db896e2..192f2a40f5b58 100644 --- a/L1Trigger/L1THGCalUtilities/python/customNtuples.py +++ b/L1Trigger/L1THGCalUtilities/python/customNtuples.py @@ -6,17 +6,16 @@ def custom_ntuples_layer1_truncation(process): if ntuple.NtupleName=='HGCalTriggerNtupleHGCClusters' or \ ntuple.NtupleName=='HGCalTriggerNtupleHGCTriggerCells' or \ ntuple.NtupleName=='HGCalTriggerNtupleHGCMulticlusters': - ntuple.Clusters = cms.InputTag('l1tHGCalBackEndLayer1Producer:HGCalBackendLayer1Processor') + ntuple.Clusters = cms.InputTag('l1tHGCalBackEndLayer1Producer:HGCalBackendLayer1ProcessorTruncation') return process -def custom_ntuples_stage1_truncation(process): +def custom_ntuples_layer1_truncationfw(process): ntuples = process.l1tHGCalTriggerNtuplizer.Ntuples for ntuple in ntuples: if ntuple.NtupleName=='HGCalTriggerNtupleHGCClusters' or \ ntuple.NtupleName=='HGCalTriggerNtupleHGCTriggerCells' or \ ntuple.NtupleName=='HGCalTriggerNtupleHGCMulticlusters': - ntuple.Clusters = cms.InputTag('l1tHGCalBackEndStage1Producer:HGCalBackendStage1Processor') - ntuple.Multiclusters = cms.InputTag('l1tHGCalBackEndStage2Producer:HGCalBackendLayer2Processor3DClustering') + ntuple.Clusters = cms.InputTag('l1tHGCalBackEndLayer1Producer:HGCalBackendLayer1ProcessorTruncationFw') return process def custom_ntuples_standalone_clustering(process): diff --git a/L1Trigger/L1THGCalUtilities/python/layer1.py b/L1Trigger/L1THGCalUtilities/python/layer1.py new file mode 100644 index 0000000000000..7ff40286771ea --- /dev/null +++ b/L1Trigger/L1THGCalUtilities/python/layer1.py @@ -0,0 +1,41 @@ +import FWCore.ParameterSet.Config as cms +from L1Trigger.L1THGCal.l1tHGCalBackEndLayer1Producer_cfi import layer1truncationfw_proc, \ + truncationfw_params, \ + layer1truncation_proc, \ + truncation_params + +class RozBinTruncation(object): + def __init__(self, + maxTcsPerBin=truncation_params.maxTcsPerBin): + self.processor = layer1truncation_proc.clone( + truncation_parameters=truncation_params.clone( + maxTcsPerBin=maxTcsPerBin + ) + ) + + def __call__(self, process, inputs): + producer = process.l1tHGCalBackEndLayer1Producer.clone( + InputTriggerCells = cms.InputTag(inputs), + ProcessorParameters = self.processor, + BypassBackendMapping = cms.bool(False) + ) + return producer + +class RozBinTruncationFw(object): + def __init__(self, + maxTcsPerBin=truncationfw_params.maxTcsPerBin, + doTruncation=truncationfw_params.doTruncation): + self.processor = layer1truncationfw_proc.clone( + truncation_parameters=truncationfw_params.clone( + maxTcsPerBin=maxTcsPerBin, + doTruncation=doTruncation + ) + ) + + def __call__(self,process,inputs): + producer = process.l1tHGCalBackEndLayer1Producer.clone( + InputTriggerCells = cms.InputTag(inputs), + ProcessorParameters = self.processor, + BypassBackendMapping = cms.bool(False) + ) + return producer diff --git a/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_multialgo_V16_cfg.py b/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_multialgo_V16_cfg.py index 974fcf9286694..85143200f78ce 100644 --- a/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_multialgo_V16_cfg.py +++ b/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_multialgo_V16_cfg.py @@ -64,6 +64,7 @@ import L1Trigger.L1THGCalUtilities.vfe as vfe import L1Trigger.L1THGCalUtilities.concentrator as concentrator import L1Trigger.L1THGCalUtilities.clustering2d as clustering2d +import L1Trigger.L1THGCalUtilities.layer1 as layer1 import L1Trigger.L1THGCalUtilities.clustering3d as clustering3d import L1Trigger.L1THGCalUtilities.selectors as selectors import L1Trigger.L1THGCalUtilities.customNtuples as ntuple @@ -74,12 +75,11 @@ ## VFE chains.register_vfe("Floatingpoint", vfe.CreateVfe()) ## ECON -chains.register_concentrator("Supertriggercell", concentrator.CreateSuperTriggerCell()) chains.register_concentrator("Threshold", concentrator.CreateThreshold()) -chains.register_concentrator("Bestchoice", concentrator.CreateBestChoice()) -chains.register_concentrator("AutoEncoder", concentrator.CreateAutoencoder()) +chains.register_concentrator("Bcstc", concentrator.CreateMixedFeOptions()) ## BE1 chains.register_backend1("Dummy", clustering2d.CreateDummy()) +chains.register_backend1("Truncationfw", layer1.RozBinTruncationFw()) ## BE2 chains.register_backend2("Histomax", clustering3d.CreateHistoMax()) # Register selector @@ -91,12 +91,12 @@ chains.register_ntuple("Genclustersntuple", ntuple.CreateNtuple(ntuple_list)) # Register trigger chains -concentrator_algos = ['Supertriggercell', 'Threshold', 'Bestchoice', 'AutoEncoder'] -backend_algos = ['Histomax'] +concentrator_algos = ['Threshold', 'Bcstc'] +layer1_algos = ['Dummy', 'Truncationfw'] ## Make cross product fo ECON and BE algos import itertools -for cc,be in itertools.product(concentrator_algos,backend_algos): - chains.register_chain('Floatingpoint', cc, 'Dummy', be, 'Genmatch', 'Genclustersntuple') +for cc,s1 in itertools.product(concentrator_algos,layer1_algos): + chains.register_chain('Floatingpoint', cc, s1, 'Histomax', 'Genmatch', 'Genclustersntuple') process = chains.create_sequences(process) diff --git a/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_stage1Truncation_V11_cfg.py b/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_stage1Truncation_V11_cfg.py index e47fea18adc91..d13d0198f92e8 100644 --- a/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_stage1Truncation_V11_cfg.py +++ b/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_stage1Truncation_V11_cfg.py @@ -58,12 +58,11 @@ process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic_T15', '') # load HGCAL TPG simulation -#process.load('L1Trigger.L1THGCal.hgcalTriggerPrimitives_cff') -process.load('L1Trigger.L1THGCal.hgcalTriggerPrimitivesNew_cff') +process.load('L1Trigger.L1THGCal.hgcalTriggerPrimitives_cff') # Use new Stage 1 processor -from L1Trigger.L1THGCal.customNewProcessors import custom_stage1_truncation -process = custom_stage1_truncation(process) +from L1Trigger.L1THGCal.customLayer1 import custom_layer1_truncationfw +process = custom_layer1_truncationfw(process) # Switch to latest trigger geometry containing information on links mapping from L1Trigger.L1THGCal.customTriggerGeometry import custom_geometry_V11_Imp3 @@ -74,10 +73,8 @@ # load ntuplizer and custom to use collections from Stag1 truncation processor process.load('L1Trigger.L1THGCalUtilities.hgcalTriggerNtuples_cff') -from L1Trigger.L1THGCalUtilities.customNtuples import custom_ntuples_stage1_truncation -from L1Trigger.L1THGCalUtilities.customNtuples import custom_ntuples_layer1_truncation -process = custom_ntuples_stage1_truncation(process) -#process = custom_ntuples_layer1_truncation(process) +from L1Trigger.L1THGCalUtilities.customNtuples import custom_ntuples_layer1_truncationfw +process = custom_ntuples_layer1_truncationfw(process) process.ntuple_step = cms.Path(process.L1THGCalTriggerNtuples) # Schedule definition diff --git a/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_stage1Truncation_V16_cfg.py b/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_stage1Truncation_V16_cfg.py index 96b271b71e483..ae6940e43409c 100644 --- a/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_stage1Truncation_V16_cfg.py +++ b/L1Trigger/L1THGCalUtilities/test/testHGCalL1T_stage1Truncation_V16_cfg.py @@ -57,12 +57,11 @@ process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic_T21', '') # load HGCAL TPG simulation -#process.load('L1Trigger.L1THGCal.hgcalTriggerPrimitives_cff') -process.load('L1Trigger.L1THGCal.hgcalTriggerPrimitivesNew_cff') +process.load('L1Trigger.L1THGCal.hgcalTriggerPrimitives_cff') # Use new Stage 1 processor -from L1Trigger.L1THGCal.customNewProcessors import custom_stage1_truncation -process = custom_stage1_truncation(process) +from L1Trigger.L1THGCal.customLayer1 import custom_layer1_truncationfw +process = custom_layer1_truncationfw(process) # Switch to latest trigger geometry containing information on links mapping from L1Trigger.L1THGCal.customTriggerGeometry import custom_geometry_V11_Imp3 @@ -73,10 +72,8 @@ # load ntuplizer and custom to use collections from Stag1 truncation processor process.load('L1Trigger.L1THGCalUtilities.hgcalTriggerNtuples_cff') -from L1Trigger.L1THGCalUtilities.customNtuples import custom_ntuples_stage1_truncation -from L1Trigger.L1THGCalUtilities.customNtuples import custom_ntuples_layer1_truncation -process = custom_ntuples_stage1_truncation(process) -#process = custom_ntuples_layer1_truncation(process) +from L1Trigger.L1THGCalUtilities.customNtuples import custom_ntuples_layer1_truncationfw +process = custom_ntuples_layer1_truncationfw(process) process.ntuple_step = cms.Path(process.L1THGCalTriggerNtuples) # Schedule definition