Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-25 02:14:04

0001 import FWCore.ParameterSet.Config as cms
0002 from PhysicsTools.NanoAOD.simplePATElectronFlatTableProducer_cfi import simplePATElectronFlatTableProducer
0003 from PhysicsTools.NanoAOD.nano_eras_cff import *
0004 from PhysicsTools.NanoAOD.common_cff import *
0005 from math import ceil,log
0006 
0007 ############################FOR bitmapVIDForEle main defn#############################
0008 electron_id_modules_WorkingPoints_nanoAOD = cms.PSet(
0009     modules = cms.vstring(        
0010         'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
0011         # HZZ ID
0012         'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer16UL_ID_ISO_cff',
0013         'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer17UL_ID_ISO_cff',
0014         'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer18UL_ID_ISO_cff',
0015         'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Winter22_HZZ_V1_cff',
0016         # Fall17: need to include the modules too to make sure they are run
0017         'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff',
0018         'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
0019         'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
0020         # Run3Winter22:
0021         'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Winter22_122X_V1_cff',
0022         'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_RunIIIWinter22_iso_V1_cff',
0023         'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_RunIIIWinter22_noIso_V1_cff',
0024     ),
0025     WorkingPoints = cms.vstring(
0026         "egmGsfElectronIDs:cutBasedElectronID-RunIIIWinter22-V1-veto",
0027         "egmGsfElectronIDs:cutBasedElectronID-RunIIIWinter22-V1-loose",
0028         "egmGsfElectronIDs:cutBasedElectronID-RunIIIWinter22-V1-medium",
0029         "egmGsfElectronIDs:cutBasedElectronID-RunIIIWinter22-V1-tight",
0030     )
0031 )
0032 
0033 # Use Fall17-94X-V2 as default for Run 2
0034 electron_id_modules_WorkingPoints_nanoAOD_Run2 = cms.PSet(
0035     modules = cms.vstring(
0036         'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff',
0037         'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
0038         'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
0039         'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
0040         # HZZ ID
0041         'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer16UL_ID_ISO_cff',
0042         'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer17UL_ID_ISO_cff',
0043         'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Summer18UL_ID_ISO_cff',
0044     ),
0045     WorkingPoints = cms.vstring(
0046         "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto",
0047         "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose",
0048         "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium",
0049         "egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight",
0050     )
0051 )
0052 
0053 # make Fall17 the default one in Run2
0054 run2_egamma.toModify(electron_id_modules_WorkingPoints_nanoAOD,
0055                           modules=electron_id_modules_WorkingPoints_nanoAOD_Run2.modules).\
0056         toModify(electron_id_modules_WorkingPoints_nanoAOD,
0057                  WorkingPoints=electron_id_modules_WorkingPoints_nanoAOD_Run2.WorkingPoints)
0058 
0059 def _get_bitmapVIDForEle_docstring(modules,WorkingPoints):
0060     docstring=''
0061     for modname in modules:
0062         ids= __import__(modname, globals(), locals(), ['idName','cutFlow'])
0063         for name in dir(ids):
0064             _id = getattr(ids,name)
0065             if hasattr(_id,'idName') and hasattr(_id,'cutFlow'):
0066                 if (len(WorkingPoints)>0 and _id.idName==WorkingPoints[0].split(':')[-1]):
0067                     docstring = 'VID compressed bitmap (%s), %d bits per cut'%(','.join([cut.cutName.value() for cut in _id.cutFlow]),int(ceil(log(len(WorkingPoints)+1,2))))
0068     return docstring
0069 
0070 bitmapVIDForEle = cms.EDProducer("EleVIDNestedWPBitmapProducer",
0071     src = cms.InputTag("slimmedElectrons"),
0072     srcForID = cms.InputTag("reducedEgamma","reducedGedGsfElectrons"),
0073     WorkingPoints = electron_id_modules_WorkingPoints_nanoAOD.WorkingPoints,
0074 )
0075 _bitmapVIDForEle_docstring = _get_bitmapVIDForEle_docstring(electron_id_modules_WorkingPoints_nanoAOD.modules,bitmapVIDForEle.WorkingPoints)
0076 
0077 bitmapVIDForEleFall17V2 = bitmapVIDForEle.clone(
0078     WorkingPoints = electron_id_modules_WorkingPoints_nanoAOD_Run2.WorkingPoints
0079     )
0080 _bitmapVIDForEleFall17V2_docstring = _get_bitmapVIDForEle_docstring(electron_id_modules_WorkingPoints_nanoAOD.modules, bitmapVIDForEleFall17V2.WorkingPoints)
0081 
0082 bitmapVIDForEleHEEP = bitmapVIDForEle.clone(
0083     WorkingPoints = cms.vstring("egmGsfElectronIDs:heepElectronID-HEEPV70"
0084     )
0085 )
0086 _bitmapVIDForEleHEEP_docstring = _get_bitmapVIDForEle_docstring(electron_id_modules_WorkingPoints_nanoAOD.modules,bitmapVIDForEleHEEP.WorkingPoints)
0087 ############################for bitmapVIDForEle defn end#############################
0088 
0089 #######################ISO ELE defn(in principle should be an import####################
0090 ##PhysicsTools/NanoAOD/python/EleIsoValueMapProducer_cfi.py
0091 isoForEle = cms.EDProducer("EleIsoValueMapProducer",
0092     src = cms.InputTag("slimmedElectrons"),
0093     relative = cms.bool(False),
0094     rho_MiniIso = cms.InputTag("fixedGridRhoFastjetAll"),
0095     rho_PFIso = cms.InputTag("fixedGridRhoFastjetAll"),
0096     EAFile_MiniIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Run3_Winter22/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_122X.txt"),
0097     EAFile_PFIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Run3_Winter22/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_122X.txt"),
0098 )
0099 
0100 isoForEleFall17V2 = isoForEle.clone(
0101     EAFile_MiniIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
0102     EAFile_PFIso = cms.FileInPath("RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt"),
0103 )
0104 #######################################ISO ELE end#####################################
0105 
0106 ######################################ptRatioForEle#####################################
0107 ###import from hysicsTools/NanoAOD/pythonElectronJetVarProducer_cfi.py
0108 ptRatioRelForEle = cms.EDProducer("ElectronJetVarProducer",
0109     srcJet = cms.InputTag("updatedJetsPuppi"),
0110     srcLep = cms.InputTag("slimmedElectrons"),
0111     srcVtx = cms.InputTag("offlineSlimmedPrimaryVertices"),
0112 )
0113 ######################################ptRatioForEle#####################################
0114 
0115 #############3###################seedGailEle#############################
0116 seedGainEle = cms.EDProducer("ElectronSeedGainProducer", src = cms.InputTag("slimmedElectrons"))
0117 ############################################seed gainELE
0118 
0119 ############################calibratedPatElectrons##############
0120 ##this is a special one, so we leave the era modifications here#####
0121 import RecoEgamma.EgammaTools.calibratedEgammas_cff
0122 
0123 calibratedPatElectronsNano = RecoEgamma.EgammaTools.calibratedEgammas_cff.calibratedPatElectrons.clone(
0124     produceCalibratedObjs = False,
0125     src = "slimmedElectrons"
0126 )
0127 
0128 (run2_egamma_2016 & tracker_apv_vfp30_2016).toModify(
0129     calibratedPatElectronsNano,
0130     correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2016_UltraLegacy_preVFP_RunFineEtaR9Gain"
0131 )
0132 
0133 (run2_egamma_2016 & ~tracker_apv_vfp30_2016).toModify(
0134     calibratedPatElectronsNano,
0135     correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2016_UltraLegacy_postVFP_RunFineEtaR9Gain"
0136 )
0137 
0138 run2_egamma_2017.toModify(
0139     calibratedPatElectronsNano,
0140     correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2017_24Feb2020_runEtaR9Gain_v2"
0141 )
0142 
0143 run2_egamma_2018.toModify(
0144     calibratedPatElectronsNano,
0145     correctionFile = "EgammaAnalysis/ElectronTools/data/ScalesSmearings/Run2018_29Sep2020_RunFineEtaR9Gain"
0146 )
0147 ##############################end calibratedPatElectronsNano############################33
0148 
0149 #####################Start slimmedElectronsWithUserData###############################3
0150 ##import from PhysicsTools/PatAlgos/python/electronsWithUserData_cfi.py
0151 slimmedElectronsWithUserData = cms.EDProducer("PATElectronUserDataEmbedder",
0152     src = cms.InputTag("slimmedElectrons"),
0153     parentSrcs = cms.VInputTag("reducedEgamma:reducedGedGsfElectrons"),
0154     userFloats = cms.PSet(        
0155         mvaIso_Fall17V2 = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17IsoV2Values"),
0156         mvaNoIso_Fall17V2 = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV2Values"),
0157         mvaIso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2RunIIIWinter22IsoV1Values"),
0158         mvaNoIso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2RunIIIWinter22NoIsoV1Values"),
0159         mvaHZZIso = cms.InputTag("electronMVAValueMapProducer:ElectronMVAEstimatorRun2Winter22HZZV1Values"),
0160 
0161         miniIsoChg = cms.InputTag("isoForEle:miniIsoChg"),
0162         miniIsoAll = cms.InputTag("isoForEle:miniIsoAll"),
0163         PFIsoChg = cms.InputTag("isoForEle:PFIsoChg"),
0164         PFIsoAll = cms.InputTag("isoForEle:PFIsoAll"),
0165         PFIsoAll04 = cms.InputTag("isoForEle:PFIsoAll04"),
0166 
0167         miniIsoChg_Fall17V2 = cms.InputTag("isoForEleFall17V2:miniIsoChg"),
0168         miniIsoAll_Fall17V2 = cms.InputTag("isoForEleFall17V2:miniIsoAll"),
0169         PFIsoChg_Fall17V2 = cms.InputTag("isoForEleFall17V2:PFIsoChg"),
0170         PFIsoAll_Fall17V2 = cms.InputTag("isoForEleFall17V2:PFIsoAll"),
0171         PFIsoAll04_Fall17V2 = cms.InputTag("isoForEleFall17V2:PFIsoAll04"),
0172 
0173         ptRatio = cms.InputTag("ptRatioRelForEle:ptRatio"),
0174         ptRel = cms.InputTag("ptRatioRelForEle:ptRel"),
0175         jetNDauChargedMVASel = cms.InputTag("ptRatioRelForEle:jetNDauChargedMVASel"),
0176     ),
0177     userIntFromBools = cms.PSet(        
0178         mvaIso_Fall17V2_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wp90"),
0179         mvaIso_Fall17V2_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wp80"),
0180         mvaIso_Fall17V2_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wpLoose"),
0181         mvaIso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-RunIIIWinter22-iso-V1-wp90"),
0182         mvaIso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-RunIIIWinter22-iso-V1-wp80"),                
0183         mvaNoIso_Fall17V2_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wp90"),
0184         mvaNoIso_Fall17V2_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wp80"),
0185         mvaNoIso_Fall17V2_WPL = cms.InputTag("egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wpLoose"),
0186         mvaNoIso_WP90 = cms.InputTag("egmGsfElectronIDs:mvaEleID-RunIIIWinter22-noIso-V1-wp90"),
0187         mvaNoIso_WP80 = cms.InputTag("egmGsfElectronIDs:mvaEleID-RunIIIWinter22-noIso-V1-wp80"),
0188         mvaIso_WPHZZ = cms.InputTag("egmGsfElectronIDs:mvaEleID-Winter22-HZZ-V1"),
0189 
0190         cutBasedID_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-RunIIIWinter22-V1-veto"),
0191         cutBasedID_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-RunIIIWinter22-V1-loose"),
0192         cutBasedID_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-RunIIIWinter22-V1-medium"),
0193         cutBasedID_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-RunIIIWinter22-V1-tight"),
0194         cutBasedID_Fall17V2_veto = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-veto"),
0195         cutBasedID_Fall17V2_loose = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-loose"),
0196         cutBasedID_Fall17V2_medium = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium"),
0197         cutBasedID_Fall17V2_tight = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight"),
0198         cutBasedID_HEEP = cms.InputTag("egmGsfElectronIDs:heepElectronID-HEEPV70"),
0199     ),
0200     userInts = cms.PSet(
0201         VIDNestedWPBitmap = cms.InputTag("bitmapVIDForEle"),
0202         VIDNestedWPBitmap_Fall17V2 = cms.InputTag("bitmapVIDForEleFall17V2"),
0203         VIDNestedWPBitmapHEEP = cms.InputTag("bitmapVIDForEleHEEP"),
0204         seedGain = cms.InputTag("seedGainEle"),
0205       
0206     ),
0207     userCands = cms.PSet(
0208         jetForLepJetVar = cms.InputTag("ptRatioRelForEle:jetForLepJetVar") # warning: Ptr is null if no match is found
0209     ),
0210 )
0211 
0212 # no need for the Run3 IDs in Run2
0213 run2_egamma.toModify(slimmedElectronsWithUserData.userFloats,
0214                      mvaIso = None,
0215                      mvaNoIso = None,
0216                      miniIsoChg = None,
0217                      miniIsoAll = None,
0218                      PFIsoChg = None,
0219                      PFIsoAll = None,
0220                      PFIsoAll04 = None).\
0221         toModify(slimmedElectronsWithUserData.userIntFromBools,
0222                  mvaIso_WPHZZ = None,
0223                  mvaIso_WP90 = None,
0224                  mvaIso_WP80 = None,
0225                  mvaNoIso_WP90 = None,
0226                  mvaNoIso_WP80 = None,
0227                  cutBasedID_veto = None,
0228                  cutBasedID_loose = None,
0229                  cutBasedID_medium = None,
0230                  cutBasedID_tight = None).\
0231         toModify(slimmedElectronsWithUserData.userInts,
0232                  VIDNestedWPBitmap = None)
0233 
0234 run2_egamma.toModify(
0235     slimmedElectronsWithUserData.userFloats,
0236     ecalTrkEnergyErrPostCorrNew = cms.InputTag("calibratedPatElectronsNano","ecalTrkEnergyErrPostCorr"),
0237     ecalTrkEnergyPreCorrNew     = cms.InputTag("calibratedPatElectronsNano","ecalTrkEnergyPreCorr"),
0238     ecalTrkEnergyPostCorrNew    = cms.InputTag("calibratedPatElectronsNano","ecalTrkEnergyPostCorr"),
0239     energyScaleUpNew            = cms.InputTag("calibratedPatElectronsNano","energyScaleUp"),
0240     energyScaleDownNew          = cms.InputTag("calibratedPatElectronsNano","energyScaleDown"),
0241     energySigmaUpNew            = cms.InputTag("calibratedPatElectronsNano","energySigmaUp"),
0242     energySigmaDownNew          = cms.InputTag("calibratedPatElectronsNano","energySigmaDown")
0243 )
0244 
0245 (run2_egamma_2016).toModify(
0246     slimmedElectronsWithUserData.userFloats,
0247     mvaHZZIso = "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Summer16ULIdIsoValues"
0248 )
0249 (run2_egamma_2017).toModify(
0250     slimmedElectronsWithUserData.userFloats,
0251     mvaHZZIso = "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Summer17ULIdIsoValues"
0252 )
0253 (run2_egamma_2018).toModify(
0254     slimmedElectronsWithUserData.userFloats,
0255     mvaHZZIso = "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Summer18ULIdIsoValues"
0256 )
0257 #################################################END slimmedElectrons with user data#####################
0258 
0259 #################################################finalElectrons#####################
0260 finalElectrons = cms.EDFilter("PATElectronRefSelector",
0261     src = cms.InputTag("slimmedElectronsWithUserData"),
0262     cut = cms.string("pt > 5 ")
0263 )
0264 #################################################finalElectrons#####################
0265 
0266 ################################################electronPROMPTMVA#####################
0267 electronPROMPTMVA= cms.EDProducer("EleBaseMVAValueMapProducer",
0268     src = cms.InputTag("linkedObjects","electrons"),
0269     weightFile =  cms.FileInPath("PhysicsTools/NanoAOD/data/el_BDTG_2017.weights.xml"),
0270     name = cms.string("electronPROMPTMVA"),
0271     backend = cms.string("TMVA"),
0272     isClassifier = cms.bool(True),
0273     variables = cms.VPSet(
0274         cms.PSet( name = cms.string("LepGood_pt"), expr = cms.string("pt")),
0275         cms.PSet( name = cms.string("LepGood_eta"), expr = cms.string("eta")),
0276         cms.PSet( name = cms.string("LepGood_jetNDauChargedMVASel"), expr = cms.string("?userCand('jetForLepJetVar').isNonnull()?userFloat('jetNDauChargedMVASel'):0")),
0277         cms.PSet( name = cms.string("LepGood_miniRelIsoCharged"), expr = cms.string("userFloat('miniIsoChg_Fall17V2')/pt")),
0278         cms.PSet( name = cms.string("LepGood_miniRelIsoNeutral"), expr = cms.string("(userFloat('miniIsoAll_Fall17V2')-userFloat('miniIsoChg_Fall17V2'))/pt")),
0279         cms.PSet( name = cms.string("LepGood_jetPtRelv2"), expr = cms.string("?userCand('jetForLepJetVar').isNonnull()?userFloat('ptRel'):0")),
0280         cms.PSet( name = cms.string("LepGood_jetDF"), expr = cms.string("?userCand('jetForLepJetVar').isNonnull()?max(userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:probbb')+userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:probb')+userCand('jetForLepJetVar').bDiscriminator('pfDeepFlavourJetTags:problepb'),0.0):0.0")),
0281         cms.PSet( name = cms.string("LepGood_jetPtRatio"), expr = cms.string("?userCand('jetForLepJetVar').isNonnull()?min(userFloat('ptRatio'),1.5):1.0/(1.0+userFloat('PFIsoAll04_Fall17V2')/pt)")),
0282         cms.PSet( name = cms.string("LepGood_dxy"), expr = cms.string("log(abs(dB('PV2D')))")),
0283         cms.PSet( name = cms.string("LepGood_sip3d"), expr = cms.string("abs(dB('PV3D')/edB('PV3D'))")),
0284         cms.PSet( name = cms.string("LepGood_dz"), expr = cms.string("log(abs(dB('PVDZ')))")),
0285         cms.PSet( name = cms.string("LepGood_mvaFall17V2noIso"), expr = cms.string("userFloat('mvaNoIso_Fall17V2')")),
0286     )
0287 )
0288 run2_egamma_2016.toModify(
0289     electronPROMPTMVA,
0290     weightFile = "PhysicsTools/NanoAOD/data/el_BDTG_2016.weights.xml",
0291 )
0292 ################################################electronPROMPTMVA end#####################
0293 
0294 ################################################electronTable defn #####################
0295 electronTable = simplePATElectronFlatTableProducer.clone(
0296     src = cms.InputTag("linkedObjects","electrons"),
0297     name= cms.string("Electron"),
0298     doc = cms.string("slimmedElectrons after basic selection (" + finalElectrons.cut.value()+")"),
0299     variables = cms.PSet(CandVars,
0300         jetIdx = Var("?hasUserCand('jet')?userCand('jet').key():-1", "int16", doc="index of the associated jet (-1 if none)"),
0301         photonIdx = Var("?overlaps('photons').size()>0?overlaps('photons')[0].key():-1", "int16", doc="index of the first associated photon (-1 if none)"),
0302         svIdx = Var("?hasUserCand('vertex')?userCand('vertex').key():-1", "int16", doc="index of matching secondary vertex"),
0303         fbrem = Var("fbrem()",float,doc="Fraction of brem",precision=10),                 
0304         rawEnergy = Var("superCluster.rawEnergy",float,doc="raw energy of Supercluster",precision=10),
0305         PreshowerEnergy = Var("superCluster.preshowerEnergy",float,doc="energy deposited in preshower",precision=10),                 
0306         ecalEnergy = Var("ecalEnergy()",float,doc="energy after ECAL-only regression applied",precision=10),
0307         ecalEnergyError = Var("ecalEnergyError",float,doc="ecalEnergy error",precision=10),
0308         energyErr = Var("p4Error('P4_COMBINATION')",float,doc="energy error of the cluster-track combination",precision=6),
0309         gsfTrkpMode = Var("gsfTrack().pMode()",float,doc="GSF track pMode",precision=10),
0310         gsfTrkpModeErr = Var("abs(gsfTrack().qoverpModeError())*gsfTrack().pMode()*gsfTrack().pMode()",float,doc="GSF track pMode error",precision=8),
0311         gsfTrketaMode = Var("gsfTrack().etaMode()",float,doc="GSF track etaMode",precision=10),
0312         gsfTrkphiMode = Var("gsfTrack().phiMode()",float,doc="GSF track phiMode",precision=10),                 
0313         isEcalDriven = Var("ecalDrivenSeed",bool,doc="is ECAL driven if true"),
0314         isEB = Var("isEB",bool,doc="object in barrel if true derived from the seedCrystal and detID information"),                 
0315         dz = Var("dB('PVDZ')",float,doc="dz (with sign) wrt first PV, in cm",precision=10),
0316         dzErr = Var("abs(edB('PVDZ'))",float,doc="dz uncertainty, in cm",precision=6),
0317         dxy = Var("dB('PV2D')",float,doc="dxy (with sign) wrt first PV, in cm",precision=10),
0318         dxyErr = Var("edB('PV2D')",float,doc="dxy uncertainty, in cm",precision=6),
0319         ip3d = Var("abs(dB('PV3D'))",float,doc="3D impact parameter wrt first PV, in cm",precision=10),
0320         sip3d = Var("abs(dB('PV3D')/edB('PV3D'))",float,doc="3D impact parameter significance wrt first PV, in cm",precision=10),
0321         deltaEtaSC = Var("superCluster().eta()-eta()",float,doc="delta eta (SC,ele) with sign",precision=10),
0322         r9 = Var("full5x5_r9()",float,doc="R9 of the supercluster, calculated with full 5x5 region",precision=10),
0323         sieie = Var("full5x5_sigmaIetaIeta()",float,doc="sigma_IetaIeta of the supercluster, calculated with full 5x5 region",precision=10),
0324         eInvMinusPInv = Var("(1-eSuperClusterOverP())/ecalEnergy()",float,doc="1/E_SC - 1/p_trk",precision=10),
0325         scEtOverPt = Var("(superCluster().energy()/(pt*cosh(superCluster().eta())))-1",float,doc="(supercluster transverse energy)/pt-1",precision=8),
0326 
0327         mvaIso = Var("userFloat('mvaIso')",float,doc="MVA Iso ID score, Winter22V1"),
0328         mvaIso_WP80 = Var("userInt('mvaIso_WP80')",bool,doc="MVA Iso ID WP80, Winter22V1"),
0329         mvaIso_WP90 = Var("userInt('mvaIso_WP90')",bool,doc="MVA Iso ID WP90, Winter22V1"),
0330         mvaNoIso = Var("userFloat('mvaNoIso')",float,doc="MVA noIso ID score, Winter22V1"),
0331         mvaNoIso_WP80 = Var("userInt('mvaNoIso_WP80')",bool,doc="MVA noIso ID WP80, Winter22V1"),
0332         mvaNoIso_WP90 = Var("userInt('mvaNoIso_WP90')",bool,doc="MVA noIso ID WP90, Winter22V1"),                 
0333         mvaHZZIso = Var("userFloat('mvaHZZIso')", float,doc="HZZ MVA Iso ID score"),
0334         mvaIso_WPHZZ = Var("userInt('mvaIso_WPHZZ')",bool,doc="MVA Iso ID WPHZZ, Winter22V1"),
0335 
0336         cutBased = Var("userInt('cutBasedID_veto')+userInt('cutBasedID_loose')+userInt('cutBasedID_medium')+userInt('cutBasedID_tight')", "uint8", doc="cut-based ID RunIII Winter22 (0:fail, 1:veto, 2:loose, 3:medium, 4:tight)"),
0337         vidNestedWPBitmap = Var("userInt('VIDNestedWPBitmap')", int, doc=_bitmapVIDForEle_docstring),
0338         vidNestedWPBitmapHEEP = Var("userInt('VIDNestedWPBitmapHEEP')", int, doc=_bitmapVIDForEleHEEP_docstring),
0339         cutBased_HEEP = Var("userInt('cutBasedID_HEEP')",bool,doc="cut-based HEEP ID"),
0340         miniPFRelIso_chg = Var("userFloat('miniIsoChg')/pt",float,doc="mini PF relative isolation, charged component"),
0341         miniPFRelIso_all = Var("userFloat('miniIsoAll')/pt",float,doc="mini PF relative isolation, total (with scaled rho*EA PU Winter22V1 corrections)"),
0342         pfRelIso03_chg = Var("userFloat('PFIsoChg')/pt",float,doc="PF relative isolation dR=0.3, charged component"),
0343         pfRelIso03_all = Var("userFloat('PFIsoAll')/pt",float,doc="PF relative isolation dR=0.3, total (with rho*EA PU Winter22V1 corrections)"),                
0344         jetRelIso = Var("?userCand('jetForLepJetVar').isNonnull()?(1./userFloat('ptRatio'))-1.:userFloat('PFIsoAll04')/pt",float,doc="Relative isolation in matched jet (1/ptRatio-1, pfRelIso04_all if no matched jet)",precision=8),        
0345         jetPtRelv2 = Var("?userCand('jetForLepJetVar').isNonnull()?userFloat('ptRel'):0",float,doc="Relative momentum of the lepton with respect to the closest jet after subtracting the lepton",precision=8),
0346         dr03TkSumPt = Var("?pt>35?dr03TkSumPt():0",float,doc="Non-PF track isolation within a delta R cone of 0.3 with electron pt > 35 GeV",precision=8),
0347         dr03TkSumPtHEEP = Var("?pt>35?dr03TkSumPtHEEP():0",float,doc="Non-PF track isolation within a delta R cone of 0.3 with electron pt > 35 GeV used in HEEP ID",precision=8),
0348         dr03EcalRecHitSumEt = Var("?pt>35?dr03EcalRecHitSumEt():0",float,doc="Non-PF Ecal isolation within a delta R cone of 0.3 with electron pt > 35 GeV",precision=8),
0349         dr03HcalDepth1TowerSumEt = Var("?pt>35?dr03HcalTowerSumEt(1):0",float,doc="Non-PF Hcal isolation within a delta R cone of 0.3 with electron pt > 35 GeV",precision=8),
0350         hoe = Var("hadronicOverEm()",float,doc="H over E",precision=8),
0351         tightCharge = Var("isGsfCtfScPixChargeConsistent() + isGsfScPixChargeConsistent()", "uint8", doc="Tight charge criteria (0:none, 1:isGsfScPixChargeConsistent, 2:isGsfCtfScPixChargeConsistent)"),
0352         convVeto = Var("passConversionVeto()",bool,doc="pass conversion veto"),
0353         lostHits = Var("gsfTrack.hitPattern.numberOfLostHits('MISSING_INNER_HITS')","uint8",doc="number of missing inner hits"),
0354         isPFcand = Var("pfCandidateRef().isNonnull()",bool,doc="electron is PF candidate"),
0355         seedGain = Var("userInt('seedGain')","uint8",doc="Gain of the seed crystal"),
0356         seediEtaOriX = Var("superCluster().seedCrysIEtaOrIx","int16",doc="iEta or iX of seed crystal. iEta is barrel-only, iX is endcap-only. iEta runs from -85 to +85, with no crystal at iEta=0. iX runs from 1 to 100."),
0357         seediPhiOriY = Var("superCluster().seedCrysIPhiOrIy","int16",doc="iPhi or iY of seed crystal. iPhi is barrel-only, iY is endcap-only. iPhi runs from 1 to 360. iY runs from 1 to 100."),
0358         jetNDauCharged = Var("?userCand('jetForLepJetVar').isNonnull()?userFloat('jetNDauChargedMVASel'):0", "uint8", doc="number of charged daughters of the closest jet"),
0359     ),
0360     externalVariables = cms.PSet(
0361         promptMVA = ExtVar(cms.InputTag("electronPROMPTMVA"),float, doc="Prompt MVA lepton ID score. Corresponds to the previous mvaTTH",precision=14),
0362         fsrPhotonIdx = ExtVar(cms.InputTag("leptonFSRphotons:eleFsrIndex"), "int16", doc="Index of the lowest-dR/ET2 among associated FSR photons"),
0363     ),
0364 )
0365 
0366 # extra variables for e/gamma custom nano
0367 _eleVarsExtra = cms.PSet(
0368     r9Frac = Var("r9()",float,doc="Fractional R9 of the supercluster",precision=10),
0369     DeltaEtaInSC = Var("deltaEtaSuperClusterTrackAtVtx",float,doc="dEta(Inner track, supercluster)",precision=10),
0370     DeltaEtaInSeed = Var("deltaEtaSeedClusterTrackAtCalo",float,doc="dEta(Inner track, seedcluster)",precision=10),
0371     DeltaPhiInSC = Var("deltaPhiSuperClusterTrackAtVtx",float,doc="dPhi(Inner track, supercluster)",precision=10),
0372     DeltaPhiInSeed = Var("deltaPhiSeedClusterTrackAtCalo",float,doc="dPhi(Inner track, seedcluster)",precision=10),
0373     full5x5HoverE = Var("full5x5_hcalOverEcal",float,doc="full5x5 H/E",precision=10),
0374     eSCOverP = Var("eSuperClusterOverP",float,doc="E/P",precision=10),
0375     eEleOverPout = Var("eEleClusterOverPout",float,doc="EleE/Pouter",precision=10),
0376     e1x5 = Var("full5x5_e1x5",float,doc="energy in 1x5",precision=10),
0377     e2x5max = Var("full5x5_e2x5Max",float,doc="energy in 2x5",precision=10),
0378     e5x5 = Var("full5x5_e5x5",float,doc="energy in 5x5",precision=10),
0379     closestKFchi2 = Var("closestCtfTrackNormChi2",float,doc="KF track Chi2",precision=10),
0380     closestKFNLayers = Var("closestCtfTrackNLayers",int,doc="KF track number of layers"),
0381     dr03HcalTowerSumEt = Var("dr03HcalTowerSumEt",float,doc="HCal isolation",precision=10),
0382     GSFchi2 = Var("gsfTrack.normalizedChi2",float,doc="GSF track Chi2",precision=10),
0383     superclusterEta = Var("superCluster.eta",float,doc="supercluster eta",precision=10),
0384     ecalPFClusIso = Var("ecalPFClusterIso",float,doc="ECAL PF cluster isolation",precision=10),
0385     hcalPFClusIso = Var("hcalPFClusterIso",float,doc="HCAL PF cluster isolation",precision=10),
0386     nBrem = Var("numberOfBrems",int,doc="number of brems"),
0387     pfPhotonIso = Var("pfIsolationVariables.sumPhotonEt",float,doc="PF photon isolation (no PU correction)",precision=10),
0388     pfChargedHadIso = Var("pfIsolationVariables.sumChargedHadronPt",float,doc="PF charged-hadron isolation (no PU correction)",precision=10),
0389     pfNeutralHadIso = Var("pfIsolationVariables.sumNeutralHadronEt",float,doc="PF neutral-hadron isolation (no PU correction)",precision=10),
0390     sigmaIphiIphiFull5x5 = Var("full5x5_sigmaIphiIphi",float,doc="Full5x5 sigmaIPhiIPhi",precision=10),
0391     etaWidth = Var("superCluster.etaWidth",float,doc="etawidth of supercluster",precision=10),
0392     phiWidth = Var("superCluster.phiWidth",float,doc="phiwidth of supercluster",precision=10),
0393     seedClusEnergy = Var("superCluster.seed.energy",float,doc="seed cluster energy",precision=10),
0394     hoeSingleTower = Var("hcalOverEcalBc",float,doc="Single HCAL tower based H/E",precision=10),
0395     hoeFull5x5 = Var("full5x5_hcalOverEcal",float,doc="Full5x5 cone-based H/E",precision=10),
0396     sigmaIetaIphiFull5x5 = Var("full5x5_showerShape.sigmaIetaIphi",float,doc="Full5x5 sigmaIEtaIPhi",precision=10),
0397     eMax = Var("full5x5_showerShape.eMax",float,doc="Emax",precision=10),
0398     e2nd = Var("full5x5_showerShape.e2nd",float,doc="E2nd",precision=10),
0399     eTop = Var("full5x5_showerShape.eTop",float,doc="Etop",precision=10),
0400     eBottom = Var("full5x5_showerShape.eBottom",float,doc="Ebottom",precision=10),
0401     eLeft = Var("full5x5_showerShape.eLeft",float,doc="Eleft",precision=10),
0402     eRight = Var("full5x5_showerShape.eRight",float,doc="Eright",precision=10),
0403     e2x5Top = Var("full5x5_showerShape.e2x5Top",float,doc="E2x5Top",precision=10),
0404     e2x5Bottom = Var("full5x5_showerShape.e2x5Bottom",float,doc="E2x5Bottom",precision=10),
0405     e2x5Left = Var("full5x5_showerShape.e2x5Left",float,doc="E2x5Left",precision=10),
0406     e2x5Right = Var("full5x5_showerShape.e2x5Right",float,doc="E2x5Right",precision=10),
0407     nSaturatedXtals = Var("nSaturatedXtals",int,doc="number of saturated crystals"),
0408     numberOfClusters = Var("superCluster.clusters.size",int,doc="number of clusters"),
0409     istrackerDriven = Var("trackerDrivenSeed",bool,doc="is tracker driven if true"),
0410     superclusterPhi = Var("superCluster().phi()",float,doc="supercluster phi",precision=10),
0411     seedClusterEta = Var("superCluster().seed().eta()",float,doc="seed cluster eta",precision=10),
0412     seedClusterPhi = Var("superCluster().seed().phi()",float,doc="seed cluster phi",precision=10),
0413     superclusterEnergy = Var("superCluster().energy()",float,doc="only PF cluster energy is corrected, no object-level regression",precision=10),
0414     energy = Var("energy()",float,doc="energy after final regression",precision=10),
0415     trackMomentumError = Var("trackMomentumError",float,doc="trackMomentum error",precision=10),
0416     trackMomentum = Var("trackMomentumAtVtx().R()",float,doc="trackMomentum at vertex",precision=10),
0417     trkLayersWithMeas = Var("gsfTrack.hitPattern.trackerLayersWithMeasurement",int,doc="trackerLayersWithMeasurement"),
0418     nValidPixBarrelHits = Var("gsfTrack.hitPattern.numberOfValidPixelBarrelHits",int,doc="numberOfValidPixelBarrelHits"),
0419     nValidPixEndcapHits = Var("gsfTrack.hitPattern.numberOfValidPixelEndcapHits",int,doc="numberOfValidPixelEndcapHits"),
0420     superClusterFbrem = Var("superClusterFbrem",float,doc="superClusterFbrem",precision=10),
0421     convVtxFitProb = Var("convVtxFitProb",float,doc="convVtxFitProb",precision=10),
0422     clustersSize = Var("superCluster.clustersSize",int,doc="clustersSize"),
0423     iEtaMod5 = Var("?superCluster.seedCrysIEtaOrIx>0?(superCluster.seedCrysIEtaOrIx-1)%5:(superCluster.seedCrysIEtaOrIx+1)%5",int,doc="iEtaMod5"),
0424     iEtaMod20 = Var("?abs(superCluster.seedCrysIEtaOrIx)<=25?(superCluster.seedCrysIEtaOrIx-(?superCluster.seedCrysIEtaOrIx>0?+1:-1))%20:(superCluster.seedCrysIEtaOrIx-(?superCluster.seedCrysIEtaOrIx>0?+26:-26))%20",int,doc="iEtaMod20"),
0425     iPhiMod2 = Var("(superCluster.seedCrysIPhiOrIy-1)%2",int,doc="iPhiMod2"),
0426     iPhiMod20 = Var("(superCluster.seedCrysIPhiOrIy-1)%20",int,doc="iPhiMod20"),
0427 )
0428 
0429 (run2_egamma).toModify(
0430         # energy scale/smearing: only for Run2
0431         electronTable.variables,
0432         pt = Var("pt*userFloat('ecalTrkEnergyPostCorrNew')/userFloat('ecalTrkEnergyPreCorrNew')", float, precision=-1, doc="p_{T}"),
0433         energyErr = Var("userFloat('ecalTrkEnergyErrPostCorrNew')", float, precision=6, doc="energy error of the cluster-track combination"),
0434         eCorr = Var("userFloat('ecalTrkEnergyPostCorrNew')/userFloat('ecalTrkEnergyPreCorrNew')", float, doc="ratio of the calibrated energy/miniaod energy"),
0435         scEtOverPt = Var("(superCluster().energy()/(pt*userFloat('ecalTrkEnergyPostCorrNew')/userFloat('ecalTrkEnergyPreCorrNew')*cosh(superCluster().eta())))-1",float,doc="(supercluster transverse energy)/pt-1",precision=8),
0436         dEscaleUp=Var("userFloat('ecalTrkEnergyPostCorrNew')-userFloat('energyScaleUpNew')", float,  doc="ecal energy scale shifted 1 sigma up(adding gain/stat/syst in quadrature)", precision=8),
0437         dEscaleDown=Var("userFloat('ecalTrkEnergyPostCorrNew')-userFloat('energyScaleDownNew')", float,  doc="ecal energy scale shifted 1 sigma down (adding gain/stat/syst in quadrature)", precision=8),
0438         dEsigmaUp=Var("userFloat('ecalTrkEnergyPostCorrNew')-userFloat('energySigmaUpNew')", float, doc="ecal energy smearing value shifted 1 sigma up", precision=8),
0439         dEsigmaDown=Var("userFloat('ecalTrkEnergyPostCorrNew')-userFloat('energySigmaDownNew')", float,  doc="ecal energy smearing value shifted 1 sigma up", precision=8),
0440         # Fall17V2 IDs and isolations are only for Run2. The names of these IDs and isolations are same as in Run3. 
0441         mvaIso = Var("userFloat('mvaIso_Fall17V2')",float,doc="MVA Iso ID score, Fall17V2"),
0442         mvaIso_WP80 = Var("userInt('mvaIso_Fall17V2_WP80')",bool,doc="MVA Iso ID WP80, Fall17V2"),
0443         mvaIso_WP90 = Var("userInt('mvaIso_Fall17V2_WP90')",bool,doc="MVA Iso ID WP90, Fall17V2"),
0444         mvaIso_WPL = Var("userInt('mvaIso_Fall17V2_WPL')",bool,doc="MVA Iso ID loose WP, Fall17V2"),
0445         mvaNoIso = Var("userFloat('mvaNoIso_Fall17V2')",float,doc="MVA noIso ID score, Fall17V2"),
0446         mvaNoIso_WP80 = Var("userInt('mvaNoIso_Fall17V2_WP80')",bool,doc="MVA noIso ID WP80, Fall17V2"),
0447         mvaIso_WPHZZ = None,
0448         mvaNoIso_WP90 = Var("userInt('mvaNoIso_Fall17V2_WP90')",bool,doc="MVA noIso ID WP90, Fall17V2"),
0449         mvaNoIso_WPL = Var("userInt('mvaNoIso_Fall17V2_WPL')",bool,doc="MVA noIso ID loose WP, Fall17V2"),
0450         cutBased = Var("userInt('cutBasedID_Fall17V2_veto')+userInt('cutBasedID_Fall17V2_loose')+userInt('cutBasedID_Fall17V2_medium')+userInt('cutBasedID_Fall17V2_tight')", "uint8", doc="cut-based ID Fall17V2 (0:fail, 1:veto, 2:loose, 3:medium, 4:tight)"),
0451         vidNestedWPBitmap = Var("userInt('VIDNestedWPBitmap_Fall17V2')", int, doc=_bitmapVIDForEleFall17V2_docstring),
0452         miniPFRelIso_chg = Var("userFloat('miniIsoChg_Fall17V2')/pt",float,doc="mini PF relative isolation, charged component in Run2"),
0453         miniPFRelIso_all = Var("userFloat('miniIsoAll_Fall17V2')/pt",float,doc="mini PF relative isolation, total (with scaled rho*EA Fall17V2 PU corrections) in Run2"),
0454         pfRelIso03_chg = Var("userFloat('PFIsoChg_Fall17V2')/pt",float,doc="PF relative isolation dR=0.3 with 94 EffArea, charged component in Run2"),
0455         pfRelIso03_all = Var("userFloat('PFIsoAll_Fall17V2')/pt",float,doc="PF relative isolation dR=0.3 with 94 EffArea, total (with rho*EA Fall17V2 PU corrections) in Run2"),
0456         jetRelIso = Var("?userCand('jetForLepJetVar').isNonnull()?(1./userFloat('ptRatio'))-1.:userFloat('PFIsoAll04_Fall17V2')/pt",float,doc="Relative isolation in matched jet (1/ptRatio-1, pfRelIso04_all if no matched jet in Run2)",precision=8),
0457 )
0458 
0459 #############electron Table END#####################
0460 # Depends on particlelevel producer run in particlelevel_cff
0461 tautaggerForMatching = cms.EDProducer("GenJetTauTaggerProducer",
0462                                       src = cms.InputTag('particleLevel:leptons')
0463 )
0464  ##PhysicsTools/NanoAOD/plugins/GenJetGenPartMerger.cc##this class misses fillDescription#TODO
0465 matchingElecPhoton = cms.EDProducer("GenJetGenPartMerger",
0466                                     srcJet =cms.InputTag("particleLevel:leptons"),
0467                                     srcPart=cms.InputTag("particleLevel:photons"),
0468                                     cut = cms.string("pt > 3"),
0469                                     hasTauAnc=cms.InputTag("tautaggerForMatching"),
0470 )
0471 electronsMCMatchForTableAlt = cms.EDProducer("GenJetMatcherDRPtByDR",  # cut on deltaR, deltaPt/Pt; pick best by deltaR
0472     src         = electronTable.src,                 # final reco collection
0473     matched     = cms.InputTag("matchingElecPhoton:merged"), # final mc-truth particle collection
0474     mcPdgId     = cms.vint32(11,22),                 # one or more PDG ID (11 = el, 22 = pho); absolute values (see below)
0475     checkCharge = cms.bool(False),              # True = require RECO and MC objects to have the same charge
0476     mcStatus    = cms.vint32(),
0477     maxDeltaR   = cms.double(0.3),              # Minimum deltaR for the match
0478     maxDPtRel   = cms.double(0.5),              # Minimum deltaPt/Pt for the match
0479     resolveAmbiguities    = cms.bool(True),     # Forbid two RECO objects to match to the same GEN object
0480     resolveByMatchQuality = cms.bool(True),    # False = just match input in order; True = pick lowest deltaR pair first
0481 )
0482 electronsMCMatchForTable = cms.EDProducer("MCMatcher",  # cut on deltaR, deltaPt/Pt; pick best by deltaR
0483     src         = electronTable.src,                 # final reco collection
0484     matched     = cms.InputTag("finalGenParticles"), # final mc-truth particle collection
0485     mcPdgId     = cms.vint32(11,22),                 # one or more PDG ID (11 = el, 22 = pho); absolute values (see below)
0486     checkCharge = cms.bool(False),              # True = require RECO and MC objects to have the same charge
0487     mcStatus    = cms.vint32(1),                # PYTHIA status code (1 = stable, 2 = shower, 3 = hard scattering)
0488     maxDeltaR   = cms.double(0.3),              # Minimum deltaR for the match
0489     maxDPtRel   = cms.double(0.5),              # Minimum deltaPt/Pt for the match
0490     resolveAmbiguities    = cms.bool(True),     # Forbid two RECO objects to match to the same GEN object
0491     resolveByMatchQuality = cms.bool(True),    # False = just match input in order; True = pick lowest deltaR pair first
0492 )
0493 #should be cloned from PhysicsTools/NanoAOD/python/candMcMatchTable_cfi.py
0494 electronMCTable = cms.EDProducer("CandMCMatchTableProducer",
0495     src     = electronTable.src,
0496     mcMapDressedLep = cms.InputTag("electronsMCMatchForTableAlt"),
0497     mcMap   = cms.InputTag("electronsMCMatchForTable"),
0498     mapTauAnc = cms.InputTag("matchingElecPhoton:hasTauAnc"),
0499     objName = electronTable.name,
0500     objType = electronTable.name, #cms.string("Electron"),
0501     branchName = cms.string("genPart"),
0502     docString = cms.string("MC matching to status==1 electrons or photons"),
0503     genparticles     = cms.InputTag("finalGenParticles"),
0504 )
0505 
0506 electronTask = cms.Task(bitmapVIDForEle,bitmapVIDForEleFall17V2,bitmapVIDForEleHEEP,isoForEle,isoForEleFall17V2,ptRatioRelForEle,seedGainEle,calibratedPatElectronsNano,slimmedElectronsWithUserData,finalElectrons)
0507 electronTablesTask = cms.Task(electronPROMPTMVA, electronTable)
0508 electronMCTask = cms.Task(tautaggerForMatching, matchingElecPhoton, electronsMCMatchForTable, electronsMCMatchForTableAlt, electronMCTable)
0509 
0510 _electronTask_Run2 = electronTask.copy()
0511 _electronTask_Run2.remove(bitmapVIDForEle)
0512 _electronTask_Run2.remove(isoForEle)
0513 _electronTask_Run2.add(calibratedPatElectronsNano)
0514 run2_egamma.toReplaceWith(electronTask, _electronTask_Run2)
0515 
0516 # Revert back to AK4 CHS jets for Run2 inputs
0517 run2_nanoAOD_ANY.toModify(
0518     ptRatioRelForEle,srcJet="updatedJets")