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

Adding unbiased superclusters to miniAOD and EGM nano #46423

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 @@ -6,6 +6,9 @@ typedef SimpleFlatTableProducer<reco::Candidate> SimpleCandidateFlatTableProduce
#include "DataFormats/TrackReco/interface/Track.h"
typedef SimpleFlatTableProducer<reco::Track> SimpleTrackFlatTableProducer;

#include "DataFormats/EgammaReco/interface/SuperCluster.h"
typedef SimpleFlatTableProducer<reco::SuperCluster> SimpleSuperclusterFlatTableProducer;

#include "DataFormats/JetReco/interface/PFJet.h"
typedef SimpleFlatTableProducer<reco::PFJet> SimplePFJetFlatTableProducer;

Expand Down Expand Up @@ -48,6 +51,7 @@ typedef EventSingletonSimpleFlatTableProducer<reco::BeamSpot> SimpleBeamspotFlat
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(SimpleCandidateFlatTableProducer);
DEFINE_FWK_MODULE(SimpleTrackFlatTableProducer);
DEFINE_FWK_MODULE(SimpleSuperclusterFlatTableProducer);
DEFINE_FWK_MODULE(SimplePFJetFlatTableProducer);
DEFINE_FWK_MODULE(SimpleVertexFlatTableProducer);
DEFINE_FWK_MODULE(SimpleSecondaryVertexFlatTableProducer);
Expand Down
24 changes: 24 additions & 0 deletions PhysicsTools/NanoAOD/python/egamma_custom_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@
)
)

superclusterTable = cms.EDProducer("SimpleSuperclusterFlatTableProducer",
src = cms.InputTag("reducedEgamma","reducedSuperClusters"),
name = cms.string("Supercluster"),
doc = cms.string("Supercluster collection"),
variables = cms.PSet(
energy = Var("energy()",float,doc="supercluster energy",precision=10),
eta = Var("eta()",float,doc="supercluster eta",precision=10),
phi = Var("phi()",float,doc="supercluster phi",precision=10),
rawEnergy = Var("rawEnergy()",float,doc="sum of basic clusters energy",precision=10),
preshowerEnergy = Var("preshowerEnergy()",float,doc="sum of energy in preshower",precision=10),
etaWidth = Var("etaWidth()",float,doc="supercluster eta width",precision=10),
phiWidth = Var("etaWidth()",float,doc="supercluster phi width",precision=10),
seedClusEnergy = Var("seed().energy()",float,doc="seed cluster energy",precision=10),
seedClusterEta = Var("seed().eta()",float,doc="seed cluster eta",precision=10),
seedClusterPhi = Var("seed().phi()",float,doc="seed cluster phi",precision=10),
)
)

def addExtraEGammaVarsCustomize(process):
#photon
process.finalPhotons.cut = cms.string("pt > 1 ")
Expand All @@ -97,5 +115,11 @@ def addExtraEGammaVarsCustomize(process):

if hasattr(process,'nanoDQM'):
process.nanoDQM.vplots.Electron.plots = _Electron_extra_plots

#superCluster
process.superclusterTable = superclusterTable

process.superclusterTask = cms.Task(process.superclusterTable)
process.nanoTableTaskCommon.add(process.superclusterTask)

