Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LowPtElectrons: final energy regression and ID (back port of 32391) #33589

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
ID = cms.InputTag("lowPtGsfElectronID"),
),

# Embedding of RECO/AOD items

# Embedding of RECO/AOD items
embedTrack = True,
embedGsfElectronCore = True,
Expand Down Expand Up @@ -71,10 +69,16 @@

# Schedule rekeying of seed BDT ValueMaps by reco::GsfElectron for run2_miniAOD_UL and bParking
from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
from Configuration.Eras.Modifier_run2_miniAOD_devel_cff import run2_miniAOD_devel
from Configuration.Eras.Modifier_bParking_cff import bParking

from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronSeedValueMaps_cff import rekeyLowPtGsfElectronSeedValueMaps
from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronID_cff import lowPtGsfElectronID
from RecoEgamma.EgammaElectronProducers.lowPtGsfElectrons_cff import lowPtGsfElectrons

_makePatLowPtElectronsTask = makePatLowPtElectronsTask.copy()
_makePatLowPtElectronsTask.add(rekeyLowPtGsfElectronSeedValueMaps)
_makePatLowPtElectronsTask.add(lowPtGsfElectronID)
(bParking | run2_miniAOD_UL).toReplaceWith(makePatLowPtElectronsTask,_makePatLowPtElectronsTask)
( (bParking & run2_miniAOD_UL) | (~bParking & run2_miniAOD_devel) ).toModify(
makePatLowPtElectronsTask, func = lambda t: t.add(lowPtGsfElectrons))
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
cut = cms.string("pt>1. && electronID('ID')>1.5"),
)

# Modifier for run2_miniAOD_devel
from Configuration.Eras.Modifier_run2_miniAOD_devel_cff import run2_miniAOD_devel
run2_miniAOD_devel.toModify(selectedPatLowPtElectrons,cut = "pt>1. && electronID('ID')>-0.25")

# Modifier for bParking (fully open selection)
from Configuration.Eras.Modifier_bParking_cff import bParking
bParking.toModify(selectedPatLowPtElectrons,cut = "")
bParking.toModify(selectedPatLowPtElectrons,cut = "pt>1.")

# Modifiers for legacy AOD
from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
Expand Down
Original file line number Diff line number Diff line change
@@ -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<reco::GsfElectronCollection> previousGsfElectrons_;
std::unique_ptr<ModifyObjectValueBase> regression_;

const edm::EDPutTokenT<reco::GsfElectronCollection> putToken_;
};

using edm::InputTag;
using reco::GsfElectronCollection;

LowPtGsfElectronFinalizer::LowPtGsfElectronFinalizer(const edm::ParameterSet& cfg)
: previousGsfElectrons_{consumes<GsfElectronCollection>(cfg.getParameter<InputTag>("previousGsfElectronsTag"))},
putToken_{produces<GsfElectronCollection>()} {
auto const& iconf = cfg.getParameterSet("regressionConfig");
auto const& mname = iconf.getParameter<std::string>("modifierName");
auto cc = consumesCollector();
regression_.reset(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<edm::InputTag>("previousGsfElectronsTag", {});
edm::ParameterSetDescription psd;
psd.setUnknown();
desc.add<edm::ParameterSetDescription>("regressionConfig", psd);
descriptions.addWithDefaultLabel(desc);
}

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(LowPtGsfElectronFinalizer);
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@
)

