Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-03-09 00:51:18

0001 import FWCore.ParameterSet.Config as cms
0002 from PhysicsTools.NanoAOD.common_cff import *
0003 from PhysicsTools.NanoAOD.nano_eras_cff import *
0004 
0005 ##################### Import reusable funtions and objects from std taus ########
0006 from PhysicsTools.NanoAOD.taus_cff import _tauId2WPMask,_tauId5WPMask,_tauId7WPMask,tausMCMatchLepTauForTable,tausMCMatchHadTauForTable,tauMCTable
0007 
0008 ##################### User floats producers, selectors ##########################
0009 
0010 
0011 finalBoostedTaus = cms.EDFilter("PATTauRefSelector",
0012     src = cms.InputTag("slimmedTausBoosted"),
0013     cut = cms.string("pt > 40 && tauID('decayModeFindingNewDMs') && (tauID('byVVLooseIsolationMVArun2DBoldDMwLT') || tauID('byVVLooseIsolationMVArun2DBnewDMwLT'))")
0014 )
0015 run2_nanoAOD_106Xv2.toModify(finalBoostedTaus,
0016                              cut = "pt > 40 && tauID('decayModeFindingNewDMs') && (tauID('byVVLooseIsolationMVArun2017v2DBoldDMwLT2017') || tauID('byVVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017') || tauID('byVVLooseIsolationMVArun2017v2DBnewDMwLT2017'))"
0017 )
0018 
0019 boostedTauTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
0020     src = cms.InputTag("finalBoostedTaus"),
0021     cut = cms.string(""), #we should not filter on cross linked collections
0022     name= cms.string("boostedTau"),
0023     doc = cms.string("slimmedBoostedTaus after basic selection (" + finalBoostedTaus.cut.value()+")"),
0024     singleton = cms.bool(False), # the number of entries is variable
0025     extension = cms.bool(False), # this is the main table for the taus
0026     variables = cms.PSet() # PSet defined below in era dependent way
0027 )
0028 _boostedTauVarsBase = cms.PSet(P4Vars,
0029        charge = Var("charge", int, doc="electric charge"),
0030        jetIdx = Var("?hasUserCand('jet')?userCand('jet').key():-1", int, doc="index of the associated jet (-1 if none)"),
0031        decayMode = Var("decayMode()",int),
0032        leadTkPtOverTauPt = Var("leadChargedHadrCand.pt/pt ",float, doc="pt of the leading track divided by tau pt",precision=10),
0033        leadTkDeltaEta = Var("leadChargedHadrCand.eta - eta ",float, doc="eta of the leading track, minus tau eta",precision=8),
0034        leadTkDeltaPhi = Var("deltaPhi(leadChargedHadrCand.phi, phi) ",float, doc="phi of the leading track, minus tau phi",precision=8),
0035 
0036        rawIso = Var( "tauID('byCombinedIsolationDeltaBetaCorrRaw3Hits')", float, doc = "combined isolation (deltaBeta corrections)", precision=10),
0037        rawIsodR03 = Var( "(tauID('chargedIsoPtSumdR03')+max(0.,tauID('neutralIsoPtSumdR03')-0.072*tauID('puCorrPtSum')))", float, doc = "combined isolation (deltaBeta corrections, dR=0.3)", precision=10),
0038        chargedIso = Var( "tauID('chargedIsoPtSum')", float, doc = "charged isolation", precision=10),
0039        neutralIso = Var( "tauID('neutralIsoPtSum')", float, doc = "neutral (photon) isolation", precision=10),
0040        puCorr = Var( "tauID('puCorrPtSum')", float, doc = "pileup correction", precision=10),
0041        photonsOutsideSignalCone = Var( "tauID('photonPtSumOutsideSignalCone')", float, doc = "sum of photons outside signal cone", precision=10),
0042        idAntiMu = _tauId2WPMask("againstMuon%s3", doc= "Anti-muon discriminator V3: ")
0043 )
0044 #MVA 2017 v2 variables
0045 _boostedTauVarsMVAIso = cms.PSet(
0046        rawMVAoldDM2017v2 = Var("tauID('byIsolationMVArun2DBoldDMwLTraw')",float, doc="byIsolationMVArun2DBoldDMwLT raw output discriminator (2017v2)",precision=10),
0047        rawMVAnewDM2017v2 = Var("tauID('byIsolationMVArun2DBnewDMwLTraw')",float,doc='byIsolationMVArun2DBnewDMwLT raw output discriminator (2017v2)',precision=10),
0048        idMVAnewDM2017v2 = _tauId7WPMask("by%sIsolationMVArun2DBnewDMwLT", doc="IsolationMVArun2DBnewDMwLT ID working point (2017v2)"),
0049        idMVAoldDM2017v2 = _tauId7WPMask("by%sIsolationMVArun2DBoldDMwLT",doc="IsolationMVArun2DBoldDMwLT ID working point (2017v2)"),
0050 )
0051 #MVA 2017 v2 dR<0.3 variables
0052 _boostedTauVarsMVAIsoDr03 = cms.PSet(
0053        rawMVAoldDMdR032017v2 = Var("tauID('byIsolationMVArun2017v2DBoldDMdR0p3wLTraw2017')",float,doc='byIsolationMVArun2DBoldDMdR0p3wLT raw output discriminator (2017v2)'),
0054        idMVAoldDMdR032017v2 = _tauId7WPMask("by%sIsolationMVArun2017v2DBoldDMdR0p3wLT2017",doc="IsolationMVArun2DBoldDMdR0p3wLT ID working point (2017v2)")
0055 )
0056 #AntiEle MVA 2018 variables
0057 _boostedTauVarsAntiEleMVA = cms.PSet(
0058        rawAntiEle2018 = Var("tauID('againstElectronMVA6Raw')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator (2018)", precision=10),
0059        rawAntiEleCat2018 = Var("tauID('againstElectronMVA6category')", int, doc="Anti-electron MVA discriminator V6 category (2018)"),
0060        idAntiEle2018 = _tauId5WPMask("againstElectron%sMVA6", doc= "Anti-electron MVA discriminator V6 (2018)")
0061 )
0062 
0063 boostedTauTable.variables = cms.PSet(
0064     _boostedTauVarsBase,
0065     _boostedTauVarsMVAIso,
0066     _boostedTauVarsAntiEleMVA
0067 )
0068 _boostedTauVarsWithDr03 = cms.PSet(
0069     _boostedTauVarsBase,
0070     _boostedTauVarsMVAIso,
0071     _boostedTauVarsMVAIsoDr03,
0072     _boostedTauVarsAntiEleMVA
0073 )
0074 run2_nanoAOD_106Xv2.toModify(boostedTauTable,
0075                              variables = _boostedTauVarsWithDr03
0076 )
0077 run2_nanoAOD_106Xv2.toModify(boostedTauTable.variables,
0078                              rawMVAoldDM2017v2 = Var("tauID('byIsolationMVArun2017v2DBoldDMwLTraw2017')",float, doc="byIsolationMVArun2DBoldDMwLT raw output discriminator (2017v2)",precision=10),
0079                              rawMVAnewDM2017v2 = Var("tauID('byIsolationMVArun2017v2DBnewDMwLTraw2017')",float,doc='byIsolationMVArun2DBnewDMwLT raw output discriminator (2017v2)',precision=10),
0080                              idMVAnewDM2017v2 = _tauId7WPMask("by%sIsolationMVArun2017v2DBnewDMwLT2017", doc="IsolationMVArun2DBnewDMwLT ID working point (2017v2)"),
0081                              idMVAoldDM2017v2 = _tauId7WPMask("by%sIsolationMVArun2017v2DBoldDMwLT2017",doc="IsolationMVArun2DBoldDMwLT ID working point (2017v2)"),
0082                              rawAntiEle2018 = Var("tauID('againstElectronMVA6Raw2018')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator (2018)", precision=10),
0083                              rawAntiEleCat2018 = Var("tauID('againstElectronMVA6category2018')", int, doc="Anti-electron MVA discriminator V6 category (2018)"),
0084                              idAntiEle2018 = _tauId5WPMask("againstElectron%sMVA62018", doc= "Anti-electron MVA discriminator V6 (2018)")
0085 )
0086 
0087 boostedTausMCMatchLepTauForTable = tausMCMatchLepTauForTable.clone(
0088     src = boostedTauTable.src
0089 )
0090 
0091 #This requires genVisTaus in taus_cff.py
0092 boostedTausMCMatchHadTauForTable = tausMCMatchHadTauForTable.clone(
0093     src = boostedTauTable.src
0094 )
0095 
0096 boostedTauMCTable = tauMCTable.clone(
0097     src = boostedTauTable.src,
0098     mcMap = cms.InputTag("boostedTausMCMatchLepTauForTable"),
0099     mcMapVisTau = cms.InputTag("boostedTausMCMatchHadTauForTable"),
0100     objName = boostedTauTable.name,
0101 )
0102 
0103 
0104 boostedTauTask = cms.Task(finalBoostedTaus)
0105 boostedTauTablesTask = cms.Task(boostedTauTable)
0106 boostedTauMCTask = cms.Task(boostedTausMCMatchLepTauForTable,boostedTausMCMatchHadTauForTable,boostedTauMCTable)
0107 
0108 #remove boosted tau from previous eras
0109 _modifiers = (run2_miniAOD_80XLegacy | run2_nanoAOD_92X | run2_nanoAOD_94XMiniAODv1 | run2_nanoAOD_94X2016 | run2_nanoAOD_94XMiniAODv2 | run2_nanoAOD_102Xv1 | run2_nanoAOD_106Xv1)
0110 (_modifiers).toReplaceWith(boostedTauTask,cms.Task())
0111 (_modifiers).toReplaceWith(boostedTauTablesTask,cms.Task())
0112 (_modifiers).toReplaceWith(boostedTauMCTask,cms.Task())