return process
2 changes: 1 addition & 1 deletion PhysicsTools/NanoAOD/python/electrons_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
electronTable.variables,
pt = Var("pt*userFloat('ecalTrkEnergyPostCorrNew')/userFloat('ecalTrkEnergyPreCorrNew')", float, precision=-1, doc="p_{T}"),
energyErr = Var("userFloat('ecalTrkEnergyErrPostCorrNew')", float, precision=6, doc="energy error of the cluster-track combination"),
eCorr = Var("userFloat('ecalTrkEnergyPostCorrNew')/userFloat('ecalTrkEnergyPreCorrNew')", float, doc="ratio of the calibrated energy/miniaod energy"),
ptPreCorr = Var("pt", float, doc="pt of the electron before energy corrections"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update the nanoDQM with this change.

scEtOverPt = Var("(superCluster().energy()/(pt*userFloat('ecalTrkEnergyPostCorrNew')/userFloat('ecalTrkEnergyPreCorrNew')*cosh(superCluster().eta())))-1",float,doc="(supercluster transverse energy)/pt-1",precision=8),
dEscaleUp=Var("userFloat('ecalTrkEnergyPostCorrNew')-userFloat('energyScaleUpNew')", float, doc="ecal energy scale shifted 1 sigma up(adding gain/stat/syst in quadrature)", precision=8),
dEscaleDown=Var("userFloat('ecalTrkEnergyPostCorrNew')-userFloat('energyScaleDownNew')", float, doc="ecal energy scale shifted 1 sigma down (adding gain/stat/syst in quadrature)", precision=8),
Expand Down
2 changes: 1 addition & 1 deletion PhysicsTools/NanoAOD/python/photons_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def make_bitmapVID_docstring(id_modules_working_points_pset):
photonTable.variables,
pt = Var("pt*userFloat('ecalEnergyPostCorrNew')/userFloat('ecalEnergyPreCorrNew')", float, precision=-1, doc="p_{T}"),
energyErr = Var("userFloat('ecalEnergyErrPostCorrNew')",float,doc="energy error of the cluster from regression",precision=6),
eCorr = Var("userFloat('ecalEnergyPostCorrNew')/userFloat('ecalEnergyPreCorrNew')",float,doc="ratio of the calibrated energy/miniaod energy"),
ptPreCorr = Var("pt",float,doc="pt of the photon before energy corrections"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update the nanoDQM with this change.

cutBased = Var(
"userInt('cutBasedID_Fall17V2_loose')+userInt('cutBasedID_Fall17V2_medium')+userInt('cutBasedID_Fall17V2_tight')",
"uint8",
Expand Down
1 change: 1 addition & 0 deletions PhysicsTools/PatAlgos/python/slimming/slimming_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
slimmedLambdaVertices,
slimmedMETs,
metFilterPathsTask,
superClusterMerger,
reducedEgamma,
slimmedHcalRecHits,
bunchSpacingProducer,
Expand Down
11 changes: 11 additions & 0 deletions RecoEgamma/EgammaPhotonProducers/python/reducedEgamma_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from RecoJets.Configuration.CaloTowersES_cfi import *

reducedEgamma = cms.EDProducer("ReducedEGProducer",
keepPfSuperclusterPtMin = cms.double(10.),
keepPfSuperclusterAbsetaMax = cms.double(2.5),
relinkSuperclusterPtMin = cms.double(99999.), # no SC linking
keepPhotons = cms.string("hadTowOverEm()<0.15 && pt>10 && (pt>14 || chargedHadronIso()<10)"), #keep in output
slimRelinkPhotons = cms.string("hadTowOverEm()<0.15 && pt>10 && (pt>14 || chargedHadronIso()<10)"), #keep only slimmed SuperCluster plus seed cluster
relinkPhotons = cms.string("(r9()>0.8 || chargedHadronIso()<20 || chargedHadronIso()<0.3*pt())"), #keep all associated clusters/rechits/conversions
Expand All @@ -13,6 +16,7 @@
keepGsfElectrons = cms.string(""), #keep in output
slimRelinkGsfElectrons = cms.string(""), #keep only slimmed SuperCluster plus seed cluster
relinkGsfElectrons = cms.string("pt>5"), #keep all associated clusters/rechits/conversions
pflowSuperclusters = cms.InputTag("superClusterMerger"),
photons = cms.InputTag("gedPhotons"),
ootPhotons = cms.InputTag("ootPhotons"),
gsfElectrons = cms.InputTag("gedGsfElectrons"),
Expand Down Expand Up @@ -50,6 +54,13 @@
hcalHitSel = interestingEgammaIsoHCALSel
)

superClusterMerger = cms.EDProducer("EgammaSuperClusterMerger",
src = cms.VInputTag(
cms.InputTag("particleFlowSuperClusterECAL:particleFlowSuperClusterECALBarrel"),
cms.InputTag("particleFlowSuperClusterECAL:particleFlowSuperClusterECALEndcapWithPreshower"),
)
)

from Configuration.Eras.Modifier_phase2_common_cff import phase2_common
phase2_common.toModify(reducedEgamma,
preshowerEcalHits = "",
Expand Down
31 changes: 30 additions & 1 deletion RecoEgamma/EgammaPhotonProducers/src/ReducedEGProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class ReducedEGProducer : public edm::stream::EDProducer<> {
}

//tokens for input collections
const edm::EDGetTokenT<reco::SuperClusterCollection> superclusterT_;
const edm::EDGetTokenT<reco::PhotonCollection> photonT_;
edm::EDGetTokenT<reco::PhotonCollection> ootPhotonT_;
const edm::EDGetTokenT<reco::GsfElectronCollection> gsfElectronT_;
Expand All @@ -178,6 +179,10 @@ class ReducedEGProducer : public edm::stream::EDProducer<> {
const edm::EDGetTokenT<reco::HIPhotonIsolationMap> recoHIPhotonIsolationMapInputToken_;
edm::EDPutTokenT<reco::HIPhotonIsolationMap> recoHIPhotonIsolationMapOutputName_;

const double scPtMin_;
const double scAbsetaMax_;
const double relinkSuperclusterPtMin_;

const bool applyPhotonCalibOnData_;
const bool applyPhotonCalibOnMC_;
const bool applyGsfElectronCalibOnData_;
Expand Down Expand Up @@ -263,7 +268,8 @@ namespace {
} // namespace

ReducedEGProducer::ReducedEGProducer(const edm::ParameterSet& config)
: photonT_(consumes(config.getParameter<edm::InputTag>("photons"))),
: superclusterT_(consumes(config.getParameter<edm::InputTag>("pflowSuperclusters"))),
photonT_(consumes(config.getParameter<edm::InputTag>("photons"))),
gsfElectronT_(consumes(config.getParameter<edm::InputTag>("gsfElectrons"))),
conversionT_(consumes(config.getParameter<edm::InputTag>("conversions"))),
singleConversionT_(consumes(config.getParameter<edm::InputTag>("singleConversions"))),
Expand All @@ -280,6 +286,9 @@ ReducedEGProducer::ReducedEGProducer(const edm::ParameterSet& config)
!config.getParameter<edm::InputTag>("hiPhotonIsolationMapInput").label().empty()
? consumes<reco::HIPhotonIsolationMap>(config.getParameter<edm::InputTag>("hiPhotonIsolationMapInput"))
: edm::EDGetTokenT<reco::HIPhotonIsolationMap>{}},
scPtMin_(config.getParameter<double>("keepPfSuperclusterPtMin")),
scAbsetaMax_(config.getParameter<double>("keepPfSuperclusterAbsetaMax")),
relinkSuperclusterPtMin_(config.getParameter<double>("relinkSuperclusterPtMin")),
//calibration flags
applyPhotonCalibOnData_(config.getParameter<bool>("applyPhotonCalibOnData")),
applyPhotonCalibOnMC_(config.getParameter<bool>("applyPhotonCalibOnMC")),
Expand Down Expand Up @@ -380,6 +389,7 @@ void ReducedEGProducer::beginRun(edm::Run const& run, const edm::EventSetup& iSe
void ReducedEGProducer::produce(edm::Event& event, const edm::EventSetup& eventSetup) {
//get input collections

auto scHandle = event.getHandle(superclusterT_);
auto photonHandle = event.getHandle(photonT_);

auto ootPhotonHandle =
Expand Down Expand Up @@ -682,6 +692,25 @@ void ReducedEGProducer::produce(edm::Event& event, const edm::EventSetup& eventS
linkHcalHits(*gsfElectron.superCluster(), *hbheHitHandle, hcalRechitMap);
}

//loop over input SuperClusters
index = -1;
for (const auto& superCluster : *scHandle) {
index++;

const double superclusPt = superCluster.energy() / std::cosh(superCluster.eta());

if (superclusPt < scPtMin_)
continue;

if (std::abs(superCluster.eta()) > scAbsetaMax_)
continue;

bool relinkSupercluster = superclusPt > relinkSuperclusterPtMin_;

reco::SuperClusterRef superClusterRef(scHandle, index);
linkSuperCluster(superClusterRef, superClusterMap, superClusters, relinkSupercluster, superClusterFullRelinkMap);
}

//loop over output SuperClusters and fill maps
index = 0;
for (auto& superCluster : superClusters) {
Expand Down