from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
run2_miniAOD_UL.toModify(
from Configuration.Eras.Modifier_run2_miniAOD_devel_cff import run2_miniAOD_devel
from Configuration.Eras.Modifier_bParking_cff import bParking
( run2_miniAOD_UL | bParking ).toModify(
lowPtGsfElectronID,
rho = "fixedGridRhoFastjetAll",
ModelWeights = ["RecoEgamma/ElectronIdentification/data/LowPtElectrons/LowPtElectrons_ID_2020Sept15.root"],
ModelThresholds = [-99.],
Version = "V1",
)
run2_miniAOD_devel.toModify(
lowPtGsfElectronID,
ModelWeights = ["RecoEgamma/ElectronIdentification/data/LowPtElectrons/LowPtElectrons_ID_2020Nov28.root"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't devel use LowPtElectrons_ID_2021May17 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • (~bParking & run2_miniAOD_devel) uses 2020Nov28
  • It overrides (~bParking & run2_miniAOD_UL), which uses 2020Sept15 (no-change policy)
  • Only (bParking & run2_miniAOD_UL) uses 2021May17

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(~bParking & run2_miniAOD_devel) uses 2020Nov28

let me rephrase my earlier question: why can't (~bParking & run2_miniAOD_devel) use LowPtElectrons_ID_2021May17?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The 2021May17 and 2020Nov28 models are trained with UL data sets.
  • The 2021May17 model is trained with the priors pT > 1 GeV and the Very Loose working point for the ElectronSeed.
  • The 2020Nov28 model is trained with the priors pT > 1 GeV and the Tight working point for the ElectronSeed.
  • The bParking modifier determines whether we use the VL or Tight working point.

)
(bParking & run2_miniAOD_UL).toModify(
lowPtGsfElectronID,
ModelWeights = ["RecoEgamma/ElectronIdentification/data/LowPtElectrons/LowPtElectrons_ID_2021May17.root"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronCores_cff import *

# Low pT electrons
from RecoEgamma.EgammaElectronProducers.lowPtGsfElectrons_cfi import *
from RecoEgamma.EgammaElectronProducers.lowPtGsfElectrons_cff import lowPtGsfElectrons

# Low pT Electron value maps
from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronSeedValueMaps_cff import lowPtGsfElectronSeedValueMaps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from RecoEgamma.EgammaIsolationAlgos.electronTrackIsolations_cfi import trkIsol03CfgV1,trkIsol04CfgV1
from RecoEgamma.EgammaIsolationAlgos.electronTrackIsolations_cfi import trkIsol03CfgV2,trkIsol04CfgV2

lowPtGsfElectrons = cms.EDProducer(
lowPtGsfElectronsPreRegression = cms.EDProducer(
"LowPtGsfElectronProducer",

# input collections
Expand Down Expand Up @@ -63,8 +63,8 @@
)

from Configuration.Eras.Modifier_fastSim_cff import fastSim
fastSim.toModify(lowPtGsfElectrons,ctfTracksTag = cms.InputTag("generalTracksBeforeMixing"))
fastSim.toModify(lowPtGsfElectronsPreRegression,ctfTracksTag = cms.InputTag("generalTracksBeforeMixing"))

from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018
pp_on_AA_2018.toModify(lowPtGsfElectrons.preselection, minSCEtBarrel = 15.0)
pp_on_AA_2018.toModify(lowPtGsfElectrons.preselection, minSCEtEndcaps = 15.0)
pp_on_AA_2018.toModify(lowPtGsfElectronsPreRegression.preselection, minSCEtBarrel = 15.0)
pp_on_AA_2018.toModify(lowPtGsfElectronsPreRegression.preselection, minSCEtEndcaps = 15.0)
55 changes: 55 additions & 0 deletions RecoEgamma/EgammaElectronProducers/python/lowPtGsfElectrons_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import FWCore.ParameterSet.Config as cms
from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronsPreRegression_cfi import lowPtGsfElectronsPreRegression

lowPtGsfElectrons = lowPtGsfElectronsPreRegression.clone()

################################################################################
# LowPtGsfElectronProducer above is run by default in RECO
# LowPtGsfElectronFinalizer below is scheduled for run2_miniAOD_UL

from RecoEgamma.EgammaTools.regressionModifier_cfi import regressionModifier106XUL
_lowPtRegressionModifier = regressionModifier106XUL.clone(
modifierName = 'EGRegressionModifierV3',
rhoTag = 'fixedGridRhoFastjetAll',
eleRegs = dict(
ecalOnlyMean = dict(
lowEtHighEtBoundary = 20.,
ebLowEtForestName = "lowPtElectron_eb_ecalOnly_05To50_mean",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the master version has a colon in all names

ebLowEtForestName = ":lowPtElectron_eb_ecalOnly_05To50_mean",

was there a change in name formatting or is this a not necessary change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to @jainshilpi no colons are needed. I will double check the implementation in master (with the colons), but I've seen errors (in >11_3_X) without them ... As far as I'm aware, the tests in 10_6_X (with no colons) appear to work.

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 RecoEgamma.EgammaElectronProducers.lowPtGsfElectronFinalizer_cfi import lowPtGsfElectronFinalizer
_lowPtGsfElectrons = lowPtGsfElectronFinalizer.clone(
previousGsfElectronsTag = "lowPtGsfElectrons::@skipCurrentProcess",
regressionConfig = _lowPtRegressionModifier,
)

from Configuration.ProcessModifiers.run2_miniAOD_UL_cff import run2_miniAOD_UL
run2_miniAOD_UL.toReplaceWith(lowPtGsfElectrons,_lowPtGsfElectrons)