1 import FWCore.ParameterSet.Config
as cms
14 finalTaus = cms.EDFilter(
"PATTauRefSelector",
15 src = cms.InputTag(
"slimmedTausUpdated"),
16 cut = cms.string(
"pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || (tauID('chargedIsoPtSumdR03')+max(0.,tauID('neutralIsoPtSumdR03')-0.072*tauID('puCorrPtSum'))<2.5) || tauID('byVVVLooseDeepTau2017v2p1VSjet'))")
19 for era
in [run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1]:
20 era.toModify(finalTaus,
21 cut = cms.string(
"pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT2015') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBnewDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBdR03oldDMwLT2017v2') || tauID('byVVVLooseDeepTau2017v2p1VSjet'))")
23 for era
in [run2_nanoAOD_94XMiniAODv1,]:
24 era.toModify(finalTaus,
25 cut = cms.string(
"pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT2017v1') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBnewDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBdR03oldDMwLT2017v2') || tauID('byVVVLooseDeepTau2017v2p1VSjet'))")
27 run2_miniAOD_80XLegacy.toModify(finalTaus,
28 src = cms.InputTag(
"slimmedTaus"),
29 cut = cms.string(
"pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT'))")
34 return Var(
" + ".
join([
"%d * tauID('%s')" % (
pow(2,i), pattern % c)
for (i,c)
in enumerate(choices)]),
"uint8",
35 doc=doc+
": bitmask "+
", ".
join([
"%d = %s" % (
pow(2,i),c)
for (i,c)
in enumerate(choices)]))
37 return _tauIdWPMask(pattern,choices=(
"Loose",
"Tight"),doc=doc)
39 return _tauIdWPMask(pattern,choices=(
"Loose",
"Medium",
"Tight"),doc=doc)
41 return _tauIdWPMask(pattern, choices=(
"VLoose",
"Loose",
"Medium",
"Tight"), doc=doc)
43 return _tauIdWPMask(pattern,choices=(
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight"),doc=doc)
45 return _tauIdWPMask(pattern,choices=(
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),doc=doc)
47 return _tauIdWPMask(pattern,choices=(
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),doc=doc)
49 return _tauIdWPMask(pattern,choices=(
"VVVLoose",
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),doc=doc)
51 tauTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
52 src = cms.InputTag(
"linkedObjects",
"taus"),
54 name= cms.string(
"Tau"),
55 doc = cms.string(
"slimmedTaus after basic selection (" + finalTaus.cut.value()+
")"),
56 singleton = cms.bool(
False),
57 extension = cms.bool(
False),
58 variables = cms.PSet()
60 _tauVarsBase = cms.PSet(P4Vars,
61 charge =
Var(
"charge", int, doc=
"electric charge"),
62 jetIdx =
Var(
"?hasUserCand('jet')?userCand('jet').key():-1", int, doc=
"index of the associated jet (-1 if none)"),
63 decayMode =
Var(
"decayMode()",int),
64 idDecayModeOldDMs =
Var(
"tauID('decayModeFinding')", bool),
66 leadTkPtOverTauPt =
Var(
"leadChargedHadrCand.pt/pt ",float, doc=
"pt of the leading track divided by tau pt",precision=10),
67 leadTkDeltaEta =
Var(
"leadChargedHadrCand.eta - eta ",float, doc=
"eta of the leading track, minus tau eta",precision=8),
68 leadTkDeltaPhi =
Var(
"deltaPhi(leadChargedHadrCand.phi, phi) ",float, doc=
"phi of the leading track, minus tau phi",precision=8),
70 dxy =
Var(
"leadChargedHadrCand().dxy()",float, doc=
"d_{xy} of lead track with respect to PV, in cm (with sign)",precision=10),
71 dz =
Var(
"leadChargedHadrCand().dz()",float, doc=
"d_{z} of lead track with respect to PV, in cm (with sign)",precision=14),
74 rawIso =
Var(
"tauID('byCombinedIsolationDeltaBetaCorrRaw3Hits')", float, doc =
"combined isolation (deltaBeta corrections)", precision=10),
75 rawIsodR03 =
Var(
"(tauID('chargedIsoPtSumdR03')+max(0.,tauID('neutralIsoPtSumdR03')-0.072*tauID('puCorrPtSum')))", float, doc =
"combined isolation (deltaBeta corrections, dR=0.3)", precision=10),
76 chargedIso =
Var(
"tauID('chargedIsoPtSum')", float, doc =
"charged isolation", precision=10),
77 neutralIso =
Var(
"tauID('neutralIsoPtSum')", float, doc =
"neutral (photon) isolation", precision=10),
78 puCorr =
Var(
"tauID('puCorrPtSum')", float, doc =
"pileup correction", precision=10),
79 photonsOutsideSignalCone =
Var(
"tauID('photonPtSumOutsideSignalCone')", float, doc =
"sum of photons outside signal cone", precision=10),
81 idAntiMu =
_tauId2WPMask(
"againstMuon%s3", doc=
"Anti-muon discriminator V3: "),
82 idAntiEleDeadECal =
Var(
"tauID('againstElectronDeadECALForNano')", bool, doc =
"Anti-electron dead-ECal discriminator"),
89 _mvaIsoVars2015 = cms.PSet(
90 rawMVAnewDM =
Var(
"tauID('byIsolationMVArun2v1DBnewDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
91 rawMVAoldDM =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
92 rawMVAoldDMdR03 =
Var(
"tauID('byIsolationMVArun2v1DBdR03oldDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
93 idMVAnewDM =
_tauId6WPMask(
"by%sIsolationMVArun2v1DBnewDMwLT", doc=
"IsolationMVArun2v1DBnewDMwLT ID working point (2015)"),
94 idMVAoldDM =
_tauId6WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2015)"),
95 idMVAoldDMdR03 =
_tauId6WPMask(
"by%sIsolationMVArun2v1DBdR03oldDMwLT", doc=
"IsolationMVArun2v1DBoldDMdR0p3wLT ID working point (2015)")
97 _mvaIsoVars2015Reduced = cms.PSet(
98 rawMVAoldDM =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw2015')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
99 idMVAoldDM =
_tauId6WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT2015", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2015)"),
101 _mvaIsoVars2017v1 = cms.PSet(
102 rawMVAoldDM2017v1 =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v1)",precision=10),
103 idMVAoldDM2017v1 =
_tauId7WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2017v1)")
105 _mvaIsoVars2017v2 = cms.PSet(
106 rawMVAnewDM2017v2 =
Var(
"tauID('byIsolationMVArun2v1DBnewDMwLTraw2017v2')",float, doc=
"byIsolationMVArun2v1DBnewDMwLT raw output discriminator (2017v2)",precision=10),
107 rawMVAoldDM2017v2 =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw2017v2')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v2)",precision=10),
108 rawMVAoldDMdR032017v2 =
Var(
"tauID('byIsolationMVArun2v1DBdR03oldDMwLTraw2017v2')",float, doc=
"byIsolationMVArun2v1DBdR03oldDMwLT raw output discriminator (2017v2)",precision=10),
109 idMVAnewDM2017v2 =
_tauId7WPMask(
"by%sIsolationMVArun2v1DBnewDMwLT2017v2", doc=
"IsolationMVArun2v1DBnewDMwLT ID working point (2017v2)"),
110 idMVAoldDM2017v2 =
_tauId7WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT2017v2", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2017v2)"),
111 idMVAoldDMdR032017v2 =
_tauId7WPMask(
"by%sIsolationMVArun2v1DBdR03oldDMwLT2017v2", doc=
"IsolationMVArun2v1DBoldDMdR0p3wLT ID working point (2017v2)")
113 _mvaAntiEVars2015 = cms.PSet(
114 rawAntiEle =
Var(
"tauID('againstElectronMVA6Raw')", float, doc=
"Anti-electron MVA discriminator V6 raw output discriminator (2015)", precision=10),
115 rawAntiEleCat =
Var(
"tauID('againstElectronMVA6category')", int, doc=
"Anti-electron MVA discriminator V6 category (2015)"),
116 idAntiEle =
_tauId5WPMask(
"againstElectron%sMVA6", doc=
"Anti-electron MVA discriminator V6 (2015)")
118 _deepTauVars2017v2p1 = cms.PSet(
119 rawDeepTau2017v2p1VSe =
Var(
"tauID('byDeepTau2017v2p1VSeraw')", float, doc=
"byDeepTau2017v2p1VSe raw output discriminator (deepTau2017v2p1)", precision=10),
120 rawDeepTau2017v2p1VSmu =
Var(
"tauID('byDeepTau2017v2p1VSmuraw')", float, doc=
"byDeepTau2017v2p1VSmu raw output discriminator (deepTau2017v2p1)", precision=10),
121 rawDeepTau2017v2p1VSjet =
Var(
"tauID('byDeepTau2017v2p1VSjetraw')", float, doc=
"byDeepTau2017v2p1VSjet raw output discriminator (deepTau2017v2p1)", precision=10),
122 idDeepTau2017v2p1VSe =
_tauId8WPMask(
"by%sDeepTau2017v2p1VSe", doc=
"byDeepTau2017v2p1VSe ID working points (deepTau2017v2p1)"),
123 idDeepTau2017v2p1VSmu =
_tauId4WPMask(
"by%sDeepTau2017v2p1VSmu", doc=
"byDeepTau2017v2p1VSmu ID working points (deepTau2017v2p1)"),
124 idDeepTau2017v2p1VSjet =
_tauId8WPMask(
"by%sDeepTau2017v2p1VSjet", doc=
"byDeepTau2017v2p1VSjet ID working points (deepTau2017v2p1)"),
127 _variablesMiniV2 = cms.PSet(
131 _variablesMiniV1 = cms.PSet(
135 _variablesMiniV1.rawMVAoldDM =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10)
136 _variablesMiniV1.rawMVAoldDM2017v1 =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw2017v1')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v1)",precision=10)
137 _variablesMiniV1.idMVAoldDM =
_tauId6WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2015)")
138 _variablesMiniV1.idMVAoldDM2017v1 =
_tauId7WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT2017v1", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2017v1)")
139 _variables80X = cms.PSet(
145 tauTable.variables = _variablesMiniV2
147 (run2_nanoAOD_92X | run2_nanoAOD_94XMiniAODv2 | run2_nanoAOD_94X2016 | run2_nanoAOD_102Xv1 | run2_nanoAOD_106Xv1).toModify(tauTable,
148 variables = cms.PSet(tauTable.variables, _mvaIsoVars2015Reduced, _mvaIsoVars2017v1, _mvaIsoVars2017v2)
150 for era
in [run2_nanoAOD_94XMiniAODv1,]:
151 era.toModify(tauTable,
152 variables = _variablesMiniV1
154 run2_miniAOD_80XLegacy.toModify(tauTable,
155 variables = _variables80X
157 for era
in [run2_nanoAOD_92X, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, \
158 run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1]:
159 era.toModify(tauTable.variables,
160 rawAntiEle2018 =
Var(
"tauID('againstElectronMVA6Raw2018')", float, doc=
"Anti-electron MVA discriminator V6 raw output discriminator (2018)", precision=10),
161 rawAntiEleCat2018 =
Var(
"tauID('againstElectronMVA6category2018')", int, doc=
"Anti-electron MVA discriminator V6 category (2018)"),
162 idAntiEle2018 =
_tauId5WPMask(
"againstElectron%sMVA62018", doc=
"Anti-electron MVA discriminator V6 (2018)"),
163 rawAntiEle =
Var(
"tauID('againstElectronMVA6Raw')", float, doc=
"Anti-electron MVA discriminator V6 raw output discriminator (2015)", precision=10),
164 rawAntiEleCat =
Var(
"tauID('againstElectronMVA6category')", int, doc=
"Anti-electron MVA discriminator V6 category (2015"),
165 idAntiEle =
_tauId5WPMask(
"againstElectron%sMVA6", doc=
"Anti-electron MVA discriminator V6 (2015)")
167 for era
in [run2_miniAOD_80XLegacy, run2_nanoAOD_92X, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, \
168 run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1]:
169 era.toModify(tauTable.variables,
170 idDecayMode =
Var(
"tauID('decayModeFinding')", bool),
171 idDecayModeNewDMs =
Var(
"tauID('decayModeFindingNewDMs')", bool),
172 idDecayModeOldDMs =
None 174 run2_miniAOD_80XLegacy.toModify(tauTable.variables,
175 idAntiEleDeadECal =
None 177 (run2_nanoAOD_106Xv2 | run2_miniAOD_devel).toModify(tauTable.variables,
178 idAntiEleDeadECal =
Var(
"tauID('againstElectronDeadECAL')", bool, doc =
"Anti-electron dead-ECal discriminator"),
181 tauGenJetsForNano = tauGenJets.clone(
182 GenParticles =
"finalGenParticles",
183 includeNeutrinos =
False 185 (run2_nanoAOD_106Xv1 & ~run2_nanoAOD_devel).toModify(tauGenJetsForNano, GenParticles =
"prunedGenParticles")
187 tauGenJetsSelectorAllHadronsForNano = tauGenJetsSelectorAllHadrons.clone(
188 src =
"tauGenJetsForNano" 191 genVisTaus = cms.EDProducer(
"GenVisTauProducer",
192 src = cms.InputTag(
"tauGenJetsSelectorAllHadronsForNano"),
193 srcGenParticles = cms.InputTag(
"finalGenParticles")
195 (run2_nanoAOD_106Xv1 & ~run2_nanoAOD_devel).toModify(genVisTaus, srcGenParticles =
"prunedGenParticles")
197 genVisTauTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
198 src = cms.InputTag(
"genVisTaus"),
199 cut = cms.string(
"pt > 10."),
200 name = cms.string(
"GenVisTau"),
201 doc = cms.string(
"gen hadronic taus "),
202 singleton = cms.bool(
False),
203 extension = cms.bool(
False),
204 variables = cms.PSet(
205 pt =
Var(
"pt", float,precision=8),
206 phi =
Var(
"phi", float,precision=8),
207 eta =
Var(
"eta", float,precision=8),
208 mass =
Var(
"mass", float,precision=8),
209 charge =
Var(
"charge", int),
210 status =
Var(
"status", int, doc=
"Hadronic tau decay mode. 0=OneProng0PiZero, 1=OneProng1PiZero, 2=OneProng2PiZero, 10=ThreeProng0PiZero, 11=ThreeProng1PiZero, 15=Other"),
211 genPartIdxMother =
Var(
"?numberOfMothers>0?motherRef(0).key():-1", int, doc=
"index of the mother particle"),
215 tausMCMatchLepTauForTable = cms.EDProducer(
"MCMatcher",
217 matched = cms.InputTag(
"finalGenParticles"),
218 mcPdgId = cms.vint32(11,13),
219 checkCharge = cms.bool(
False),
220 mcStatus = cms.vint32(),
221 maxDeltaR = cms.double(0.3),
222 maxDPtRel = cms.double(0.5),
223 resolveAmbiguities = cms.bool(
True),
224 resolveByMatchQuality = cms.bool(
True),
227 tausMCMatchHadTauForTable = cms.EDProducer(
"MCMatcher",
229 matched = cms.InputTag(
"genVisTaus"),
230 mcPdgId = cms.vint32(15),
231 checkCharge = cms.bool(
False),
232 mcStatus = cms.vint32(),
233 maxDeltaR = cms.double(0.3),
234 maxDPtRel = cms.double(1.),
235 resolveAmbiguities = cms.bool(
True),
236 resolveByMatchQuality = cms.bool(
True),
239 tauMCTable = cms.EDProducer(
"CandMCMatchTableProducer",
241 mcMap = cms.InputTag(
"tausMCMatchLepTauForTable"),
242 mcMapVisTau = cms.InputTag(
"tausMCMatchHadTauForTable"),
243 objName = tauTable.name,
244 objType = tauTable.name,
245 branchName = cms.string(
"genPart"),
246 docString = cms.string(
"MC matching to status==2 taus"),
250 tauSequence = cms.Sequence(patTauMVAIDsSeq + finalTaus)
251 _tauSequence80X = cms.Sequence(finalTaus)
252 run2_miniAOD_80XLegacy.toReplaceWith(tauSequence,_tauSequence80X)
253 tauTables = cms.Sequence(tauTable)
254 genTauSequence = cms.Sequence(tauGenJetsForNano + tauGenJetsSelectorAllHadronsForNano + genVisTaus + genVisTauTable)
255 tauMC = cms.Sequence(genTauSequence + tausMCMatchLepTauForTable + tausMCMatchHadTauForTable + tauMCTable)
def _tauId7WPMask(pattern, doc)
def _tauId5WPMask(pattern, doc)
def _tauId4WPMask(pattern, doc)
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
def _tauId3WPMask(pattern, doc)
def _tauId6WPMask(pattern, doc)
def _tauIdWPMask(pattern, choices, doc="")
Tables for final output and docs ##########################.
static std::string join(char **cmd)
def _tauId2WPMask(pattern, doc)
def _tauId8WPMask(pattern, doc)
Power< A, B >::type pow(const A &a, const B &b)