Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-29 01:21:40

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 ##################### Updated tau collection with MVA-based tau-Ids rerun #######
0004 # Used only in some eras
0005 from RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi import *
0006 from RecoTauTag.RecoTau.PATTauDiscriminationByMVAIsolationRun2_cff import *
0007 from RecoTauTag.RecoTau.TauDiscriminatorTools import noPrediscriminants
0008 
0009 from PhysicsTools.NanoAOD.nano_eras_cff import *
0010 
0011 ### MVAIso 2017v2
0012 ## DBoldDM
0013 # Raw
0014 patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw = patDiscriminationByIsolationMVArun2v1raw.clone(
0015    PATTauProducer = cms.InputTag('slimmedTaus'),
0016    Prediscriminants = noPrediscriminants,
0017    loadMVAfromDB = cms.bool(True),
0018    mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT"), # name of the training you want to use
0019    mvaOpt = cms.string("DBoldDMwLTwGJ"), # option you want to use for your training (i.e., which variables are used to compute the BDT score)
0020    verbosity = cms.int32(0)
0021 )
0022 # WPs
0023 patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT = patDiscriminationByIsolationMVArun2v1.clone(
0024    PATTauProducer = cms.InputTag('slimmedTaus'),
0025    Prediscriminants = noPrediscriminants,
0026    toMultiplex = cms.InputTag('patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw'),
0027    loadMVAfromDB = cms.bool(True),
0028    mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT_mvaOutput_normalization"), # normalization fo the training you want to use
0029    mapping = cms.VPSet(
0030       cms.PSet(
0031          category = cms.uint32(0),
0032          cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT"), # this is the name of the working point you want to use
0033          variable = cms.string("pt"),
0034       )
0035    ),
0036    workingPoints = cms.vstring(
0037       "_VVLoose",
0038       "_VLoose",
0039       "_Loose",
0040       "_Medium",
0041       "_Tight",
0042       "_VTight",
0043       "_VVTight"
0044    )
0045 )
0046 # MVAIso DBoldDM Seqeunce
0047 patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTTask = cms.Task(
0048     patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw,
0049     patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT
0050 )
0051 ## DBnewDM
0052 # Raw
0053 patTauDiscriminationByIsolationMVArun2v1DBnewDMwLTraw = patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw.clone(
0054    mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT"), # name of the training you want to use
0055    mvaOpt = cms.string("DBnewDMwLTwGJ") # option you want to use for your training (i.e., which variables are used to compute the BDT score)
0056 )
0057 # WPs
0058 patTauDiscriminationByIsolationMVArun2v1DBnewDMwLT = patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT.clone(
0059    toMultiplex = cms.InputTag('patTauDiscriminationByIsolationMVArun2v1DBnewDMwLTraw'),
0060    mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT_mvaOutput_normalization"), # normalization fo the training you want to use
0061    mapping = cms.VPSet(
0062       cms.PSet(
0063          category = cms.uint32(0),
0064          cut = cms.string("RecoTauTag_tauIdMVAIsoDBnewDMwLT"), # this is the name of the working point you want to use
0065          variable = cms.string("pt"),
0066       )
0067    )
0068 )
0069 # MVAIso DBnewDM Seqeunce
0070 patTauDiscriminationByIsolationMVArun2v1DBnewDMwLTTask = cms.Task(
0071     patTauDiscriminationByIsolationMVArun2v1DBnewDMwLTraw,
0072     patTauDiscriminationByIsolationMVArun2v1DBnewDMwLT
0073 )
0074 ## DBoldDMdR0p3
0075 # Raw
0076 patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLTraw = patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw.clone(
0077    mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT"), # name of the training you want to use
0078    mvaOpt = cms.string("DBoldDMwLTwGJ"), # option you want to use for your training (i.e., which variables are used to compute the BDT score)
0079    srcChargedIsoPtSum = cms.string('chargedIsoPtSumdR03'),
0080    srcFootprintCorrection = cms.string('footprintCorrectiondR03'),
0081    srcNeutralIsoPtSum = cms.string('neutralIsoPtSumdR03'),
0082    srcPUcorrPtSum = cms.string('puCorrPtSum'),
0083    srcPhotonPtSumOutsideSignalCone = cms.string('photonPtSumOutsideSignalConedR03')
0084 )
0085 # WPs
0086 patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLT = patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT.clone(
0087    toMultiplex = cms.InputTag('patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLTraw'),
0088    mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT_mvaOutput_normalization"), # normalization fo the training you want to use
0089    mapping = cms.VPSet(
0090       cms.PSet(
0091          category = cms.uint32(0),
0092          cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMdR0p3wLT"), # this is the name of the working point you want to use
0093          variable = cms.string("pt"),
0094       )
0095    )
0096 )
0097 # MVAIso DBoldDMdR0p3 Seqeunce
0098 patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLTTask = cms.Task(
0099     patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLTraw,
0100     patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLT
0101 )
0102 ### MVAIso 2017v1 for Nano on top of MiniAODv1
0103 ## DBoldDM
0104 # Raw
0105 patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw2017v1 = patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw.clone(
0106    mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"), # name of the training you want to use
0107    mvaOpt = cms.string("DBoldDMwLTwGJ") # option you want to use for your training (i.e., which variables are used to compute the BDT score)
0108 )
0109 # WPs
0110 patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2017v1 = patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT.clone(
0111    toMultiplex = cms.InputTag('patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw2017v1'),
0112    mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1_mvaOutput_normalization"), # normalization fo the training you want to use
0113    mapping = cms.VPSet(
0114       cms.PSet(
0115          category = cms.uint32(0),
0116          cut = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2017v1"), # this is the name of the working point you want to use
0117          variable = cms.string("pt"),
0118       )
0119    ),
0120    workingPoints = cms.vstring(
0121       "_WPEff95",
0122       "_WPEff90",
0123       "_WPEff80",
0124       "_WPEff70",
0125       "_WPEff60",
0126       "_WPEff50",
0127       "_WPEff40"
0128    )
0129 )
0130 # MVAIso DBoldDM Seqeunce
0131 patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2017v1Task = cms.Task(
0132     patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw2017v1,
0133     patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2017v1
0134 )
0135 ### MVAIso 2015 for Nano on top of MiniAODv2
0136 ## DBoldDM
0137 # Raw
0138 patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw2015 = patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw.clone(
0139    mvaName = cms.string("RecoTauTag_tauIdMVADBoldDMwLTv1"), # name of the training you want to use
0140    mvaOpt = cms.string("DBoldDMwLT") # option you want to use for your training (i.e., which variables are used to compute the BDT score)
0141 )
0142 # WPs
0143 patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2015 = patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT.clone(
0144    toMultiplex = cms.InputTag('patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw2015'),
0145    mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVADBoldDMwLTv1_mvaOutput_normalization"), # normalization fo the training you want to use
0146    mapping = cms.VPSet(
0147       cms.PSet(
0148          category = cms.uint32(0),
0149          cut = cms.string("RecoTauTag_tauIdMVADBoldDMwLTv1"), # this is the name of the working point you want to use
0150          variable = cms.string("pt"),
0151       )
0152    ),
0153    workingPoints = cms.vstring(
0154       "_WPEff90",
0155       "_WPEff80",
0156       "_WPEff70",
0157       "_WPEff60",
0158       "_WPEff50",
0159       "_WPEff40"
0160    )
0161 )
0162 # MVAIso DBoldDM Seqeunce
0163 patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2015Task = cms.Task(
0164     patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTraw2015,
0165     patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2015
0166 )
0167 
0168 
0169 ### Define new anit-e discriminants (2018)
0170 antiElectronDiscrMVA6_version = "MVA"
0171 ## Raw
0172 from RecoTauTag.RecoTau.patTauDiscriminationAgainstElectronMVA6_cfi import patTauDiscriminationAgainstElectronMVA6
0173 patTauDiscriminationByElectronRejectionMVA62018Raw = patTauDiscriminationAgainstElectronMVA6.clone(
0174     PATTauProducer = 'slimmedTaus',
0175     Prediscriminants = noPrediscriminants, #already selected for MiniAOD
0176     srcElectrons = 'slimmedElectrons',
0177     vetoEcalCracks = False, #keep tau candidates in EB-EE cracks
0178     mvaName_NoEleMatch_wGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_wGwoGSF_BL',
0179     mvaName_NoEleMatch_wGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_wGwoGSF_EC',
0180     mvaName_NoEleMatch_woGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_woGwoGSF_BL',
0181     mvaName_NoEleMatch_woGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_woGwoGSF_EC',
0182     mvaName_wGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_wGwGSF_BL',
0183     mvaName_wGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_wGwGSF_EC',
0184     mvaName_woGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_woGwGSF_BL',
0185     mvaName_woGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_woGwGSF_EC'
0186 )
0187 ## anti-e 2018 WPs
0188 from RecoTauTag.RecoTau.PATTauDiscriminantCutMultiplexer_cfi import patTauDiscriminantCutMultiplexer
0189 # VLoose
0190 patTauDiscriminationByElectronRejectionMVA62018 = patTauDiscriminantCutMultiplexer.clone(
0191     PATTauProducer = patTauDiscriminationByElectronRejectionMVA62018Raw.PATTauProducer,
0192     Prediscriminants = patTauDiscriminationByElectronRejectionMVA62018Raw.Prediscriminants,
0193     toMultiplex = cms.InputTag("patTauDiscriminationByElectronRejectionMVA62018Raw"),
0194     mapping = cms.VPSet(
0195         cms.PSet(
0196             category = cms.uint32(0),
0197             cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_woGwoGSF_BL'),
0198             variable = cms.string('pt')
0199         ),
0200         cms.PSet(
0201             category = cms.uint32(2),
0202             cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_wGwoGSF_BL'),
0203             variable = cms.string('pt')
0204         ),
0205         cms.PSet(
0206             category = cms.uint32(5),
0207             cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_woGwGSF_BL'),
0208             variable = cms.string('pt')
0209         ),
0210         cms.PSet(
0211             category = cms.uint32(7),
0212             cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_wGwGSF_BL'),
0213             variable = cms.string('pt')
0214         ),
0215         cms.PSet(
0216             category = cms.uint32(8),
0217             cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_woGwoGSF_EC'),
0218             variable = cms.string('pt')
0219         ),
0220         cms.PSet(
0221             category = cms.uint32(10),
0222             cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_NoEleMatch_wGwoGSF_EC'),
0223             variable = cms.string('pt')
0224         ),
0225         cms.PSet(
0226             category = cms.uint32(13),
0227             cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_woGwGSF_EC'),
0228             variable = cms.string('pt')
0229         ),
0230         cms.PSet(
0231             category = cms.uint32(15),
0232             cut = cms.string('RecoTauTag_antiElectron'+antiElectronDiscrMVA6_version+'_wGwGSF_EC'),
0233             variable = cms.string('pt')
0234         )
0235     ),
0236     rawValues = cms.vstring(
0237         "discriminator",
0238         "category"
0239     ),
0240     workingPoints = cms.vstring(
0241       "_VLoose",
0242       "_Loose",
0243       "_Medium",
0244       "_Tight",
0245       "_VTight"
0246     )
0247 )
0248 ### Define v1 anit-e discriminants (2015)
0249 antiElectronDiscrMVA6v1_version = "MVA6v1"
0250 ## Raw
0251 patTauDiscriminationByElectronRejectionMVA62015Raw = patTauDiscriminationAgainstElectronMVA6.clone(
0252     PATTauProducer = 'slimmedTaus',
0253     Prediscriminants = noPrediscriminants, #already selected for MiniAOD
0254     srcElectrons = 'slimmedElectrons',
0255     vetoEcalCracks = True, #don't keep tau candidates in EB-EE cracks for v1
0256     mvaName_NoEleMatch_wGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_NoEleMatch_wGwoGSF_BL',
0257     mvaName_NoEleMatch_wGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_NoEleMatch_wGwoGSF_EC',
0258     mvaName_NoEleMatch_woGwoGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_NoEleMatch_woGwoGSF_BL',
0259     mvaName_NoEleMatch_woGwoGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_NoEleMatch_woGwoGSF_EC',
0260     mvaName_wGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_wGwGSF_BL',
0261     mvaName_wGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_wGwGSF_EC',
0262     mvaName_woGwGSF_BL = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_woGwGSF_BL',
0263     mvaName_woGwGSF_EC = 'RecoTauTag_antiElectron'+antiElectronDiscrMVA6v1_version+'_gbr_woGwGSF_EC'
0264 )
0265 ## anti-e v1 WPs
0266 patTauDiscriminationByElectronRejectionMVA62015 = patTauDiscriminationByElectronRejectionMVA62018.clone(
0267     PATTauProducer = patTauDiscriminationByElectronRejectionMVA62015Raw.PATTauProducer,
0268     Prediscriminants = patTauDiscriminationByElectronRejectionMVA62015Raw.Prediscriminants,
0269     toMultiplex = cms.InputTag("patTauDiscriminationByElectronRejectionMVA62015Raw"),
0270     rawValues = cms.vstring(
0271         "discriminator",
0272         "category"
0273     ),
0274     workingPoints = cms.vstring(
0275       "_WPEff99",
0276       "_WPEff96",
0277       "_WPEff91",
0278       "_WPEff85",
0279       "_WPEff79"
0280     )
0281 )
0282 for m in patTauDiscriminationByElectronRejectionMVA62015.mapping:
0283     m.cut = m.cut.value().replace(antiElectronDiscrMVA6_version, antiElectronDiscrMVA6v1_version + "_gbr")
0284 ### Put all anti-e tau-IDs into a sequence
0285 _patTauDiscriminationByElectronRejection2018Task = cms.Task(
0286     patTauDiscriminationByElectronRejectionMVA62018Raw,
0287     patTauDiscriminationByElectronRejectionMVA62018
0288 )
0289 _patTauDiscriminationByElectronRejection2015Task = cms.Task(
0290     patTauDiscriminationByElectronRejectionMVA62015Raw,
0291     patTauDiscriminationByElectronRejectionMVA62015
0292 )
0293 patTauDiscriminationByElectronRejectionTask = _patTauDiscriminationByElectronRejection2015Task.copy()
0294 for era in [run2_nanoAOD_92X,run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,\
0295             run2_nanoAOD_94X2016,run2_nanoAOD_102Xv1,run2_nanoAOD_106Xv1]:
0296     era.toReplaceWith(patTauDiscriminationByElectronRejectionTask,
0297                       _patTauDiscriminationByElectronRejection2018Task)
0298 
0299 
0300 ### put all new MVA tau-Id stuff to one Sequence
0301 _patTauMVAIDsTask2017v2 = cms.Task(
0302     patTauDiscriminationByIsolationMVArun2v1DBoldDMwLTTask,
0303     patTauDiscriminationByIsolationMVArun2v1DBnewDMwLTTask,
0304     patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLTTask,
0305     patTauDiscriminationByElectronRejectionTask
0306 )
0307 patTauMVAIDsTask = _patTauMVAIDsTask2017v2.copy()
0308 patTauMVAIDsTask.add(patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2015Task)
0309 
0310 _patTauMVAIDsTaskWith2017v1 = _patTauMVAIDsTask2017v2.copy()
0311 _patTauMVAIDsTaskWith2017v1.add(patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2017v1Task)
0312 for era in [run2_nanoAOD_94XMiniAODv1,]:
0313     era.toReplaceWith(patTauMVAIDsTask,_patTauMVAIDsTaskWith2017v1)
0314 
0315 # embed new MVA tau-Ids into new tau collection
0316 def tauIDMVAinputs(module, wp):
0317     return cms.PSet(inputTag = cms.InputTag(module), workingPointIndex = cms.int32(-1 if wp=="raw" else -2 if wp=="category" else globals()[module].workingPoints.index(wp)))
0318 slimmedTausUpdated = cms.EDProducer("PATTauIDEmbedder",
0319     src = cms.InputTag('slimmedTaus'),
0320     tauIDSources = cms.PSet() # PSet defined below in era dependent way
0321 )
0322 _tauIDSources2017v2 = cms.PSet(
0323         #oldDM
0324         byIsolationMVArun2v1DBoldDMwLTraw2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT", "raw"),
0325         byVVLooseIsolationMVArun2v1DBoldDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT", "_VVLoose"),
0326         byVLooseIsolationMVArun2v1DBoldDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT", "_VLoose"),
0327         byLooseIsolationMVArun2v1DBoldDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT", "_Loose"),
0328         byMediumIsolationMVArun2v1DBoldDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT", "_Medium"),
0329         byTightIsolationMVArun2v1DBoldDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT", "_Tight"),
0330         byVTightIsolationMVArun2v1DBoldDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT", "_VTight"),
0331         byVVTightIsolationMVArun2v1DBoldDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT", "_VVTight"),
0332         #newDM
0333         byIsolationMVArun2v1DBnewDMwLTraw2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBnewDMwLT", "raw"),
0334         byVVLooseIsolationMVArun2v1DBnewDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBnewDMwLT", "_VVLoose"),
0335         byVLooseIsolationMVArun2v1DBnewDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBnewDMwLT", "_VLoose"),
0336         byLooseIsolationMVArun2v1DBnewDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBnewDMwLT", "_Loose"),
0337         byMediumIsolationMVArun2v1DBnewDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBnewDMwLT", "_Medium"),
0338         byTightIsolationMVArun2v1DBnewDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBnewDMwLT", "_Tight"),
0339         byVTightIsolationMVArun2v1DBnewDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBnewDMwLT", "_VTight"),
0340         byVVTightIsolationMVArun2v1DBnewDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBnewDMwLT", "_VVTight"),
0341         #oldDMdR0p3
0342         byIsolationMVArun2v1DBdR03oldDMwLTraw2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLT", "raw"),
0343         byVVLooseIsolationMVArun2v1DBdR03oldDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLT", "_VVLoose"),
0344         byVLooseIsolationMVArun2v1DBdR03oldDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLT", "_VLoose"),
0345         byLooseIsolationMVArun2v1DBdR03oldDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLT", "_Loose"),
0346         byMediumIsolationMVArun2v1DBdR03oldDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLT", "_Medium"),
0347         byTightIsolationMVArun2v1DBdR03oldDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLT", "_Tight"),
0348         byVTightIsolationMVArun2v1DBdR03oldDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLT", "_VTight"),
0349         byVVTightIsolationMVArun2v1DBdR03oldDMwLT2017v2 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMdR0p3wLT", "_VVTight")
0350 )
0351 _tauIDSources2017v1 = cms.PSet(
0352     byIsolationMVArun2v1DBoldDMwLTraw2017v1 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2017v1", "raw"),
0353     byVVLooseIsolationMVArun2v1DBoldDMwLT2017v1 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2017v1", "_WPEff95"),
0354     byVLooseIsolationMVArun2v1DBoldDMwLT2017v1 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2017v1", "_WPEff90"),
0355     byLooseIsolationMVArun2v1DBoldDMwLT2017v1 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2017v1", "_WPEff80"),
0356     byMediumIsolationMVArun2v1DBoldDMwLT2017v1 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2017v1", "_WPEff70"),
0357     byTightIsolationMVArun2v1DBoldDMwLT2017v1 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2017v1", "_WPEff60"),
0358     byVTightIsolationMVArun2v1DBoldDMwLT2017v1 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2017v1", "_WPEff50"),
0359     byVVTightIsolationMVArun2v1DBoldDMwLT2017v1 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2017v1", "_WPEff40")
0360 )
0361 _tauIDSourcesWith2017v1 = cms.PSet(
0362     _tauIDSources2017v2.clone(),
0363     _tauIDSources2017v1
0364 )
0365 _tauIDSources2015 = cms.PSet(
0366     byIsolationMVArun2v1DBoldDMwLTraw2015 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2015", "raw"),
0367     byVLooseIsolationMVArun2v1DBoldDMwLT2015 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2015", "_WPEff90"),
0368     byLooseIsolationMVArun2v1DBoldDMwLT2015 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2015", "_WPEff80"),
0369     byMediumIsolationMVArun2v1DBoldDMwLT2015 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2015", "_WPEff70"),
0370     byTightIsolationMVArun2v1DBoldDMwLT2015 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2015", "_WPEff60"),
0371     byVTightIsolationMVArun2v1DBoldDMwLT2015 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2015", "_WPEff50"),
0372     byVVTightIsolationMVArun2v1DBoldDMwLT2015 = tauIDMVAinputs("patTauDiscriminationByIsolationMVArun2v1DBoldDMwLT2015", "_WPEff40")
0373 )
0374 _tauIDSourcesWith2015 = cms.PSet(
0375     _tauIDSources2017v2.clone(),
0376     _tauIDSources2015
0377 )
0378 slimmedTausUpdated.tauIDSources=_tauIDSourcesWith2015
0379 
0380 for era in [run2_nanoAOD_94XMiniAODv1,]:
0381     era.toModify(slimmedTausUpdated,
0382                  tauIDSources = _tauIDSourcesWith2017v1
0383     )
0384 
0385 _antiETauIDSources2018 = cms.PSet(
0386     againstElectronMVA6Raw2018 = tauIDMVAinputs("patTauDiscriminationByElectronRejectionMVA62018", "raw"),
0387     againstElectronMVA6category2018 = tauIDMVAinputs("patTauDiscriminationByElectronRejectionMVA62018", "category"),
0388     againstElectronVLooseMVA62018 = tauIDMVAinputs("patTauDiscriminationByElectronRejectionMVA62018", "_VLoose"),
0389     againstElectronLooseMVA62018 = tauIDMVAinputs("patTauDiscriminationByElectronRejectionMVA62018", "_Loose"),
0390     againstElectronMediumMVA62018 = tauIDMVAinputs("patTauDiscriminationByElectronRejectionMVA62018", "_Medium"),
0391     againstElectronTightMVA62018 = tauIDMVAinputs("patTauDiscriminationByElectronRejectionMVA62018", "_Tight"),
0392     againstElectronVTightMVA62018 = tauIDMVAinputs("patTauDiscriminationByElectronRejectionMVA62018", "_VTight")
0393 )
0394 _tauIDSourcesWithAntiE2018 = cms.PSet(
0395     slimmedTausUpdated.tauIDSources.clone(),
0396     _antiETauIDSources2018
0397 )
0398 _antiETauIDSources2015 = cms.PSet(
0399     againstElectronMVA6Raw2015 = tauIDMVAinputs("patTauDiscriminationByElectronRejectionMVA62015", "raw"),
0400     againstElectronMVA6category2015 = tauIDMVAinputs("patTauDiscriminationByElectronRejectionMVA62015", "category"),
0401     againstElectronVLooseMVA62015 = tauIDMVAinputs("patTauDiscriminationByElectronRejectionMVA62015", "_WPEff99"),
0402     againstElectronLooseMVA62015 = tauIDMVAinputs("patTauDiscriminationByElectronRejectionMVA62015", "_WPEff96"),
0403     againstElectronMediumMVA62015 = tauIDMVAinputs("patTauDiscriminationByElectronRejectionMVA62015", "_WPEff91"),
0404     againstElectronTightMVA62015 = tauIDMVAinputs("patTauDiscriminationByElectronRejectionMVA62015", "_WPEff85"),
0405     againstElectronVTightMVA62015 = tauIDMVAinputs("patTauDiscriminationByElectronRejectionMVA62015", "_WPEff79")
0406 )
0407 _tauIDSourcesWithAntiE2015 = cms.PSet(
0408     slimmedTausUpdated.tauIDSources.clone(),
0409     _antiETauIDSources2015
0410 )
0411 slimmedTausUpdated.tauIDSources=_tauIDSourcesWithAntiE2015
0412 for era in [run2_nanoAOD_92X,run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,\
0413             run2_nanoAOD_94X2016,run2_nanoAOD_102Xv1,run2_nanoAOD_106Xv1]:
0414     era.toModify(slimmedTausUpdated,
0415                  tauIDSources = _tauIDSourcesWithAntiE2018
0416     )
0417 
0418 ## anti-electron in dead-ECal regions
0419 from RecoTauTag.RecoTau.patTauDiscriminationAgainstElectronDeadECAL_cfi import patTauDiscriminationAgainstElectronDeadECAL
0420 patTauDiscriminationAgainstElectronDeadECALForNano = patTauDiscriminationAgainstElectronDeadECAL.clone(
0421     PATTauProducer = 'slimmedTaus',
0422     Prediscriminants = noPrediscriminants
0423 )
0424 _patTauMVAIDsTaskWithAntiEdeadECal = patTauMVAIDsTask.copy()
0425 _patTauMVAIDsTaskWithAntiEdeadECal.add(patTauDiscriminationAgainstElectronDeadECALForNano)
0426 _tauIDSourcesWithAntiEdeadECal = cms.PSet(
0427     slimmedTausUpdated.tauIDSources.clone(),
0428     againstElectronDeadECALForNano = cms.PSet(
0429         inputTag = cms.InputTag("patTauDiscriminationAgainstElectronDeadECALForNano"),
0430         workingPointIndex = cms.int32(-99)
0431     )
0432 )
0433 for era in [run2_miniAOD_80XLegacy,run2_nanoAOD_92X,run2_nanoAOD_94XMiniAODv1,\
0434             run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_94X2016,run2_nanoAOD_102Xv1,\
0435             run2_nanoAOD_106Xv1]:
0436     era.toReplaceWith(patTauMVAIDsTask,_patTauMVAIDsTaskWithAntiEdeadECal)
0437     era.toModify(slimmedTausUpdated,
0438                  tauIDSources = _tauIDSourcesWithAntiEdeadECal
0439     )
0440 
0441 patTauMVAIDsTask.add(slimmedTausUpdated)
0442