-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33817 from bainbrid/LowPtElectrons_nanoAOD_integr…
…ation LowPtElectrons: NanoAOD integration
- Loading branch information
Showing
16 changed files
with
710 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
from PhysicsTools.NanoAOD.nano_eras_cff import * | ||
from PhysicsTools.NanoAOD.common_cff import * | ||
|
||
################################################################################ | ||
# Modules | ||
################################################################################ | ||
|
||
from RecoEgamma.EgammaTools.lowPtElectronModifier_cfi import lowPtElectronModifier | ||
from RecoEgamma.EgammaElectronProducers.lowPtGsfElectrons_cfi import lowPtRegressionModifier | ||
modifiedLowPtElectrons = cms.EDProducer( | ||
"ModifiedElectronProducer", | ||
src = cms.InputTag("slimmedLowPtElectrons"), | ||
modifierConfig = cms.PSet( | ||
modifications = cms.VPSet(lowPtElectronModifier,lowPtRegressionModifier) | ||
) | ||
) | ||
|
||
from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronID_cfi import lowPtGsfElectronID | ||
lowPtPATElectronID = lowPtGsfElectronID.clone( | ||
usePAT = True, | ||
electrons = "modifiedLowPtElectrons", | ||
unbiased = "", | ||
ModelWeights = [ | ||
'RecoEgamma/ElectronIdentification/data/LowPtElectrons/LowPtElectrons_ID_2020Nov28.root', | ||
], | ||
) | ||
|
||
isoForLowPtEle = cms.EDProducer( | ||
"EleIsoValueMapProducer", | ||
src = cms.InputTag("modifiedLowPtElectrons"), | ||
relative = cms.bool(False), | ||
rho_MiniIso = cms.InputTag("fixedGridRhoFastjetAll"), | ||
rho_PFIso = cms.InputTag("fixedGridRhoFastjetAll"), | ||
EAFile_MiniIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"), | ||
EAFile_PFIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"), | ||
) | ||
|
||
updatedLowPtElectronsWithUserData = cms.EDProducer( | ||
"PATElectronUserDataEmbedder", | ||
src = cms.InputTag("modifiedLowPtElectrons"), | ||
userFloats = cms.PSet( | ||
ID = cms.InputTag("lowPtPATElectronID"), | ||
miniIsoChg = cms.InputTag("isoForLowPtEle:miniIsoChg"), | ||
miniIsoAll = cms.InputTag("isoForLowPtEle:miniIsoAll"), | ||
), | ||
userIntFromBools = cms.PSet(), | ||
userInts = cms.PSet(), | ||
userCands = cms.PSet(), | ||
) | ||
|
||
finalLowPtElectrons = cms.EDFilter( | ||
"PATElectronRefSelector", | ||
src = cms.InputTag("updatedLowPtElectronsWithUserData"), | ||
cut = cms.string("pt > 1. && userFloat('ID') > -0.25"), | ||
) | ||
|
||
################################################################################ | ||
# electronTable | ||
################################################################################ | ||
|
||
lowPtElectronTable = cms.EDProducer( | ||
"SimpleCandidateFlatTableProducer", | ||
src = cms.InputTag("finalLowPtElectrons"), | ||
cut = cms.string(""), | ||
name= cms.string("LowPtElectron"), | ||
doc = cms.string("slimmedLowPtElectrons after basic selection (" + finalLowPtElectrons.cut.value()+")"), | ||
singleton = cms.bool(False), # the number of entries is variable | ||
extension = cms.bool(False), # this is the main table for the electrons | ||
variables = cms.PSet( | ||
# Basic variables | ||
CandVars, | ||
# BDT scores and WPs | ||
embeddedID = Var("electronID('ID')",float,doc="ID, BDT (raw) score"), | ||
ID = Var("userFloat('ID')",float,doc="New ID, BDT (raw) score"), | ||
unbiased = Var("electronID('unbiased')",float,doc="ElectronSeed, pT- and dxy- agnostic BDT (raw) score"), | ||
ptbiased = Var("electronID('ptbiased')",float,doc="ElectronSeed, pT- and dxy- dependent BDT (raw) score"), | ||
# Isolation | ||
miniPFRelIso_chg = Var("userFloat('miniIsoChg')/pt",float, | ||
doc="mini PF relative isolation, charged component"), | ||
miniPFRelIso_all = Var("userFloat('miniIsoAll')/pt",float, | ||
doc="mini PF relative isolation, total (with scaled rho*EA PU corrections)"), | ||
# Conversions | ||
convVeto = Var("passConversionVeto()",bool,doc="pass conversion veto"), | ||
convWP = Var("userInt('convOpen')*1 + userInt('convLoose')*2 + userInt('convTight')*4", | ||
int,doc="conversion flag bit map: 1=Veto, 2=Loose, 3=Tight"), | ||
convVtxRadius = Var("userFloat('convVtxRadius')",float,doc="conversion vertex radius (cm)",precision=7), | ||
# Tracking | ||
lostHits = Var("gsfTrack.hitPattern.numberOfLostHits('MISSING_INNER_HITS')","uint8",doc="number of missing inner hits"), | ||
# Cluster-related | ||
energyErr = Var("p4Error('P4_COMBINATION')",float,doc="energy error of the cluster-track combination",precision=6), | ||
deltaEtaSC = Var("superCluster().eta()-eta()",float,doc="delta eta (SC,ele) with sign",precision=10), | ||
r9 = Var("full5x5_r9()",float,doc="R9 of the SC, calculated with full 5x5 region",precision=10), | ||
sieie = Var("full5x5_sigmaIetaIeta()",float,doc="sigma_IetaIeta of the SC, calculated with full 5x5 region",precision=10), | ||
eInvMinusPInv = Var("(1-eSuperClusterOverP())/ecalEnergy()",float,doc="1/E_SC - 1/p_trk",precision=10), | ||
scEtOverPt = Var("(superCluster().energy()/(pt*cosh(superCluster().eta())))-1",float,doc="(SC energy)/pt-1",precision=8), | ||
hoe = Var("hadronicOverEm()",float,doc="H over E",precision=8), | ||
# Displacement | ||
dxy = Var("dB('PV2D')",float,doc="dxy (with sign) wrt first PV, in cm",precision=10), | ||
dxyErr = Var("edB('PV2D')",float,doc="dxy uncertainty, in cm",precision=6), | ||
dz = Var("dB('PVDZ')",float,doc="dz (with sign) wrt first PV, in cm",precision=10), | ||
dzErr = Var("abs(edB('PVDZ'))",float,doc="dz uncertainty, in cm",precision=6), | ||
ip3d = Var("abs(dB('PV3D'))",float,doc="3D impact parameter wrt first PV, in cm",precision=10), | ||
sip3d = Var("abs(dB('PV3D')/edB('PV3D'))",float,doc="3D impact parameter significance wrt first PV, in cm",precision=10), | ||
# Cross-referencing | ||
#jetIdx | ||
#photonIdx | ||
), | ||
) | ||
|
||
################################################################################ | ||
# electronTable (MC) | ||
################################################################################ | ||
|
||
from PhysicsTools.NanoAOD.particlelevel_cff import particleLevel | ||
particleLevelForMatchingLowPt = particleLevel.clone( | ||
lepMinPt = cms.double(1.), | ||
phoMinPt = cms.double(1), | ||
) | ||
|
||
tautaggerForMatchingLowPt = cms.EDProducer( | ||
"GenJetTauTaggerProducer", | ||
src = cms.InputTag('particleLevelForMatchingLowPt:leptons') | ||
) | ||
|
||
matchingLowPtElecPhoton = cms.EDProducer( | ||
"GenJetGenPartMerger", | ||
srcJet =cms.InputTag("particleLevelForMatchingLowPt:leptons"), | ||
srcPart=cms.InputTag("particleLevelForMatchingLowPt:photons"), | ||
hasTauAnc=cms.InputTag("tautaggerForMatchingLowPt"), | ||
) | ||
|
||
lowPtElectronsMCMatchForTableAlt = cms.EDProducer( | ||
"GenJetMatcherDRPtByDR", # cut on deltaR, deltaPt/Pt; pick best by deltaR | ||
src = lowPtElectronTable.src, # final reco collection | ||
matched = cms.InputTag("matchingLowPtElecPhoton:merged"), # final mc-truth particle collection | ||
mcPdgId = cms.vint32(11,22), # one or more PDG ID (11 = el, 22 = pho); absolute values (see below) | ||
checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge | ||
mcStatus = cms.vint32(), | ||
maxDeltaR = cms.double(0.3), # Minimum deltaR for the match | ||
maxDPtRel = cms.double(0.5), # Minimum deltaPt/Pt for the match | ||
resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object | ||
resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first | ||
) | ||
|
||
lowPtElectronsMCMatchForTable = cms.EDProducer( | ||
"MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR | ||
src = lowPtElectronTable.src, # final reco collection | ||
matched = cms.InputTag("finalGenParticles"), # final mc-truth particle collection | ||
mcPdgId = cms.vint32(11), # one or more PDG ID (11 = ele); absolute values (see below) | ||
checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge | ||
mcStatus = cms.vint32(1), # PYTHIA status code (1 = stable, 2 = shower, 3 = hard scattering) | ||
maxDeltaR = cms.double(0.3), # Minimum deltaR for the match | ||
maxDPtRel = cms.double(0.5), # Minimum deltaPt/Pt for the match | ||
resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object | ||
resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first | ||
) | ||
|
||
from PhysicsTools.NanoAOD.electrons_cff import electronMCTable | ||
lowPtElectronMCTable = cms.EDProducer( | ||
"CandMCMatchTableProducer", | ||
src = lowPtElectronTable.src, | ||
mcMapDressedLep = cms.InputTag("lowPtElectronsMCMatchForTableAlt"), | ||
mcMap = cms.InputTag("lowPtElectronsMCMatchForTable"), | ||
mapTauAnc = cms.InputTag("matchingLowPtElecPhoton:hasTauAnc"), | ||
objName = lowPtElectronTable.name, | ||
objType = electronMCTable.objType, | ||
branchName = cms.string("genPart"), | ||
docString = cms.string("MC matching to status==1 electrons or photons"), | ||
genparticles = cms.InputTag("finalGenParticles"), | ||
) | ||
|
||
################################################################################ | ||
# Sequences | ||
################################################################################ | ||
|
||
lowPtElectronSequence = cms.Sequence(modifiedLowPtElectrons | ||
+lowPtPATElectronID | ||
+isoForLowPtEle | ||
+updatedLowPtElectronsWithUserData | ||
+finalLowPtElectrons) | ||
lowPtElectronTables = cms.Sequence(lowPtElectronTable) | ||
lowPtElectronMC = cms.Sequence( | ||
particleLevelForMatchingLowPt | ||
+tautaggerForMatchingLowPt | ||
+matchingLowPtElecPhoton | ||
+lowPtElectronsMCMatchForTable | ||
+lowPtElectronsMCMatchForTableAlt | ||
+lowPtElectronMCTable) | ||
|
||
################################################################################ | ||
# Modifiers | ||
################################################################################ | ||
|
||
_modifiers = ( run2_miniAOD_80XLegacy | | ||
run2_nanoAOD_94XMiniAODv1 | | ||
run2_nanoAOD_94XMiniAODv2 | | ||
run2_nanoAOD_94X2016 | | ||
run2_nanoAOD_102Xv1 | | ||
run2_nanoAOD_106Xv1 ) | ||
(_modifiers).toReplaceWith(lowPtElectronSequence,cms.Sequence()) | ||
(_modifiers).toReplaceWith(lowPtElectronTables,cms.Sequence()) | ||
(_modifiers).toReplaceWith(lowPtElectronMC,cms.Sequence()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.