CMS 3D CMS Logo

boostedTaus_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
4 
5 
6 from PhysicsTools.NanoAOD.taus_cff import _tauIdWPMask, tausMCMatchLepTauForTable, tausMCMatchHadTauForTable,tauMCTable
7 
8 
9 
10 
11 finalBoostedTaus = cms.EDFilter("PATTauRefSelector",
12  src = cms.InputTag("slimmedTausBoosted"),
13  cut = cms.string("pt > 40 && tauID('decayModeFindingNewDMs') && (tauID('byVVLooseIsolationMVArun2DBoldDMwLT') || tauID('byVVLooseIsolationMVArun2DBnewDMwLT'))")
14 )
15 run2_nanoAOD_106Xv2.toModify(finalBoostedTaus,
16  cut = "pt > 40 && tauID('decayModeFindingNewDMs') && (tauID('byVVLooseIsolationMVArun2017v2DBoldDMwLT2017') || tauID('byVVLooseIsolationMVArun2017v2DBoldDMdR0p3wLT2017') || tauID('byVVLooseIsolationMVArun2017v2DBnewDMwLT2017'))"
17 )
18 
19 boostedTauTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
20  src = cms.InputTag("finalBoostedTaus"),
21  cut = cms.string(""), #we should not filter on cross linked collections
22  name= cms.string("boostedTau"),
23  doc = cms.string("slimmedBoostedTaus after basic selection (" + finalBoostedTaus.cut.value()+")"),
24  singleton = cms.bool(False), # the number of entries is variable
25  extension = cms.bool(False), # this is the main table for the taus
26  variables = cms.PSet() # PSet defined below in era dependent way
27 )
28 _boostedTauVarsBase = cms.PSet(P4Vars,
29  charge = Var("charge", int, doc="electric charge"),
30  jetIdx = Var("?hasUserCand('jet')?userCand('jet').key():-1", int, doc="index of the associated jet (-1 if none)"),
31  decayMode = Var("decayMode()",int),
32  leadTkPtOverTauPt = Var("leadChargedHadrCand.pt/pt ",float, doc="pt of the leading track divided by tau pt",precision=10),
33  leadTkDeltaEta = Var("leadChargedHadrCand.eta - eta ",float, doc="eta of the leading track, minus tau eta",precision=8),
34  leadTkDeltaPhi = Var("deltaPhi(leadChargedHadrCand.phi, phi) ",float, doc="phi of the leading track, minus tau phi",precision=8),
35 
36  rawIso = Var( "tauID('byCombinedIsolationDeltaBetaCorrRaw3Hits')", float, doc = "combined isolation (deltaBeta corrections)", precision=10),
37  rawIsodR03 = Var( "(tauID('chargedIsoPtSumdR03')+max(0.,tauID('neutralIsoPtSumdR03')-0.072*tauID('puCorrPtSum')))", float, doc = "combined isolation (deltaBeta corrections, dR=0.3)", precision=10),
38  chargedIso = Var( "tauID('chargedIsoPtSum')", float, doc = "charged isolation", precision=10),
39  neutralIso = Var( "tauID('neutralIsoPtSum')", float, doc = "neutral (photon) isolation", precision=10),
40  puCorr = Var( "tauID('puCorrPtSum')", float, doc = "pileup correction", precision=10),
41  photonsOutsideSignalCone = Var( "tauID('photonPtSumOutsideSignalCone')", float, doc = "sum of photons outside signal cone", precision=10),
42  idAntiMu = _tauIdWPMask("againstMuon%s3", choices=("Loose","Tight"), doc= "Anti-muon discriminator V3: ")
43 )
44 #MVA 2017 v2 variables
45 _boostedTauVarsMVAIso = cms.PSet(
46  rawMVAoldDM2017v2 = Var("tauID('byIsolationMVArun2DBoldDMwLTraw')",float, doc="byIsolationMVArun2DBoldDMwLT raw output discriminator (2017v2)",precision=10),
47  rawMVAnewDM2017v2 = Var("tauID('byIsolationMVArun2DBnewDMwLTraw')",float,doc='byIsolationMVArun2DBnewDMwLT raw output discriminator (2017v2)',precision=10),
48  idMVAnewDM2017v2 = _tauIdWPMask("by%sIsolationMVArun2DBnewDMwLT", choices=("VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"), doc="IsolationMVArun2DBnewDMwLT ID working point (2017v2)"),
49  idMVAoldDM2017v2 = _tauIdWPMask("by%sIsolationMVArun2DBoldDMwLT",choices=("VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"), doc="IsolationMVArun2DBoldDMwLT ID working point (2017v2)"),
50 )
51 #MVA 2017 v2 dR<0.3 variables
52 _boostedTauVarsMVAIsoDr03 = cms.PSet(
53  rawMVAoldDMdR032017v2 = Var("tauID('byIsolationMVArun2017v2DBoldDMdR0p3wLTraw2017')",float,doc='byIsolationMVArun2DBoldDMdR0p3wLT raw output discriminator (2017v2)'),
54  idMVAoldDMdR032017v2 = _tauIdWPMask("by%sIsolationMVArun2017v2DBoldDMdR0p3wLT2017",choices=("VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),doc="IsolationMVArun2DBoldDMdR0p3wLT ID working point (2017v2)")
55 )
56 #AntiEle MVA 2018 variables
57 _boostedTauVarsAntiEleMVA = cms.PSet(
58  rawAntiEle2018 = Var("tauID('againstElectronMVA6Raw')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator (2018)", precision=10),
59  rawAntiEleCat2018 = Var("tauID('againstElectronMVA6category')", int, doc="Anti-electron MVA discriminator V6 category (2018)"),
60  idAntiEle2018 = _tauIdWPMask("againstElectron%sMVA6", choices=("VLoose","Loose","Medium","Tight","VTight"), doc= "Anti-electron MVA discriminator V6 (2018)")
61 )
62 
63 boostedTauTable.variables = cms.PSet(
64  _boostedTauVarsBase,
65  _boostedTauVarsMVAIso,
66  _boostedTauVarsAntiEleMVA
67 )
68 _boostedTauVarsWithDr03 = cms.PSet(
69  _boostedTauVarsBase,
70  _boostedTauVarsMVAIso,
71  _boostedTauVarsMVAIsoDr03,
72  _boostedTauVarsAntiEleMVA
73 )
74 run2_nanoAOD_106Xv2.toModify(boostedTauTable,
75  variables = _boostedTauVarsWithDr03
76 )
77 run2_nanoAOD_106Xv2.toModify(boostedTauTable.variables,
78  rawMVAoldDM2017v2 = Var("tauID('byIsolationMVArun2017v2DBoldDMwLTraw2017')",float, doc="byIsolationMVArun2DBoldDMwLT raw output discriminator (2017v2)",precision=10),
79  rawMVAnewDM2017v2 = Var("tauID('byIsolationMVArun2017v2DBnewDMwLTraw2017')",float,doc='byIsolationMVArun2DBnewDMwLT raw output discriminator (2017v2)',precision=10),
80  idMVAnewDM2017v2 = _tauIdWPMask("by%sIsolationMVArun2017v2DBnewDMwLT2017", choices=("VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),doc="IsolationMVArun2DBnewDMwLT ID working point (2017v2)"),
81  idMVAoldDM2017v2 = _tauIdWPMask("by%sIsolationMVArun2017v2DBoldDMwLT2017",choices=("VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),doc="IsolationMVArun2DBoldDMwLT ID working point (2017v2)"),
82  rawAntiEle2018 = Var("tauID('againstElectronMVA6Raw2018')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator (2018)", precision=10),
83  rawAntiEleCat2018 = Var("tauID('againstElectronMVA6category2018')", int, doc="Anti-electron MVA discriminator V6 category (2018)"),
84  idAntiEle2018 = _tauIdWPMask("againstElectron%sMVA62018", choices=("VLoose","Loose","Medium","Tight","VTight"), doc= "Anti-electron MVA discriminator V6 (2018)")
85 )
86 
87 boostedTausMCMatchLepTauForTable = tausMCMatchLepTauForTable.clone(
88  src = boostedTauTable.src
89 )
90 
91 #This requires genVisTaus in taus_cff.py
92 boostedTausMCMatchHadTauForTable = tausMCMatchHadTauForTable.clone(
93  src = boostedTauTable.src
94 )
95 
96 boostedTauMCTable = tauMCTable.clone(
97  src = boostedTauTable.src,
98  mcMap = cms.InputTag("boostedTausMCMatchLepTauForTable"),
99  mcMapVisTau = cms.InputTag("boostedTausMCMatchHadTauForTable"),
100  objName = boostedTauTable.name,
101 )
102 
103 
104 boostedTauTask = cms.Task(finalBoostedTaus)
105 boostedTauTablesTask = cms.Task(boostedTauTable)
106 boostedTauMCTask = cms.Task(boostedTausMCMatchLepTauForTable,boostedTausMCMatchHadTauForTable,boostedTauMCTable)
107 
108 #remove boosted tau from previous eras
109 _modifiers = (run2_miniAOD_80XLegacy | run2_nanoAOD_92X | run2_nanoAOD_94XMiniAODv1 | run2_nanoAOD_94X2016 | run2_nanoAOD_94XMiniAODv2 | run2_nanoAOD_102Xv1 | run2_nanoAOD_106Xv1 | run3_nanoAOD_122)
110 (_modifiers).toReplaceWith(boostedTauTask,cms.Task())
111 (_modifiers).toReplaceWith(boostedTauTablesTask,cms.Task())
112 (_modifiers).toReplaceWith(boostedTauMCTask,cms.Task())
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20
def _tauIdWPMask(pattern, choices, doc="", from_raw=False, wp_thrs=None)
Tables for final output and docs ##########################.
Definition: taus_cff.py:36