CMS 3D CMS Logo

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