From 4302286cae73216f11247e4569ad207b13e6bd2c Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 13 Dec 2024 13:49:45 +0100 Subject: [PATCH] Make EcalUncalibRecHitSoAToLegacy a global module. --- .../python/customizeHLTforCMSSW.py | 19 ++++ .../plugins/EcalUncalibRecHitSoAToLegacy.cc | 98 +++++++++---------- 2 files changed, 67 insertions(+), 50 deletions(-) diff --git a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py index 37e82223d290f..3d37a07194f46 100644 --- a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py +++ b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py @@ -48,6 +48,23 @@ def customiseForOffline(process): return process +def customizeHLTfor46935(process): + """Changes parameter names of EcalUncalibRecHitSoAToLegacy producer""" + for prod in producers_by_type(process, 'EcalUncalibRecHitSoAToLegacy'): + if hasattr(prod, 'uncalibRecHitsPortableEB'): + prod.inputCollectionEB = prod.uncalibRecHitsPortableEB + delattr(prod, 'uncalibRecHitsPortableEB') + if hasattr(prod, 'uncalibRecHitsPortableEE'): + prod.inputCollectionEE = prod.uncalibRecHitsPortableEE + delattr(prod, 'uncalibRecHitsPortableEE') + if hasattr(prod, 'recHitsLabelCPUEB'): + prod.outputLabelEB = prod.recHitsLabelCPUEB + delattr(prod, 'recHitsLabelCPUEB') + if hasattr(prod, 'recHitsLabelCPUEE'): + prod.outputLabelEE = prod.recHitsLabelCPUEE + delattr(prod, 'recHitsLabelCPUEE') + return process + # CMSSW version specific customizations def customizeHLTforCMSSW(process, menuType="GRun"): @@ -55,5 +72,7 @@ def customizeHLTforCMSSW(process, menuType="GRun"): # add call to action function in proper order: newest last! # process = customiseFor12718(process) + + process = customizeHLTfor46935(process) return process diff --git a/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitSoAToLegacy.cc b/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitSoAToLegacy.cc index 32ebbf669186f..08afd4fc10cb4 100644 --- a/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitSoAToLegacy.cc +++ b/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitSoAToLegacy.cc @@ -4,14 +4,14 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/EmptyGroupDescription.h" #include "FWCore/Utilities/interface/EDGetToken.h" #include "FWCore/Utilities/interface/EDPutToken.h" #include "DataFormats/EcalRecHit/interface/EcalUncalibratedRecHitHostCollection.h" -class EcalUncalibRecHitSoAToLegacy : public edm::stream::EDProducer<> { +class EcalUncalibRecHitSoAToLegacy : public edm::global::EDProducer<> { public: explicit EcalUncalibRecHitSoAToLegacy(edm::ParameterSet const &ps); ~EcalUncalibRecHitSoAToLegacy() override = default; @@ -19,86 +19,84 @@ class EcalUncalibRecHitSoAToLegacy : public edm::stream::EDProducer<> { private: using InputProduct = EcalUncalibratedRecHitHostCollection; - void produce(edm::Event &, edm::EventSetup const &) override; + void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override; private: const bool isPhase2_; - const edm::EDGetTokenT uncalibRecHitsPortableEB_; - const edm::EDGetTokenT uncalibRecHitsPortableEE_; - const edm::EDPutTokenT uncalibRecHitsCPUEBToken_; - const edm::EDPutTokenT uncalibRecHitsCPUEEToken_; + const edm::EDGetTokenT inputTokenEB_; + const edm::EDGetTokenT inputTokenEE_; + const edm::EDPutTokenT outputTokenEB_; + const edm::EDPutTokenT outputTokenEE_; }; void EcalUncalibRecHitSoAToLegacy::fillDescriptions(edm::ConfigurationDescriptions &confDesc) { edm::ParameterSetDescription desc; - desc.add("uncalibRecHitsPortableEB", + desc.add("inputCollectionEB", edm::InputTag("ecalMultiFitUncalibRecHitPortable", "EcalUncalibRecHitsEB")); - desc.add("recHitsLabelCPUEB", "EcalUncalibRecHitsEB"); + desc.add("outputLabelEB", "EcalUncalibRecHitsEB"); desc.ifValue(edm::ParameterDescription("isPhase2", false, true), false >> (edm::ParameterDescription( - "uncalibRecHitsPortableEE", + "inputCollectionEE", edm::InputTag("ecalMultiFitUncalibRecHitPortable", "EcalUncalibRecHitsEE"), true) and - edm::ParameterDescription("recHitsLabelCPUEE", "EcalUncalibRecHitsEE", true)) or + edm::ParameterDescription("outputLabelEE", "EcalUncalibRecHitsEE", true)) or true >> edm::EmptyGroupDescription()); confDesc.add("ecalUncalibRecHitSoAToLegacy", desc); } EcalUncalibRecHitSoAToLegacy::EcalUncalibRecHitSoAToLegacy(edm::ParameterSet const &ps) : isPhase2_{ps.getParameter("isPhase2")}, - uncalibRecHitsPortableEB_{consumes(ps.getParameter("uncalibRecHitsPortableEB"))}, - uncalibRecHitsPortableEE_{ - isPhase2_ ? edm::EDGetTokenT{} - : consumes(ps.getParameter("uncalibRecHitsPortableEE"))}, - uncalibRecHitsCPUEBToken_{ - produces(ps.getParameter("recHitsLabelCPUEB"))}, - uncalibRecHitsCPUEEToken_{ - isPhase2_ ? edm::EDPutTokenT{} - : produces(ps.getParameter("recHitsLabelCPUEE"))} {} + inputTokenEB_{consumes(ps.getParameter("inputCollectionEB"))}, + inputTokenEE_{isPhase2_ ? edm::EDGetTokenT{} + : consumes(ps.getParameter("inputCollectionEE"))}, + outputTokenEB_{produces(ps.getParameter("outputLabelEB"))}, + outputTokenEE_{isPhase2_ + ? edm::EDPutTokenT{} + : produces(ps.getParameter("outputLabelEE"))} {} -void EcalUncalibRecHitSoAToLegacy::produce(edm::Event &event, edm::EventSetup const &setup) { - auto const &uncalRecHitsEBColl = event.get(uncalibRecHitsPortableEB_); - auto const &uncalRecHitsEBCollView = uncalRecHitsEBColl.const_view(); - auto recHitsCPUEB = std::make_unique(); - recHitsCPUEB->reserve(uncalRecHitsEBCollView.size()); +void EcalUncalibRecHitSoAToLegacy::produce(edm::StreamID sid, edm::Event &event, edm::EventSetup const &setup) const { + auto const &inputCollEB = event.get(inputTokenEB_); + auto const &inputCollEBView = inputCollEB.const_view(); + auto outputCollEB = std::make_unique(); + outputCollEB->reserve(inputCollEBView.size()); - for (uint32_t i = 0; i < uncalRecHitsEBCollView.size(); ++i) { - recHitsCPUEB->emplace_back(DetId{uncalRecHitsEBCollView.id()[i]}, - uncalRecHitsEBCollView.amplitude()[i], - uncalRecHitsEBCollView.pedestal()[i], - uncalRecHitsEBCollView.jitter()[i], - uncalRecHitsEBCollView.chi2()[i], - uncalRecHitsEBCollView.flags()[i]); + for (uint32_t i = 0; i < inputCollEBView.size(); ++i) { + outputCollEB->emplace_back(DetId{inputCollEBView.id()[i]}, + inputCollEBView.amplitude()[i], + inputCollEBView.pedestal()[i], + inputCollEBView.jitter()[i], + inputCollEBView.chi2()[i], + inputCollEBView.flags()[i]); if (isPhase2_) { - (*recHitsCPUEB)[i].setAmplitudeError(uncalRecHitsEBCollView.amplitudeError()[i]); + (*outputCollEB)[i].setAmplitudeError(inputCollEBView.amplitudeError()[i]); } - (*recHitsCPUEB)[i].setJitterError(uncalRecHitsEBCollView.jitterError()[i]); + (*outputCollEB)[i].setJitterError(inputCollEBView.jitterError()[i]); for (uint32_t sample = 0; sample < EcalDataFrame::MAXSAMPLES; ++sample) { - (*recHitsCPUEB)[i].setOutOfTimeAmplitude(sample, uncalRecHitsEBCollView.outOfTimeAmplitudes()[i][sample]); + (*outputCollEB)[i].setOutOfTimeAmplitude(sample, inputCollEBView.outOfTimeAmplitudes()[i][sample]); } } - event.put(uncalibRecHitsCPUEBToken_, std::move(recHitsCPUEB)); + event.put(outputTokenEB_, std::move(outputCollEB)); if (!isPhase2_) { - auto const &uncalRecHitsEEColl = event.get(uncalibRecHitsPortableEE_); - auto const &uncalRecHitsEECollView = uncalRecHitsEEColl.const_view(); - auto recHitsCPUEE = std::make_unique(); - recHitsCPUEE->reserve(uncalRecHitsEECollView.size()); + auto const &inputCollEE = event.get(inputTokenEE_); + auto const &inputCollEEView = inputCollEE.const_view(); + auto outputCollEE = std::make_unique(); + outputCollEE->reserve(inputCollEEView.size()); - for (uint32_t i = 0; i < uncalRecHitsEECollView.size(); ++i) { - recHitsCPUEE->emplace_back(DetId{uncalRecHitsEECollView.id()[i]}, - uncalRecHitsEECollView.amplitude()[i], - uncalRecHitsEECollView.pedestal()[i], - uncalRecHitsEECollView.jitter()[i], - uncalRecHitsEECollView.chi2()[i], - uncalRecHitsEECollView.flags()[i]); - (*recHitsCPUEE)[i].setJitterError(uncalRecHitsEECollView.jitterError()[i]); + for (uint32_t i = 0; i < inputCollEEView.size(); ++i) { + outputCollEE->emplace_back(DetId{inputCollEEView.id()[i]}, + inputCollEEView.amplitude()[i], + inputCollEEView.pedestal()[i], + inputCollEEView.jitter()[i], + inputCollEEView.chi2()[i], + inputCollEEView.flags()[i]); + (*outputCollEE)[i].setJitterError(inputCollEEView.jitterError()[i]); for (uint32_t sample = 0; sample < EcalDataFrame::MAXSAMPLES; ++sample) { - (*recHitsCPUEE)[i].setOutOfTimeAmplitude(sample, uncalRecHitsEECollView.outOfTimeAmplitudes()[i][sample]); + (*outputCollEE)[i].setOutOfTimeAmplitude(sample, inputCollEEView.outOfTimeAmplitudes()[i][sample]); } } - event.put(uncalibRecHitsCPUEEToken_, std::move(recHitsCPUEE)); + event.put(outputTokenEE_, std::move(outputCollEE)); } }