diff --git a/PhysicsTools/PatAlgos/python/producersLayer1/lowPtElectronProducer_cff.py b/PhysicsTools/PatAlgos/python/producersLayer1/lowPtElectronProducer_cff.py index f6f745d01b956..a61cf8bd999e6 100644 --- a/PhysicsTools/PatAlgos/python/producersLayer1/lowPtElectronProducer_cff.py +++ b/PhysicsTools/PatAlgos/python/producersLayer1/lowPtElectronProducer_cff.py @@ -26,8 +26,6 @@ ID = cms.InputTag("lowPtGsfElectronID"), ), - # Embedding of RECO/AOD items - # Embedding of RECO/AOD items embedTrack = True, embedGsfElectronCore = True, @@ -69,11 +67,22 @@ genParticleMatch = "electronMatch" ) -# Schedule rekeying of seed BDT ValueMaps by reco::GsfElectron for run2_miniAOD_UL +# For run2_miniAOD_UL ... from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL -from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronSeedValueMaps_cff import rekeyLowPtGsfElectronSeedValueMaps -from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronID_cfi import lowPtGsfElectronID _makePatLowPtElectronsTask = makePatLowPtElectronsTask.copy() + +# (1) rekey seed BDT ValueMaps by reco::GsfElectron +from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronSeedValueMaps_cff import rekeyLowPtGsfElectronSeedValueMaps _makePatLowPtElectronsTask.add(rekeyLowPtGsfElectronSeedValueMaps) + +# (2) rerun ID +from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronID_cfi import lowPtGsfElectronID _makePatLowPtElectronsTask.add(lowPtGsfElectronID) + +# (3) apply energy regression +from RecoEgamma.EgammaElectronProducers.lowPtGsfElectrons_cfi import lowPtGsfElectrons +_makePatLowPtElectronsTask.add(lowPtGsfElectrons) + +# Append to Task run2_miniAOD_UL.toReplaceWith(makePatLowPtElectronsTask,_makePatLowPtElectronsTask) + diff --git a/PhysicsTools/PatAlgos/python/selectionLayer1/lowPtElectronSelector_cfi.py b/PhysicsTools/PatAlgos/python/selectionLayer1/lowPtElectronSelector_cfi.py index 7ea6b50afd8b8..0ef6e859e5be7 100644 --- a/PhysicsTools/PatAlgos/python/selectionLayer1/lowPtElectronSelector_cfi.py +++ b/PhysicsTools/PatAlgos/python/selectionLayer1/lowPtElectronSelector_cfi.py @@ -6,7 +6,7 @@ # selectedPatLowPtElectrons = cms.EDFilter("PATElectronSelector", src = cms.InputTag("patLowPtElectrons"), - cut = cms.string("pt>1. && electronID('ID')>1.5"), + cut = cms.string("pt > 1. && electronID('ID') > -0.25"), ) # Modifier for bParking (fully open selection) diff --git a/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronFinalizer.cc b/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronFinalizer.cc new file mode 100644 index 0000000000000..9274afeb5e901 --- /dev/null +++ b/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronFinalizer.cc @@ -0,0 +1,65 @@ +#include "CommonTools/CandAlgos/interface/ModifyObjectValueBase.h" +#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" + +class LowPtGsfElectronFinalizer : public edm::stream::EDProducer<> { +public: + explicit LowPtGsfElectronFinalizer(const edm::ParameterSet&); + + void produce(edm::Event&, const edm::EventSetup&) override; + + static void fillDescriptions(edm::ConfigurationDescriptions&); + +private: + const edm::EDGetTokenT previousGsfElectrons_; + std::unique_ptr regression_; + + const edm::EDPutTokenT putToken_; +}; + +using edm::InputTag; +using reco::GsfElectronCollection; + +LowPtGsfElectronFinalizer::LowPtGsfElectronFinalizer(const edm::ParameterSet& cfg) + : previousGsfElectrons_{consumes(cfg.getParameter("previousGsfElectronsTag"))}, + putToken_{produces()} { + auto const& iconf = cfg.getParameterSet("regressionConfig"); + auto const& mname = iconf.getParameter("modifierName"); + auto cc = consumesCollector(); + regression_ = ModifyObjectValueFactory::get()->create(mname, iconf, cc); +} + +void LowPtGsfElectronFinalizer::produce(edm::Event& event, const edm::EventSetup& setup) { + // Setup regression for event + regression_->setEvent(event); + regression_->setEventContent(setup); + + // Create new modified electron collection + reco::GsfElectronCollection outputElectrons; + for (auto const& electron : event.get(previousGsfElectrons_)) { + outputElectrons.emplace_back(electron); + auto& newElectron = outputElectrons.back(); + regression_->modifyObject(newElectron); + } + + // Emplace modified electrons to event + event.emplace(putToken_, std::move(outputElectrons)); +} + +void LowPtGsfElectronFinalizer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("previousGsfElectronsTag", {}); + edm::ParameterSetDescription psd; + psd.setUnknown(); + desc.add("regressionConfig", psd); + descriptions.addWithDefaultLabel(desc); +} + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(LowPtGsfElectronFinalizer); diff --git a/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronIDProducer.cc b/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronIDProducer.cc index 6b2d8cf39a3c2..bba7853345515 100644 --- a/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronIDProducer.cc +++ b/RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronIDProducer.cc @@ -172,7 +172,7 @@ void LowPtGsfElectronIDProducer::fillDescriptions(edm::ConfigurationDescriptions desc.add("rho", edm::InputTag("fixedGridRhoFastjetAll")); desc.add >("ModelNames", {""}); desc.add >( - "ModelWeights", {"RecoEgamma/ElectronIdentification/data/LowPtElectrons/LowPtElectrons_ID_2020Sept15.root"}); + "ModelWeights", {"RecoEgamma/ElectronIdentification/data/LowPtElectrons/LowPtElectrons_ID_2020Nov28.root"}); desc.add >("ModelThresholds", {-99.}); desc.add("PassThrough", false); desc.add("MinPtThreshold", 0.5); diff --git a/RecoEgamma/EgammaElectronProducers/python/lowPtGsfElectronSequence_cff.py b/RecoEgamma/EgammaElectronProducers/python/lowPtGsfElectronSequence_cff.py index 270f26685a3a3..dc35cd98556fb 100644 --- a/RecoEgamma/EgammaElectronProducers/python/lowPtGsfElectronSequence_cff.py +++ b/RecoEgamma/EgammaElectronProducers/python/lowPtGsfElectronSequence_cff.py @@ -66,6 +66,7 @@ from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronCores_cff import lowPtGsfElectronCores # Low pT electrons +from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronsPreRegression_cfi import * from RecoEgamma.EgammaElectronProducers.lowPtGsfElectrons_cfi import * # Low pT Electron value maps @@ -84,6 +85,7 @@ lowPtGsfElePfGsfTracks, lowPtGsfElectronSuperClusters, lowPtGsfElectronCores, + lowPtGsfElectronsPreRegression, lowPtGsfElectrons, lowPtGsfElectronSeedValueMaps, rekeyLowPtGsfElectronSeedValueMaps, diff --git a/RecoEgamma/EgammaElectronProducers/python/lowPtGsfElectronsPreRegression_cfi.py b/RecoEgamma/EgammaElectronProducers/python/lowPtGsfElectronsPreRegression_cfi.py new file mode 100644 index 0000000000000..2b73f9e0f4d58 --- /dev/null +++ b/RecoEgamma/EgammaElectronProducers/python/lowPtGsfElectronsPreRegression_cfi.py @@ -0,0 +1,6 @@ +from RecoEgamma.EgammaElectronProducers.gsfElectrons_cfi import ecalDrivenGsfElectrons + +lowPtGsfElectronsPreRegression = ecalDrivenGsfElectrons.clone(gsfElectronCoresTag = "lowPtGsfElectronCores") + +from Configuration.Eras.Modifier_fastSim_cff import fastSim +fastSim.toModify(lowPtGsfElectronsPreRegression,ctfTracksTag = "generalTracksBeforeMixing") diff --git a/RecoEgamma/EgammaElectronProducers/python/lowPtGsfElectrons_cfi.py b/RecoEgamma/EgammaElectronProducers/python/lowPtGsfElectrons_cfi.py index 5b8cc16ea5376..272a416aa6cf2 100644 --- a/RecoEgamma/EgammaElectronProducers/python/lowPtGsfElectrons_cfi.py +++ b/RecoEgamma/EgammaElectronProducers/python/lowPtGsfElectrons_cfi.py @@ -1,10 +1,49 @@ -from RecoEgamma.EgammaElectronProducers.gsfElectrons_cfi import ecalDrivenGsfElectrons +import FWCore.ParameterSet.Config as cms -lowPtGsfElectrons = ecalDrivenGsfElectrons.clone(gsfElectronCoresTag = "lowPtGsfElectronCores") +from RecoEgamma.EgammaTools.regressionModifier_cfi import regressionModifier106XUL -from Configuration.Eras.Modifier_fastSim_cff import fastSim -fastSim.toModify(lowPtGsfElectrons,ctfTracksTag = "generalTracksBeforeMixing") +_lowPtRegressionModifier = regressionModifier106XUL.clone( + modifierName = 'EGRegressionModifierV3', + rhoTag = 'fixedGridRhoFastjetAll', + eleRegs = dict( + ecalOnlyMean = dict( + lowEtHighEtBoundary = 20., + ebLowEtForestName = ":lowPtElectron_eb_ecalOnly_05To50_mean", + ebHighEtForestName = ":lowPtElectron_eb_ecalOnly_05To50_mean", + eeLowEtForestName = ":lowPtElectron_ee_ecalOnly_05To50_mean", + eeHighEtForestName = ":lowPtElectron_ee_ecalOnly_05To50_mean", + ), + ecalOnlySigma = dict( + lowEtHighEtBoundary = 20., + ebLowEtForestName = ":lowPtElectron_eb_ecalOnly_05To50_sigma", + ebHighEtForestName = ":lowPtElectron_eb_ecalOnly_05To50_sigma", + eeLowEtForestName = ":lowPtElectron_ee_ecalOnly_05To50_sigma", + eeHighEtForestName = ":lowPtElectron_ee_ecalOnly_05To50_sigma", + ), + epComb = dict( + ecalTrkRegressionConfig = dict( + lowEtHighEtBoundary = 20., + ebLowEtForestName = ":lowPtElectron_eb_ecalTrk_05To50_mean", + ebHighEtForestName = ":lowPtElectron_eb_ecalTrk_05To50_mean", + eeLowEtForestName = ":lowPtElectron_ee_ecalTrk_05To50_mean", + eeHighEtForestName = ":lowPtElectron_ee_ecalTrk_05To50_mean", + ), + ecalTrkRegressionUncertConfig = dict( + lowEtHighEtBoundary = 20., + ebLowEtForestName = ":lowPtElectron_eb_ecalTrk_05To50_sigma", + ebHighEtForestName = ":lowPtElectron_eb_ecalTrk_05To50_sigma", + eeLowEtForestName = ":lowPtElectron_ee_ecalTrk_05To50_sigma", + eeHighEtForestName = ":lowPtElectron_ee_ecalTrk_05To50_sigma", + ), + ) + ), +) -from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA -pp_on_AA.toModify(lowPtGsfElectrons.preselection, minSCEtBarrel = 15.0) -pp_on_AA.toModify(lowPtGsfElectrons.preselection, minSCEtEndcaps = 15.0) +from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronFinalizer_cfi import lowPtGsfElectronFinalizer +lowPtGsfElectrons = lowPtGsfElectronFinalizer.clone( + previousGsfElectronsTag = "lowPtGsfElectronsPreRegression", + regressionConfig = _lowPtRegressionModifier, +) + +from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL +run2_miniAOD_UL.toModify(lowPtGsfElectrons, previousGsfElectronsTag = "lowPtGsfElectrons::@skipCurrentProcess")