From 3c38256b87e234f873b88e6b20b004cfa3842a7a Mon Sep 17 00:00:00 2001 From: Giovanni Date: Wed, 23 Aug 2023 16:41:39 +0200 Subject: [PATCH 1/6] FillDescriptions part 1 (not yet removing the defaults from the cff files) --- .../L1TCorrelatorLayer1PatternFileWriter.h | 14 +++ .../interface/egamma/pfeginput_ref.h | 5 +- .../interface/egamma/pftkegalgo_ref.h | 7 +- .../egamma/pftkegsorter_barrel_ref.h | 4 + .../interface/egamma/pftkegsorter_ref.h | 7 ++ .../interface/l1-converters/hgcalinput_ref.h | 6 +- .../l1-converters/muonGmtToL1ct_ref.h | 7 +- .../interface/l1-converters/tkinput_ref.h | 5 +- .../interface/pf/pfalgo2hgc_ref.h | 5 +- .../interface/pf/pfalgo3_ref.h | 5 +- .../interface/pf/pfalgo_common_ref.h | 4 +- .../interface/pf/pfalgo_dummy_ref.h | 5 +- .../interface/puppi/linpuppi_ref.h | 5 +- ...buffered_folded_multififo_regionizer_ref.h | 2 + .../regionizer/multififo_regionizer_ref.h | 6 +- .../regionizer/regionizer_base_ref.h | 5 +- .../interface/regionizer/tdr_regionizer_ref.h | 5 +- .../plugins/L1TCorrelatorLayer1Producer.cc | 111 ++++++++++++++++-- .../plugins/L1TEGMultiMerger.cc | 14 +++ .../plugins/L1TPFCandMultiMerger.cc | 27 +++++ .../python/l1ctLayer1_cff.py | 3 - .../python/l1ctLayer1_patternWriters_cff.py | 35 +++--- .../L1TCorrelatorLayer1PatternFileWriter.cc | 84 ++++++++++++- .../src/egamma/pfeginput_ref.cpp | 11 +- .../src/egamma/pftkegalgo_ref.cpp | 67 +++++++++++ .../src/l1-converters/hgcalinputt_ref.cpp | 7 ++ .../src/l1-converters/muonGmtToL1ct_ref.cpp | 8 ++ .../src/l1-converters/tkinput_ref.cpp | 48 ++++++++ .../src/pf/pfalgo2hgc_ref.cpp | 16 +++ .../src/pf/pfalgo3_ref.cpp | 22 ++++ .../src/pf/pfalgo_common_ref.cpp | 9 ++ .../src/pf/pfalgo_dummy_ref.cpp | 9 ++ .../src/puppi/linpuppi_ref.cpp | 36 +++++- ...ffered_folded_multififo_regionizer_ref.cpp | 18 ++- .../regionizer/multififo_regionizer_ref.cpp | 38 +++++- .../src/regionizer/regionizer_base_ref.cpp | 11 +- .../src/regionizer/tdr_regionizer_ref.cpp | 16 ++- .../test/make_l1ct_binaryFiles_cfg.py | 9 +- 38 files changed, 636 insertions(+), 60 deletions(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/L1TCorrelatorLayer1PatternFileWriter.h b/L1Trigger/Phase2L1ParticleFlow/interface/L1TCorrelatorLayer1PatternFileWriter.h index dc786b910eecd..0a10bc16d4866 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/L1TCorrelatorLayer1PatternFileWriter.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/L1TCorrelatorLayer1PatternFileWriter.h @@ -2,6 +2,7 @@ #define L1Trigger_Phase2L1ParticleFlow_L1TCorrelatorLayer1PatternFileWriter_h #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "L1Trigger/DemonstratorTools/interface/BoardDataWriter.h" #include "L1Trigger/DemonstratorTools/interface/utilities.h" @@ -12,6 +13,8 @@ class L1TCorrelatorLayer1PatternFileWriter { L1TCorrelatorLayer1PatternFileWriter(const edm::ParameterSet& iConfig, const l1ct::Event& eventTemplate); ~L1TCorrelatorLayer1PatternFileWriter(); + static edm::ParameterSetDescription getParameterSetDescription(); + void write(const l1ct::Event& event); void flush(); @@ -51,19 +54,30 @@ class L1TCorrelatorLayer1PatternFileWriter { static Partition parsePartition(const std::string& partition); + static std::unique_ptr describeTF(); + static std::unique_ptr describeGCT(); + static std::unique_ptr describeHGC(); + static std::unique_ptr describeGMT(); + static std::unique_ptr describeGTT(); + static std::unique_ptr describePuppi(); + static std::unique_ptr describeEG(); + void configTimeSlices(const edm::ParameterSet& iConfig, const std::string& prefix, unsigned int nSectors, unsigned int nTimeSlices, unsigned int linksFactor); + static std::unique_ptr describeTimeSlices(const std::string& prefix); void configSectors(const edm::ParameterSet& iConfig, const std::string& prefix, unsigned int nSectors, unsigned int linksFactor); + static std::unique_ptr describeSectors(const std::string& prefix); void configLinks(const edm::ParameterSet& iConfig, const std::string& prefix, unsigned int linksFactor, unsigned int offset); + static std::unique_ptr describeLinks(const std::string& prefix); void writeTF(const l1ct::Event& event, l1t::demo::EventData& out); void writeBarrelGCT(const l1ct::Event& event, l1t::demo::EventData& out); diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pfeginput_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pfeginput_ref.h index 599eae5484522..88a071c1223f4 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pfeginput_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pfeginput_ref.h @@ -7,7 +7,8 @@ namespace edm { class ParameterSet; -} + class ParameterSetDescription; +} // namespace edm namespace l1ct { @@ -16,6 +17,8 @@ namespace l1ct { EGInputSelectorEmuConfig(unsigned int emIdMask, unsigned int nHADCALO_IN, unsigned int nEMCALO_OUT, int debug) : idMask(emIdMask), nHADCALO_IN(nHADCALO_IN), nEMCALO_OUT(nEMCALO_OUT), debug(debug) {} + static edm::ParameterSetDescription getParameterSetDescription(); + emid_t idMask; unsigned int nHADCALO_IN; unsigned int nEMCALO_OUT; diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pftkegalgo_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pftkegalgo_ref.h index 560325e46cb0c..58ddfccec14b4 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pftkegalgo_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pftkegalgo_ref.h @@ -9,7 +9,8 @@ namespace edm { class ParameterSet; -} + class ParameterSetDescription; +} // namespace edm namespace l1ct { @@ -47,6 +48,7 @@ namespace l1ct { ap_int dZ; int dRMin2; int dRMax2; + static edm::ParameterSetDescription getParameterSetDescription(); }; IsoParameters tkIsoParams_tkEle; @@ -65,6 +67,7 @@ namespace l1ct { const double bdtScore_loose_wp; // XGBOOST score const double bdtScore_tight_wp; // XGBOOST score const std::string conifer_model; + static edm::ParameterSetDescription getParameterSetDescription(); }; CompIDParameters compIDparams; @@ -131,6 +134,8 @@ namespace l1ct { hwIsoTypeTkEm(hwIsoTypeTkEm), compIDparams(compIDparams), debug(debug) {} + + static edm::ParameterSetDescription getParameterSetDescription(); }; class PFTkEGAlgoEmulator { diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pftkegsorter_barrel_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pftkegsorter_barrel_ref.h index 2895848dd11fe..624b3851fa36d 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pftkegsorter_barrel_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pftkegsorter_barrel_ref.h @@ -18,6 +18,10 @@ namespace l1ct { PFTkEGSorterBarrelEmulator(const edm::ParameterSet& iConfig) : PFTkEGSorterEmulator(iConfig.getParameter("nObjToSort"), iConfig.getParameter("nObjSorted")) {} + + static edm::ParameterSetDescription getParameterSetDescription() { + return PFTkEGSorterEmulator::getParameterSetDescription(); + } #endif ~PFTkEGSorterBarrelEmulator() override {} diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pftkegsorter_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pftkegsorter_ref.h index fffb556552b0d..9e1c7b364514c 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pftkegsorter_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/egamma/pftkegsorter_ref.h @@ -9,6 +9,7 @@ #ifdef CMSSW_GIT_HASH #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #endif namespace l1ct { @@ -22,6 +23,12 @@ namespace l1ct { : PFTkEGSorterEmulator(iConfig.getParameter("nObjToSort"), iConfig.getParameter("nObjSorted")) {} + static edm::ParameterSetDescription getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("nObjToSort"); + description.add("nObjSorted"); + return description; + } #endif virtual ~PFTkEGSorterEmulator() {} diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/hgcalinput_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/hgcalinput_ref.h index 5fd80ba3954d7..c7c82f0b4c8ae 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/hgcalinput_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/hgcalinput_ref.h @@ -5,7 +5,8 @@ namespace edm { class ParameterSet; -} + class ParameterSetDescription; +} // namespace edm namespace l1ct { class HgcalClusterDecoderEmulator { @@ -16,6 +17,9 @@ namespace l1ct { HgcalClusterDecoderEmulator(const edm::ParameterSet &pset); ~HgcalClusterDecoderEmulator(); + + static edm::ParameterSetDescription getParameterSetDescription(); + l1ct::HadCaloObjEmu decode(const ap_uint<256> &in) const; }; } // namespace l1ct diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/muonGmtToL1ct_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/muonGmtToL1ct_ref.h index 4d1705d1b1778..aad7976a7b720 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/muonGmtToL1ct_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/muonGmtToL1ct_ref.h @@ -5,14 +5,19 @@ namespace edm { class ParameterSet; -} + class ParameterSetDescription; +} // namespace edm namespace l1ct { class GMTMuonDecoderEmulator { public: GMTMuonDecoderEmulator(float z0Scale, float dxyScale); GMTMuonDecoderEmulator(const edm::ParameterSet &iConfig); + ~GMTMuonDecoderEmulator(); + + static edm::ParameterSetDescription getParameterSetDescription(); + l1ct::MuObjEmu decode(const ap_uint<64> &in) const; protected: diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/tkinput_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/tkinput_ref.h index 2545a6dabc243..98d592f17e7f0 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/tkinput_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/l1-converters/tkinput_ref.h @@ -7,7 +7,8 @@ namespace edm { class ParameterSet; -} + class ParameterSetDescription; +} // namespace edm namespace l1ct { class TrackInputEmulator { @@ -27,6 +28,8 @@ namespace l1ct { bool bitwise = true, bool slim = true); + static edm::ParameterSetDescription getParameterSetDescription(); + std::pair decodeTrack(ap_uint<96> tkword, const l1ct::PFRegionEmu §or) const { return decodeTrack(tkword, sector, bitwise_, slim_); } diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo2hgc_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo2hgc_ref.h index ee9dbc93206a7..fbd53dabd8455 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo2hgc_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo2hgc_ref.h @@ -5,7 +5,8 @@ namespace edm { class ParameterSet; -} + class ParameterSetDescription; +} // namespace edm namespace l1ct { @@ -27,6 +28,8 @@ namespace l1ct { ~PFAlgo2HGCEmulator() override {} + static edm::ParameterSetDescription getParameterSetDescription(); + void run(const PFInputRegion& in, OutputRegion& out) const override; /// moves all objects from out.pfphoton to the beginning of out.pfneutral: nothing to do for this algo diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo3_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo3_ref.h index 85a1a01db572d..aa184887a1d0b 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo3_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo3_ref.h @@ -5,7 +5,8 @@ namespace edm { class ParameterSet; -} + class ParameterSetDescription; +} // namespace edm namespace l1ct { @@ -37,6 +38,8 @@ namespace l1ct { ~PFAlgo3Emulator() override {} + static edm::ParameterSetDescription getParameterSetDescription(); + void run(const PFInputRegion& in, OutputRegion& out) const override; void toFirmware(const PFInputRegion& in, diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo_common_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo_common_ref.h index eacb4ee7ff178..dcb63d3ca289f 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo_common_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo_common_ref.h @@ -9,7 +9,8 @@ namespace edm { class ParameterSet; -} + class ParameterSetDescription; +} // namespace edm namespace l1ct { @@ -38,6 +39,7 @@ namespace l1ct { void loadPtErrBins( unsigned int nbins, const float absetas[], const float scales[], const float offs[], bool verbose = false); void loadPtErrBins(const edm::ParameterSet& iConfig); + static void addCaloResolutionParameterSetDescription(edm::ParameterSetDescription& to); void setDebug(bool debug = true) { debug_ = debug; } diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo_dummy_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo_dummy_ref.h index 8eec4d19ac22b..938c44182804d 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo_dummy_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo_dummy_ref.h @@ -5,7 +5,8 @@ namespace edm { class ParameterSet; -} + class ParameterSetDescription; +} // namespace edm namespace l1ct { @@ -18,6 +19,8 @@ namespace l1ct { ~PFAlgoDummyEmulator() override {} + static edm::ParameterSetDescription getParameterSetDescription(); + void run(const PFInputRegion& in, OutputRegion& out) const override; /// moves all objects from out.pfphoton to the beginning of out.pfneutral: nothing to do for this algo diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/puppi/linpuppi_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/puppi/linpuppi_ref.h index dea624afd1a5a..4591f5ef3dc4f 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/puppi/linpuppi_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/puppi/linpuppi_ref.h @@ -7,7 +7,8 @@ namespace edm { class ParameterSet; -} + class ParameterSetDescription; +} // namespace edm namespace l1ct { @@ -138,6 +139,8 @@ namespace l1ct { LinPuppiEmulator(const edm::ParameterSet &iConfig); + static edm::ParameterSetDescription getParameterSetDescription(); + // charged void linpuppi_chs_ref(const PFRegionEmu ®ion, const PVObjEmu &pv, diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/buffered_folded_multififo_regionizer_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/buffered_folded_multififo_regionizer_ref.h index 596838f963715..cf30b63f10978 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/buffered_folded_multififo_regionizer_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/buffered_folded_multififo_regionizer_ref.h @@ -57,6 +57,8 @@ namespace l1ct { ~BufferedFoldedMultififoRegionizerEmulator() override; + static edm::ParameterSetDescription getParameterSetDescription(); + void initSectorsAndRegions(const RegionizerDecodedInputs& in, const std::vector& out) override; void run(const RegionizerDecodedInputs& in, std::vector& out) override; diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_ref.h index c62dd73eb49e1..554302a38ab54 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_ref.h @@ -8,7 +8,8 @@ namespace edm { class ParameterSet; -} + class ParameterSetDescription; +} // namespace edm namespace l1ct { class EGInputSelectorEmulator; @@ -50,6 +51,9 @@ namespace l1ct { ~MultififoRegionizerEmulator() override; + static edm::ParameterSetDescription getParameterSetDescription(); + static edm::ParameterSetDescription getParameterSetDescriptionBarrel(); + static BarrelSetup parseBarrelSetup(const std::string& setup); void setEgInterceptMode(bool afterFifo, const l1ct::EGInputSelectorEmuConfig& interceptorConfig); diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/regionizer_base_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/regionizer_base_ref.h index 5ae375d54f819..1f1550538e4d1 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/regionizer_base_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/regionizer_base_ref.h @@ -5,7 +5,8 @@ namespace edm { class ParameterSet; -} + class ParameterSetDescription; +} // namespace edm namespace l1ct { @@ -16,6 +17,8 @@ namespace l1ct { virtual ~RegionizerEmulator(); + static edm::ParameterSetDescription getParameterSetDescription(); + void setDebug(bool debug = true) { debug_ = debug; } virtual void initSectorsAndRegions(const RegionizerDecodedInputs& in, const std::vector& out) {} diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/tdr_regionizer_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/tdr_regionizer_ref.h index f486902602ac9..3ee4950c81e01 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/tdr_regionizer_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/tdr_regionizer_ref.h @@ -6,7 +6,8 @@ namespace edm { class ParameterSet; -} + class ParameterSetDescription; +} // namespace edm namespace l1ct { class TDRRegionizerEmulator : public RegionizerEmulator { @@ -24,6 +25,8 @@ namespace l1ct { ~TDRRegionizerEmulator() override; + static edm::ParameterSetDescription getParameterSetDescription(); + void initSectorsAndRegions(const RegionizerDecodedInputs& in, const std::vector& out) override; void run(const RegionizerDecodedInputs& in, std::vector& out) override; diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc index 6d3779404c679..4aa1c4289d6fa 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc @@ -10,6 +10,9 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/FileInPath.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/ParameterSet/interface/allowedValues.h" #include "DataFormats/Common/interface/View.h" #include "DataFormats/Common/interface/RefToPtr.h" @@ -48,6 +51,8 @@ class L1TCorrelatorLayer1Producer : public edm::stream::EDProducer<> { explicit L1TCorrelatorLayer1Producer(const edm::ParameterSet &); ~L1TCorrelatorLayer1Producer() override; + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + private: edm::ParameterSet config_; @@ -80,7 +85,7 @@ class L1TCorrelatorLayer1Producer : public edm::stream::EDProducer<> { const std::string regionDumpName_; bool writeRawHgcalCluster_; std::fstream fRegionDump_; - const std::vector patternWriterConfigs_; + const edm::VParameterSet patternWriterConfigs_; std::vector> patternWriters_; // region of interest debugging @@ -175,6 +180,13 @@ class L1TCorrelatorLayer1Producer : public edm::stream::EDProducer<> { typedef l1ct::OutputRegion::ObjType OutputType; std::unique_ptr> vecOutput(OutputType i, bool usePuppi) const; std::pair totAndMax(const std::vector &perRegion) const; + + // utilities + template + static edm::ParameterDescription getParDesc(const std::string &name) { + return edm::ParameterDescription( + name + "Parameters", T::getParameterSetDescription(), true); + } }; // @@ -194,13 +206,12 @@ L1TCorrelatorLayer1Producer::L1TCorrelatorLayer1Producer(const edm::ParameterSet l1pualgo_(nullptr), l1tkegalgo_(nullptr), l1tkegsorter_(nullptr), - regionDumpName_(iConfig.getUntrackedParameter("dumpFileName", "")), - writeRawHgcalCluster_(iConfig.getUntrackedParameter("writeRawHgcalCluster", false)), - patternWriterConfigs_(iConfig.getUntrackedParameter>( - "patternWriters", std::vector())), - debugEta_(iConfig.getUntrackedParameter("debugEta", 0)), - debugPhi_(iConfig.getUntrackedParameter("debugPhi", 0)), - debugR_(iConfig.getUntrackedParameter("debugR", -1)) { + regionDumpName_(iConfig.getUntrackedParameter("dumpFileName")), + writeRawHgcalCluster_(iConfig.getUntrackedParameter("writeRawHgcalCluster")), + patternWriterConfigs_(iConfig.getUntrackedParameter("patternWriters")), + debugEta_(iConfig.getUntrackedParameter("debugEta")), + debugPhi_(iConfig.getUntrackedParameter("debugPhi")), + debugR_(iConfig.getUntrackedParameter("debugR")) { produces("PF"); produces("Puppi"); produces("PuppiRegional"); @@ -330,6 +341,82 @@ L1TCorrelatorLayer1Producer::L1TCorrelatorLayer1Producer(const edm::ParameterSet L1TCorrelatorLayer1Producer::~L1TCorrelatorLayer1Producer() {} +void L1TCorrelatorLayer1Producer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { + edm::ParameterSetDescription desc; + // Inputs and cuts + desc.add("tracks", edm::InputTag("l1tPFTracksFromL1Tracks")); + desc.add("muons", edm::InputTag("l1tSAMuonsGmt", "promptSAMuons")); + desc.add>("emClusters", std::vector()); + desc.add>("hadClusters", std::vector()); + desc.add("vtxCollection", edm::InputTag("l1tVertexFinderEmulator", "L1VerticesEmulation")); + desc.add("vtxCollectionEmulation", true); + desc.add("emPtCut", 0.0); + desc.add("hadPtCut", 0.0); + desc.add("trkPtCut", 0.0); + desc.add("nVtx"); + // Input conversion + edm::EmptyGroupDescription emptyGroup; + desc.ifValue(edm::ParameterDescription("trackInputConversionAlgo", "Ideal", true), + "Ideal" >> emptyGroup or "Emulator" >> getParDesc("trackInputConversion")); + desc.ifValue(edm::ParameterDescription("muonInputConversionAlgo", "Ideal", true), + "Ideal" >> emptyGroup or "Emulator" >> getParDesc("muonInputConversion")); + desc.ifValue( + edm::ParameterDescription("hgcalInputConversionAlgo", "Ideal", true), + "Ideal" >> emptyGroup or "Emulator" >> getParDesc("hgcalInputConversion")); + // Regionizer + auto idealRegPD = getParDesc("regionizerAlgo"); + auto tdrRegPD = getParDesc("regionizerAlgo"); + auto multififoRegPD = getParDesc("regionizerAlgo"); + auto bfMultififoRegPD = getParDesc("regionizerAlgo"); + auto multififoBarrelRegPD = edm::ParameterDescription( + "regionizerAlgoParameters", l1ct::MultififoRegionizerEmulator::getParameterSetDescriptionBarrel(), true); + desc.ifValue(edm::ParameterDescription("regionizerAlgo", "Ideal", true), + "Ideal" >> idealRegPD or "TDR" >> tdrRegPD or "Multififo" >> multififoRegPD or + "BufferedFoldedMultififo" >> bfMultififoRegPD or "MultififoBarrel" >> multififoBarrelRegPD); + // PF + desc.ifValue(edm::ParameterDescription("pfAlgo", "PFAlgo3", true), + "PFAlgo3" >> getParDesc("pfAlgo") or + "PFAlgo2HGC" >> getParDesc("pfAlgo") or + "PFAlgoDummy" >> getParDesc("pfAlgo")); + // Puppi + desc.ifValue(edm::ParameterDescription("puAlgo", "LinearizedPuppi", true), + "LinearizedPuppi" >> getParDesc("puAlgo")); + // EGamma + desc.add("tkEgAlgoParameters", l1ct::PFTkEGAlgoEmuConfig::getParameterSetDescription()); + // EGamma sort + desc.ifValue(edm::ParameterDescription("tkEgSorterAlgo", "Barrel", true), + "Barrel" >> getParDesc("tkEgSorter") or + "Endcap" >> getParDesc("tkEgSorter")); + // geometry: calo sectors + edm::ParameterSetDescription caloSectorPSD; + caloSectorPSD.add>("etaBoundaries"); + caloSectorPSD.add("phiSlices", 3); + caloSectorPSD.add("phiZero", 0.); + desc.addVPSet("caloSectors", caloSectorPSD); + // geometry: regions + edm::ParameterSetDescription regionPSD; + regionPSD.add>("etaBoundaries"); + regionPSD.add("phiSlices", 9); + regionPSD.add("etaExtra", 0.25); + regionPSD.add("phiExtra", 0.25); + desc.addVPSet("regions", regionPSD); + // geometry: boards + edm::ParameterSetDescription boardPSD; + boardPSD.add>("regions"); + desc.addVPSet("boards", boardPSD); + // dump files + desc.addUntracked("dumpFileName", ""); + desc.addUntracked("writeRawHgcalCluster", false); + // pattern files + desc.addVPSetUntracked( + "patternWriters", L1TCorrelatorLayer1PatternFileWriter::getParameterSetDescription(), edm::VParameterSet()); + // debug + desc.addUntracked("debugEta", 0.); + desc.addUntracked("debugPhi", 0.); + desc.addUntracked("debugR", -1.); + descriptions.add("l1tCorrelatorLayer1", desc); +} + void L1TCorrelatorLayer1Producer::beginStream(edm::StreamID id) { if (!regionDumpName_.empty()) { if (id == 0) { @@ -453,7 +540,7 @@ void L1TCorrelatorLayer1Producer::produce(edm::Event &iEvent, const edm::EventSe hwpv.hwZ0 = l1ct::Scales::makeZ0(pvwd.z0()); event_.pvs.push_back(hwpv); event_.pvs_emu.push_back(pvwd.vertexWord()); - //Do a quick histogram vertexing to get multiple vertices (Hack for the taus) + //get additional vertices if requested if (nVtx_ > 1) { std::stable_sort(ptsums.begin(), ptsums.end(), [](const auto &a, const auto &b) { return a.first > b.first; }); for (int i0 = 0; i0 < std::min(int(ptsums.size()), int(nVtx_)); i0++) { @@ -567,7 +654,7 @@ void L1TCorrelatorLayer1Producer::initSectorsAndRegions(const edm::ParameterSet event_.decoded.hadcalo.clear(); event_.raw.hgcalcluster.clear(); - for (const edm::ParameterSet &preg : iConfig.getParameter>("caloSectors")) { + for (const edm::ParameterSet &preg : iConfig.getParameter("caloSectors")) { std::vector etaBoundaries = preg.getParameter>("etaBoundaries"); if (!std::is_sorted(etaBoundaries.begin(), etaBoundaries.end())) throw cms::Exception("Configuration", "caloSectors.etaBoundaries not sorted\n"); @@ -593,7 +680,7 @@ void L1TCorrelatorLayer1Producer::initSectorsAndRegions(const edm::ParameterSet event_.raw.muon.region = l1ct::PFRegionEmu(0., 0.); // centered at (0,0) event_.pfinputs.clear(); - for (const edm::ParameterSet &preg : iConfig.getParameter>("regions")) { + for (const edm::ParameterSet &preg : iConfig.getParameter("regions")) { std::vector etaBoundaries = preg.getParameter>("etaBoundaries"); if (!std::is_sorted(etaBoundaries.begin(), etaBoundaries.end())) throw cms::Exception("Configuration", "regions.etaBoundaries not sorted\n"); @@ -611,7 +698,7 @@ void L1TCorrelatorLayer1Producer::initSectorsAndRegions(const edm::ParameterSet } event_.board_out.clear(); - const std::vector &board_params = iConfig.getParameter>("boards"); + const edm::VParameterSet &board_params = iConfig.getParameter("boards"); event_.board_out.resize(board_params.size()); for (unsigned int bidx = 0; bidx < board_params.size(); bidx++) { event_.board_out[bidx].region_index = board_params[bidx].getParameter>("regions"); diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TEGMultiMerger.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TEGMultiMerger.cc index 44a83bf22db7a..fd91a0f7bdda6 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TEGMultiMerger.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TEGMultiMerger.cc @@ -7,6 +7,8 @@ #include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/Utilities/interface/transform.h" #include "FWCore/Utilities/interface/InputTag.h" #include @@ -16,6 +18,7 @@ class L1TEGMultiMerger : public edm::global::EDProducer<> { public: explicit L1TEGMultiMerger(const edm::ParameterSet&); ~L1TEGMultiMerger() override; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; @@ -120,5 +123,16 @@ void L1TEGMultiMerger::produce(edm::StreamID, edm::Event& iEvent, const edm::Eve emMerger.produce(iEvent, refmapper); } +void L1TEGMultiMerger::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription psetDesc; + psetDesc.add("instance"); + psetDesc.add>("pfProducers"); + edm::ParameterSetDescription desc; + desc.addVPSet("tkElectrons", psetDesc); + desc.addVPSet("tkEms", psetDesc); + desc.addVPSet("tkEgs", psetDesc); + descriptions.addWithDefaultLabel(desc); +} + #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(L1TEGMultiMerger); diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TPFCandMultiMerger.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TPFCandMultiMerger.cc index 61e629b23097e..6644cb851c40a 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TPFCandMultiMerger.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TPFCandMultiMerger.cc @@ -3,6 +3,8 @@ #include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/Utilities/interface/transform.h" #include "FWCore/Utilities/interface/InputTag.h" #include "DataFormats/Common/interface/CloneTrait.h" @@ -12,6 +14,7 @@ class L1TPFCandMultiMerger : public edm::global::EDProducer<> { public: explicit L1TPFCandMultiMerger(const edm::ParameterSet&); ~L1TPFCandMultiMerger() override; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; @@ -91,5 +94,29 @@ void L1TPFCandMultiMerger::produce(edm::StreamID, edm::Event& iEvent, const edm: } } +void L1TPFCandMultiMerger::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // l1tLayer1 + edm::ParameterSetDescription desc; + desc.add>("pfProducers", + { + edm::InputTag("l1tLayer1Barrel"), + edm::InputTag("l1tLayer1HGCal"), + edm::InputTag("l1tLayer1HGCalNoTK"), + edm::InputTag("l1tLayer1HF"), + }); + desc.add>("labelsToMerge", + { + "PF", + "Puppi", + "Calo", + "TK", + }); + desc.add>("regionalLabelsToMerge", + { + "Puppi", + }); + descriptions.addWithDefaultLabel(desc); +} + #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(L1TPFCandMultiMerger); diff --git a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_cff.py b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_cff.py index 06962889d01ed..7d06f3d1d4fb1 100644 --- a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_cff.py +++ b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_cff.py @@ -414,8 +414,6 @@ l1tLayer1HF = cms.EDProducer("L1TCorrelatorLayer1Producer", tracks = cms.InputTag(''), muons = cms.InputTag('l1tSAMuonsGmt','promptSAMuons'), - useStandaloneMuons = cms.bool(False), - useTrackerMuons = cms.bool(False), emClusters = cms.VInputTag(), hadClusters = cms.VInputTag(cms.InputTag('l1tPFClustersFromCombinedCaloHF:calibrated')), vtxCollection = cms.InputTag("l1tVertexFinderEmulator","L1VerticesEmulation"), @@ -425,7 +423,6 @@ hadPtCut = cms.double(15.0), trkPtCut = cms.double(2.0), muonInputConversionAlgo = cms.string("Ideal"), - muonInputConversionParameters = muonInputConversionParameters.clone(), hgcalInputConversionAlgo = cms.string("Ideal"), regionizerAlgo = cms.string("Ideal"), pfAlgo = cms.string("PFAlgoDummy"), diff --git a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py index 9bd1434d9cd3d..b71e76d8b0c51 100644 --- a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py +++ b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_patternWriters_cff.py @@ -20,6 +20,13 @@ maxLinesPerInputFile = cms.uint32(1024), maxLinesPerOutputFile = cms.uint32(1024), eventsPerFile = cms.uint32(_eventsPerFile), + tfTimeSlices = cms.VPSet(), + gctSectors = cms.VPSet(), + gmtTimeSlices = cms.VPSet(), + gmtNumberOfMuons = cms.uint32(12), + gttLink = cms.int32(-1), + gttLatency = cms.uint32(156+10), + gttNumberOfPVs = cms.uint32(_gttNumberOfPVs), ) ## Barrel (54) split in 3 phi slices barrelWriterOutputOnlyPhiConfigs = [ @@ -37,11 +44,6 @@ gctLinksEcal = cms.vint32(-1), ) for s in range(3)]), gmtTimeSlices = cms.VPSet(*[cms.PSet(gmtLink = cms.int32(4*17+t)) for t in range(3)]), - gmtNumberOfMuons = cms.uint32(12), - gttLatency = cms.uint32(156+10), - gttNumberOfPVs = cms.uint32(_gttNumberOfPVs), - inputFileName = cms.string("l1BarrelPhi1Serenity-inputs-vu9p"), - outputFileName = cms.string("l1BarrelPhi1Serenity-outputs") ) barrelSerenityVU9PPhi1Config = barrelSerenityPhi1Config.clone( gttLink = cms.int32(4*28+3), @@ -85,7 +87,7 @@ eventsPerFile = cms.uint32(_eventsPerFile), tfTimeSlices = cms.VPSet(*[cms.PSet(tfSectors = cms.VPSet()) for i in range(3)]), hgcTimeSlices = cms.VPSet(*[cms.PSet(hgcSectors = cms.VPSet()) for i in range(3)]), - gmtTimeSlices = cms.VPSet(cms.PSet(),cms.PSet(),cms.PSet()), + gmtTimeSlices = cms.VPSet(*[cms.PSet(gmtLink = cms.int32(-1)) for i in range(3)]), gmtNumberOfMuons = cms.uint32(12), gttLink = cms.int32(-1), gttLatency = cms.uint32(_gttLatency), @@ -174,19 +176,18 @@ maxLinesPerInputFile = cms.uint32(1024), maxLinesPerOutputFile = cms.uint32(1024), eventsPerFile = cms.uint32(_eventsPerFile), + hgcTimeSlices = cms.VPSet(*[cms.PSet(hgcSectors = cms.VPSet()) for i in range(3)]), + gmtTimeSlices = cms.VPSet(*[cms.PSet(gmtLink = cms.int32(-1)) for i in range(3)]), + gmtNumberOfMuons = cms.uint32(12), + #gttLink = cms.int32(-1), + #gttLatency = cms.uint32(_gttLatency), + #gttNumberOfPVs = cms.uint32(_gttNumberOfPVs), ) hgcalNoTKOutputWriterConfig = _hgcalNoTKWriterConfig.clone( outputLinksPuppi = cms.vuint32(*range(4)), outputFileName = cms.string("l1HGCalNoTK-outputs") ) -hgcalNoTKVU13PWriterConfig = _hgcalNoTKWriterConfig.clone( - hgcTimeSlices = cms.VPSet(*[cms.PSet(hgcSectors = cms.VPSet()) for i in range(3)]), - gmtTimeSlices = cms.VPSet(*[cms.PSet(gmtLink = cms.int32(-1)) for i in range(3)]), - gmtNumberOfMuons = cms.uint32(12), - gttLink = cms.int32(-1), - gttLatency = cms.uint32(_gttLatency), - gttNumberOfPVs = cms.uint32(_gttNumberOfPVs), -) +hgcalNoTKVU13PWriterConfig = _hgcalNoTKWriterConfig.clone() for t in range(3): for isec in range(6): q0 = 3*isec + 6 @@ -205,7 +206,7 @@ tfTimeSlices = None, tfSectors = cms.VPSet(*[cms.PSet(tfLink = cms.int32(-1)) for i in range(18)]), hgcTimeSlices = None, - hgcSectors = cms.VPSet(*[cms.PSet() for i in range(6)]), + hgcSectors = cms.VPSet(*[cms.PSet(hgcLinks = cms.vint32()) for i in range(6)]), gmtTimeSlices = None, gmtLink = cms.int32(4*27+0), gttLink = 4*27+3, @@ -232,8 +233,8 @@ hgcalWriterVU13PTM18WriterConfig.tfSectors[isec].tfLink = (ilink if ilink < 12 else (4*30+(ilink-12))) for iphi in range(3): isec, ilink = 3*ie+iphi, 2*iphi+ie - hgcalWriterVU9PTM18WriterConfig.hgcSectors[isec].hgcLinks = cms.vint32(*range(4*(12+ilink),4*(12+ilink)+4)) - hgcalWriterVU13PTM18WriterConfig.hgcSectors[isec].hgcLinks = cms.vint32(*range(4*(13+ilink),4*(13+ilink)+4)) + hgcalWriterVU9PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(12+ilink),4*(12+ilink)+4) + hgcalWriterVU13PTM18WriterConfig.hgcSectors[isec].hgcLinks += range(4*(13+ilink),4*(13+ilink)+4) hgcalTM18WriterConfigs = [ hgcalWriterOutputTM18WriterConfig, diff --git a/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.cc b/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.cc index a8176b96846d5..e39f86c267216 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.cc +++ b/L1Trigger/Phase2L1ParticleFlow/src/L1TCorrelatorLayer1PatternFileWriter.cc @@ -1,15 +1,14 @@ #include "L1Trigger/Phase2L1ParticleFlow/interface/L1TCorrelatorLayer1PatternFileWriter.h" #include "FWCore/Utilities/interface/Exception.h" +#include "FWCore/ParameterSet/interface/allowedValues.h" #include L1TCorrelatorLayer1PatternFileWriter::L1TCorrelatorLayer1PatternFileWriter(const edm::ParameterSet& iConfig, const l1ct::Event& eventTemplate) : partition_(parsePartition(iConfig.getParameter("partition"))), tmuxFactor_(iConfig.getParameter("tmuxFactor")), - writeInputs_(iConfig.existsAs("inputFileName") && - !iConfig.getParameter("inputFileName").empty()), - writeOutputs_(iConfig.existsAs("outputFileName") && - !iConfig.getParameter("outputFileName").empty()), + writeInputs_(!iConfig.getParameter("inputFileName").empty()), + writeOutputs_(!iConfig.getParameter("outputFileName").empty()), tfTimeslices_(std::max(1u, tfTmuxFactor_ / tmuxFactor_)), hgcTimeslices_(std::max(1u, hgcTmuxFactor_ / tmuxFactor_)), gctTimeslices_(std::max(1u, gctTmuxFactor_ / tmuxFactor_)), @@ -113,6 +112,60 @@ L1TCorrelatorLayer1PatternFileWriter::L1TCorrelatorLayer1PatternFileWriter(const L1TCorrelatorLayer1PatternFileWriter::~L1TCorrelatorLayer1PatternFileWriter() {} +edm::ParameterSetDescription L1TCorrelatorLayer1PatternFileWriter::getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("inputFileName", ""); + description.add("inputFileExtension", "txt.gz"); + description.add("maxLinesPerInputFile", 1024u); + description.add("nInputFramesPerBX", 9u); + description.add("outputFileName", ""); + description.add("outputFileExtension", "txt.gz"); + description.add("maxLinesPerOutputFile", 1024u); + description.add("nOutputFramesPerBX", 9u); + description.add("tmuxFactor", 6u); + description.add("eventsPerFile", 12u); + description.add("fileFormat"); + + description.ifValue(edm::ParameterDescription("partition", "Barrel", true), + "Barrel" >> (describeTF() and describeGCT() and describeGTT() and describeGMT() and + describePuppi() and describeEG()) or + "HGCal" >> (describeTF() and describeHGC() and describeGTT() and describeGMT() and + describePuppi() and describeEG()) or + "HGCalNoTk" >> (describeHGC() and describeGMT() and describePuppi()) or + "HF" >> (describePuppi())); + return description; +} + +std::unique_ptr L1TCorrelatorLayer1PatternFileWriter::describeTF() { + return describeTimeSlices("tf"); +} +std::unique_ptr L1TCorrelatorLayer1PatternFileWriter::describeGCT() { + edm::ParameterSetDescription gctSectorPSD; + gctSectorPSD.add>("gctLinksEcal"); + gctSectorPSD.add>("gctLinksHad"); + return std::make_unique>>("gctSectors", gctSectorPSD, true); +} +std::unique_ptr L1TCorrelatorLayer1PatternFileWriter::describeHGC() { + return describeTimeSlices("hgc"); +} +std::unique_ptr L1TCorrelatorLayer1PatternFileWriter::describeGMT() { + return describeTimeSlices("gmt") and edm::ParameterDescription("gmtNumberOfMuons", 12, true); +} +std::unique_ptr L1TCorrelatorLayer1PatternFileWriter::describeGTT() { + return describeTimeSlices("gtt") and + edm::ParameterDescription("gttLatency", 162, true) and // minimal latency is 18 BX + edm::ParameterDescription("gttNumberOfPVs", 10, true); +} +std::unique_ptr L1TCorrelatorLayer1PatternFileWriter::describePuppi() { + return edm::ParameterDescription>("outputRegions", std::vector(), true) and + edm::ParameterDescription>("outputLinksPuppi", std::vector(), true); +} +std::unique_ptr L1TCorrelatorLayer1PatternFileWriter::describeEG() { + return edm::ParameterDescription("outputLinkEgamma", -1, true) and + edm::ParameterDescription("nEgammaObjectsOut", 16, true) and + edm::ParameterDescription("outputBoard", -1, true); +} + void L1TCorrelatorLayer1PatternFileWriter::write(const l1ct::Event& event) { if (writeInputs_) { l1t::demo::EventData inputs; @@ -182,6 +235,14 @@ void L1TCorrelatorLayer1PatternFileWriter::configTimeSlices(const edm::Parameter } } +std::unique_ptr L1TCorrelatorLayer1PatternFileWriter::describeTimeSlices( + const std::string& prefix) { + edm::ParameterSetDescription timeslicesPSD; + timeslicesPSD.addNode(describeSectors(prefix)); + return edm::ParameterDescription>(prefix + "TimeSlices", timeslicesPSD, true) xor + describeSectors(prefix); +} + void L1TCorrelatorLayer1PatternFileWriter::configSectors(const edm::ParameterSet& iConfig, const std::string& prefix, unsigned int nSectors, @@ -198,6 +259,15 @@ void L1TCorrelatorLayer1PatternFileWriter::configSectors(const edm::ParameterSet configLinks(iConfig, prefix, linksFactor, 0); } } + +std::unique_ptr L1TCorrelatorLayer1PatternFileWriter::describeSectors( + const std::string& prefix) { + edm::ParameterSetDescription sectorsPSD; + sectorsPSD.addNode(describeLinks(prefix)); + return edm::ParameterDescription>(prefix + "Sectors", sectorsPSD, true) xor + describeLinks(prefix); +} + void L1TCorrelatorLayer1PatternFileWriter::configLinks(const edm::ParameterSet& iConfig, const std::string& prefix, unsigned int linksFactor, @@ -220,6 +290,12 @@ void L1TCorrelatorLayer1PatternFileWriter::configLinks(const edm::ParameterSet& } } +std::unique_ptr L1TCorrelatorLayer1PatternFileWriter::describeLinks( + const std::string& prefix) { + return edm::ParameterDescription(prefix + "Link", true) xor + edm::ParameterDescription>(prefix + "Links", true); +} + void L1TCorrelatorLayer1PatternFileWriter::writeTF(const l1ct::Event& event, l1t::demo::EventData& out) { for (unsigned int iS = 0, nS = event.raw.track.size(); iS < nS; ++iS) { l1t::demo::LinkId key{"tf", iS}; diff --git a/L1Trigger/Phase2L1ParticleFlow/src/egamma/pfeginput_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/egamma/pfeginput_ref.cpp index 560e0eb96df7f..b8289c959f743 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/egamma/pfeginput_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/egamma/pfeginput_ref.cpp @@ -4,13 +4,22 @@ using namespace l1ct; #ifdef CMSSW_GIT_HASH #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" l1ct::EGInputSelectorEmuConfig::EGInputSelectorEmuConfig(const edm::ParameterSet &pset) : idMask(pset.getParameter("emIDMask")), nHADCALO_IN(pset.getParameter("nHADCALO_IN")), nEMCALO_OUT(pset.getParameter("nEMCALO_OUT")), - debug(pset.getUntrackedParameter("debug", 0)) {} + debug(pset.getUntrackedParameter("debug")) {} +edm::ParameterSetDescription l1ct::EGInputSelectorEmuConfig::getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("emIDMask", 30); + description.add("nHADCALO_IN"); + description.add("nEMCALO_OUT"); + description.addUntracked("debug", 0); + return description; +} #endif void EGInputSelectorEmulator::toFirmware(const PFInputRegion &in, HadCaloObj hadcalo[/*nCALO*/]) const { diff --git a/L1Trigger/Phase2L1ParticleFlow/src/egamma/pftkegalgo_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/egamma/pftkegalgo_ref.cpp index da9baff109831..097ec687420d7 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/egamma/pftkegalgo_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/egamma/pftkegalgo_ref.cpp @@ -13,6 +13,7 @@ using namespace l1ct; #ifdef CMSSW_GIT_HASH #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" l1ct::PFTkEGAlgoEmuConfig::PFTkEGAlgoEmuConfig(const edm::ParameterSet &pset) : nTRACK(pset.getParameter("nTRACK")), @@ -45,17 +46,83 @@ l1ct::PFTkEGAlgoEmuConfig::PFTkEGAlgoEmuConfig(const edm::ParameterSet &pset) compIDparams(pset.getParameter("compositeParametersTkEle")), debug(pset.getUntrackedParameter("debug", 0)) {} +edm::ParameterSetDescription l1ct::PFTkEGAlgoEmuConfig::getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("nTRACK"); + description.add("nTRACK_EGIN"); + description.add("nEMCALO_EGIN"); + description.add("nEM_EGOUT"); + description.add("doBremRecovery", false); + description.add("writeBeforeBremRecovery", false); + description.add("filterHwQuality", false); + description.add("caloHwQual", 4); + description.add("doEndcapHwQual", false); + description.add("dEtaMaxBrem", 0.02); + description.add("dPhiMaxBrem", 0.1); + description.add>("absEtaBoundaries", + { + 0.0, + 0.9, + 1.5, + }); + description.add>("dEtaValues", + { + 0.025, + 0.015, + 0.01, + }); + description.add>("dPhiValues", + { + 0.07, + 0.07, + 0.07, + }); + description.add("caloEtMin", 0.0); + description.add("trkQualityPtMin", 10.0); + description.add("writeEGSta", false); + description.add("tkIsoParametersTkEm", IsoParameters::getParameterSetDescription()); + description.add("tkIsoParametersTkEle", IsoParameters::getParameterSetDescription()); + description.add("pfIsoParametersTkEm", IsoParameters::getParameterSetDescription()); + description.add("pfIsoParametersTkEle", IsoParameters::getParameterSetDescription()); + description.add("doTkIso", true); + description.add("doPfIso", true); + description.add("hwIsoTypeTkEle", 0); + description.add("hwIsoTypeTkEm", 2); + description.add("doCompositeTkEle", false); + description.add("nCompCandPerCluster", 3); + description.add("compositeParametersTkEle", + CompIDParameters::getParameterSetDescription()); + return description; +} + l1ct::PFTkEGAlgoEmuConfig::IsoParameters::IsoParameters(const edm::ParameterSet &pset) : IsoParameters(pset.getParameter("tkQualityPtMin"), pset.getParameter("dZ"), pset.getParameter("dRMin"), pset.getParameter("dRMax")) {} +edm::ParameterSetDescription l1ct::PFTkEGAlgoEmuConfig::IsoParameters::getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("tkQualityPtMin"); + description.add("dZ", 0.6); + description.add("dRMin"); + description.add("dRMax"); + description.add("tkQualityChi2Max"); + return description; +} + l1ct::PFTkEGAlgoEmuConfig::CompIDParameters::CompIDParameters(const edm::ParameterSet &pset) : CompIDParameters(pset.getParameter("loose_wp"), pset.getParameter("tight_wp"), pset.getParameter("model")) {} +edm::ParameterSetDescription l1ct::PFTkEGAlgoEmuConfig::CompIDParameters::getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("loose_wp", -0.732422); + description.add("tight_wp", 0.214844); + description.add("model", "L1Trigger/Phase2L1ParticleFlow/data/compositeID.json"); + return description; +} #endif PFTkEGAlgoEmulator::PFTkEGAlgoEmulator(const PFTkEGAlgoEmuConfig &config) diff --git a/L1Trigger/Phase2L1ParticleFlow/src/l1-converters/hgcalinputt_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/l1-converters/hgcalinputt_ref.cpp index e4713944edf02..7cd2aeb8ef9c0 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/l1-converters/hgcalinputt_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/l1-converters/hgcalinputt_ref.cpp @@ -2,9 +2,16 @@ #ifdef CMSSW_GIT_HASH #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" + l1ct::HgcalClusterDecoderEmulator::HgcalClusterDecoderEmulator(const edm::ParameterSet &pset) : slim_(pset.getParameter("slim")) {} +edm::ParameterSetDescription l1ct::HgcalClusterDecoderEmulator::getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("slim", false); + return description; +} #endif l1ct::HgcalClusterDecoderEmulator::~HgcalClusterDecoderEmulator() {} diff --git a/L1Trigger/Phase2L1ParticleFlow/src/l1-converters/muonGmtToL1ct_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/l1-converters/muonGmtToL1ct_ref.cpp index 0c3ddda6a1c43..67342116f8f90 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/l1-converters/muonGmtToL1ct_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/l1-converters/muonGmtToL1ct_ref.cpp @@ -2,10 +2,18 @@ #ifdef CMSSW_GIT_HASH #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" l1ct::GMTMuonDecoderEmulator::GMTMuonDecoderEmulator(const edm::ParameterSet &iConfig) : z0Scale_(iConfig.getParameter("z0Scale")), dxyScale_(iConfig.getParameter("dxyScale")) {} +edm::ParameterSetDescription l1ct::GMTMuonDecoderEmulator::getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("z0Scale", 1.875); + description.add("dxyScale", 3.85); + return description; +} + #endif l1ct::GMTMuonDecoderEmulator::GMTMuonDecoderEmulator(float z0Scale, float dxyScale) diff --git a/L1Trigger/Phase2L1ParticleFlow/src/l1-converters/tkinput_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/l1-converters/tkinput_ref.cpp index ca61b38eb3eb6..21d5e71eab989 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/l1-converters/tkinput_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/l1-converters/tkinput_ref.cpp @@ -10,6 +10,8 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/ParameterSet/interface/allowedValues.h" namespace { l1ct::TrackInputEmulator::Region parseRegion(const std::string &str) { @@ -80,6 +82,52 @@ l1ct::TrackInputEmulator::TrackInputEmulator(const edm::ParameterSet &iConfig) } } +edm::ParameterSetDescription l1ct::TrackInputEmulator::getParameterSetDescription() { + edm::ParameterSetDescription description; + // region-independent parameters and/or defaults + description.add("ptLUTBits", 11u); + description.add("etaPreOffs", 0); + description.add("etaSigned", true); + description.add("phiBits", 10u); + description.add("z0Bits", 12u); + description.ifValue(edm::ParameterDescription("trackWordEncoding", "biased", true), + edm::allowedValues("biased", "unbised", "stepping")); + description.add("bitwiseAccurate", true); + description.add("slimDataFormat", false); + description.addUntracked("debug", false); + // region-dependent parameters and/or defaults + auto barrelParamerers = edm::ParameterDescription("etaLUTBits", 10, true) and + edm::ParameterDescription("etaShift", 15 - 10, true) and + edm::ParameterDescription("etaPostOffs", 0, true) and + edm::ParameterDescription("dEtaBarrelBits", 8, true) and + edm::ParameterDescription("dEtaBarrelZ0PreShift", 2, true) and + edm::ParameterDescription("dEtaBarrelZ0PostShift", 2, true) and + edm::ParameterDescription("dEtaBarrelFloatOffs", 0.0, true) and + edm::ParameterDescription("dPhiBarrelBits", 4, true) and + edm::ParameterDescription("dPhiBarrelRInvPreShift", 4, true) and + edm::ParameterDescription("dPhiBarrelRInvPostShift", 4, true) and + edm::ParameterDescription("dPhiBarrelFloatOffs", 0.0, true); + auto endcapParameters = edm::ParameterDescription("etaLUTBits", 11, true) and + edm::ParameterDescription("etaShift", 15 - 11, true) and + edm::ParameterDescription("etaPostOffs", 150, true) and + edm::ParameterDescription("dEtaHGCalBits", 10, true) and + edm::ParameterDescription("dEtaHGCalZ0PreShift", 2, true) and + edm::ParameterDescription("dEtaHGCalRInvPreShift", 6, true) and + edm::ParameterDescription("dEtaHGCalLUTBits", 10, true) and + edm::ParameterDescription("dEtaHGCalLUTShift", 2, true) and + edm::ParameterDescription("dEtaHGCalFloatOffs", 0.0, true) and + edm::ParameterDescription("dPhiHGCalBits", 4, true) and + edm::ParameterDescription("dPhiHGCalZ0PreShift", 4, true) and + edm::ParameterDescription("dPhiHGCalZ0PostShift", 6, true) and + edm::ParameterDescription("dPhiHGCalRInvShift", 4, true) and + edm::ParameterDescription("dPhiHGCalTanlInvShift", 22, true) and + edm::ParameterDescription("dPhiHGCalTanlLUTBits", 10, true) and + edm::ParameterDescription("dPhiHGCalFloatOffs", 0.0, true); + description.ifValue(edm::ParameterDescription("region", "barrel", true), + "barrel" >> std::move(barrelParamerers) or "endcap" >> std::move(endcapParameters)); + return description; +} + #endif l1ct::TrackInputEmulator::TrackInputEmulator(Region region, Encoding encoding, bool bitwise, bool slim) diff --git a/L1Trigger/Phase2L1ParticleFlow/src/pf/pfalgo2hgc_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/pf/pfalgo2hgc_ref.cpp index ff7fe8b05be2d..bec78588a66ba 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/pf/pfalgo2hgc_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/pf/pfalgo2hgc_ref.cpp @@ -8,6 +8,7 @@ #ifdef CMSSW_GIT_HASH #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" l1ct::PFAlgo2HGCEmulator::PFAlgo2HGCEmulator(const edm::ParameterSet& iConfig) : PFAlgoEmulatorBase(iConfig.getParameter("nTrack"), @@ -22,6 +23,21 @@ l1ct::PFAlgo2HGCEmulator::PFAlgo2HGCEmulator(const edm::ParameterSet& iConfig) loadPtErrBins(iConfig); } +edm::ParameterSetDescription l1ct::PFAlgo2HGCEmulator::getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("nTrack", 30); + description.add("nCalo", 20); + description.add("nMu", 4); + description.add("nSelCalo", 20); + description.add("trackMuDR", 0.2); + description.add("trackCaloDR", 0.1); + description.add("maxInvisiblePt", 10.0); + description.add("tightTrackMaxInvisiblePt", 20); + addCaloResolutionParameterSetDescription(description); + description.addUntracked("debug", false); + return description; +} + #endif void l1ct::PFAlgo2HGCEmulator::toFirmware(const PFInputRegion& in, diff --git a/L1Trigger/Phase2L1ParticleFlow/src/pf/pfalgo3_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/pf/pfalgo3_ref.cpp index fe0e3e0bd5ae6..9df780c81849c 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/pf/pfalgo3_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/pf/pfalgo3_ref.cpp @@ -9,6 +9,7 @@ #ifdef CMSSW_GIT_HASH #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" l1ct::PFAlgo3Emulator::PFAlgo3Emulator(const edm::ParameterSet& iConfig) : PFAlgoEmulatorBase(iConfig.getParameter("nTrack"), @@ -27,6 +28,27 @@ l1ct::PFAlgo3Emulator::PFAlgo3Emulator(const edm::ParameterSet& iConfig) debug_ = iConfig.getUntrackedParameter("debug", false); loadPtErrBins(iConfig); } + +edm::ParameterSetDescription l1ct::PFAlgo3Emulator::getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("nTrack", 25); + description.add("nCalo", 18); + description.add("nMu", 2); + description.add("nSelCalo", 18); + description.add("nEmCalo", 12); + description.add("nPhoton", 12); + description.add("nAllNeutral", 25); + description.add("trackMuDR", 0.2); + description.add("trackEmDR", 0.04); + description.add("emCaloDR", 0.1); + description.add("trackCaloDR", 0.15); + description.add("maxInvisiblePt", 10.0); + description.add("tightTrackMaxInvisiblePt", 20); + addCaloResolutionParameterSetDescription(description); + description.addUntracked("debug", false); + return description; +} + #endif void l1ct::PFAlgo3Emulator::toFirmware(const PFInputRegion& in, diff --git a/L1Trigger/Phase2L1ParticleFlow/src/pf/pfalgo_common_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/pf/pfalgo_common_ref.cpp index 1e7fa983f559a..bff4ff27775d7 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/pf/pfalgo_common_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/pf/pfalgo_common_ref.cpp @@ -6,6 +6,7 @@ #ifdef CMSSW_GIT_HASH #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #endif l1ct::PFAlgoEmulatorBase::~PFAlgoEmulatorBase() {} @@ -43,6 +44,14 @@ void l1ct::PFAlgoEmulatorBase::loadPtErrBins(const edm::ParameterSet &iConfig) { loadPtErrBins(absetas.size(), &absetas[0], &scales[0], &offs[0]); } +void l1ct::PFAlgoEmulatorBase::addCaloResolutionParameterSetDescription(edm::ParameterSetDescription &to) { + edm::ParameterSetDescription description; + description.add>("etaBins"); + description.add>("offset"); + description.add>("scale"); + to.add("caloResolution", description); +} + #endif l1ct::pt_t l1ct::PFAlgoEmulatorBase::ptErr_ref(const l1ct::PFRegionEmu ®ion, const l1ct::TkObjEmu &track) const { diff --git a/L1Trigger/Phase2L1ParticleFlow/src/pf/pfalgo_dummy_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/pf/pfalgo_dummy_ref.cpp index 0f39904bce93b..baad992b18549 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/pf/pfalgo_dummy_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/pf/pfalgo_dummy_ref.cpp @@ -8,12 +8,21 @@ #ifdef CMSSW_GIT_HASH #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" l1ct::PFAlgoDummyEmulator::PFAlgoDummyEmulator(const edm::ParameterSet& iConfig) : PFAlgoEmulatorBase( 0, iConfig.getParameter("nCalo"), iConfig.getParameter("nMu"), 0, 0, 0, 0, 0) { debug_ = iConfig.getUntrackedParameter("debug", false); } + +edm::ParameterSetDescription l1ct::PFAlgoDummyEmulator::getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("nCalo"); + description.add("nMu"); + description.addUntracked("debug", false); + return description; +} #endif void l1ct::PFAlgoDummyEmulator::run(const PFInputRegion& in, OutputRegion& out) const { diff --git a/L1Trigger/Phase2L1ParticleFlow/src/puppi/linpuppi_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/puppi/linpuppi_ref.cpp index 8ef2679747d0d..e2643999529e1 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/puppi/linpuppi_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/puppi/linpuppi_ref.cpp @@ -9,6 +9,8 @@ #ifdef CMSSW_GIT_HASH #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/ParameterSet/interface/allowedValues.h" #include "FWCore/Utilities/interface/transform.h" #include "FWCore/Utilities/interface/Exception.h" #endif @@ -115,9 +117,7 @@ l1ct::LinPuppiEmulator::LinPuppiEmulator(const edm::ParameterSet &iConfig) ptCut_(edm::vector_transform(iConfig.getParameter>("ptCut"), l1ct::Scales::makePtFromFloat)), nFinalSort_(iConfig.getParameter("nFinalSort")), debug_(iConfig.getUntrackedParameter("debug", false)), - fakePuppi_(iConfig.existsAs("fakePuppi") ? iConfig.getParameter("fakePuppi") - : false) // it's only for debug, but still better be tracked -{ + fakePuppi_(iConfig.getParameter("fakePuppi")) { if (absEtaBins_.size() + 1 != ptSlopeNe_.size()) throw cms::Exception("Configuration", "size mismatch for ptSlopes parameter"); if (absEtaBins_.size() + 1 != ptSlopePh_.size()) @@ -152,6 +152,36 @@ l1ct::LinPuppiEmulator::LinPuppiEmulator(const edm::ParameterSet &iConfig) else throw cms::Exception("Configuration", "unsupported finalSortAlgo '" + sortAlgo + "'"); } + +edm::ParameterSetDescription l1ct::LinPuppiEmulator::getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("nTrack"); + description.add("nIn"); + description.add("nOut"); + description.add("nVtx", 1); + description.add("dZ"); + description.add("dr"); + description.add("drMin"); + description.add("ptMax"); + description.add>("absEtaCuts"); + description.add>("ptCut"); + description.add>("ptSlopes"); + description.add>("ptSlopesPhoton"); + description.add>("ptZeros"); + description.add>("ptZerosPhoton"); + description.add>("alphaSlopes"); + description.add>("alphaZeros"); + description.add>("alphaCrop"); + description.add>("priors"); + description.add>("priorsPhoton"); + description.add("nFinalSort"); + description.ifValue( + edm::ParameterDescription("finalSortAlgo", "Insertion", true), + edm::allowedValues("Insertion", "BitonicRUFL", "BitonicHLS", "Hybrid", "FoldedHybrid")); + description.add("fakePuppi", false); + description.addUntracked("debug", false); + return description; +} #endif void l1ct::LinPuppiEmulator::puppisort_and_crop_ref(unsigned int nOutMax, diff --git a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/buffered_folded_multififo_regionizer_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/buffered_folded_multififo_regionizer_ref.cpp index e03e29850148d..9717416c15b0d 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/buffered_folded_multififo_regionizer_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/buffered_folded_multififo_regionizer_ref.cpp @@ -5,6 +5,7 @@ #ifdef CMSSW_GIT_HASH #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" l1ct::BufferedFoldedMultififoRegionizerEmulator::BufferedFoldedMultififoRegionizerEmulator( const edm::ParameterSet& iConfig) @@ -17,12 +18,27 @@ l1ct::BufferedFoldedMultififoRegionizerEmulator::BufferedFoldedMultififoRegioniz /*outii=*/6, /*pauseii=*/3, iConfig.getParameter("useAlsoVtxCoords")) { - debug_ = iConfig.getUntrackedParameter("debug", false); + debug_ = iConfig.getUntrackedParameter("debug"); if (iConfig.existsAs("egInterceptMode")) { const auto& emSelCfg = iConfig.getParameter("egInterceptMode"); setEgInterceptMode(emSelCfg.getParameter("afterFifo"), emSelCfg); } } + +edm::ParameterSetDescription l1ct::BufferedFoldedMultififoRegionizerEmulator::getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("nClocks", 162); + description.add("nTrack", 30); + description.add("nCalo", 20); + description.add("nEmCalo", 10); + description.add("nMu", 4); + edm::ParameterSetDescription egIntercept = l1ct::EGInputSelectorEmuConfig::getParameterSetDescription(); + egIntercept.add("afterFifo", true); + description.addOptional("egInterceptMode", egIntercept); + description.add("useAlsoVtxCoords", true); + description.addUntracked("debug", false); + return description; +} #endif l1ct::BufferedFoldedMultififoRegionizerEmulator::BufferedFoldedMultififoRegionizerEmulator(unsigned int nclocks, diff --git a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/multififo_regionizer_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/multififo_regionizer_ref.cpp index cfe6ec7664565..7b2de76db7e47 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/multififo_regionizer_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/multififo_regionizer_ref.cpp @@ -8,6 +8,8 @@ #ifdef CMSSW_GIT_HASH #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/ParameterSet/interface/allowedValues.h" l1ct::MultififoRegionizerEmulator::MultififoRegionizerEmulator(const edm::ParameterSet& iConfig) : MultififoRegionizerEmulator(iConfig.getParameter("nEndcaps"), @@ -43,7 +45,41 @@ l1ct::MultififoRegionizerEmulator::MultififoRegionizerEmulator(const std::string /*outii=*/1, /*pauseii=*/0, iConfig.getParameter("useAlsoVtxCoords")) { - debug_ = iConfig.getUntrackedParameter("debug", false); + debug_ = iConfig.getUntrackedParameter("debug"); +} + +edm::ParameterSetDescription l1ct::MultififoRegionizerEmulator::getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("nEndcaps", 2); + description.add("nClocks", 54); + description.add("nTkLinks", 2); + description.add("nCaloLinks", 3); + description.add("nTrack", 30); + description.add("nCalo", 20); + description.add("nEmCalo", 10); + description.add("nMu", 4); + edm::ParameterSetDescription egIntercept = l1ct::EGInputSelectorEmuConfig::getParameterSetDescription(); + egIntercept.add("afterFifo", true); + description.addOptional("egInterceptMode", egIntercept); + description.add("useAlsoVtxCoords", true); + description.addUntracked("debug", false); + return description; +} + +edm::ParameterSetDescription l1ct::MultififoRegionizerEmulator::getParameterSetDescriptionBarrel() { + edm::ParameterSetDescription description; + description.ifValue(edm::ParameterDescription("barrelSetup", "Full54", true), + edm::allowedValues("Full54", "Full27")); + description.add("nClocks", 54); + description.add("nHCalLinks", 2); + description.add("nECalLinks", 1); + description.add("nTrack", 22); + description.add("nCalo", 15); + description.add("nEmCalo", 12); + description.add("nMu", 2); + description.add("useAlsoVtxCoords", true); + description.addUntracked("debug", false); + return description; } #endif diff --git a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/regionizer_base_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/regionizer_base_ref.cpp index f79f9f6934903..42d9a15bb87af 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/regionizer_base_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/regionizer_base_ref.cpp @@ -6,9 +6,18 @@ #ifdef CMSSW_GIT_HASH #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" + l1ct::RegionizerEmulator::RegionizerEmulator(const edm::ParameterSet& iConfig) : useAlsoVtxCoords_(iConfig.getParameter("useAlsoVtxCoords")), - debug_(iConfig.getUntrackedParameter("debug", false)) {} + debug_(iConfig.getUntrackedParameter("debug")) {} + +edm::ParameterSetDescription l1ct::RegionizerEmulator::getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("useAlsoVtxCoords", true); + description.addUntracked("debug", false); + return description; +} #endif l1ct::RegionizerEmulator::~RegionizerEmulator() {} diff --git a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/tdr_regionizer_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/tdr_regionizer_ref.cpp index 8a654985ab2e0..79616c2753888 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/tdr_regionizer_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/tdr_regionizer_ref.cpp @@ -5,6 +5,7 @@ #ifdef CMSSW_GIT_HASH #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" l1ct::TDRRegionizerEmulator::TDRRegionizerEmulator(const edm::ParameterSet& iConfig) : TDRRegionizerEmulator(iConfig.getParameter("nTrack"), @@ -14,7 +15,20 @@ l1ct::TDRRegionizerEmulator::TDRRegionizerEmulator(const edm::ParameterSet& iCon iConfig.getParameter("nClocks"), iConfig.getParameter>("bigRegionEdges"), iConfig.getParameter("doSort")) { - debug_ = iConfig.getUntrackedParameter("debug", false); + debug_ = iConfig.getUntrackedParameter("debug"); +} + +edm::ParameterSetDescription l1ct::TDRRegionizerEmulator::getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("nClocks", 162); + description.add("nTrack", 22); + description.add("nCalo", 15); + description.add("nEmCalo", 12); + description.add("nMu", 2); + description.add("doSort", false); + description.add>("bigRegionEdges", {-560, -80, 400, -560}); + description.addUntracked("debug", false); + return description; } #endif diff --git a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py index 249725522860e..a778a86ffb84a 100644 --- a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py +++ b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py @@ -164,12 +164,15 @@ process.l1tLayer1HGCalTM18 = process.l1tLayer1HGCal.clone() process.l1tLayer1HGCalTM18.regionizerAlgo = "BufferedFoldedMultififo" process.l1tLayer1HGCalTM18.regionizerAlgoParameters.nClocks = 162 - process.l1tLayer1HGCalTM18.regionizerAlgoParameters.nTkLinks = 1 - process.l1tLayer1HGCalTM18.regionizerAlgoParameters.nCaloLinks = 1 + del process.l1tLayer1HGCalTM18.regionizerAlgoParameters.nEndcaps + del process.l1tLayer1HGCalTM18.regionizerAlgoParameters.nTkLinks + del process.l1tLayer1HGCalTM18.regionizerAlgoParameters.nCaloLinks process.l1tLayer1HGCalNoTKTM18 = process.l1tLayer1HGCalNoTK.clone() process.l1tLayer1HGCalNoTKTM18.regionizerAlgo = "BufferedFoldedMultififo" process.l1tLayer1HGCalNoTKTM18.regionizerAlgoParameters.nClocks = 162 - process.l1tLayer1HGCalNoTKTM18.regionizerAlgoParameters.nCaloLinks = 1 + del process.l1tLayer1HGCalNoTKTM18.regionizerAlgoParameters.nEndcaps + del process.l1tLayer1HGCalNoTKTM18.regionizerAlgoParameters.nTkLinks + del process.l1tLayer1HGCalNoTKTM18.regionizerAlgoParameters.nCaloLinks process.runPF.insert(process.runPF.index(process.l1tLayer1HGCal)+1, process.l1tLayer1HGCalTM18) process.runPF.insert(process.runPF.index(process.l1tLayer1HGCalNoTK)+1, process.l1tLayer1HGCalNoTKTM18) if not args.patternFilesOFF: From 3476f770a260719f5fbcb91b7b013a7399b0e613 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Fri, 25 Aug 2023 13:38:57 +0200 Subject: [PATCH 2/6] Cleanup some configuration settings, using the defaults from fillDescriptions --- .../plugins/L1TCorrelatorLayer1Producer.cc | 2 +- .../python/l1ctLayer1_cff.py | 214 ++++++------------ 2 files changed, 73 insertions(+), 143 deletions(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc index 4aa1c4289d6fa..a6a77c217fe14 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc @@ -344,7 +344,7 @@ L1TCorrelatorLayer1Producer::~L1TCorrelatorLayer1Producer() {} void L1TCorrelatorLayer1Producer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; // Inputs and cuts - desc.add("tracks", edm::InputTag("l1tPFTracksFromL1Tracks")); + desc.add("tracks", edm::InputTag("")); desc.add("muons", edm::InputTag("l1tSAMuonsGmt", "promptSAMuons")); desc.add>("emClusters", std::vector()); desc.add>("hadClusters", std::vector()); diff --git a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_cff.py b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_cff.py index 7d06f3d1d4fb1..2e7082629a1cb 100644 --- a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_cff.py +++ b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer1_cff.py @@ -9,54 +9,35 @@ from L1Trigger.Phase2L1ParticleFlow.l1TkEgAlgoEmulator_cfi import tkEgAlgoParameters,tkEgSorterParameters -muonInputConversionParameters = cms.PSet( - z0Scale = cms.double(1.875), - dxyScale = cms.double(3.85) -) - l1tLayer1Barrel = cms.EDProducer("L1TCorrelatorLayer1Producer", tracks = cms.InputTag('l1tPFTracksFromL1Tracks'), muons = cms.InputTag('l1tSAMuonsGmt','promptSAMuons'), emClusters = cms.VInputTag(cms.InputTag('l1tPFClustersFromL1EGClusters:selected')), hadClusters = cms.VInputTag(cms.InputTag('l1tPFClustersFromCombinedCaloHCal:calibrated')), vtxCollection = cms.InputTag("l1tVertexFinderEmulator","L1VerticesEmulation"), - vtxCollectionEmulation = cms.bool(True), - emPtCut = cms.double(0.5), + nVtx = cms.int32(1), + emPtCut = cms.double(0.5), hadPtCut = cms.double(1.0), - trkPtCut = cms.double(2.0), + trkPtCut = cms.double(2.0), trackInputConversionAlgo = cms.string("Emulator"), trackInputConversionParameters = cms.PSet( region = cms.string("barrel"), - trackWordEncoding = cms.string("biased"), - bitwiseAccurate = cms.bool(True), slimDataFormat = cms.bool(True), ptLUTBits = cms.uint32(11), etaLUTBits = cms.uint32(10), - etaPreOffs = cms.int32(0), etaShift = cms.uint32(15-10), - etaPostOffs = cms.int32(0), - etaSigned = cms.bool(True), phiBits = cms.uint32(10), z0Bits = cms.uint32(12), dEtaBarrelBits = cms.uint32(8), dEtaBarrelZ0PreShift = cms.uint32(2), dEtaBarrelZ0PostShift = cms.uint32(2), - dEtaBarrelFloatOffs = cms.double(0.0), dPhiBarrelBits = cms.uint32(4), dPhiBarrelRInvPreShift = cms.uint32(4), dPhiBarrelRInvPostShift = cms.uint32(4), - dPhiBarrelFloatOffs = cms.double(0.0) ), muonInputConversionAlgo = cms.string("Emulator"), - muonInputConversionParameters = muonInputConversionParameters.clone(), - hgcalInputConversionAlgo = cms.string("Ideal"), regionizerAlgo = cms.string("Ideal"), pfAlgo = cms.string("PFAlgo3"), - puAlgo = cms.string("LinearizedPuppi"), - nVtx = cms.int32(1), - regionizerAlgoParameters = cms.PSet( - useAlsoVtxCoords = cms.bool(True), - ), pfAlgoParameters = cms.PSet( nTrack = cms.uint32(25), nCalo = cms.uint32(18), @@ -76,8 +57,8 @@ offset = cms.vdouble( 2.909, 2.864, 0.294), scale = cms.vdouble( 0.119, 0.127, 0.442), ), - debug = cms.untracked.bool(False) ), + puAlgo = cms.string("LinearizedPuppi"), puAlgoParameters = cms.PSet( nTrack = cms.uint32(22), nIn = cms.uint32(25), @@ -100,43 +81,36 @@ alphaCrop = cms.vdouble( 4 ), # max. absolute value for alpha term priors = cms.vdouble( 5.0 ), priorsPhoton = cms.vdouble( 1.0 ), - debug = cms.untracked.bool(False) ), - tkEgAlgoParameters=tkEgAlgoParameters.clone( + tkEgAlgoParameters = tkEgAlgoParameters.clone( nTRACK = 25, nTRACK_EGIN = 13, nEMCALO_EGIN = 10, nEM_EGOUT = 10, ), tkEgSorterAlgo = cms.string("Barrel"), - tkEgSorterParameters=tkEgSorterParameters.clone( + tkEgSorterParameters = tkEgSorterParameters.clone( nObjToSort = 10 ), caloSectors = cms.VPSet( cms.PSet( etaBoundaries = cms.vdouble(-1.5, 1.5), phiSlices = cms.uint32(3), - phiZero = cms.double(0), ) ), regions = cms.VPSet( cms.PSet( etaBoundaries = cms.vdouble(-1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5), phiSlices = cms.uint32(9), - etaExtra = cms.double(0.25), - phiExtra = cms.double(0.25), ), ), - boards=cms.VPSet( + boards = cms.VPSet( cms.PSet( - regions=cms.vuint32(*[0+9*ie+i for ie in range(6) for i in range(3)])), # phi splitting - # regions=cms.vuint32(range(0, 18))), # eta splitting + regions = cms.vuint32(*[0+9*ie+i for ie in range(6) for i in range(3)])), # phi splitting cms.PSet( - regions=cms.vuint32(*[3+9*ie+i for ie in range(6) for i in range(3)])), # phi splitting - # regions=cms.vuint32(range(18, 36))), # eta splitting + regions = cms.vuint32(*[3+9*ie+i for ie in range(6) for i in range(3)])), # phi splitting cms.PSet( - regions=cms.vuint32(*[6+9*ie+i for ie in range(6) for i in range(3)])), # phi splitting - # regions=cms.vuint32(range(36, 54))), # eta splitting + regions = cms.vuint32(*[6+9*ie+i for ie in range(6) for i in range(3)])), # phi splitting ) ) @@ -146,7 +120,7 @@ cms.PSet( etaBoundaries = cms.vdouble(-3.0, -1.5), phiSlices = cms.uint32(3), - phiZero = cms.double(math.pi/2) # The edge of the 0th HGCal sectors is at 30 deg, the center at 30+120/2=90 = pi/2 + phiZero = cms.double(math.pi/2) # The edge of the 0th HGCal sectors is at 30 deg, the center at 30+120/2 = 90 = pi/2 ), cms.PSet( etaBoundaries = cms.vdouble(+1.5, +3.0), @@ -162,23 +136,18 @@ emClusters = cms.VInputTag(cms.InputTag('l1tPFClustersFromHGC3DClusters:egamma')), # used only for E/gamma hadClusters = cms.VInputTag(cms.InputTag('l1tPFClustersFromHGC3DClusters')), vtxCollection = cms.InputTag("l1tVertexFinderEmulator","L1VerticesEmulation"), - vtxCollectionEmulation = cms.bool(True), - nVtx = cms.int32(1), - emPtCut = cms.double(0.5), + nVtx = cms.int32(1), + emPtCut = cms.double(0.5), hadPtCut = cms.double(1.0), - trkPtCut = cms.double(2.0), + trkPtCut = cms.double(2.0), trackInputConversionAlgo = cms.string("Emulator"), trackInputConversionParameters = cms.PSet( region = cms.string("endcap"), - trackWordEncoding = cms.string("biased"), - bitwiseAccurate = cms.bool(True), slimDataFormat = cms.bool(False), ptLUTBits = cms.uint32(11), etaLUTBits = cms.uint32(11), - etaPreOffs = cms.int32(0), etaShift = cms.uint32(15-11), etaPostOffs = cms.int32(150), - etaSigned = cms.bool(True), phiBits = cms.uint32(10), z0Bits = cms.uint32(12), dEtaHGCalBits = cms.uint32(10), @@ -186,21 +155,15 @@ dEtaHGCalRInvPreShift = cms.uint32(6), dEtaHGCalLUTBits = cms.uint32(10), dEtaHGCalLUTShift = cms.uint32(2), - dEtaHGCalFloatOffs = cms.double(0.0), dPhiHGCalBits = cms.uint32(4), dPhiHGCalZ0PreShift = cms.uint32(4), dPhiHGCalZ0PostShift = cms.uint32(6), dPhiHGCalRInvShift = cms.uint32(4), dPhiHGCalTanlInvShift = cms.uint32(22), dPhiHGCalTanlLUTBits = cms.uint32(10), - dPhiHGCalFloatOffs = cms.double(0.0) ), muonInputConversionAlgo = cms.string("Emulator"), - muonInputConversionParameters = muonInputConversionParameters.clone(), hgcalInputConversionAlgo = cms.string("Emulator"), - hgcalInputConversionParameters = cms.PSet( - slim = cms.bool(False) - ), regionizerAlgo = cms.string("Multififo"), regionizerAlgoParameters = cms.PSet( useAlsoVtxCoords = cms.bool(True), @@ -234,7 +197,6 @@ offset = cms.vdouble( 1.793, 1.827, 2.363, 2.538, 2.812, 2.642), scale = cms.vdouble( 0.138, 0.137, 0.124, 0.115, 0.106, 0.121), ), - debug = cms.untracked.bool(False) ), puAlgo = cms.string("LinearizedPuppi"), puAlgoParameters = cms.PSet( @@ -259,21 +221,20 @@ alphaCrop = cms.vdouble( 3 , 3 ), # max. absolute value for alpha term priors = cms.vdouble( 5.0, 5.0 ), priorsPhoton = cms.vdouble( 1.5, 1.5 ), #When e/g ID not applied, use: cms.vdouble( 3.5, 3.5, 7.0 ), - debug = cms.untracked.bool(False) ), - tkEgAlgoParameters=tkEgAlgoParameters.clone( + tkEgAlgoParameters = tkEgAlgoParameters.clone( nTRACK = 30, nTRACK_EGIN = 10, nEMCALO_EGIN = 10, nEM_EGOUT = 5, - doBremRecovery=True, - doEndcapHwQual=True, - writeBeforeBremRecovery=False, - writeEGSta=True, - doCompositeTkEle=True, - trkQualityPtMin=0.), # This should be 10 GeV when doCompositeTkEle=False + doBremRecovery = True, + doEndcapHwQual = True, + writeBeforeBremRecovery = False, + writeEGSta = True, + doCompositeTkEle = True, + trkQualityPtMin = 0.), # This should be 10 GeV when doCompositeTkEle = False tkEgSorterAlgo = cms.string("Endcap"), - tkEgSorterParameters=tkEgSorterParameters.clone( + tkEgSorterParameters = tkEgSorterParameters.clone( nObjToSort = 5 ), caloSectors = _hgcalSectors, @@ -281,22 +242,18 @@ cms.PSet( etaBoundaries = cms.vdouble(-2.5, -1.5), phiSlices = cms.uint32(9), - etaExtra = cms.double(0.25), - phiExtra = cms.double(0.25), ), cms.PSet( etaBoundaries = cms.vdouble(+1.5, +2.5), phiSlices = cms.uint32(9), - etaExtra = cms.double(0.25), - phiExtra = cms.double(0.25), ) ), - boards=cms.VPSet( + boards = cms.VPSet( cms.PSet( - regions=cms.vuint32(range(0, 9))), + regions = cms.vuint32(range(0, 9))), cms.PSet( - regions=cms.vuint32(range(9, 18))), + regions = cms.vuint32(range(9, 18))), ), writeRawHgcalCluster = cms.untracked.bool(True) ) @@ -310,18 +267,15 @@ l1tLayer1HGCalExtended = l1tLayer1HGCal.clone(tracks = cms.InputTag('l1tPFTracksFromL1TracksExtended')) l1tLayer1HGCalNoTK = cms.EDProducer("L1TCorrelatorLayer1Producer", - tracks = cms.InputTag(''), muons = cms.InputTag('l1tSAMuonsGmt','promptSAMuons'), emClusters = cms.VInputTag(cms.InputTag('l1tPFClustersFromHGC3DClusters:egamma')), # used only for E/gamma hadClusters = cms.VInputTag(cms.InputTag('l1tPFClustersFromHGC3DClusters')), vtxCollection = cms.InputTag("l1tVertexFinderEmulator","L1VerticesEmulation"), - vtxCollectionEmulation = cms.bool(True), - nVtx = cms.int32(1), - emPtCut = cms.double(0.5), + nVtx = cms.int32(1), + emPtCut = cms.double(0.5), hadPtCut = cms.double(1.0), - trkPtCut = cms.double(2.0), + trkPtCut = cms.double(2.0), muonInputConversionAlgo = cms.string("Emulator"), - muonInputConversionParameters = muonInputConversionParameters.clone(), hgcalInputConversionAlgo = cms.string("Emulator"), hgcalInputConversionParameters = cms.PSet( slim = cms.bool(True) @@ -348,7 +302,6 @@ pfAlgoParameters = cms.PSet( nCalo = cms.uint32(12), nMu = cms.uint32(4), # unused - debug = cms.untracked.bool(False) ), puAlgo = cms.string("LinearizedPuppi"), puAlgoParameters = cms.PSet( @@ -373,68 +326,53 @@ alphaCrop = cms.vdouble( 4 ), # max. absolute value for alpha term priors = cms.vdouble( 7.0 ), priorsPhoton = cms.vdouble( 5.0 ), #When e/g ID not applied, use: cms.vdouble( 3.5, 3.5, 7.0 ), - debug = cms.untracked.bool(False) ), - tkEgAlgoParameters=tkEgAlgoParameters.clone( + tkEgAlgoParameters = tkEgAlgoParameters.clone( nTRACK = 30, nTRACK_EGIN = 10, nEMCALO_EGIN = 10, nEM_EGOUT = 5, - doBremRecovery=True, - doEndcapHwQual=True, - writeBeforeBremRecovery=False, - writeEGSta=True), + doBremRecovery = True, + doEndcapHwQual = True, + writeBeforeBremRecovery = False, + writeEGSta = True), tkEgSorterAlgo = cms.string("Endcap"), - tkEgSorterParameters=tkEgSorterParameters.clone( - nObjToSort=5 + tkEgSorterParameters = tkEgSorterParameters.clone( + nObjToSort = 5 ), caloSectors = _hgcalSectors, regions = cms.VPSet( cms.PSet( etaBoundaries = cms.vdouble(-3.0, -2.5), phiSlices = cms.uint32(9), - etaExtra = cms.double(0.25), - phiExtra = cms.double(0.25), ), cms.PSet( etaBoundaries = cms.vdouble(+2.5, +3.0), phiSlices = cms.uint32(9), - etaExtra = cms.double(0.25), - phiExtra = cms.double(0.25), ) ), - boards=cms.VPSet( - cms.PSet( - regions=cms.vuint32(range(0,18))), + boards = cms.VPSet( + cms.PSet(regions = cms.vuint32(range(0,18))), ), writeRawHgcalCluster = cms.untracked.bool(True) ) l1tLayer1HF = cms.EDProducer("L1TCorrelatorLayer1Producer", - tracks = cms.InputTag(''), muons = cms.InputTag('l1tSAMuonsGmt','promptSAMuons'), - emClusters = cms.VInputTag(), hadClusters = cms.VInputTag(cms.InputTag('l1tPFClustersFromCombinedCaloHF:calibrated')), vtxCollection = cms.InputTag("l1tVertexFinderEmulator","L1VerticesEmulation"), - vtxCollectionEmulation = cms.bool(True), - nVtx = cms.int32(1), - emPtCut = cms.double(0.5), + nVtx = cms.int32(1), + emPtCut = cms.double(0.5), hadPtCut = cms.double(15.0), - trkPtCut = cms.double(2.0), - muonInputConversionAlgo = cms.string("Ideal"), - hgcalInputConversionAlgo = cms.string("Ideal"), - regionizerAlgo = cms.string("Ideal"), + trkPtCut = cms.double(2.0), pfAlgo = cms.string("PFAlgoDummy"), - puAlgo = cms.string("LinearizedPuppi"), - regionizerAlgoParameters = cms.PSet( - useAlsoVtxCoords = cms.bool(True), - ), pfAlgoParameters = cms.PSet( nCalo = cms.uint32(18), nMu = cms.uint32(4), # unused debug = cms.untracked.bool(False) ), + puAlgo = cms.string("LinearizedPuppi"), puAlgoParameters = cms.PSet( nTrack = cms.uint32(0), # unused nIn = cms.uint32(18), @@ -459,42 +397,36 @@ priorsPhoton = cms.vdouble( 6.0 ), debug = cms.untracked.bool(False) ), - tkEgAlgoParameters=tkEgAlgoParameters.clone( + tkEgAlgoParameters = tkEgAlgoParameters.clone( nTRACK = 5, # to be defined nTRACK_EGIN = 5, # to be defined nEMCALO_EGIN = 5, # to be defined nEM_EGOUT = 5, # to be defined - doBremRecovery=True, - writeEGSta=True), + doBremRecovery = True, + writeEGSta = True), tkEgSorterAlgo = cms.string("Endcap"), - tkEgSorterParameters=tkEgSorterParameters.clone(), + tkEgSorterParameters = tkEgSorterParameters.clone(), caloSectors = cms.VPSet( cms.PSet( etaBoundaries = cms.vdouble(-5.5, -3.0), phiSlices = cms.uint32(9), - phiZero = cms.double(0), ), cms.PSet( etaBoundaries = cms.vdouble(+3.0, +5.5), phiSlices = cms.uint32(9), - phiZero = cms.double(0), ) ), regions = cms.VPSet( cms.PSet( etaBoundaries = cms.vdouble(-5.5, -3.0), phiSlices = cms.uint32(9), - etaExtra = cms.double(0.25), - phiExtra = cms.double(0.25), ), cms.PSet( etaBoundaries = cms.vdouble(+3.0, +5.5), phiSlices = cms.uint32(9), - etaExtra = cms.double(0.25), - phiExtra = cms.double(0.25), ) ), - boards=cms.VPSet(), + boards = cms.VPSet(), ) @@ -505,8 +437,6 @@ cms.InputTag("l1tLayer1HGCalNoTK"), cms.InputTag("l1tLayer1HF") ), - labelsToMerge = cms.vstring("PF", "Puppi", "Calo", "TK"), - regionalLabelsToMerge = cms.vstring("Puppi"), ) @@ -521,39 +451,39 @@ l1tLayer1EG = cms.EDProducer( "L1TEGMultiMerger", - tkElectrons=cms.VPSet( + tkElectrons = cms.VPSet( cms.PSet( - instance=cms.string("L1TkEleEE"), - pfProducers=cms.VInputTag( + instance = cms.string("L1TkEleEE"), + pfProducers = cms.VInputTag( cms.InputTag("l1tLayer1HGCal", 'L1TkEle') ) ), cms.PSet( - instance=cms.string("L1TkEleEB"), - pfProducers=cms.VInputTag( + instance = cms.string("L1TkEleEB"), + pfProducers = cms.VInputTag( cms.InputTag("l1tLayer1Barrel", 'L1TkEle') ) ) ), - tkEms=cms.VPSet( + tkEms = cms.VPSet( cms.PSet( - instance=cms.string("L1TkEmEE"), - pfProducers=cms.VInputTag( + instance = cms.string("L1TkEmEE"), + pfProducers = cms.VInputTag( cms.InputTag("l1tLayer1HGCal", 'L1TkEm'), cms.InputTag("l1tLayer1HGCalNoTK", 'L1TkEm') ) ), cms.PSet( - instance=cms.string("L1TkEmEB"), - pfProducers=cms.VInputTag( + instance = cms.string("L1TkEmEB"), + pfProducers = cms.VInputTag( cms.InputTag("l1tLayer1Barrel", 'L1TkEm') ) ) ), - tkEgs=cms.VPSet( + tkEgs = cms.VPSet( cms.PSet( - instance=cms.string("L1EgEE"), - pfProducers=cms.VInputTag( + instance = cms.string("L1EgEE"), + pfProducers = cms.VInputTag( cms.InputTag("l1tLayer1HGCal", 'L1Eg'), cms.InputTag("l1tLayer1HGCalNoTK", 'L1Eg') ) @@ -563,39 +493,39 @@ l1tLayer1EGElliptic = cms.EDProducer( "L1TEGMultiMerger", - tkElectrons=cms.VPSet( + tkElectrons = cms.VPSet( cms.PSet( - instance=cms.string("L1TkEleEE"), - pfProducers=cms.VInputTag( + instance = cms.string("L1TkEleEE"), + pfProducers = cms.VInputTag( cms.InputTag("l1tLayer1HGCalElliptic", 'L1TkEle') ) ), cms.PSet( - instance=cms.string("L1TkEleEB"), - pfProducers=cms.VInputTag( + instance = cms.string("L1TkEleEB"), + pfProducers = cms.VInputTag( cms.InputTag("l1tLayer1Barrel", 'L1TkEle') ) ) ), - tkEms=cms.VPSet( + tkEms = cms.VPSet( cms.PSet( - instance=cms.string("L1TkEmEE"), - pfProducers=cms.VInputTag( + instance = cms.string("L1TkEmEE"), + pfProducers = cms.VInputTag( cms.InputTag("l1tLayer1HGCalElliptic", 'L1TkEm'), cms.InputTag("l1tLayer1HGCalNoTK", 'L1TkEm') ) ), cms.PSet( - instance=cms.string("L1TkEmEB"), - pfProducers=cms.VInputTag( + instance = cms.string("L1TkEmEB"), + pfProducers = cms.VInputTag( cms.InputTag("l1tLayer1Barrel", 'L1TkEm') ) ) ), - tkEgs=cms.VPSet( + tkEgs = cms.VPSet( cms.PSet( - instance=cms.string("L1EgEE"), - pfProducers=cms.VInputTag( + instance = cms.string("L1EgEE"), + pfProducers = cms.VInputTag( cms.InputTag("l1tLayer1HGCalElliptic", 'L1Eg'), cms.InputTag("l1tLayer1HGCalNoTK", 'L1Eg') ) From 321ccc4cea119fffbe57ee92df5f756e99291153 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Tue, 5 Sep 2023 15:39:43 +0200 Subject: [PATCH 3/6] Barrel TM18 configuration for Serenity --- .../L1TParticleFlow/interface/datatypes.h | 27 +- ...buffered_folded_multififo_regionizer_ref.h | 75 +-- .../middle_buffer_multififo_regionizer_ref.h | 112 ++++ .../multififo_regionizer_elements_ref.h | 112 ++++ .../multififo_regionizer_elements_ref.icc | 10 +- .../regionizer/multififo_regionizer_ref.h | 1 + .../plugins/L1TCorrelatorLayer1Producer.cc | 8 +- ...ffered_folded_multififo_regionizer_ref.cpp | 7 +- ...middle_buffer_multififo_regionizer_ref.cpp | 498 ++++++++++++++++++ .../regionizer/multififo_regionizer_ref.cpp | 15 +- .../src/regionizer/tdr_regionizer_ref.cpp | 8 +- .../test/make_l1ct_binaryFiles_cfg.py | 13 +- 12 files changed, 779 insertions(+), 107 deletions(-) create mode 100644 L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h create mode 100644 L1Trigger/Phase2L1ParticleFlow/src/regionizer/middle_buffer_multififo_regionizer_ref.cpp diff --git a/DataFormats/L1TParticleFlow/interface/datatypes.h b/DataFormats/L1TParticleFlow/interface/datatypes.h index be802bc540b6e..c2b2fd0c35e02 100644 --- a/DataFormats/L1TParticleFlow/interface/datatypes.h +++ b/DataFormats/L1TParticleFlow/interface/datatypes.h @@ -1,17 +1,6 @@ #ifndef DataFormats_L1TParticleFlow_datatypes_h #define DataFormats_L1TParticleFlow_datatypes_h -#if (!defined(__CLANG__)) && defined(__GNUC__) && defined(CMSSW_GIT_HASH) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wint-in-bool-context" -#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" -#pragma GCC diagnostic ignored "-Wuninitialized" -#endif -#include -#if (!defined(__CLANG__)) && defined(__GNUC__) && defined(CMSSW_GIT_HASH) -#pragma GCC diagnostic pop -#endif - #include #include #include @@ -163,8 +152,14 @@ namespace l1ct { inline float floatPt(pt_t pt) { return pt.to_float(); } inline float floatPt(dpt_t pt) { return pt.to_float(); } inline float floatPt(pt2_t pt2) { return pt2.to_float(); } - inline int intPt(pt_t pt) { return (ap_ufixed<16, 14>(pt) << 2).to_int(); } - inline int intPt(dpt_t pt) { return (ap_fixed<18, 16>(pt) << 2).to_int(); } + inline int intPt(pt_t pt) { + ap_uint rawPt = pt.range(); + return rawPt.to_int(); + } + inline int intPt(dpt_t pt) { + ap_int rawPt = pt.range(); + return rawPt.to_int(); + } inline float floatEta(eta_t eta) { return eta.to_float() * ETAPHI_LSB; } inline float floatPhi(phi_t phi) { return phi.to_float() * ETAPHI_LSB; } inline float floatEta(tkdeta_t eta) { return eta.to_float() * ETAPHI_LSB; } @@ -181,9 +176,9 @@ namespace l1ct { inline pt_t makePt(int pt) { return ap_ufixed<16, 14>(pt) >> 2; } inline dpt_t makeDPt(int dpt) { return ap_fixed<18, 16>(dpt) >> 2; } - inline pt_t makePtFromFloat(float pt) { return pt_t(0.25 * round(pt * 4)); } + inline pt_t makePtFromFloat(float pt) { return pt_t(0.25 * std::round(pt * 4)); } inline dpt_t makeDPtFromFloat(float dpt) { return dpt_t(dpt); } - inline z0_t makeZ0(float z0) { return z0_t(round(z0 / Z0_LSB)); } + inline z0_t makeZ0(float z0) { return z0_t(std::round(z0 / Z0_LSB)); } inline ap_uint ptToInt(pt_t pt) { // note: this can be synthethized, e.g. when pT is used as intex in a LUT @@ -216,7 +211,7 @@ namespace l1ct { inline float maxAbsPhi() { return ((1 << (phi_t::width - 1)) - 1) * ETAPHI_LSB; } inline float maxAbsGlbEta() { return ((1 << (glbeta_t::width - 1)) - 1) * ETAPHI_LSB; } inline float maxAbsGlbPhi() { return ((1 << (glbphi_t::width - 1)) - 1) * ETAPHI_LSB; } - }; // namespace Scales + } // namespace Scales inline int dr2_int(eta_t eta1, phi_t phi1, eta_t eta2, phi_t phi2) { ap_int deta = (eta1 - eta2); diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/buffered_folded_multififo_regionizer_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/buffered_folded_multififo_regionizer_ref.h index cf30b63f10978..a9a531f65ad4e 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/buffered_folded_multififo_regionizer_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/buffered_folded_multififo_regionizer_ref.h @@ -6,38 +6,6 @@ #include #include -namespace l1ct { - namespace multififo_regionizer { - template - inline bool local_eta_window(const T& t, const l1ct::glbeta_t& etaMin, const l1ct::glbeta_t& etaMax); - template <> - inline bool local_eta_window(const l1ct::TkObjEmu& t, - const l1ct::glbeta_t& etaMin, - const l1ct::glbeta_t& etaMax); - - template - class EtaBuffer { - public: - EtaBuffer() {} - EtaBuffer(unsigned int maxitems, const l1ct::glbeta_t& etaMin = 0, const l1ct::glbeta_t& etaMax = 0) - : size_(maxitems), iwrite_(0), iread_(0), etaMin_(etaMin), etaMax_(etaMax) {} - void maybe_push(const T& t); - void writeNewEvent() { - iwrite_ = 1 - iwrite_; - items_[iwrite_].clear(); - } - void readNewEvent() { iread_ = 1 - iread_; } - T pop(); - unsigned int writeSize() const { return items_[iwrite_].size(); } - unsigned int readSize() const { return items_[iread_].size(); } - - private: - unsigned int size_, iwrite_, iread_; - l1ct::glbeta_t etaMin_, etaMax_; - std::deque items_[2]; - }; - } // namespace multififo_regionizer -} // namespace l1ct namespace l1ct { class BufferedFoldedMultififoRegionizerEmulator : public FoldedMultififoRegionizerEmulator { public: @@ -88,9 +56,9 @@ namespace l1ct { } protected: - std::vector> tkBuffers_; - std::vector> caloBuffers_; - std::vector> muBuffers_; + std::vector> tkBuffers_; + std::vector> caloBuffers_; + std::vector> muBuffers_; void findEtaBounds_(const l1ct::PFRegionEmu& sec, const std::vector& reg, @@ -106,41 +74,4 @@ namespace l1ct { }; } // namespace l1ct -template -inline bool l1ct::multififo_regionizer::local_eta_window(const T& t, - const l1ct::glbeta_t& etaMin, - const l1ct::glbeta_t& etaMax) { - return (etaMin == etaMax) || (etaMin <= t.hwEta && t.hwEta <= etaMax); -} -template <> -inline bool l1ct::multififo_regionizer::local_eta_window(const l1ct::TkObjEmu& t, - const l1ct::glbeta_t& etaMin, - const l1ct::glbeta_t& etaMax) { - return (etaMin == etaMax) || (etaMin <= t.hwEta && t.hwEta <= etaMax) || - (etaMin <= t.hwVtxEta() && t.hwVtxEta() <= etaMax); -} -template -void l1ct::multififo_regionizer::EtaBuffer::maybe_push(const T& t) { - if ((t.hwPt != 0) && local_eta_window(t, etaMin_, etaMax_)) { - if (items_[iwrite_].size() < size_) { - items_[iwrite_].push_back(t); - } else { - // uncommenting the message below may be useful for debugging - //dbgCout() << "WARNING: sector buffer is full for " << typeid(T).name() << ", pt = " << t.intPt() - // << ", eta = " << t.intEta() << ", phi = " << t.intPhi() << "\n"; - } - } -} - -template -T l1ct::multififo_regionizer::EtaBuffer::pop() { - T ret; - ret.clear(); - if (!items_[iread_].empty()) { - ret = items_[iread_].front(); - items_[iread_].pop_front(); - } - return ret; -} - #endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h new file mode 100644 index 0000000000000..7f9685c119143 --- /dev/null +++ b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h @@ -0,0 +1,112 @@ +#ifndef middle_buffer_multififo_regionizer_ref_h +#define middle_buffer_multififo_regionizer_ref_h + +#include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_ref.h" +#include "L1Trigger/Phase2L1ParticleFlow/interface/dbgPrintf.h" +#include +#include + +namespace l1ct { + class MiddleBufferMultififoRegionizerEmulator : public RegionizerEmulator { + public: + MiddleBufferMultififoRegionizerEmulator(unsigned int nclocks, + unsigned int etabufferDepth, + unsigned int ntklinks, + unsigned int nHCalLinks, + unsigned int nECalLinks, + unsigned int ntk, + unsigned int ncalo, + unsigned int nem, + unsigned int nmu, + bool streaming, + unsigned int outii, + unsigned int pauseii, + bool useAlsoVtxCoords); + // note: this one will work only in CMSSW + MiddleBufferMultififoRegionizerEmulator(const edm::ParameterSet& iConfig); + + ~MiddleBufferMultififoRegionizerEmulator() override; + + static edm::ParameterSetDescription getParameterSetDescription(); + + void initSectorsAndRegions(const RegionizerDecodedInputs& in, const std::vector& out) override; + + void run(const RegionizerDecodedInputs& in, std::vector& out) override; + + // link emulation from decoded inputs (for simulation) + void fillLinks(unsigned int iclock, + const RegionizerDecodedInputs& in, + std::vector& links, + std::vector& valid); + void fillLinks(unsigned int iclock, + const RegionizerDecodedInputs& in, + std::vector& links, + std::vector& valid); + void fillLinks(unsigned int iclock, + const RegionizerDecodedInputs& in, + std::vector& links, + std::vector& valid); + void fillLinks(unsigned int iclock, + const RegionizerDecodedInputs& in, + std::vector& links, + std::vector& valid); + template + void fillLinks(unsigned int iclock, const RegionizerDecodedInputs& in, std::vector& links) { + std::vector unused; + fillLinks(iclock, in, links, unused); + } + void destream(int iclock, + const std::vector& tk_out, + const std::vector& em_out, + const std::vector& calo_out, + const std::vector& mu_out, + PFInputRegion& out); + + // clock-cycle emulation + bool step(bool newEvent, + const std::vector& links_tk, + const std::vector& links_hadCalo, + const std::vector& links_emCalo, + const std::vector& links_mu, + std::vector& out_tk, + std::vector& out_hadCalo, + std::vector& out_emCalo, + std::vector& out_mu, + bool /*unused*/); + + template + void toFirmware(const std::vector& emu, TFw fw[]) { + for (unsigned int i = 0, n = emu.size(); i < n; ++i) { + fw[i] = emu[i]; + } + } + + void reset(); + + protected: + const unsigned int NTK_SECTORS, NCALO_SECTORS; + const unsigned int NTK_LINKS, HCAL_LINKS, ECAL_LINKS, NMU_LINKS; + unsigned int nclocks_, etabuffer_depth_, ntk_, ncalo_, nem_, nmu_, outii_, pauseii_, nregions_pre_, nregions_post_; + bool streaming_; + bool init_; + unsigned int iclock_; + + multififo_regionizer::Regionizer tkRegionizerPre_, tkRegionizerPost_; + multififo_regionizer::Regionizer hadCaloRegionizerPre_, hadCaloRegionizerPost_; + multififo_regionizer::Regionizer emCaloRegionizerPre_, emCaloRegionizerPost_; + multififo_regionizer::Regionizer muRegionizerPre_, muRegionizerPost_; + std::vector tkRoutes_, caloRoutes_, emCaloRoutes_, muRoutes_; + std::vector> tkBuffers_; + std::vector> hadCaloBuffers_; + std::vector> emCaloBuffers_; + std::vector> muBuffers_; + + template + void fillCaloLinks_(unsigned int iclock, + const std::vector>& in, + std::vector& links, + std::vector& valid); + }; +} // namespace l1ct + +#endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_elements_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_elements_ref.h index 91d36a366a1ae..5212bbd23897a 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_elements_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_elements_ref.h @@ -5,6 +5,7 @@ #include #include +#include #include namespace l1ct { @@ -76,6 +77,64 @@ namespace l1ct { T pop_queue_(std::vector& queue); }; + template + inline bool local_eta_phi_window(const T& t, + const l1ct::glbeta_t& etaMin, + const l1ct::glbeta_t& etaMax, + const l1ct::glbphi_t& phiMin, + const l1ct::glbphi_t& phiMax); + template <> + inline bool local_eta_phi_window(const l1ct::TkObjEmu& t, + const l1ct::glbeta_t& etaMin, + const l1ct::glbeta_t& etaMax, + const l1ct::glbphi_t& phiMin, + const l1ct::glbphi_t& phiMax); + + template + class EtaPhiBuffer { + public: + EtaPhiBuffer() {} + EtaPhiBuffer(unsigned int maxitems, + const l1ct::glbeta_t& etaMin = 0, + const l1ct::glbeta_t& etaMax = 0, + const l1ct::glbeta_t& etaShift = 0, + const l1ct::glbphi_t& phiMin = 0, + const l1ct::glbphi_t& phiMax = 0, + const l1ct::glbphi_t& phiShift = 0) + : size_(maxitems), + iwrite_(0), + iread_(0), + etaMin_(etaMin), + etaMax_(etaMax), + etaShift_(etaShift), + phiMin_(phiMin), + phiMax_(phiMax), + phiShift_(phiShift) {} + void maybe_push(const T& t); + void writeNewEvent() { + iwrite_ = 1 - iwrite_; + items_[iwrite_].clear(); + //std::cout << "Starting to write on " << iwrite_ << " (size " << items_[iwrite_].size() << ", other size " << items_[1-iwrite_].size() << ", reading " << iread_ << ")" << std::endl; + } + void readNewEvent() { + iread_ = 1 - iread_; + //std::cout << "Starting to read on " << iread_ << " (size " << items_[iread_].size() << ", other size " << items_[1-iread_].size() << ", writing " << iwrite_ << ")" << std::endl; + } + T pop(); + unsigned int writeSize() const { return items_[iwrite_].size(); } + unsigned int readSize() const { return items_[iread_].size(); } + unsigned int maxSize() const { return size_; } + void reset(); + + private: + unsigned int size_, iwrite_, iread_; + l1ct::glbeta_t etaMin_, etaMax_; + l1ct::glbeta_t etaShift_; + l1ct::glbphi_t phiMin_, phiMax_; + l1ct::glbphi_t phiShift_; + std::deque items_[2]; + }; + // forward decl for later template class RegionMux; @@ -183,4 +242,57 @@ namespace l1ct { } // namespace multififo_regionizer } // namespace l1ct +template +inline bool l1ct::multififo_regionizer::local_eta_phi_window(const T& t, + const l1ct::glbeta_t& etaMin, + const l1ct::glbeta_t& etaMax, + const l1ct::glbphi_t& phiMin, + const l1ct::glbphi_t& phiMax) { + return (etaMin == etaMax) || + (etaMin <= t.hwEta && t.hwEta <= etaMax && ((phiMin == phiMax) || (phiMin <= t.hwPhi && t.hwPhi <= phiMax))); +} +template <> +inline bool l1ct::multififo_regionizer::local_eta_phi_window(const l1ct::TkObjEmu& t, + const l1ct::glbeta_t& etaMin, + const l1ct::glbeta_t& etaMax, + const l1ct::glbphi_t& phiMin, + const l1ct::glbphi_t& phiMax) { + return (etaMin == etaMax) || + (etaMin <= t.hwEta && t.hwEta <= etaMax && ((phiMin == phiMax) || (phiMin <= t.hwPhi && t.hwPhi <= phiMax))) || + (etaMin <= t.hwVtxEta() && t.hwVtxEta() <= etaMax && + ((phiMin == phiMax) || (phiMin <= t.hwVtxPhi() && t.hwVtxPhi() <= phiMax))); +} +template +void l1ct::multififo_regionizer::EtaPhiBuffer::maybe_push(const T& t) { + if ((t.hwPt != 0) && local_eta_phi_window(t, etaMin_, etaMax_, phiMin_, phiMax_)) { + if (items_[iwrite_].size() < size_) { + items_[iwrite_].push_back(t); + items_[iwrite_].back().hwEta += etaShift_; + items_[iwrite_].back().hwPhi += phiShift_; + } else { + // uncommenting the message below may be useful for debugging + //dbgCout() << "WARNING: sector buffer is full for " << typeid(T).name() << ", pt = " << t.intPt() + // << ", eta = " << t.intEta() << ", phi = " << t.intPhi() << "\n"; + } + } +} + +template +T l1ct::multififo_regionizer::EtaPhiBuffer::pop() { + T ret; + ret.clear(); + if (!items_[iread_].empty()) { + ret = items_[iread_].front(); + items_[iread_].pop_front(); + } + return ret; +} +template +void l1ct::multififo_regionizer::EtaPhiBuffer::reset() { + iread_ = 0; + iwrite_ = 0; + items_[0].clear(); + items_[1].clear(); +} + #endif diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_elements_ref.icc b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_elements_ref.icc index 66b0538ac38fe..a884ed2f91780 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_elements_ref.icc +++ b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_elements_ref.icc @@ -41,6 +41,11 @@ void l1ct::multififo_regionizer::maybe_push(const l1ct::TkObjEmu template void l1ct::multififo_regionizer::RegionBuffer::initFifos(unsigned int nfifos) { assert(nfifos_ == 0); + bool isGood = + (nfifos == 1 || nfifos == 2 || nfifos == 3 || nfifos == 4 || nfifos == 6 || nfifos == 8 || nfifos == 12); + if (!isGood) { + dbgCerr() << "Error, created regionizer for nfifos == " << nfifos << ", not supported." << std::endl; + } nfifos_ = nfifos; fifos_.resize(nfifos); unsigned int nmerged = nfifos; @@ -53,11 +58,6 @@ void l1ct::multififo_regionizer::RegionBuffer::initFifos(unsigned int nfifos) for (auto& t : queues_.back().second) t.clear(); } - bool isGood = - (nfifos == 1 || nfifos == 2 || nfifos == 3 || nfifos == 4 || nfifos == 6 || nfifos == 8 || nfifos == 12); - if (!isGood) { - dbgCerr() << "Error, created regionizer for nfifos == " << nfifos << ", not supported." << std::endl; - } assert(isGood); } diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_ref.h index 554302a38ab54..049a1d216c90a 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_ref.h @@ -34,6 +34,7 @@ namespace l1ct { enum class BarrelSetup { Full54, Full27, Central18, Central9, Phi18, Phi9 }; MultififoRegionizerEmulator(BarrelSetup barrelSetup, + unsigned int ntklinks, unsigned int nHCalLinks, unsigned int nECalLinks, unsigned int nclocks, diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc index a6a77c217fe14..8baa5b066ac8a 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCorrelatorLayer1Producer.cc @@ -28,6 +28,7 @@ #include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/regionizer_base_ref.h" #include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_ref.h" #include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/buffered_folded_multififo_regionizer_ref.h" +#include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h" #include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/tdr_regionizer_ref.h" #include "L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo2hgc_ref.h" #include "L1Trigger/Phase2L1ParticleFlow/interface/pf/pfalgo3_ref.h" @@ -268,6 +269,9 @@ L1TCorrelatorLayer1Producer::L1TCorrelatorLayer1Producer(const edm::ParameterSet const auto &pset = iConfig.getParameter("regionizerAlgoParameters"); regionizer_ = std::make_unique(pset.getParameter("barrelSetup"), pset); + } else if (regalgo == "MiddleBufferMultififo") { + regionizer_ = std::make_unique( + iConfig.getParameter("regionizerAlgoParameters")); } else if (regalgo == "TDR") { regionizer_ = std::make_unique( iConfig.getParameter("regionizerAlgoParameters")); @@ -370,9 +374,11 @@ void L1TCorrelatorLayer1Producer::fillDescriptions(edm::ConfigurationDescription auto bfMultififoRegPD = getParDesc("regionizerAlgo"); auto multififoBarrelRegPD = edm::ParameterDescription( "regionizerAlgoParameters", l1ct::MultififoRegionizerEmulator::getParameterSetDescriptionBarrel(), true); + auto mbMultififoRegPD = getParDesc("regionizerAlgo"); desc.ifValue(edm::ParameterDescription("regionizerAlgo", "Ideal", true), "Ideal" >> idealRegPD or "TDR" >> tdrRegPD or "Multififo" >> multififoRegPD or - "BufferedFoldedMultififo" >> bfMultififoRegPD or "MultififoBarrel" >> multififoBarrelRegPD); + "BufferedFoldedMultififo" >> bfMultififoRegPD or "MultififoBarrel" >> multififoBarrelRegPD or + "MiddleBufferMultififo" >> mbMultififoRegPD); // PF desc.ifValue(edm::ParameterDescription("pfAlgo", "PFAlgo3", true), "PFAlgo3" >> getParDesc("pfAlgo") or diff --git a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/buffered_folded_multififo_regionizer_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/buffered_folded_multififo_regionizer_ref.cpp index 9717416c15b0d..9f1e9ca3f8bcf 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/buffered_folded_multififo_regionizer_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/buffered_folded_multififo_regionizer_ref.cpp @@ -88,16 +88,17 @@ void l1ct::BufferedFoldedMultififoRegionizerEmulator::initSectorsAndRegions(cons l1ct::glbeta_t etaMin, etaMax; findEtaBounds_(fold_[ie].sectors.track[0].region, fold_[ie].regions, etaMin, etaMax); for (unsigned int isec = 0; ntk_ > 0 && isec < NTK_SECTORS; ++isec) { - tkBuffers_[2 * isec + ie] = l1ct::multififo_regionizer::EtaBuffer(nclocks_ / 2, etaMin, etaMax); + tkBuffers_[2 * isec + ie] = + l1ct::multififo_regionizer::EtaPhiBuffer(nclocks_ / 2, etaMin, etaMax); } findEtaBounds_(fold_[ie].sectors.hadcalo[0].region, fold_[ie].regions, etaMin, etaMax); for (unsigned int isec = 0; ncalo_ > 0 && isec < NCALO_SECTORS; ++isec) { caloBuffers_[2 * isec + ie] = - l1ct::multififo_regionizer::EtaBuffer(nclocks_ / 2, etaMin, etaMax); + l1ct::multififo_regionizer::EtaPhiBuffer(nclocks_ / 2, etaMin, etaMax); } findEtaBounds_(fold_[ie].sectors.muon.region, fold_[ie].regions, etaMin, etaMax); if (nmu_ > 0) { - muBuffers_[ie] = l1ct::multififo_regionizer::EtaBuffer(nclocks_ / 2, etaMin, etaMax); + muBuffers_[ie] = l1ct::multififo_regionizer::EtaPhiBuffer(nclocks_ / 2, etaMin, etaMax); } } } diff --git a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/middle_buffer_multififo_regionizer_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/middle_buffer_multififo_regionizer_ref.cpp new file mode 100644 index 0000000000000..219b41ed0abdc --- /dev/null +++ b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/middle_buffer_multififo_regionizer_ref.cpp @@ -0,0 +1,498 @@ +#include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h" +#include "L1Trigger/Phase2L1ParticleFlow/interface/dbgPrintf.h" +#include "L1Trigger/Phase2L1ParticleFlow/interface/regionizer/multififo_regionizer_elements_ref.icc" + +#include +#include +#include + +#ifdef CMSSW_GIT_HASH +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/ParameterSet/interface/allowedValues.h" + +l1ct::MiddleBufferMultififoRegionizerEmulator::MiddleBufferMultififoRegionizerEmulator(const edm::ParameterSet& iConfig) + : MiddleBufferMultififoRegionizerEmulator(iConfig.getParameter("nClocks"), + iConfig.getParameter("etaBufferDepth"), + iConfig.getParameter("nTkLinks"), + iConfig.getParameter("nHCalLinks"), + iConfig.getParameter("nECalLinks"), + iConfig.getParameter("nTrack"), + iConfig.getParameter("nCalo"), + iConfig.getParameter("nEmCalo"), + iConfig.getParameter("nMu"), + /*streaming=*/true, + /*outii=*/2, + /*pauseii=*/1, + iConfig.getParameter("useAlsoVtxCoords")) { + debug_ = iConfig.getUntrackedParameter("debug", false); +} + +edm::ParameterSetDescription l1ct::MiddleBufferMultififoRegionizerEmulator::getParameterSetDescription() { + edm::ParameterSetDescription description; + description.add("nClocks", 162); + description.add("etaBufferDepth", 54); + description.add("nTkLinks", 1); + description.add("nHCalLinks", 1); + description.add("nECalLinks", 1); + description.add("nTrack", 22); + description.add("nCalo", 15); + description.add("nEmCalo", 12); + description.add("nMu", 2); + description.add("useAlsoVtxCoords", true); + description.addUntracked("debug", false); + return description; +} + +#endif + +l1ct::MiddleBufferMultififoRegionizerEmulator::MiddleBufferMultififoRegionizerEmulator(unsigned int nclocks, + unsigned int etabufferDepth, + unsigned int ntklinks, + unsigned int nHCalLinks, + unsigned int nECalLinks, + unsigned int ntk, + unsigned int ncalo, + unsigned int nem, + unsigned int nmu, + bool streaming, + unsigned int outii, + unsigned int pauseii, + bool useAlsoVtxCoords) + : RegionizerEmulator(useAlsoVtxCoords), + NTK_SECTORS(9), + NCALO_SECTORS(3), + NTK_LINKS(ntklinks), + HCAL_LINKS(nHCalLinks), + ECAL_LINKS(nECalLinks), + NMU_LINKS(1), + nclocks_(nclocks), + etabuffer_depth_(etabufferDepth), + ntk_(ntk), + ncalo_(ncalo), + nem_(nem), + nmu_(nmu), + outii_(outii), + pauseii_(pauseii), + nregions_pre_(27), + nregions_post_(54), + streaming_(streaming), + init_(false), + iclock_(0), + tkRegionizerPre_(ntk, ntk, false, outii, pauseii, useAlsoVtxCoords), + tkRegionizerPost_(ntk, (ntk + outii - 1) / outii, true, outii, pauseii, useAlsoVtxCoords), + hadCaloRegionizerPre_(ncalo, ncalo, false, outii, pauseii), + hadCaloRegionizerPost_(ncalo, (ncalo + outii - 1) / outii, true, outii, pauseii), + emCaloRegionizerPre_(nem, nem, false, outii, pauseii), + emCaloRegionizerPost_(nem, (nem + outii - 1) / outii, true, outii, pauseii), + muRegionizerPre_(nmu, nmu, false, outii, pauseii), + muRegionizerPost_(nmu, std::max(1u, (nmu + outii - 1) / outii), true, outii, pauseii), + tkBuffers_(ntk ? nregions_post_ : 0), + hadCaloBuffers_(ncalo ? nregions_post_ : 0), + emCaloBuffers_(nem ? nregions_post_ : 0), + muBuffers_(nmu ? nregions_post_ : 0) { + unsigned int phisectors = 9, etaslices = 3; + for (unsigned int ietaslice = 0; ietaslice < etaslices && ntk > 0; ++ietaslice) { + for (unsigned int ie = 0; ie < 2; ++ie) { // 0 = negative, 1 = positive + unsigned int nTFEtaSlices = ietaslice == 1 ? 2 : 1; + if ((ietaslice == 0 && ie == 1) || (ietaslice == 2 && ie == 0)) + continue; + unsigned int ireg0 = phisectors * ietaslice, il0 = 3 * NTK_LINKS * (nTFEtaSlices - 1) * ie; + for (unsigned int is = 0; is < NTK_SECTORS; ++is) { // 9 tf sectors + for (unsigned int il = 0; il < NTK_LINKS; ++il) { // max tracks per sector per clock + unsigned int isp = (is + 1) % NTK_SECTORS, ism = (is + NTK_SECTORS - 1) % NTK_SECTORS; + tkRoutes_.emplace_back(is + NTK_SECTORS * ie, il, is + ireg0, il0 + il); + tkRoutes_.emplace_back(is + NTK_SECTORS * ie, il, isp + ireg0, il0 + il + NTK_LINKS); + tkRoutes_.emplace_back(is + NTK_SECTORS * ie, il, ism + ireg0, il0 + il + 2 * NTK_LINKS); + } + } + } + } + // calo + for (unsigned int ie = 0; ie < etaslices; ++ie) { + for (unsigned int is = 0; is < NCALO_SECTORS; ++is) { // NCALO_SECTORS sectors + for (unsigned int j = 0; j < 3; ++j) { // 3 regions x sector + for (unsigned int il = 0; il < HCAL_LINKS; ++il) { + caloRoutes_.emplace_back(is, il, 3 * is + j + phisectors * ie, il); + if (j) { + caloRoutes_.emplace_back((is + 1) % 3, il, 3 * is + j + phisectors * ie, il + HCAL_LINKS); + } + } + for (unsigned int il = 0; il < ECAL_LINKS; ++il) { + emCaloRoutes_.emplace_back(is, il, 3 * is + j + phisectors * ie, il); + if (j) { + emCaloRoutes_.emplace_back((is + 1) % 3, il, 3 * is + j + phisectors * ie, il + ECAL_LINKS); + } + } + } + } + } + // mu + for (unsigned int il = 0; il < NMU_LINKS && nmu > 0; ++il) { + for (unsigned int j = 0; j < nregions_pre_; ++j) { + muRoutes_.emplace_back(0, il, j, il); + } + } +} + +l1ct::MiddleBufferMultififoRegionizerEmulator::~MiddleBufferMultififoRegionizerEmulator() {} + +void l1ct::MiddleBufferMultififoRegionizerEmulator::initSectorsAndRegions(const RegionizerDecodedInputs& in, + const std::vector& out) { + assert(!init_); + init_ = true; + assert(out.size() == nregions_post_); + + std::vector mergedRegions; + unsigned int neta = 3, nphi = 9; + for (unsigned int ieta = 0; ieta < neta; ++ieta) { + for (unsigned int iphi = 0; iphi < nphi; ++iphi) { + const PFRegionEmu& reg0 = out[(2 * ieta + 0) * nphi + iphi].region; + const PFRegionEmu& reg1 = out[(2 * ieta + 1) * nphi + iphi].region; + assert(reg0.hwPhiCenter == reg1.hwPhiCenter); + mergedRegions.emplace_back(reg0.floatEtaMin(), + reg1.floatEtaMax(), + reg0.floatPhiCenter(), + reg0.floatPhiHalfWidth() * 2, + reg0.floatEtaExtra(), + reg0.floatPhiExtra()); + if (debug_) { + dbgCout() << "Created region with etaCenter " << mergedRegions.back().region.hwEtaCenter.to_int() + << ", halfWidth " << mergedRegions.back().region.hwEtaHalfWidth.to_int() << "\n"; + } + for (int i = 0; i < 2; ++i) { + unsigned int iout = (2 * ieta + i) * nphi + iphi; + const l1ct::PFRegionEmu& from = mergedRegions.back().region; + const l1ct::PFRegionEmu& to = out[iout].region; + l1ct::glbeta_t etaMin = to.hwEtaCenter - to.hwEtaHalfWidth - to.hwEtaExtra - from.hwEtaCenter; + l1ct::glbeta_t etaMax = to.hwEtaCenter + to.hwEtaHalfWidth + to.hwEtaExtra - from.hwEtaCenter; + l1ct::glbeta_t etaShift = from.hwEtaCenter - to.hwEtaCenter; + l1ct::glbphi_t phiMin = -to.hwPhiHalfWidth - to.hwPhiExtra; + l1ct::glbphi_t phiMax = +to.hwPhiHalfWidth + to.hwPhiExtra; + l1ct::glbphi_t phiShift = 0; + if (ntk_ > 0) + tkBuffers_[iout] = l1ct::multififo_regionizer::EtaPhiBuffer( + etabuffer_depth_, etaMin, etaMax, etaShift, phiMin, phiMax, phiShift); + if (ncalo_ > 0) + hadCaloBuffers_[iout] = l1ct::multififo_regionizer::EtaPhiBuffer( + etabuffer_depth_, etaMin, etaMax, etaShift, phiMin, phiMax, phiShift); + if (nem_ > 0) + emCaloBuffers_[iout] = l1ct::multififo_regionizer::EtaPhiBuffer( + etabuffer_depth_, etaMin, etaMax, etaShift, phiMin, phiMax, phiShift); + if (nmu_ > 0) + muBuffers_[iout] = l1ct::multififo_regionizer::EtaPhiBuffer( + etabuffer_depth_, etaMin, etaMax, etaShift, phiMin, phiMax, phiShift); + } + } + } + if (ntk_) { + assert(in.track.size() == 2 * NTK_SECTORS); + tkRegionizerPre_.initSectors(in.track); + tkRegionizerPre_.initRegions(mergedRegions); + tkRegionizerPre_.initRouting(tkRoutes_); + tkRegionizerPost_.initRegions(out); + } + if (ncalo_) { + assert(in.hadcalo.size() == NCALO_SECTORS); + hadCaloRegionizerPre_.initSectors(in.hadcalo); + hadCaloRegionizerPre_.initRegions(mergedRegions); + hadCaloRegionizerPre_.initRouting(caloRoutes_); + hadCaloRegionizerPost_.initRegions(out); + } + if (nem_) { + assert(in.emcalo.size() == NCALO_SECTORS); + emCaloRegionizerPre_.initSectors(in.emcalo); + emCaloRegionizerPre_.initRegions(mergedRegions); + emCaloRegionizerPre_.initRouting(emCaloRoutes_); + emCaloRegionizerPost_.initRegions(out); + } + if (nmu_) { + muRegionizerPre_.initSectors(in.muon); + muRegionizerPre_.initRegions(mergedRegions); + muRegionizerPre_.initRouting(muRoutes_); + muRegionizerPost_.initRegions(out); + } +} + +bool l1ct::MiddleBufferMultififoRegionizerEmulator::step(bool newEvent, + const std::vector& links_tk, + const std::vector& links_hadCalo, + const std::vector& links_emCalo, + const std::vector& links_mu, + std::vector& out_tk, + std::vector& out_hadCalo, + std::vector& out_emCalo, + std::vector& out_mu, + bool /*unused*/) { + iclock_ = (newEvent ? 0 : iclock_ + 1); + bool newRead = iclock_ == 2 * etabuffer_depth_; + + std::vector pre_out_tk; + std::vector pre_out_hadCalo; + std::vector pre_out_emCalo; + std::vector pre_out_mu; + bool ret = false; + if (ntk_) + ret = tkRegionizerPre_.step(newEvent, links_tk, pre_out_tk, false); + if (nmu_) + ret = muRegionizerPre_.step(newEvent, links_mu, pre_out_mu, false); + if (ncalo_) + ret = hadCaloRegionizerPre_.step(newEvent, links_hadCalo, pre_out_hadCalo, false); + if (nem_) + ret = emCaloRegionizerPre_.step(newEvent, links_emCalo, pre_out_emCalo, false); + + // in the no-streaming case, we just output the pre-regionizer + if (!streaming_) { + out_tk.swap(pre_out_tk); + out_mu.swap(pre_out_mu); + out_hadCalo.swap(pre_out_hadCalo); + out_emCalo.swap(pre_out_emCalo); + return ret; + } + + // otherwise, we push into the eta buffers + if (newEvent) { + for (auto& b : tkBuffers_) + b.writeNewEvent(); + for (auto& b : hadCaloBuffers_) + b.writeNewEvent(); + for (auto& b : emCaloBuffers_) + b.writeNewEvent(); + for (auto& b : muBuffers_) + b.writeNewEvent(); + } + unsigned int neta = 3, nphi = 9; + for (unsigned int ieta = 0; ieta < neta; ++ieta) { + for (unsigned int iphi = 0; iphi < nphi; ++iphi) { + unsigned int iin = ieta * nphi + iphi; + //if (ieta == 0 && iphi == 0 && pre_out_tk[iin].hwPt != 0) std::cout << "iclock " << iclock_ << ", pre_out_tk[" << iin << "] = " << pre_out_tk[iin].pack().to_string(16) << std::endl; + for (int i = 0; i < 2; ++i) { + unsigned int iout = (2 * ieta + i) * nphi + iphi; + if (ntk_) + tkBuffers_[iout].maybe_push(pre_out_tk[iin]); + if (ncalo_) + hadCaloBuffers_[iout].maybe_push(pre_out_hadCalo[iin]); + if (nem_) + emCaloBuffers_[iout].maybe_push(pre_out_emCalo[iin]); + if (nmu_) + muBuffers_[iout].maybe_push(pre_out_mu[iin]); + } + } + } + + // and we read from eta buffers into muxes + if (newRead) { + for (auto& b : tkBuffers_) + b.readNewEvent(); + for (auto& b : hadCaloBuffers_) + b.readNewEvent(); + for (auto& b : emCaloBuffers_) + b.readNewEvent(); + for (auto& b : muBuffers_) + b.readNewEvent(); + } + std::vector bufferOut_tk(ntk_ ? nregions_post_ : 0); + std::vector bufferOut_hadCalo(ncalo_ ? nregions_post_ : 0); + std::vector bufferOut_emCalo(nem_ ? nregions_post_ : 0); + std::vector bufferOut_mu(nmu_ ? nregions_post_ : 0); + for (unsigned int i = 0; i < nregions_post_; ++i) { + if (ntk_) + bufferOut_tk[i] = tkBuffers_[i].pop(); + if (ncalo_) + bufferOut_hadCalo[i] = hadCaloBuffers_[i].pop(); + if (nem_) + bufferOut_emCalo[i] = emCaloBuffers_[i].pop(); + if (nmu_) + bufferOut_mu[i] = muBuffers_[i].pop(); + } + if (ntk_) + tkRegionizerPost_.muxonly_step(newEvent, /*flush=*/true, bufferOut_tk, out_tk); + if (ncalo_) + hadCaloRegionizerPost_.muxonly_step(newEvent, /*flush=*/true, bufferOut_hadCalo, out_hadCalo); + if (nem_) + emCaloRegionizerPost_.muxonly_step(newEvent, /*flush=*/true, bufferOut_emCalo, out_emCalo); + if (nmu_) + muRegionizerPost_.muxonly_step(newEvent, /*flush=*/true, bufferOut_mu, out_mu); + + return newRead; +} + +void l1ct::MiddleBufferMultififoRegionizerEmulator::fillLinks(unsigned int iclock, + const l1ct::RegionizerDecodedInputs& in, + std::vector& links, + std::vector& valid) { + if (ntk_ == 0) + return; + assert(NTK_LINKS == 1); + links.resize(NTK_SECTORS * NTK_LINKS * 2); + valid.resize(links.size()); + // emulate reduced rate from 96b tracks on 64b links + unsigned int itkclock = 2 * (iclock / 3) + (iclock % 3) - 1; // will underflow for iclock == 0 but it doesn't matter + for (unsigned int is = 0, idx = 0; is < 2 * NTK_SECTORS; ++is, ++idx) { // tf sectors + const l1ct::DetectorSector& sec = in.track[is]; + unsigned int ntracks = sec.size(); + unsigned int nw64 = (ntracks * 3 + 1) / 2; + if (iclock % 3 == 0) { + links[idx].clear(); + valid[idx] = (iclock == 0) || (iclock < nw64); + } else if (itkclock < ntracks && itkclock < nclocks_ - 1) { + links[idx] = sec[itkclock]; + valid[idx] = true; + } else { + links[idx].clear(); + valid[idx] = false; + } + } +} + +template +void l1ct::MiddleBufferMultififoRegionizerEmulator::fillCaloLinks_(unsigned int iclock, + const std::vector>& in, + std::vector& links, + std::vector& valid) { + unsigned int NLINKS = (typeid(T) == typeid(l1ct::HadCaloObjEmu) ? HCAL_LINKS : ECAL_LINKS); + links.resize(NCALO_SECTORS * NLINKS); + valid.resize(links.size()); + for (unsigned int is = 0, idx = 0; is < NCALO_SECTORS; ++is) { + for (unsigned int il = 0; il < NLINKS; ++il, ++idx) { + unsigned int ioffs = iclock * NLINKS + il; + if (ioffs < in[is].size() && iclock < nclocks_ - 1) { + links[idx] = in[is][ioffs]; + valid[idx] = true; + } else { + links[idx].clear(); + valid[idx] = false; + } + } + } +} + +void l1ct::MiddleBufferMultififoRegionizerEmulator::fillLinks(unsigned int iclock, + const l1ct::RegionizerDecodedInputs& in, + std::vector& links, + std::vector& valid) { + if (ncalo_ == 0) + return; + fillCaloLinks_(iclock, in.hadcalo, links, valid); +} + +void l1ct::MiddleBufferMultififoRegionizerEmulator::fillLinks(unsigned int iclock, + const l1ct::RegionizerDecodedInputs& in, + std::vector& links, + std::vector& valid) { + if (nem_ == 0) + return; + fillCaloLinks_(iclock, in.emcalo, links, valid); +} + +void l1ct::MiddleBufferMultififoRegionizerEmulator::fillLinks(unsigned int iclock, + const l1ct::RegionizerDecodedInputs& in, + std::vector& links, + std::vector& valid) { + if (nmu_ == 0) + return; + assert(NMU_LINKS == 1); + links.resize(NMU_LINKS); + valid.resize(links.size()); + if (iclock < in.muon.size() && iclock < nclocks_ - 1) { + links[0] = in.muon[iclock]; + valid[0] = true; + } else { + links[0].clear(); + valid[0] = false; + } +} + +void l1ct::MiddleBufferMultififoRegionizerEmulator::destream(int iclock, + const std::vector& tk_out, + const std::vector& em_out, + const std::vector& calo_out, + const std::vector& mu_out, + PFInputRegion& out) { + if (ntk_) + tkRegionizerPost_.destream(iclock, tk_out, out.track); + if (ncalo_) + hadCaloRegionizerPost_.destream(iclock, calo_out, out.hadcalo); + if (nem_) + emCaloRegionizerPost_.destream(iclock, em_out, out.emcalo); + if (nmu_) + muRegionizerPost_.destream(iclock, mu_out, out.muon); +} + +void l1ct::MiddleBufferMultififoRegionizerEmulator::reset() { + tkRegionizerPre_.reset(); + emCaloRegionizerPre_.reset(); + hadCaloRegionizerPre_.reset(); + muRegionizerPre_.reset(); + tkRegionizerPost_.reset(); + emCaloRegionizerPost_.reset(); + hadCaloRegionizerPost_.reset(); + muRegionizerPost_.reset(); + for (auto& b : tkBuffers_) + b.reset(); + for (auto& b : hadCaloBuffers_) + b.reset(); + for (auto& b : emCaloBuffers_) + b.reset(); + for (auto& b : muBuffers_) + b.reset(); +} + +void l1ct::MiddleBufferMultififoRegionizerEmulator::run(const RegionizerDecodedInputs& in, + std::vector& out) { + assert(streaming_); // doesn't make sense otherwise + if (!init_) + initSectorsAndRegions(in, out); + reset(); + std::vector tk_links_in, tk_out; + std::vector em_links_in, em_out; + std::vector calo_links_in, calo_out; + std::vector mu_links_in, mu_out; + + // read and sort the inputs + for (unsigned int iclock = 0; iclock < nclocks_; ++iclock) { + fillLinks(iclock, in, tk_links_in); + fillLinks(iclock, in, em_links_in); + fillLinks(iclock, in, calo_links_in); + fillLinks(iclock, in, mu_links_in); + + bool newevt = (iclock == 0); + step(newevt, tk_links_in, calo_links_in, em_links_in, mu_links_in, tk_out, calo_out, em_out, mu_out, true); + } + + // set up an empty event + for (auto& l : tk_links_in) + l.clear(); + for (auto& l : em_links_in) + l.clear(); + for (auto& l : calo_links_in) + l.clear(); + for (auto& l : mu_links_in) + l.clear(); + + // read and put the inputs in the regions + assert(out.size() == nregions_post_); + for (unsigned int iclock = 0; iclock < nclocks_; ++iclock) { + bool newevt = (iclock == 0); + step(newevt, tk_links_in, calo_links_in, em_links_in, mu_links_in, tk_out, calo_out, em_out, mu_out, true); + + unsigned int ireg = (iclock / (outii_ + pauseii_)); + if ((iclock % (outii_ + pauseii_)) >= outii_) + continue; + if (ireg >= nregions_post_) + break; + + if (streaming_) { + destream(iclock, tk_out, em_out, calo_out, mu_out, out[ireg]); + } else { + if (iclock % outii_ == 0) { + out[ireg].track = tk_out; + out[ireg].emcalo = em_out; + out[ireg].hadcalo = calo_out; + out[ireg].muon = mu_out; + } + } + } + + reset(); +} diff --git a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/multififo_regionizer_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/multififo_regionizer_ref.cpp index 7b2de76db7e47..90d3b7a0d3480 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/multififo_regionizer_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/multififo_regionizer_ref.cpp @@ -34,6 +34,7 @@ l1ct::MultififoRegionizerEmulator::MultififoRegionizerEmulator(const edm::Parame l1ct::MultififoRegionizerEmulator::MultififoRegionizerEmulator(const std::string& barrelSetup, const edm::ParameterSet& iConfig) : MultififoRegionizerEmulator(parseBarrelSetup(barrelSetup), + iConfig.getParameter("nTkLinks"), iConfig.getParameter("nHCalLinks"), iConfig.getParameter("nECalLinks"), iConfig.getParameter("nClocks"), @@ -71,6 +72,7 @@ edm::ParameterSetDescription l1ct::MultififoRegionizerEmulator::getParameterSetD description.ifValue(edm::ParameterDescription("barrelSetup", "Full54", true), edm::allowedValues("Full54", "Full27")); description.add("nClocks", 54); + description.add("nTkLinks", 2); description.add("nHCalLinks", 2); description.add("nECalLinks", 1); description.add("nTrack", 22); @@ -154,6 +156,7 @@ l1ct::MultififoRegionizerEmulator::MultififoRegionizerEmulator(unsigned int nend } l1ct::MultififoRegionizerEmulator::MultififoRegionizerEmulator(BarrelSetup barrelSetup, + unsigned int ntklinks, unsigned int nHCalLinks, unsigned int nECalLinks, unsigned int nclocks, @@ -168,7 +171,7 @@ l1ct::MultififoRegionizerEmulator::MultififoRegionizerEmulator(BarrelSetup barre : RegionizerEmulator(useAlsoVtxCoords), NTK_SECTORS((barrelSetup == BarrelSetup::Phi18 || barrelSetup == BarrelSetup::Phi9) ? 5 : 9), NCALO_SECTORS((barrelSetup == BarrelSetup::Phi18 || barrelSetup == BarrelSetup::Phi9) ? 2 : 3), - NTK_LINKS(2), + NTK_LINKS(ntklinks), NCALO_LINKS(2), HCAL_LINKS(nHCalLinks), ECAL_LINKS(nECalLinks), @@ -237,13 +240,13 @@ l1ct::MultififoRegionizerEmulator::MultififoRegionizerEmulator(BarrelSetup barre } else if (barrelSetup == BarrelSetup::Central18 || barrelSetup == BarrelSetup::Central9) { nTFEtaSlices = 2; } - unsigned int ireg0 = phisectors * ietaslice, il0 = 6 * (nTFEtaSlices - 1) * ie; + unsigned int ireg0 = phisectors * ietaslice, il0 = 3 * NTK_LINKS * (nTFEtaSlices - 1) * ie; if (barrelSetup == BarrelSetup::Phi18 || barrelSetup == BarrelSetup::Phi9) { for (unsigned int iregphi = 0; iregphi < (nregions_ / etaslices); ++iregphi) { for (unsigned int il = 0; il < NTK_LINKS; ++il) { tkRoutes_.emplace_back((iregphi + 1) + NTK_SECTORS * ie, il, iregphi + ireg0, il0 + il); - tkRoutes_.emplace_back((iregphi + 0) + NTK_SECTORS * ie, il, iregphi + ireg0, il0 + il + 2); - tkRoutes_.emplace_back((iregphi + 2) + NTK_SECTORS * ie, il, iregphi + ireg0, il0 + il + 4); + tkRoutes_.emplace_back((iregphi + 0) + NTK_SECTORS * ie, il, iregphi + ireg0, il0 + il + NTK_LINKS); + tkRoutes_.emplace_back((iregphi + 2) + NTK_SECTORS * ie, il, iregphi + ireg0, il0 + il + 2 * NTK_LINKS); } } } else { @@ -251,8 +254,8 @@ l1ct::MultififoRegionizerEmulator::MultififoRegionizerEmulator(BarrelSetup barre for (unsigned int il = 0; il < NTK_LINKS; ++il) { // max tracks per sector per clock unsigned int isp = (is + 1) % NTK_SECTORS, ism = (is + NTK_SECTORS - 1) % NTK_SECTORS; tkRoutes_.emplace_back(is + NTK_SECTORS * ie, il, is + ireg0, il0 + il); - tkRoutes_.emplace_back(is + NTK_SECTORS * ie, il, isp + ireg0, il0 + il + 2); - tkRoutes_.emplace_back(is + NTK_SECTORS * ie, il, ism + ireg0, il0 + il + 4); + tkRoutes_.emplace_back(is + NTK_SECTORS * ie, il, isp + ireg0, il0 + il + NTK_LINKS); + tkRoutes_.emplace_back(is + NTK_SECTORS * ie, il, ism + ireg0, il0 + il + 2 * NTK_LINKS); } } } diff --git a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/tdr_regionizer_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/tdr_regionizer_ref.cpp index 79616c2753888..5d9d635dc8b02 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/tdr_regionizer_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/tdr_regionizer_ref.cpp @@ -75,9 +75,11 @@ void l1ct::TDRRegionizerEmulator::initSectorsAndRegions(const RegionizerDecodedI netaInBR_, nphiInBR_, nmu_, bigRegionEdges_[i], bigRegionEdges_[i + 1], nclocks_, 1, false); } - dbgCout() << "in.track.size() = " << in.track.size() << std::endl; - dbgCout() << "in.hadcalo.size() = " << in.hadcalo.size() << std::endl; - dbgCout() << "in.emcalo.size() = " << in.emcalo.size() << std::endl; + if (debug_) { + dbgCout() << "in.track.size() = " << in.track.size() << std::endl; + dbgCout() << "in.hadcalo.size() = " << in.hadcalo.size() << std::endl; + dbgCout() << "in.emcalo.size() = " << in.emcalo.size() << std::endl; + } if (ntk_) { for (unsigned int i = 0; i < nBigRegions_; i++) { diff --git a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py index a778a86ffb84a..c6c0e54794bce 100644 --- a/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py +++ b/L1Trigger/Phase2L1ParticleFlow/test/make_l1ct_binaryFiles_cfg.py @@ -173,13 +173,24 @@ del process.l1tLayer1HGCalNoTKTM18.regionizerAlgoParameters.nEndcaps del process.l1tLayer1HGCalNoTKTM18.regionizerAlgoParameters.nTkLinks del process.l1tLayer1HGCalNoTKTM18.regionizerAlgoParameters.nCaloLinks + process.l1tLayer1BarrelSerenityTM18 = process.l1tLayer1BarrelSerenity.clone() + process.l1tLayer1BarrelSerenityTM18.regionizerAlgo = "MiddleBufferMultififo" + process.l1tLayer1BarrelSerenityTM18.regionizerAlgoParameters = cms.PSet( + nTrack = process.l1tLayer1BarrelSerenity.regionizerAlgoParameters.nTrack, + nCalo = process.l1tLayer1BarrelSerenity.regionizerAlgoParameters.nCalo, + nEmCalo = process.l1tLayer1BarrelSerenity.regionizerAlgoParameters.nEmCalo, + nMu = process.l1tLayer1BarrelSerenity.regionizerAlgoParameters.nMu, + ) + process.l1tLayer1BarrelSerenityTM18.boards = cms.VPSet(*[cms.PSet(regions = cms.vuint32(*range(18*i,18*i+18))) for i in range(3)]) process.runPF.insert(process.runPF.index(process.l1tLayer1HGCal)+1, process.l1tLayer1HGCalTM18) process.runPF.insert(process.runPF.index(process.l1tLayer1HGCalNoTK)+1, process.l1tLayer1HGCalNoTKTM18) + process.runPF.insert(process.runPF.index(process.l1tLayer1BarrelSerenity)+1, process.l1tLayer1BarrelSerenityTM18) if not args.patternFilesOFF: process.l1tLayer1HGCalTM18.patternWriters = cms.untracked.VPSet(*hgcalTM18WriterConfigs) process.l1tLayer1HGCalNoTKTM18.patternWriters = cms.untracked.VPSet(hgcalNoTKOutputTM18WriterConfig) + process.l1tLayer1BarrelSerenityTM18.patternWriters = cms.untracked.VPSet() if not args.dumpFilesOFF: - for det in "HGCalTM18", "HGCalNoTKTM18": + for det in "HGCalTM18", "HGCalNoTKTM18", "BarrelSerenityTM18": getattr(process, 'l1tLayer1'+det).dumpFileName = cms.untracked.string("TTbar_PU200_"+det+".dump") process.source.fileNames = [ '/store/cmst3/group/l1tr/gpetrucc/12_5_X/NewInputs125X/150223/TTbar_PU200/inputs125X_1.root' ] From a4e76a75b81be577efdc5438623092c7f563a306 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 13 Nov 2023 09:21:59 +0100 Subject: [PATCH 4/6] 27-buffer version of barrel regionizer --- .../middle_buffer_multififo_regionizer_ref.h | 6 +- ...middle_buffer_multififo_regionizer_ref.cpp | 128 +++++++++++++----- 2 files changed, 99 insertions(+), 35 deletions(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h index 7f9685c119143..5ffcdbc738649 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h @@ -10,6 +10,7 @@ namespace l1ct { class MiddleBufferMultififoRegionizerEmulator : public RegionizerEmulator { public: MiddleBufferMultififoRegionizerEmulator(unsigned int nclocks, + unsigned int nbuffers, unsigned int etabufferDepth, unsigned int ntklinks, unsigned int nHCalLinks, @@ -86,11 +87,12 @@ namespace l1ct { protected: const unsigned int NTK_SECTORS, NCALO_SECTORS; const unsigned int NTK_LINKS, HCAL_LINKS, ECAL_LINKS, NMU_LINKS; - unsigned int nclocks_, etabuffer_depth_, ntk_, ncalo_, nem_, nmu_, outii_, pauseii_, nregions_pre_, nregions_post_; + unsigned int nclocks_, nbuffers_, etabuffer_depth_, ntk_, ncalo_, nem_, nmu_, outii_, pauseii_, nregions_pre_, + nregions_post_; bool streaming_; bool init_; unsigned int iclock_; - + std::vector mergedRegions_, outputRegions_; multififo_regionizer::Regionizer tkRegionizerPre_, tkRegionizerPost_; multififo_regionizer::Regionizer hadCaloRegionizerPre_, hadCaloRegionizerPost_; multififo_regionizer::Regionizer emCaloRegionizerPre_, emCaloRegionizerPost_; diff --git a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/middle_buffer_multififo_regionizer_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/middle_buffer_multififo_regionizer_ref.cpp index 219b41ed0abdc..94cc9579b7594 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/middle_buffer_multififo_regionizer_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/middle_buffer_multififo_regionizer_ref.cpp @@ -13,6 +13,7 @@ l1ct::MiddleBufferMultififoRegionizerEmulator::MiddleBufferMultififoRegionizerEmulator(const edm::ParameterSet& iConfig) : MiddleBufferMultififoRegionizerEmulator(iConfig.getParameter("nClocks"), + iConfig.getParameter("nBuffers"), iConfig.getParameter("etaBufferDepth"), iConfig.getParameter("nTkLinks"), iConfig.getParameter("nHCalLinks"), @@ -31,6 +32,7 @@ l1ct::MiddleBufferMultififoRegionizerEmulator::MiddleBufferMultififoRegionizerEm edm::ParameterSetDescription l1ct::MiddleBufferMultififoRegionizerEmulator::getParameterSetDescription() { edm::ParameterSetDescription description; description.add("nClocks", 162); + description.add("nBuffers", 54); description.add("etaBufferDepth", 54); description.add("nTkLinks", 1); description.add("nHCalLinks", 1); @@ -47,6 +49,7 @@ edm::ParameterSetDescription l1ct::MiddleBufferMultififoRegionizerEmulator::getP #endif l1ct::MiddleBufferMultififoRegionizerEmulator::MiddleBufferMultififoRegionizerEmulator(unsigned int nclocks, + unsigned int nbuffers, unsigned int etabufferDepth, unsigned int ntklinks, unsigned int nHCalLinks, @@ -67,6 +70,7 @@ l1ct::MiddleBufferMultififoRegionizerEmulator::MiddleBufferMultififoRegionizerEm ECAL_LINKS(nECalLinks), NMU_LINKS(1), nclocks_(nclocks), + nbuffers_(nbuffers), etabuffer_depth_(etabufferDepth), ntk_(ntk), ncalo_(ncalo), @@ -87,10 +91,11 @@ l1ct::MiddleBufferMultififoRegionizerEmulator::MiddleBufferMultififoRegionizerEm emCaloRegionizerPost_(nem, (nem + outii - 1) / outii, true, outii, pauseii), muRegionizerPre_(nmu, nmu, false, outii, pauseii), muRegionizerPost_(nmu, std::max(1u, (nmu + outii - 1) / outii), true, outii, pauseii), - tkBuffers_(ntk ? nregions_post_ : 0), - hadCaloBuffers_(ncalo ? nregions_post_ : 0), - emCaloBuffers_(nem ? nregions_post_ : 0), - muBuffers_(nmu ? nregions_post_ : 0) { + tkBuffers_(ntk ? nbuffers_ : 0), + hadCaloBuffers_(ncalo ? nbuffers_ : 0), + emCaloBuffers_(nem ? nbuffers_ : 0), + muBuffers_(nmu ? nbuffers_ : 0) { + assert(nbuffers_ == nregions_post_ || nbuffers_ == nregions_pre_); unsigned int phisectors = 9, etaslices = 3; for (unsigned int ietaslice = 0; ietaslice < etaslices && ntk > 0; ++ietaslice) { for (unsigned int ie = 0; ie < 2; ++ie) { // 0 = negative, 1 = positive @@ -145,6 +150,9 @@ void l1ct::MiddleBufferMultififoRegionizerEmulator::initSectorsAndRegions(const std::vector mergedRegions; unsigned int neta = 3, nphi = 9; + mergedRegions.reserve(nregions_pre_); + mergedRegions_.reserve(nregions_pre_); + outputRegions_.reserve(nregions_post_); for (unsigned int ieta = 0; ieta < neta; ++ieta) { for (unsigned int iphi = 0; iphi < nphi; ++iphi) { const PFRegionEmu& reg0 = out[(2 * ieta + 0) * nphi + iphi].region; @@ -156,32 +164,47 @@ void l1ct::MiddleBufferMultififoRegionizerEmulator::initSectorsAndRegions(const reg0.floatPhiHalfWidth() * 2, reg0.floatEtaExtra(), reg0.floatPhiExtra()); + mergedRegions_.push_back(mergedRegions.back().region); + outputRegions_.push_back(reg0); + outputRegions_.push_back(reg1); if (debug_) { dbgCout() << "Created region with etaCenter " << mergedRegions.back().region.hwEtaCenter.to_int() << ", halfWidth " << mergedRegions.back().region.hwEtaHalfWidth.to_int() << "\n"; } - for (int i = 0; i < 2; ++i) { - unsigned int iout = (2 * ieta + i) * nphi + iphi; - const l1ct::PFRegionEmu& from = mergedRegions.back().region; - const l1ct::PFRegionEmu& to = out[iout].region; - l1ct::glbeta_t etaMin = to.hwEtaCenter - to.hwEtaHalfWidth - to.hwEtaExtra - from.hwEtaCenter; - l1ct::glbeta_t etaMax = to.hwEtaCenter + to.hwEtaHalfWidth + to.hwEtaExtra - from.hwEtaCenter; - l1ct::glbeta_t etaShift = from.hwEtaCenter - to.hwEtaCenter; - l1ct::glbphi_t phiMin = -to.hwPhiHalfWidth - to.hwPhiExtra; - l1ct::glbphi_t phiMax = +to.hwPhiHalfWidth + to.hwPhiExtra; - l1ct::glbphi_t phiShift = 0; + if (nbuffers_ == nregions_post_) { + for (int i = 0; i < 2; ++i) { + unsigned int iout = (2 * ieta + i) * nphi + iphi; + const l1ct::PFRegionEmu& from = mergedRegions.back().region; + const l1ct::PFRegionEmu& to = out[iout].region; + l1ct::glbeta_t etaMin = to.hwEtaCenter - to.hwEtaHalfWidth - to.hwEtaExtra - from.hwEtaCenter; + l1ct::glbeta_t etaMax = to.hwEtaCenter + to.hwEtaHalfWidth + to.hwEtaExtra - from.hwEtaCenter; + l1ct::glbeta_t etaShift = from.hwEtaCenter - to.hwEtaCenter; + l1ct::glbphi_t phiMin = -to.hwPhiHalfWidth - to.hwPhiExtra; + l1ct::glbphi_t phiMax = +to.hwPhiHalfWidth + to.hwPhiExtra; + l1ct::glbphi_t phiShift = 0; + if (ntk_ > 0) + tkBuffers_[iout] = l1ct::multififo_regionizer::EtaPhiBuffer( + etabuffer_depth_, etaMin, etaMax, etaShift, phiMin, phiMax, phiShift); + if (ncalo_ > 0) + hadCaloBuffers_[iout] = l1ct::multififo_regionizer::EtaPhiBuffer( + etabuffer_depth_, etaMin, etaMax, etaShift, phiMin, phiMax, phiShift); + if (nem_ > 0) + emCaloBuffers_[iout] = l1ct::multififo_regionizer::EtaPhiBuffer( + etabuffer_depth_, etaMin, etaMax, etaShift, phiMin, phiMax, phiShift); + if (nmu_ > 0) + muBuffers_[iout] = l1ct::multififo_regionizer::EtaPhiBuffer( + etabuffer_depth_, etaMin, etaMax, etaShift, phiMin, phiMax, phiShift); + } + } else if (nbuffers_ == nregions_pre_) { + unsigned int iout = ieta * nphi + iphi; if (ntk_ > 0) - tkBuffers_[iout] = l1ct::multififo_regionizer::EtaPhiBuffer( - etabuffer_depth_, etaMin, etaMax, etaShift, phiMin, phiMax, phiShift); + tkBuffers_[iout] = l1ct::multififo_regionizer::EtaPhiBuffer(etabuffer_depth_); if (ncalo_ > 0) - hadCaloBuffers_[iout] = l1ct::multififo_regionizer::EtaPhiBuffer( - etabuffer_depth_, etaMin, etaMax, etaShift, phiMin, phiMax, phiShift); + hadCaloBuffers_[iout] = l1ct::multififo_regionizer::EtaPhiBuffer(etabuffer_depth_); if (nem_ > 0) - emCaloBuffers_[iout] = l1ct::multififo_regionizer::EtaPhiBuffer( - etabuffer_depth_, etaMin, etaMax, etaShift, phiMin, phiMax, phiShift); + emCaloBuffers_[iout] = l1ct::multififo_regionizer::EtaPhiBuffer(etabuffer_depth_); if (nmu_ > 0) - muBuffers_[iout] = l1ct::multififo_regionizer::EtaPhiBuffer( - etabuffer_depth_, etaMin, etaMax, etaShift, phiMin, phiMax, phiShift); + muBuffers_[iout] = l1ct::multififo_regionizer::EtaPhiBuffer(etabuffer_depth_); } } } @@ -266,8 +289,8 @@ bool l1ct::MiddleBufferMultififoRegionizerEmulator::step(bool newEvent, for (unsigned int iphi = 0; iphi < nphi; ++iphi) { unsigned int iin = ieta * nphi + iphi; //if (ieta == 0 && iphi == 0 && pre_out_tk[iin].hwPt != 0) std::cout << "iclock " << iclock_ << ", pre_out_tk[" << iin << "] = " << pre_out_tk[iin].pack().to_string(16) << std::endl; - for (int i = 0; i < 2; ++i) { - unsigned int iout = (2 * ieta + i) * nphi + iphi; + for (int i = 0, n = nbuffers_ == nregions_pre_ ? 1 : 2; i < n; ++i) { + unsigned int iout = (n * ieta + i) * nphi + iphi; if (ntk_) tkBuffers_[iout].maybe_push(pre_out_tk[iin]); if (ncalo_) @@ -295,15 +318,54 @@ bool l1ct::MiddleBufferMultififoRegionizerEmulator::step(bool newEvent, std::vector bufferOut_hadCalo(ncalo_ ? nregions_post_ : 0); std::vector bufferOut_emCalo(nem_ ? nregions_post_ : 0); std::vector bufferOut_mu(nmu_ ? nregions_post_ : 0); - for (unsigned int i = 0; i < nregions_post_; ++i) { - if (ntk_) - bufferOut_tk[i] = tkBuffers_[i].pop(); - if (ncalo_) - bufferOut_hadCalo[i] = hadCaloBuffers_[i].pop(); - if (nem_) - bufferOut_emCalo[i] = emCaloBuffers_[i].pop(); - if (nmu_) - bufferOut_mu[i] = muBuffers_[i].pop(); + if (nbuffers_ == nregions_post_) { // just copy directly + for (unsigned int i = 0; i < nregions_post_; ++i) { + if (ntk_) + bufferOut_tk[i] = tkBuffers_[i].pop(); + if (ncalo_) + bufferOut_hadCalo[i] = hadCaloBuffers_[i].pop(); + if (nem_) + bufferOut_emCalo[i] = emCaloBuffers_[i].pop(); + if (nmu_) + bufferOut_mu[i] = muBuffers_[i].pop(); + } + } else if (nbuffers_ == nregions_pre_) { // propagate and copy + unsigned int neta = 3, nphi = 9; + for (unsigned int ieta = 0; ieta < neta; ++ieta) { + for (unsigned int iphi = 0; iphi < nphi; ++iphi) { + unsigned int iin = ieta * nphi + iphi; + const l1ct::PFRegionEmu& from = mergedRegions_[iin]; + l1ct::TkObjEmu tk = ntk_ ? tkBuffers_[iin].pop() : l1ct::TkObjEmu(); + l1ct::HadCaloObjEmu calo = ncalo_ ? hadCaloBuffers_[iin].pop() : l1ct::HadCaloObjEmu(); + l1ct::EmCaloObjEmu em = nem_ ? emCaloBuffers_[iin].pop() : l1ct::EmCaloObjEmu(); + l1ct::MuObjEmu mu = nmu_ ? muBuffers_[iin].pop() : l1ct::MuObjEmu(); + for (int i = 0; i < 2; ++i) { + const l1ct::PFRegionEmu& to = outputRegions_[2 * iin + i]; + unsigned int iout = (2 * ieta + i) * nphi + iphi; + l1ct::glbeta_t etaMin = to.hwEtaCenter - to.hwEtaHalfWidth - to.hwEtaExtra - from.hwEtaCenter; + l1ct::glbeta_t etaMax = to.hwEtaCenter + to.hwEtaHalfWidth + to.hwEtaExtra - from.hwEtaCenter; + l1ct::glbeta_t etaShift = from.hwEtaCenter - to.hwEtaCenter; + l1ct::glbphi_t phiMin = -to.hwPhiHalfWidth - to.hwPhiExtra; + l1ct::glbphi_t phiMax = +to.hwPhiHalfWidth + to.hwPhiExtra; + if (tk.hwPt > 0 && l1ct::multififo_regionizer::local_eta_phi_window(tk, etaMin, etaMax, phiMin, phiMax)) { + bufferOut_tk[iout] = tk; + bufferOut_tk[iout].hwEta += etaShift; + } + if (calo.hwPt > 0 && l1ct::multififo_regionizer::local_eta_phi_window(calo, etaMin, etaMax, phiMin, phiMax)) { + bufferOut_hadCalo[iout] = calo; + bufferOut_hadCalo[iout].hwEta += etaShift; + } + if (em.hwPt > 0 && l1ct::multififo_regionizer::local_eta_phi_window(em, etaMin, etaMax, phiMin, phiMax)) { + bufferOut_emCalo[iout] = em; + bufferOut_emCalo[iout].hwEta += etaShift; + } + if (mu.hwPt > 0 && l1ct::multififo_regionizer::local_eta_phi_window(mu, etaMin, etaMax, phiMin, phiMax)) { + bufferOut_mu[iout] = mu; + bufferOut_mu[iout].hwEta += etaShift; + } + } + } + } } if (ntk_) tkRegionizerPost_.muxonly_step(newEvent, /*flush=*/true, bufferOut_tk, out_tk); From e690b44f5722721e8bc9b2fe09559984773893ec Mon Sep 17 00:00:00 2001 From: Giovanni Date: Wed, 15 Nov 2023 10:10:05 +0100 Subject: [PATCH 5/6] Support single-link mode for MiddleBufferMultififoRegionizerEmulator --- .../middle_buffer_multififo_regionizer_ref.h | 11 +++ ...middle_buffer_multififo_regionizer_ref.cpp | 80 ++++++++++++++++++- 2 files changed, 87 insertions(+), 4 deletions(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h index 5ffcdbc738649..b53d34f05a6f3 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/regionizer/middle_buffer_multififo_regionizer_ref.h @@ -56,6 +56,7 @@ namespace l1ct { std::vector unused; fillLinks(iclock, in, links, unused); } + void destream(int iclock, const std::vector& tk_out, const std::vector& em_out, @@ -108,6 +109,16 @@ namespace l1ct { const std::vector>& in, std::vector& links, std::vector& valid); + + void fillSharedCaloLinks(unsigned int iclock, + const std::vector>& em_in, + const std::vector>& had_in, + std::vector& links, + std::vector& valid); + + void encode(const l1ct::EmCaloObjEmu& from, l1ct::HadCaloObjEmu& to); + void encode(const l1ct::HadCaloObjEmu& from, l1ct::HadCaloObjEmu& to); + void decode(l1ct::HadCaloObjEmu& had, l1ct::EmCaloObjEmu& em); }; } // namespace l1ct diff --git a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/middle_buffer_multififo_regionizer_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/middle_buffer_multififo_regionizer_ref.cpp index 94cc9579b7594..4dd4aa91a9928 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/middle_buffer_multififo_regionizer_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/middle_buffer_multififo_regionizer_ref.cpp @@ -226,7 +226,8 @@ void l1ct::MiddleBufferMultififoRegionizerEmulator::initSectorsAndRegions(const assert(in.emcalo.size() == NCALO_SECTORS); emCaloRegionizerPre_.initSectors(in.emcalo); emCaloRegionizerPre_.initRegions(mergedRegions); - emCaloRegionizerPre_.initRouting(emCaloRoutes_); + if (ECAL_LINKS) + emCaloRegionizerPre_.initRouting(emCaloRoutes_); emCaloRegionizerPost_.initRegions(out); } if (nmu_) { @@ -261,8 +262,16 @@ bool l1ct::MiddleBufferMultififoRegionizerEmulator::step(bool newEvent, ret = muRegionizerPre_.step(newEvent, links_mu, pre_out_mu, false); if (ncalo_) ret = hadCaloRegionizerPre_.step(newEvent, links_hadCalo, pre_out_hadCalo, false); - if (nem_) - ret = emCaloRegionizerPre_.step(newEvent, links_emCalo, pre_out_emCalo, false); + if (nem_) { + if (ECAL_LINKS) { + ret = emCaloRegionizerPre_.step(newEvent, links_emCalo, pre_out_emCalo, false); + } else if (ncalo_) { + pre_out_emCalo.resize(pre_out_hadCalo.size()); + for (unsigned int i = 0, n = pre_out_hadCalo.size(); i < n; ++i) { + decode(pre_out_hadCalo[i], pre_out_emCalo[i]); + } + } + } // in the no-streaming case, we just output the pre-regionizer if (!streaming_) { @@ -428,6 +437,34 @@ void l1ct::MiddleBufferMultififoRegionizerEmulator::fillCaloLinks_(unsigned int } } } +void l1ct::MiddleBufferMultififoRegionizerEmulator::fillSharedCaloLinks( + unsigned int iclock, + const std::vector>& em_in, + const std::vector>& had_in, + std::vector& links, + std::vector& valid) { + assert(ECAL_LINKS == 0 && HCAL_LINKS == 1 && ncalo_ != 0 && nem_ != 0); + links.resize(NCALO_SECTORS); + valid.resize(links.size()); + // for the moment we assume the first 54 clocks are for EM, the rest for HAD + const unsigned int NCLK_EM = 54; + for (unsigned int is = 0; is < NCALO_SECTORS; ++is) { + links[is].clear(); + if (iclock < NCLK_EM) { + valid[is] = true; + if (iclock < em_in[is].size()) { + encode(em_in[is][iclock], links[is]); + } + } else { + if (iclock - NCLK_EM < had_in[is].size()) { + encode(had_in[is][iclock - NCLK_EM], links[is]); + valid[is] = true; + } else { + valid[is] = false; + } + } + } // sectors +} void l1ct::MiddleBufferMultififoRegionizerEmulator::fillLinks(unsigned int iclock, const l1ct::RegionizerDecodedInputs& in, @@ -435,7 +472,10 @@ void l1ct::MiddleBufferMultififoRegionizerEmulator::fillLinks(unsigned int icloc std::vector& valid) { if (ncalo_ == 0) return; - fillCaloLinks_(iclock, in.hadcalo, links, valid); + if (nem_ != 0 && ECAL_LINKS == 0 && HCAL_LINKS == 1) + fillSharedCaloLinks(iclock, in.emcalo, in.hadcalo, links, valid); + else + fillCaloLinks_(iclock, in.hadcalo, links, valid); } void l1ct::MiddleBufferMultififoRegionizerEmulator::fillLinks(unsigned int iclock, @@ -558,3 +598,35 @@ void l1ct::MiddleBufferMultififoRegionizerEmulator::run(const RegionizerDecodedI reset(); } + +void l1ct::MiddleBufferMultififoRegionizerEmulator::encode(const l1ct::EmCaloObjEmu& from, l1ct::HadCaloObjEmu& to) { + assert(!from.hwEmID[5]); + to.hwPt = from.hwPt; + to.hwEmPt = from.hwPtErr; + to.hwEta = from.hwEta; + to.hwPhi = from.hwPhi; + to.hwEmID[5] = true; + to.hwEmID(4, 0) = from.hwEmID(4, 0); + to.src = from.src; +} +void l1ct::MiddleBufferMultififoRegionizerEmulator::encode(const l1ct::HadCaloObjEmu& from, l1ct::HadCaloObjEmu& to) { + assert(!from.hwEmID[5]); + to = from; +} +void l1ct::MiddleBufferMultififoRegionizerEmulator::decode(l1ct::HadCaloObjEmu& had, l1ct::EmCaloObjEmu& em) { + if (had.hwPt && had.hwEmID[5]) { + em.hwPt = had.hwPt; + em.hwPtErr = had.hwEmPt; + em.hwEta = had.hwEta; + em.hwPhi = had.hwPhi; + em.hwEmID[5] = 0; + em.hwEmID(4, 0) = had.hwEmID(4, 0); + em.hwSrrTot = 0; + em.hwMeanZ = 0; + em.hwHoe = 0; + em.src = had.src; + had.clear(); + } else { + em.clear(); + } +} \ No newline at end of file From d67bf45330ecc2586495e18a1fef55b8f364227c Mon Sep 17 00:00:00 2001 From: Giovanni Date: Wed, 15 Nov 2023 12:14:00 +0100 Subject: [PATCH 6/6] By default run TM18 barrel in 27-buffer single-link mode --- .../src/regionizer/middle_buffer_multififo_regionizer_ref.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/middle_buffer_multififo_regionizer_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/middle_buffer_multififo_regionizer_ref.cpp index 4dd4aa91a9928..abf74bd65c495 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/regionizer/middle_buffer_multififo_regionizer_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/regionizer/middle_buffer_multififo_regionizer_ref.cpp @@ -32,11 +32,11 @@ l1ct::MiddleBufferMultififoRegionizerEmulator::MiddleBufferMultififoRegionizerEm edm::ParameterSetDescription l1ct::MiddleBufferMultififoRegionizerEmulator::getParameterSetDescription() { edm::ParameterSetDescription description; description.add("nClocks", 162); - description.add("nBuffers", 54); + description.add("nBuffers", 27); description.add("etaBufferDepth", 54); description.add("nTkLinks", 1); description.add("nHCalLinks", 1); - description.add("nECalLinks", 1); + description.add("nECalLinks", 0); description.add("nTrack", 22); description.add("nCalo", 15); description.add("nEmCalo", 12);