|
| 1 | +import FWCore.ParameterSet.Config as cms |
| 2 | +from PhysicsTools.NanoAOD.nano_eras_cff import * |
| 3 | +from PhysicsTools.NanoAOD.common_cff import * |
| 4 | + |
| 5 | +################################################################################ |
| 6 | +# Modules |
| 7 | +################################################################################ |
| 8 | + |
| 9 | +from RecoEgamma.EgammaTools.lowPtElectronModifier_cfi import lowPtElectronModifier |
| 10 | +from RecoEgamma.EgammaElectronProducers.lowPtGsfElectrons_cfi import lowPtRegressionModifier |
| 11 | +modifiedLowPtElectrons = cms.EDProducer( |
| 12 | + "ModifiedElectronProducer", |
| 13 | + src = cms.InputTag("slimmedLowPtElectrons"), |
| 14 | + modifierConfig = cms.PSet( |
| 15 | + modifications = cms.VPSet(lowPtElectronModifier,lowPtRegressionModifier) |
| 16 | + ) |
| 17 | +) |
| 18 | + |
| 19 | +from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronID_cfi import lowPtGsfElectronID |
| 20 | +lowPtPATElectronID = lowPtGsfElectronID.clone( |
| 21 | + usePAT = True, |
| 22 | + electrons = "modifiedLowPtElectrons", |
| 23 | + unbiased = "", |
| 24 | + ModelWeights = [ |
| 25 | + 'RecoEgamma/ElectronIdentification/data/LowPtElectrons/LowPtElectrons_ID_2020Nov28.root', |
| 26 | + ], |
| 27 | +) |
| 28 | + |
| 29 | +isoForLowPtEle = cms.EDProducer( |
| 30 | + "EleIsoValueMapProducer", |
| 31 | + src = cms.InputTag("modifiedLowPtElectrons"), |
| 32 | + relative = cms.bool(False), |
| 33 | + rho_MiniIso = cms.InputTag("fixedGridRhoFastjetAll"), |
| 34 | + rho_PFIso = cms.InputTag("fixedGridRhoFastjetAll"), |
| 35 | + EAFile_MiniIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"), |
| 36 | + EAFile_PFIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"), |
| 37 | +) |
| 38 | + |
| 39 | +updatedLowPtElectronsWithUserData = cms.EDProducer( |
| 40 | + "PATElectronUserDataEmbedder", |
| 41 | + src = cms.InputTag("modifiedLowPtElectrons"), |
| 42 | + userFloats = cms.PSet( |
| 43 | + ID = cms.InputTag("lowPtPATElectronID"), |
| 44 | + miniIsoChg = cms.InputTag("isoForLowPtEle:miniIsoChg"), |
| 45 | + miniIsoAll = cms.InputTag("isoForLowPtEle:miniIsoAll"), |
| 46 | + ), |
| 47 | + userIntFromBools = cms.PSet(), |
| 48 | + userInts = cms.PSet(), |
| 49 | + userCands = cms.PSet(), |
| 50 | +) |
| 51 | + |
| 52 | +finalLowPtElectrons = cms.EDFilter( |
| 53 | + "PATElectronRefSelector", |
| 54 | + src = cms.InputTag("updatedLowPtElectronsWithUserData"), |
| 55 | + cut = cms.string("pt > 1. && userFloat('ID') > -0.25"), |
| 56 | +) |
| 57 | + |
| 58 | +################################################################################ |
| 59 | +# electronTable |
| 60 | +################################################################################ |
| 61 | + |
| 62 | +lowPtElectronTable = cms.EDProducer( |
| 63 | + "SimpleCandidateFlatTableProducer", |
| 64 | + src = cms.InputTag("finalLowPtElectrons"), |
| 65 | + cut = cms.string(""), |
| 66 | + name= cms.string("LowPtElectron"), |
| 67 | + doc = cms.string("slimmedLowPtElectrons after basic selection (" + finalLowPtElectrons.cut.value()+")"), |
| 68 | + singleton = cms.bool(False), # the number of entries is variable |
| 69 | + extension = cms.bool(False), # this is the main table for the electrons |
| 70 | + variables = cms.PSet( |
| 71 | + # Basic variables |
| 72 | + CandVars, |
| 73 | + # BDT scores and WPs |
| 74 | + embeddedID = Var("electronID('ID')",float,doc="ID, BDT (raw) score"), |
| 75 | + ID = Var("userFloat('ID')",float,doc="New ID, BDT (raw) score"), |
| 76 | + unbiased = Var("electronID('unbiased')",float,doc="ElectronSeed, pT- and dxy- agnostic BDT (raw) score"), |
| 77 | + ptbiased = Var("electronID('ptbiased')",float,doc="ElectronSeed, pT- and dxy- dependent BDT (raw) score"), |
| 78 | + # Isolation |
| 79 | + miniPFRelIso_chg = Var("userFloat('miniIsoChg')/pt",float, |
| 80 | + doc="mini PF relative isolation, charged component"), |
| 81 | + miniPFRelIso_all = Var("userFloat('miniIsoAll')/pt",float, |
| 82 | + doc="mini PF relative isolation, total (with scaled rho*EA PU corrections)"), |
| 83 | + # Conversions |
| 84 | + convVeto = Var("passConversionVeto()",bool,doc="pass conversion veto"), |
| 85 | + convWP = Var("userInt('convOpen')*1 + userInt('convLoose')*2 + userInt('convTight')*4", |
| 86 | + int,doc="conversion flag bit map: 1=Veto, 2=Loose, 3=Tight"), |
| 87 | + convVtxRadius = Var("userFloat('convVtxRadius')",float,doc="conversion vertex radius (cm)",precision=7), |
| 88 | + # Tracking |
| 89 | + lostHits = Var("gsfTrack.hitPattern.numberOfLostHits('MISSING_INNER_HITS')","uint8",doc="number of missing inner hits"), |
| 90 | + # Cluster-related |
| 91 | + energyErr = Var("p4Error('P4_COMBINATION')",float,doc="energy error of the cluster-track combination",precision=6), |
| 92 | + deltaEtaSC = Var("superCluster().eta()-eta()",float,doc="delta eta (SC,ele) with sign",precision=10), |
| 93 | + r9 = Var("full5x5_r9()",float,doc="R9 of the SC, calculated with full 5x5 region",precision=10), |
| 94 | + sieie = Var("full5x5_sigmaIetaIeta()",float,doc="sigma_IetaIeta of the SC, calculated with full 5x5 region",precision=10), |
| 95 | + eInvMinusPInv = Var("(1-eSuperClusterOverP())/ecalEnergy()",float,doc="1/E_SC - 1/p_trk",precision=10), |
| 96 | + scEtOverPt = Var("(superCluster().energy()/(pt*cosh(superCluster().eta())))-1",float,doc="(SC energy)/pt-1",precision=8), |
| 97 | + hoe = Var("hadronicOverEm()",float,doc="H over E",precision=8), |
| 98 | + # Displacement |
| 99 | + dxy = Var("dB('PV2D')",float,doc="dxy (with sign) wrt first PV, in cm",precision=10), |
| 100 | + dxyErr = Var("edB('PV2D')",float,doc="dxy uncertainty, in cm",precision=6), |
| 101 | + dz = Var("dB('PVDZ')",float,doc="dz (with sign) wrt first PV, in cm",precision=10), |
| 102 | + dzErr = Var("abs(edB('PVDZ'))",float,doc="dz uncertainty, in cm",precision=6), |
| 103 | + ip3d = Var("abs(dB('PV3D'))",float,doc="3D impact parameter wrt first PV, in cm",precision=10), |
| 104 | + sip3d = Var("abs(dB('PV3D')/edB('PV3D'))",float,doc="3D impact parameter significance wrt first PV, in cm",precision=10), |
| 105 | + # Cross-referencing |
| 106 | + #jetIdx |
| 107 | + #photonIdx |
| 108 | + ), |
| 109 | +) |
| 110 | + |
| 111 | +################################################################################ |
| 112 | +# electronTable (MC) |
| 113 | +################################################################################ |
| 114 | + |
| 115 | +from PhysicsTools.NanoAOD.particlelevel_cff import particleLevel |
| 116 | +particleLevelForMatchingLowPt = particleLevel.clone( |
| 117 | + lepMinPt = cms.double(1.), |
| 118 | + phoMinPt = cms.double(1), |
| 119 | +) |
| 120 | + |
| 121 | +tautaggerForMatchingLowPt = cms.EDProducer( |
| 122 | + "GenJetTauTaggerProducer", |
| 123 | + src = cms.InputTag('particleLevelForMatchingLowPt:leptons') |
| 124 | +) |
| 125 | + |
| 126 | +matchingLowPtElecPhoton = cms.EDProducer( |
| 127 | + "GenJetGenPartMerger", |
| 128 | + srcJet =cms.InputTag("particleLevelForMatchingLowPt:leptons"), |
| 129 | + srcPart=cms.InputTag("particleLevelForMatchingLowPt:photons"), |
| 130 | + hasTauAnc=cms.InputTag("tautaggerForMatchingLowPt"), |
| 131 | +) |
| 132 | + |
| 133 | +lowPtElectronsMCMatchForTableAlt = cms.EDProducer( |
| 134 | + "GenJetMatcherDRPtByDR", # cut on deltaR, deltaPt/Pt; pick best by deltaR |
| 135 | + src = lowPtElectronTable.src, # final reco collection |
| 136 | + matched = cms.InputTag("matchingLowPtElecPhoton:merged"), # final mc-truth particle collection |
| 137 | + mcPdgId = cms.vint32(11,22), # one or more PDG ID (11 = el, 22 = pho); absolute values (see below) |
| 138 | + checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge |
| 139 | + mcStatus = cms.vint32(), |
| 140 | + maxDeltaR = cms.double(0.3), # Minimum deltaR for the match |
| 141 | + maxDPtRel = cms.double(0.5), # Minimum deltaPt/Pt for the match |
| 142 | + resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object |
| 143 | + resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first |
| 144 | +) |
| 145 | + |
| 146 | +lowPtElectronsMCMatchForTable = cms.EDProducer( |
| 147 | + "MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR |
| 148 | + src = lowPtElectronTable.src, # final reco collection |
| 149 | + matched = cms.InputTag("finalGenParticles"), # final mc-truth particle collection |
| 150 | + mcPdgId = cms.vint32(11), # one or more PDG ID (11 = ele); absolute values (see below) |
| 151 | + checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge |
| 152 | + mcStatus = cms.vint32(1), # PYTHIA status code (1 = stable, 2 = shower, 3 = hard scattering) |
| 153 | + maxDeltaR = cms.double(0.3), # Minimum deltaR for the match |
| 154 | + maxDPtRel = cms.double(0.5), # Minimum deltaPt/Pt for the match |
| 155 | + resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object |
| 156 | + resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first |
| 157 | +) |
| 158 | + |
| 159 | +from PhysicsTools.NanoAOD.electrons_cff import electronMCTable |
| 160 | +lowPtElectronMCTable = cms.EDProducer( |
| 161 | + "CandMCMatchTableProducer", |
| 162 | + src = lowPtElectronTable.src, |
| 163 | + mcMapDressedLep = cms.InputTag("lowPtElectronsMCMatchForTableAlt"), |
| 164 | + mcMap = cms.InputTag("lowPtElectronsMCMatchForTable"), |
| 165 | + mapTauAnc = cms.InputTag("matchingLowPtElecPhoton:hasTauAnc"), |
| 166 | + objName = lowPtElectronTable.name, |
| 167 | + objType = electronMCTable.objType, |
| 168 | + branchName = cms.string("genPart"), |
| 169 | + docString = cms.string("MC matching to status==1 electrons or photons"), |
| 170 | + genparticles = cms.InputTag("finalGenParticles"), |
| 171 | +) |
| 172 | + |
| 173 | +################################################################################ |
| 174 | +# Sequences |
| 175 | +################################################################################ |
| 176 | + |
| 177 | +lowPtElectronSequence = cms.Sequence(modifiedLowPtElectrons |
| 178 | + +lowPtPATElectronID |
| 179 | + +isoForLowPtEle |
| 180 | + +updatedLowPtElectronsWithUserData |
| 181 | + +finalLowPtElectrons) |
| 182 | +lowPtElectronTables = cms.Sequence(lowPtElectronTable) |
| 183 | +lowPtElectronMC = cms.Sequence( |
| 184 | + particleLevelForMatchingLowPt |
| 185 | + +tautaggerForMatchingLowPt |
| 186 | + +matchingLowPtElecPhoton |
| 187 | + +lowPtElectronsMCMatchForTable |
| 188 | + +lowPtElectronsMCMatchForTableAlt |
| 189 | + +lowPtElectronMCTable) |
| 190 | + |
| 191 | +################################################################################ |
| 192 | +# Modifiers |
| 193 | +################################################################################ |
| 194 | + |
| 195 | +_modifiers = ( run2_miniAOD_80XLegacy | |
| 196 | + run2_nanoAOD_94XMiniAODv1 | |
| 197 | + run2_nanoAOD_94XMiniAODv2 | |
| 198 | + run2_nanoAOD_94X2016 | |
| 199 | + run2_nanoAOD_102Xv1 | |
| 200 | + run2_nanoAOD_106Xv1 ) |
| 201 | +(_modifiers).toReplaceWith(lowPtElectronSequence,cms.Sequence()) |
| 202 | +(_modifiers).toReplaceWith(lowPtElectronTables,cms.Sequence()) |
| 203 | +(_modifiers).toReplaceWith(lowPtElectronMC,cms.Sequence()) |
0 commit comments