From 735f23d7a8480a9ee3e9381237f82894b2657ca6 Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 23 Nov 2023 17:48:10 +0100 Subject: [PATCH] Change naming to match TM18 and TM16 input logic --- .../interface/egamma/l2egsorter_ref.h | 51 +++++++++---------- .../plugins/L1TCtL2EgProducer.cc | 4 +- .../python/l1ctLayer2EG_cff.py | 4 +- .../src/egamma/l2egsorter_ref.cpp | 20 ++++---- 4 files changed, 39 insertions(+), 40 deletions(-) diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/egamma/l2egsorter_ref.h b/L1Trigger/Phase2L1ParticleFlow/interface/egamma/l2egsorter_ref.h index c5b75b37384e6..283ab6bcbcf94 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/egamma/l2egsorter_ref.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/egamma/l2egsorter_ref.h @@ -17,28 +17,28 @@ namespace l1ct { class L2EgSorterEmulator { public: - L2EgSorterEmulator(unsigned int nBoards, unsigned int nEGPerBoard, unsigned int nEGOut, bool debug) - : nBOARDS(nBoards), nEGPerBoard(nEGPerBoard), nEGOut(nEGOut), debug_(debug) {} + L2EgSorterEmulator(unsigned int nRegions, unsigned int nEGPerRegion, unsigned int nEGOut, bool debug) + : nREGIONS(nRegions), nEGPerRegion(nEGPerRegion), nEGOut(nEGOut), debug_(debug) {} L2EgSorterEmulator(const edm::ParameterSet &iConfig); virtual ~L2EgSorterEmulator() {} - template + template void toFirmware(const std::vector &in, - EGIsoObj (&photons_in)[NBoards][NObjs], - EGIsoEleObj (&eles_in)[NBoards][NObjs]) const { - for (unsigned int ib = 0; ib < NBoards; ib++) { - const auto &board = in[ib]; + EGIsoObj (&photons_in)[NRegions][NObjs], + EGIsoEleObj (&eles_in)[NRegions][NObjs]) const { + for (unsigned int ib = 0; ib < NRegions; ib++) { + const auto ®ion = in[ib]; for (unsigned int io = 0; io < NObjs; io++) { EGIsoObj pho; EGIsoEleObj ele; - if (io < board.egphoton.size()) - pho = board.egphoton[io]; + if (io < region.egphoton.size()) + pho = region.egphoton[io]; else pho.clear(); - if (io < board.egelectron.size()) - ele = board.egelectron[io]; + if (io < region.egelectron.size()) + ele = region.egelectron[io]; else ele.clear(); @@ -59,17 +59,17 @@ namespace l1ct { void setDebug(int verbose) { debug_ = verbose; } - unsigned int nInputBoards() const { return nBOARDS; } - unsigned int nInputObjPerBoard() const { return nEGPerBoard; } + unsigned int nInputRegions() const { return nREGIONS; } + unsigned int nInputObjPerRegion() const { return nEGPerRegion; } unsigned int nOutputObj() const { return nEGOut; } private: template void resize_input(std::vector &in) const { - if (in.size() > nEGPerBoard) { - in.resize(nEGPerBoard); - } else if (in.size() < nEGPerBoard) { - for (unsigned int i = 0, diff = (nEGPerBoard - in.size()); i < diff; ++i) { + if (in.size() > nEGPerRegion) { + in.resize(nEGPerRegion); + } else if (in.size() < nEGPerRegion) { + for (unsigned int i = 0, diff = (nEGPerRegion - in.size()); i < diff; ++i) { in.push_back(T()); in.back().clear(); } @@ -90,17 +90,16 @@ namespace l1ct { } template - void merge_boards(const std::vector &in_board1, - const std::vector &in_board2, + void merge_regions(const std::vector &in_region1, + const std::vector &in_region2, std::vector &out, unsigned int nOut) const { // we crate a bitonic list - out = in_board1; + out = in_region1; std::reverse(out.begin(), out.end()); - std::copy(in_board2.begin(), in_board2.end(), std::back_inserter(out)); + std::copy(in_region2.begin(), in_region2.end(), std::back_inserter(out)); hybridBitonicMergeRef(&out[0], out.size(), 0, false); - // std::merge(in_board1.begin(), in_board1.end(), in_board2_copy.begin(), in_board2_copy.end(), std::back_inserter(out), comparePt); if (out.size() > nOut) out.resize(nOut); } @@ -112,7 +111,7 @@ namespace l1ct { if (out.size() > nEGOut) out.resize(nEGOut); } else if (in_objs.size() == 2) { - merge_boards(in_objs[0], in_objs[1], out, nEGOut); + merge_regions(in_objs[0], in_objs[1], out, nEGOut); } else { std::vector> to_merge; for (unsigned int id = 0, idn = 1; id < in_objs.size(); id += 2, idn = id + 1) { @@ -120,7 +119,7 @@ namespace l1ct { to_merge.push_back(in_objs[id]); } else { std::vector pair_merge; - merge_boards(in_objs[id], in_objs[idn], pair_merge, nEGPerBoard); + merge_regions(in_objs[id], in_objs[idn], pair_merge, nEGPerRegion); to_merge.push_back(pair_merge); } } @@ -128,8 +127,8 @@ namespace l1ct { } } - const unsigned int nBOARDS; - const unsigned int nEGPerBoard; + const unsigned int nREGIONS; + const unsigned int nEGPerRegion; const unsigned int nEGOut; int debug_; }; diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc index 6bd03b11b2115..fa240a280af78 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1TCtL2EgProducer.cc @@ -311,7 +311,7 @@ void L1TCtL2EgProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::Ev merge(tkEGInputs_, iEvent, constituents, outEgs); iEvent.put(std::move(outEgs), tkEGInstanceLabel_); - auto regions = std::make_unique>(l2egsorter.nInputBoards()); + auto regions = std::make_unique>(l2egsorter.nInputRegions()); merge(tkEleInputs_, iEvent, constituents, regions); merge(tkEmInputs_, iEvent, constituents, regions); @@ -326,7 +326,7 @@ void L1TCtL2EgProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::Ev if (inData.has(linkData.linkId)) data = inData.at(linkData.linkId); - encodeLayer1EgObjs(l2egsorter.nInputObjPerBoard(), data, (*regions)[ireg].egphoton, (*regions)[ireg].egelectron); + encodeLayer1EgObjs(l2egsorter.nInputObjPerRegion(), data, (*regions)[ireg].egphoton, (*regions)[ireg].egelectron); data.resize(data.size() + linkData.nTrailingWords, {0}); inData.add(linkData.linkId, data); } diff --git a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer2EG_cff.py b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer2EG_cff.py index f5f7308ce8a41..aef3d3be76e6e 100644 --- a/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer2EG_cff.py +++ b/L1Trigger/Phase2L1ParticleFlow/python/l1ctLayer2EG_cff.py @@ -43,8 +43,8 @@ tkEmInstanceLabel=cms.string("L1CtTkEm"), tkEleInstanceLabel=cms.string("L1CtTkElectron"), sorter=cms.PSet( - nBOARDS=cms.uint32(5), - nEGPerBoard=cms.uint32(16), + nREGIONS=cms.uint32(5), + nEGPerRegion=cms.uint32(16), nEGOut=cms.uint32(12), debug=cms.untracked.uint32(0), ), diff --git a/L1Trigger/Phase2L1ParticleFlow/src/egamma/l2egsorter_ref.cpp b/L1Trigger/Phase2L1ParticleFlow/src/egamma/l2egsorter_ref.cpp index 751d75e467235..64bc9314ff5ce 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/egamma/l2egsorter_ref.cpp +++ b/L1Trigger/Phase2L1ParticleFlow/src/egamma/l2egsorter_ref.cpp @@ -12,8 +12,8 @@ using namespace l1ct; #include "FWCore/ParameterSet/interface/ParameterSet.h" l1ct::L2EgSorterEmulator::L2EgSorterEmulator(const edm::ParameterSet &pset) - : L2EgSorterEmulator(pset.getParameter("nBOARDS"), - pset.getParameter("nEGPerBoard"), + : L2EgSorterEmulator(pset.getParameter("nREGIONS"), + pset.getParameter("nEGPerRegion"), pset.getParameter("nEGOut"), pset.getUntrackedParameter("debug", 0)) {} #endif @@ -43,11 +43,11 @@ void L2EgSorterEmulator::run(const std::vector &in, std::vector &out_photons, std::vector &out_eles) const { if (debug_) { - unsigned int board_n = 0; - for (const auto &board : in) { - dbgCout() << "BOARD " << board_n++ << std::endl; - print_objects(board.egphoton, "photon_in"); - print_objects(board.egelectron, "electron_in"); + unsigned int region_n = 0; + for (const auto ®ion : in) { + dbgCout() << "REGION " << region_n++ << std::endl; + print_objects(region.egphoton, "photon_in"); + print_objects(region.egelectron, "electron_in"); } } @@ -56,9 +56,9 @@ void L2EgSorterEmulator::run(const std::vector &in, std::vector> eles_in; photons_in.reserve(in.size()); eles_in.reserve(in.size()); - for (const auto &board : in) { - std::vector photons = board.egphoton; - std::vector eles = board.egelectron; + for (const auto ®ion : in) { + std::vector photons = region.egphoton; + std::vector eles = region.egelectron; resize_input(photons); resize_input(eles);