Skip to content

Commit

Permalink
Cleaning Stage1 / Layer1 Producers / Processors / Algos structure and…
Browse files Browse the repository at this point in the history
… config (cms-sw#104)

* WIP: cleaning Stage1/Layer1 structure and config

* fix compilation issue with layer 1 emulator algo

* apply code-format

* update documentation
  • Loading branch information
jbsauvan authored Apr 25, 2024
1 parent ee8ddc2 commit 4ee39c7
Show file tree
Hide file tree
Showing 42 changed files with 337 additions and 676 deletions.
12 changes: 6 additions & 6 deletions L1Trigger/L1THGCal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions L1Trigger/L1THGCal/interface/HGCalAlgoWrapperBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ typedef HGCalAlgoWrapperBaseT<l1t::HGCalMulticlusterBxCollection,
typedef HGCalAlgoWrapperBaseT<std::vector<edm::Ptr<l1t::HGCalTriggerCell>>,
std::vector<edm::Ptr<l1t::HGCalTriggerCell>>,
std::tuple<const HGCalTriggerGeometryBase* const, const unsigned&, const uint32_t&>>
HGCalStage1TruncationWrapperBase;
HGCalLayer1TruncationWrapperBase;

#include "FWCore/PluginManager/interface/PluginFactory.h"
typedef edmplugin::PluginFactory<HGCalHistoClusteringWrapperBase*(const edm::ParameterSet&)>
HGCalHistoClusteringWrapperBaseFactory;
typedef edmplugin::PluginFactory<HGCalTowerMapsWrapperBase*(const edm::ParameterSet&)> HGCalTowerMapsWrapperBaseFactory;
typedef edmplugin::PluginFactory<HGCalStage2FilteringWrapperBase*(const edm::ParameterSet&)>
HGCalStage2FilteringWrapperBaseFactory;
typedef edmplugin::PluginFactory<HGCalStage1TruncationWrapperBase*(const edm::ParameterSet&)>
HGCalStage1TruncationWrapperBaseFactory;
typedef edmplugin::PluginFactory<HGCalLayer1TruncationWrapperBase*(const edm::ParameterSet&)>
HGCalLayer1TruncationWrapperBaseFactory;

#endif
7 changes: 2 additions & 5 deletions L1Trigger/L1THGCal/interface/HGCalProcessorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ typedef HGCalProcessorBaseT<edm::Handle<l1t::HGCalTriggerCellBxCollection>,
l1t::HGCalTriggerSumsBxCollection,
l1t::HGCalConcentratorDataBxCollection>>
HGCalConcentratorProcessorBase;
typedef HGCalProcessorBaseT<edm::Handle<l1t::HGCalTriggerCellBxCollection>, l1t::HGCalClusterBxCollection>
HGCalBackendLayer1ProcessorBase;
typedef HGCalProcessorBaseT<std::pair<uint32_t, std::vector<edm::Ptr<l1t::HGCalTriggerCell>>>,
std::vector<edm::Ptr<l1t::HGCalTriggerCell>>>
HGCalBackendStage1ProcessorBase;
l1t::HGCalClusterBxCollection>
HGCalBackendLayer1ProcessorBase;
typedef HGCalProcessorBaseT<edm::Handle<l1t::HGCalClusterBxCollection>,
std::pair<l1t::HGCalMulticlusterBxCollection, l1t::HGCalClusterBxCollection>>
HGCalBackendLayer2ProcessorBase;
Expand All @@ -40,7 +38,6 @@ typedef HGCalProcessorBaseT<
typedef edmplugin::PluginFactory<HGCalVFEProcessorBase*(const edm::ParameterSet&)> HGCalVFEProcessorBaseFactory;
typedef edmplugin::PluginFactory<HGCalConcentratorProcessorBase*(const edm::ParameterSet&)> HGCalConcentratorFactory;
typedef edmplugin::PluginFactory<HGCalBackendLayer1ProcessorBase*(const edm::ParameterSet&)> HGCalBackendLayer1Factory;
typedef edmplugin::PluginFactory<HGCalBackendStage1ProcessorBase*(const edm::ParameterSet&)> HGCalBackendStage1Factory;
typedef edmplugin::PluginFactory<HGCalBackendLayer2ProcessorBase*(const edm::ParameterSet&)> HGCalBackendLayer2Factory;
typedef edmplugin::PluginFactory<HGCalTowerMapProcessorBase*(const edm::ParameterSet&)> HGCalTowerMapFactory;
typedef edmplugin::PluginFactory<HGCalTowerProcessorBase*(const edm::ParameterSet&)> HGCalTowerFactory;
Expand Down
24 changes: 0 additions & 24 deletions L1Trigger/L1THGCal/interface/backend/HGCalBackendLayer1Processor.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<uint32_t, std::vector<edm::Ptr<l1t::HGCalTriggerCell>>>& fpga_id_tcs,
l1t::HGCalClusterBxCollection& clusters) override;

private:
std::unique_ptr<HGCalClusteringDummyImpl> clusteringDummy_;
std::unique_ptr<HGCalLayer1TruncationImpl> truncation_;
};

#endif
Original file line number Diff line number Diff line change
@@ -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<uint32_t, std::vector<edm::Ptr<l1t::HGCalTriggerCell>>>& fpga_id_tcs,
l1t::HGCalClusterBxCollection& clusters) override;

private:
std::unique_ptr<HGCalClusteringDummyImpl> clusteringDummy_;
std::unique_ptr<HGCalLayer1TruncationWrapperBase> truncationWrapper_;
const edm::ParameterSet conf_;
};

#endif
25 changes: 0 additions & 25 deletions L1Trigger/L1THGCal/interface/backend/HGCalBackendStage1Processor.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#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"
#include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h"

#include <vector>

class HGCalStage1TruncationImpl {
class HGCalLayer1TruncationImpl {
public:
HGCalStage1TruncationImpl(const edm::ParameterSet& conf);
HGCalLayer1TruncationImpl(const edm::ParameterSet& conf);

void setGeometry(const HGCalTriggerGeometryBase* const geom) { triggerTools_.setGeometry(geom); }

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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 <vector>
#include <memory>
Expand All @@ -21,11 +21,11 @@ typedef std::vector<unsigned> 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;
Expand All @@ -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;
Expand Down
Loading

0 comments on commit 4ee39c7

Please sign in to comment.