1 import FWCore.ParameterSet.Config
as cms
15 from RecoTauTag.RecoTau.tauIdWPsDefs
import WORKING_POINTS_v2p5
17 finalTaus = cms.EDFilter(
"PATTauRefSelector",
18 src = cms.InputTag(
"slimmedTaus"),
19 cut = cms.string(
"pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || (tauID('chargedIsoPtSumdR03')+max(0.,tauID('neutralIsoPtSumdR03')-0.072*tauID('puCorrPtSum'))<2.5) || tauID('byVVVLooseDeepTau2017v2p1VSjet') || tauID('byVVVLooseDeepTau2018v2p5VSjet'))")
22 run3_nanoAOD_124.toModify(finalTaus,
23 cut = cms.string(
"pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || (tauID('chargedIsoPtSumdR03')+max(0.,tauID('neutralIsoPtSumdR03')-0.072*tauID('puCorrPtSum'))<2.5) || tauID('byVVVLooseDeepTau2017v2p1VSjet') || (tauID('byDeepTau2018v2p5VSjetraw') > {}))".
format(WORKING_POINTS_v2p5[
"jet"][
"VVVLoose"]))
27 def _tauIdWPMask(pattern, choices, doc="", from_raw=False, wp_thrs=None):
29 assert wp_thrs
is not None,
"wp_thrs argument in _tauIdWPMask() is None, expect it to be dict-like" 32 for wp_name
in choices:
33 if not isinstance(wp_thrs[wp_name], float):
34 raise TypeError(
"Threshold for WP=%s is not a float number." % wp_name)
35 wp_definition =
"test_bit(tauID('{}')-{}+1,0)".
format(pattern, wp_thrs[wp_name])
36 var_definition.append(wp_definition)
37 var_definition =
" + ".
join(var_definition)
39 var_definition =
" + ".
join([
"tauID('%s')" % (pattern % c)
for c
in choices])
41 doc = doc +
": "+
", ".
join([
"%d = %s" % (i,c)
for (i,c)
in enumerate(choices, start=1)])
42 return Var(var_definition,
"uint8", doc=doc)
44 tauTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
45 src = cms.InputTag(
"linkedObjects",
"taus"),
47 name= cms.string(
"Tau"),
48 doc = cms.string(
"slimmedTaus after basic selection (" + finalTaus.cut.value()+
")"),
49 singleton = cms.bool(
False),
50 extension = cms.bool(
False),
51 variables = cms.PSet()
53 _tauVarsBase = cms.PSet(P4Vars,
54 charge =
Var(
"charge", int, doc=
"electric charge"),
55 jetIdx =
Var(
"?hasUserCand('jet')?userCand('jet').key():-1", int, doc=
"index of the associated jet (-1 if none)"),
56 decayMode =
Var(
"decayMode()",int),
57 idDecayModeOldDMs =
Var(
"tauID('decayModeFinding')", bool),
59 leadTkPtOverTauPt =
Var(
"leadChargedHadrCand.pt/pt ",float, doc=
"pt of the leading track divided by tau pt",precision=10),
60 leadTkDeltaEta =
Var(
"leadChargedHadrCand.eta - eta ",float, doc=
"eta of the leading track, minus tau eta",precision=8),
61 leadTkDeltaPhi =
Var(
"deltaPhi(leadChargedHadrCand.phi, phi) ",float, doc=
"phi of the leading track, minus tau phi",precision=8),
63 dxy =
Var(
"leadChargedHadrCand().dxy()",float, doc=
"d_{xy} of lead track with respect to PV, in cm (with sign)",precision=10),
64 dz =
Var(
"leadChargedHadrCand().dz()",float, doc=
"d_{z} of lead track with respect to PV, in cm (with sign)",precision=14),
67 rawIso =
Var(
"tauID('byCombinedIsolationDeltaBetaCorrRaw3Hits')", float, doc =
"combined isolation (deltaBeta corrections)", precision=10),
68 rawIsodR03 =
Var(
"(tauID('chargedIsoPtSumdR03')+max(0.,tauID('neutralIsoPtSumdR03')-0.072*tauID('puCorrPtSum')))", float, doc =
"combined isolation (deltaBeta corrections, dR=0.3)", precision=10),
69 chargedIso =
Var(
"tauID('chargedIsoPtSum')", float, doc =
"charged isolation", precision=10),
70 neutralIso =
Var(
"tauID('neutralIsoPtSum')", float, doc =
"neutral (photon) isolation", precision=10),
71 puCorr =
Var(
"tauID('puCorrPtSum')", float, doc =
"pileup correction", precision=10),
72 photonsOutsideSignalCone =
Var(
"tauID('photonPtSumOutsideSignalCone')", float, doc =
"sum of photons outside signal cone", precision=10),
74 idAntiMu =
_tauIdWPMask(
"againstMuon%s3", choices=(
"Loose",
"Tight"), doc=
"Anti-muon discriminator V3: "),
75 idAntiEleDeadECal =
Var(
"tauID('againstElectronDeadECAL')", bool, doc =
"Anti-electron dead-ECal discriminator"),
82 _mvaIsoVars2015 = cms.PSet(
83 rawMVAnewDM =
Var(
"tauID('byIsolationMVArun2v1DBnewDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
84 rawMVAoldDM =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
85 rawMVAoldDMdR03 =
Var(
"tauID('byIsolationMVArun2v1DBdR03oldDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
86 idMVAnewDM =
_tauIdWPMask(
"by%sIsolationMVArun2v1DBnewDMwLT", choices=(
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"), doc=
"IsolationMVArun2v1DBnewDMwLT ID working point (2015)"),
87 idMVAoldDM =
_tauIdWPMask(
"by%sIsolationMVArun2v1DBoldDMwLT", choices=(
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"), doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2015)"),
88 idMVAoldDMdR03 =
_tauIdWPMask(
"by%sIsolationMVArun2v1DBdR03oldDMwLT", choices=(
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"), doc=
"IsolationMVArun2v1DBoldDMdR0p3wLT ID working point (2015)")
90 _mvaIsoVars2015Reduced = cms.PSet(
91 rawMVAoldDM =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw2015')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
92 idMVAoldDM =
_tauIdWPMask(
"by%sIsolationMVArun2v1DBoldDMwLT2015", choices=(
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"), doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2015)"),
94 _mvaIsoVars2017v1 = cms.PSet(
95 rawMVAoldDM2017v1 =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v1)",precision=10),
96 idMVAoldDM2017v1 =
_tauIdWPMask(
"by%sIsolationMVArun2v1DBoldDMwLT", choices=(
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"), doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2017v1)")
98 _mvaIsoVars2017v2 = cms.PSet(
99 rawMVAnewDM2017v2 =
Var(
"tauID('byIsolationMVArun2v1DBnewDMwLTraw2017v2')",float, doc=
"byIsolationMVArun2v1DBnewDMwLT raw output discriminator (2017v2)",precision=10),
100 rawMVAoldDM2017v2 =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw2017v2')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v2)",precision=10),
101 rawMVAoldDMdR032017v2 =
Var(
"tauID('byIsolationMVArun2v1DBdR03oldDMwLTraw2017v2')",float, doc=
"byIsolationMVArun2v1DBdR03oldDMwLT raw output discriminator (2017v2)",precision=10),
102 idMVAnewDM2017v2 =
_tauIdWPMask(
"by%sIsolationMVArun2v1DBnewDMwLT2017v2",
103 choices=(
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
104 doc=
"IsolationMVArun2v1DBnewDMwLT ID working point (2017v2)"),
105 idMVAoldDM2017v2 =
_tauIdWPMask(
"by%sIsolationMVArun2v1DBoldDMwLT2017v2",
106 choices=(
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
107 doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2017v2)"),
108 idMVAoldDMdR032017v2 =
_tauIdWPMask(
"by%sIsolationMVArun2v1DBdR03oldDMwLT2017v2",
109 choices=(
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
110 doc=
"IsolationMVArun2v1DBoldDMdR0p3wLT ID working point (2017v2)")
112 _mvaAntiEVars2015 = cms.PSet(
113 rawAntiEle =
Var(
"tauID('againstElectronMVA6Raw')", float, doc=
"Anti-electron MVA discriminator V6 raw output discriminator (2015)", precision=10),
114 rawAntiEleCat =
Var(
"tauID('againstElectronMVA6category')", int, doc=
"Anti-electron MVA discriminator V6 category (2015"),
115 idAntiEle =
_tauIdWPMask(
"againstElectron%sMVA6", choices=(
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight"), doc=
"Anti-electron MVA discriminator V6 (2015)"),
117 _deepTauVars2017v2p1 = cms.PSet(
118 rawDeepTau2017v2p1VSe =
Var(
"tauID('byDeepTau2017v2p1VSeraw')", float, doc=
"byDeepTau2017v2p1VSe raw output discriminator (deepTau2017v2p1)", precision=10),
119 rawDeepTau2017v2p1VSmu =
Var(
"tauID('byDeepTau2017v2p1VSmuraw')", float, doc=
"byDeepTau2017v2p1VSmu raw output discriminator (deepTau2017v2p1)", precision=10),
120 rawDeepTau2017v2p1VSjet =
Var(
"tauID('byDeepTau2017v2p1VSjetraw')", float, doc=
"byDeepTau2017v2p1VSjet raw output discriminator (deepTau2017v2p1)", precision=10),
121 idDeepTau2017v2p1VSe =
_tauIdWPMask(
"by%sDeepTau2017v2p1VSe",
122 choices=(
"VVVLoose",
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
123 doc=
"byDeepTau2017v2p1VSe ID working points (deepTau2017v2p1)"),
124 idDeepTau2017v2p1VSmu =
_tauIdWPMask(
"by%sDeepTau2017v2p1VSmu",
125 choices=(
"VLoose",
"Loose",
"Medium",
"Tight"),
126 doc=
"byDeepTau2017v2p1VSmu ID working points (deepTau2017v2p1)"),
127 idDeepTau2017v2p1VSjet =
_tauIdWPMask(
"by%sDeepTau2017v2p1VSjet",
128 choices=(
"VVVLoose",
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
129 doc=
"byDeepTau2017v2p1VSjet ID working points (deepTau2017v2p1)"),
131 _deepTauVars2018v2p5 = cms.PSet(
132 rawDeepTau2018v2p5VSe =
Var(
"tauID('byDeepTau2018v2p5VSeraw')", float, doc=
"byDeepTau2018v2p5VSe raw output discriminator (deepTau2018v2p5)", precision=10),
133 rawDeepTau2018v2p5VSmu =
Var(
"tauID('byDeepTau2018v2p5VSmuraw')", float, doc=
"byDeepTau2018v2p5VSmu raw output discriminator (deepTau2018v2p5)", precision=10),
134 rawDeepTau2018v2p5VSjet =
Var(
"tauID('byDeepTau2018v2p5VSjetraw')", float, doc=
"byDeepTau2018v2p5VSjet raw output discriminator (deepTau2018v2p5)", precision=10),
135 idDeepTau2018v2p5VSe =
_tauIdWPMask(
"by%sDeepTau2018v2p5VSe",
136 choices=(
"VVVLoose",
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
137 doc=
"byDeepTau2018v2p5VSe ID working points (deepTau2018v2p5)"),
138 idDeepTau2018v2p5VSmu =
_tauIdWPMask(
"by%sDeepTau2018v2p5VSmu",
139 choices=(
"VLoose",
"Loose",
"Medium",
"Tight"),
140 doc=
"byDeepTau2018v2p5VSmu ID working points (deepTau2018v2p5)"),
141 idDeepTau2018v2p5VSjet =
_tauIdWPMask(
"by%sDeepTau2018v2p5VSjet",
142 choices=(
"VVVLoose",
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
143 doc=
"byDeepTau2018v2p5VSjet ID working points (deepTau2018v2p5)"),
146 _variablesMiniV2 = cms.PSet(
148 _deepTauVars2017v2p1,
151 _variablesMiniV1 = cms.PSet(
155 _variablesMiniV1.rawMVAoldDM =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10)
156 _variablesMiniV1.rawMVAoldDM2017v1 =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw2017v1')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v1)",precision=10)
157 _variablesMiniV1.idMVAoldDM =
_tauIdWPMask(
"by%sIsolationMVArun2v1DBoldDMwLT",
158 choices=(
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
159 doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2015)")
160 _variablesMiniV1.idMVAoldDM2017v1 =
_tauIdWPMask(
"by%sIsolationMVArun2v1DBoldDMwLT2017v1",
161 choices=(
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
162 doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2017v1)")
163 _variables80X = cms.PSet(
169 tauTable.variables = _variablesMiniV2
172 run3_nanoAOD_124.toModify(
174 idDeepTau2018v2p5VSe =
_tauIdWPMask(
"byDeepTau2018v2p5VSeraw",
175 choices=(
"VVVLoose",
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
176 doc=
"byDeepTau2018v2p5VSe ID working points (deepTau2018v2p5)",
177 from_raw=
True, wp_thrs=WORKING_POINTS_v2p5[
"e"]),
178 idDeepTau2018v2p5VSmu =
_tauIdWPMask(
"byDeepTau2018v2p5VSmuraw",
179 choices=(
"VLoose",
"Loose",
"Medium",
"Tight"),
180 doc=
"byDeepTau2018v2p5VSmu ID working points (deepTau2018v2p5)",
181 from_raw=
True, wp_thrs=WORKING_POINTS_v2p5[
"mu"]),
182 idDeepTau2018v2p5VSjet =
_tauIdWPMask(
"byDeepTau2018v2p5VSjetraw",
183 choices=(
"VVVLoose",
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
184 doc=
"byDeepTau2018v2p5VSjet ID working points (deepTau2018v2p5)",
185 from_raw=
True, wp_thrs=WORKING_POINTS_v2p5[
"jet"])
189 tauGenJetsForNano = tauGenJets.clone(
190 GenParticles =
"finalGenParticles",
191 includeNeutrinos =
False 194 tauGenJetsSelectorAllHadronsForNano = tauGenJetsSelectorAllHadrons.clone(
195 src =
"tauGenJetsForNano" 198 genVisTaus = cms.EDProducer(
"GenVisTauProducer",
199 src = cms.InputTag(
"tauGenJetsSelectorAllHadronsForNano"),
200 srcGenParticles = cms.InputTag(
"finalGenParticles")
203 genVisTauTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
204 src = cms.InputTag(
"genVisTaus"),
205 cut = cms.string(
"pt > 10."),
206 name = cms.string(
"GenVisTau"),
207 doc = cms.string(
"gen hadronic taus "),
208 singleton = cms.bool(
False),
209 extension = cms.bool(
False),
210 variables = cms.PSet(
211 pt =
Var(
"pt", float,precision=8),
212 phi =
Var(
"phi", float,precision=8),
213 eta =
Var(
"eta", float,precision=8),
214 mass =
Var(
"mass", float,precision=8),
215 charge =
Var(
"charge", int),
216 status =
Var(
"status", int, doc=
"Hadronic tau decay mode. 0=OneProng0PiZero, 1=OneProng1PiZero, 2=OneProng2PiZero, 10=ThreeProng0PiZero, 11=ThreeProng1PiZero, 15=Other"),
217 genPartIdxMother =
Var(
"?numberOfMothers>0?motherRef(0).key():-1", int, doc=
"index of the mother particle"),
221 tausMCMatchLepTauForTable = cms.EDProducer(
"MCMatcher",
223 matched = cms.InputTag(
"finalGenParticles"),
224 mcPdgId = cms.vint32(11,13),
225 checkCharge = cms.bool(
False),
226 mcStatus = cms.vint32(),
227 maxDeltaR = cms.double(0.3),
228 maxDPtRel = cms.double(0.5),
229 resolveAmbiguities = cms.bool(
True),
230 resolveByMatchQuality = cms.bool(
True),
233 tausMCMatchHadTauForTable = cms.EDProducer(
"MCMatcher",
235 matched = cms.InputTag(
"genVisTaus"),
236 mcPdgId = cms.vint32(15),
237 checkCharge = cms.bool(
False),
238 mcStatus = cms.vint32(),
239 maxDeltaR = cms.double(0.3),
240 maxDPtRel = cms.double(1.),
241 resolveAmbiguities = cms.bool(
True),
242 resolveByMatchQuality = cms.bool(
True),
245 tauMCTable = cms.EDProducer(
"CandMCMatchTableProducer",
247 mcMap = cms.InputTag(
"tausMCMatchLepTauForTable"),
248 mcMapVisTau = cms.InputTag(
"tausMCMatchHadTauForTable"),
249 objName = tauTable.name,
250 objType = tauTable.name,
251 branchName = cms.string(
"genPart"),
252 docString = cms.string(
"MC matching to status==2 taus"),
256 tauTask = cms.Task(finalTaus)
257 tauTablesTask = cms.Task(tauTable)
259 genTauTask = cms.Task(tauGenJetsForNano,tauGenJetsSelectorAllHadronsForNano,genVisTaus,genVisTauTable)
260 tauMCTask = cms.Task(genTauTask,tausMCMatchLepTauForTable,tausMCMatchHadTauForTable,tauMCTable)
def Var(expr, valtype, doc=None, precision=-1)
def _tauIdWPMask(pattern, choices, doc="", from_raw=False, wp_thrs=None)
Tables for final output and docs ##########################.
static std::string join(char **cmd)