1 import FWCore.ParameterSet.Config
as cms
13 finalTaus = cms.EDFilter(
"PATTauRefSelector",
14 src = cms.InputTag(
"slimmedTausUpdated"),
15 cut = cms.string(
"pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT2015') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBnewDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBdR03oldDMwLT2017v2') || tauID('byVVVLooseDeepTau2017v2VSjet'))")
18 from Configuration.Eras.Modifier_run2_miniAOD_devel_cff
import run2_miniAOD_devel
19 from Configuration.Eras.Modifier_run2_tau_ul_2016_cff
import run2_tau_ul_2016
20 from Configuration.Eras.Modifier_run2_tau_ul_2018_cff
import run2_tau_ul_2018
21 for era
in [run2_miniAOD_devel,run2_tau_ul_2016,run2_tau_ul_2018]:
22 era.toModify(finalTaus,
23 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'))")
26 from Configuration.Eras.Modifier_run2_nanoAOD_94X2016_cff
import run2_nanoAOD_94X2016
27 from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv2_cff
import run2_nanoAOD_94XMiniAODv2
28 from Configuration.Eras.Modifier_run2_nanoAOD_102Xv1_cff
import run2_nanoAOD_102Xv1
29 for era
in [run2_nanoAOD_94X2016,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_102Xv1]:
30 era.toModify(finalTaus,
31 cut = cms.string(
"pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT2015') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBnewDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBdR03oldDMwLT2017v2'))")
33 from Configuration.Eras.Modifier_run2_nanoAOD_94XMiniAODv1_cff
import run2_nanoAOD_94XMiniAODv1
34 for era
in [run2_nanoAOD_94XMiniAODv1,]:
35 era.toModify(finalTaus,
36 cut = cms.string(
"pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT2017v1') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBnewDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBdR03oldDMwLT2017v2'))")
38 from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff
import run2_miniAOD_80XLegacy
39 run2_miniAOD_80XLegacy.toModify(finalTaus,
40 src = cms.InputTag(
"slimmedTaus"),
41 cut = cms.string(
"pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT'))")
46 return Var(
" + ".
join([
"%d * tauID('%s')" % (
pow(2,i), pattern % c)
for (i,c)
in enumerate(choices)]),
"uint8",
47 doc=doc+
": bitmask "+
", ".
join([
"%d = %s" % (
pow(2,i),c)
for (i,c)
in enumerate(choices)]))
49 return _tauIdWPMask(pattern,choices=(
"Loose",
"Tight"),doc=doc)
51 return _tauIdWPMask(pattern,choices=(
"Loose",
"Medium",
"Tight"),doc=doc)
53 return _tauIdWPMask(pattern, choices=(
"VLoose",
"Loose",
"Medium",
"Tight"), doc=doc)
55 return _tauIdWPMask(pattern,choices=(
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight"),doc=doc)
57 return _tauIdWPMask(pattern,choices=(
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),doc=doc)
59 return _tauIdWPMask(pattern,choices=(
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),doc=doc)
61 return _tauIdWPMask(pattern,choices=(
"VVVLoose",
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),doc=doc)
63 tauTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
64 src = cms.InputTag(
"linkedObjects",
"taus"),
66 name= cms.string(
"Tau"),
67 doc = cms.string(
"slimmedTaus after basic selection (" + finalTaus.cut.value()+
")"),
68 singleton = cms.bool(
False),
69 extension = cms.bool(
False),
70 variables = cms.PSet()
72 _tauVarsBase = cms.PSet(P4Vars,
73 charge =
Var(
"charge", int, doc=
"electric charge"),
74 jetIdx =
Var(
"?hasUserCand('jet')?userCand('jet').key():-1", int, doc=
"index of the associated jet (-1 if none)"),
75 decayMode =
Var(
"decayMode()",int),
76 idDecayMode =
Var(
"tauID('decayModeFinding')", bool),
77 idDecayModeNewDMs =
Var(
"tauID('decayModeFindingNewDMs')", bool),
79 leadTkPtOverTauPt =
Var(
"leadChargedHadrCand.pt/pt ",float, doc=
"pt of the leading track divided by tau pt",precision=10),
80 leadTkDeltaEta =
Var(
"leadChargedHadrCand.eta - eta ",float, doc=
"eta of the leading track, minus tau eta",precision=8),
81 leadTkDeltaPhi =
Var(
"deltaPhi(leadChargedHadrCand.phi, phi) ",float, doc=
"phi of the leading track, minus tau phi",precision=8),
83 dxy =
Var(
"leadChargedHadrCand().dxy()",float, doc=
"d_{xy} of lead track with respect to PV, in cm (with sign)",precision=10),
84 dz =
Var(
"leadChargedHadrCand().dz()",float, doc=
"d_{z} of lead track with respect to PV, in cm (with sign)",precision=14),
87 rawIso =
Var(
"tauID('byCombinedIsolationDeltaBetaCorrRaw3Hits')", float, doc =
"combined isolation (deltaBeta corrections)", precision=10),
88 rawIsodR03 =
Var(
"(tauID('chargedIsoPtSumdR03')+max(0.,tauID('neutralIsoPtSumdR03')-0.072*tauID('puCorrPtSum')))", float, doc =
"combined isolation (deltaBeta corrections, dR=0.3)", precision=10),
89 chargedIso =
Var(
"tauID('chargedIsoPtSum')", float, doc =
"charged isolation", precision=10),
90 neutralIso =
Var(
"tauID('neutralIsoPtSum')", float, doc =
"neutral (photon) isolation", precision=10),
91 puCorr =
Var(
"tauID('puCorrPtSum')", float, doc =
"pileup correction", precision=10),
92 photonsOutsideSignalCone =
Var(
"tauID('photonPtSumOutsideSignalCone')", float, doc =
"sum of photons outside signal cone", precision=10),
94 rawAntiEle =
Var(
"tauID('againstElectronMVA6Raw')", float, doc=
"Anti-electron MVA discriminator V6 raw output discriminator", precision=10),
95 rawAntiEleCat =
Var(
"tauID('againstElectronMVA6category')", int, doc=
"Anti-electron MVA discriminator V6 category"),
97 idAntiMu =
_tauId2WPMask(
"againstMuon%s3", doc=
"Anti-muon discriminator V3: "),
98 idAntiEle =
_tauId5WPMask(
"againstElectron%sMVA6", doc=
"Anti-electron MVA discriminator V6"),
105 _mvaIsoVars2015 = cms.PSet(
106 rawMVAnewDM =
Var(
"tauID('byIsolationMVArun2v1DBnewDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
107 rawMVAoldDM =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
108 rawMVAoldDMdR03 =
Var(
"tauID('byIsolationMVArun2v1DBdR03oldDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
109 idMVAnewDM =
_tauId6WPMask(
"by%sIsolationMVArun2v1DBnewDMwLT", doc=
"IsolationMVArun2v1DBnewDMwLT ID working point (2015)"),
110 idMVAoldDM =
_tauId6WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2015)"),
111 idMVAoldDMdR03 =
_tauId6WPMask(
"by%sIsolationMVArun2v1DBdR03oldDMwLT", doc=
"IsolationMVArun2v1DBoldDMdR0p3wLT ID working point (2015)")
113 _mvaIsoVars2015Reduced = cms.PSet(
114 rawMVAoldDM =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw2015')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
115 idMVAoldDM =
_tauId6WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT2015", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2015)"),
117 _mvaIsoVars2017v1 = cms.PSet(
118 rawMVAoldDM2017v1 =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v1)",precision=10),
119 idMVAoldDM2017v1 =
_tauId7WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2017v1)")
121 _mvaIsoVars2017v2 = cms.PSet(
122 rawMVAnewDM2017v2 =
Var(
"tauID('byIsolationMVArun2v1DBnewDMwLTraw2017v2')",float, doc=
"byIsolationMVArun2v1DBnewDMwLT raw output discriminator (2017v2)",precision=10),
123 rawMVAoldDM2017v2 =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw2017v2')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v2)",precision=10),
124 rawMVAoldDMdR032017v2 =
Var(
"tauID('byIsolationMVArun2v1DBdR03oldDMwLTraw2017v2')",float, doc=
"byIsolationMVArun2v1DBdR03oldDMwLT raw output discriminator (2017v2)",precision=10),
125 idMVAnewDM2017v2 =
_tauId7WPMask(
"by%sIsolationMVArun2v1DBnewDMwLT2017v2", doc=
"IsolationMVArun2v1DBnewDMwLT ID working point (2017v2)"),
126 idMVAoldDM2017v2 =
_tauId7WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT2017v2", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2017v2)"),
127 idMVAoldDMdR032017v2 =
_tauId7WPMask(
"by%sIsolationMVArun2v1DBdR03oldDMwLT2017v2", doc=
"IsolationMVArun2v1DBoldDMdR0p3wLT ID working point (2017v2)")
129 _mvaAntiEVars2018 = cms.PSet(
130 rawAntiEle2018 =
Var(
"tauID('againstElectronMVA6Raw2018')", float, doc=
"Anti-electron MVA discriminator V6 raw output discriminator (2018)", precision=10),
131 rawAntiEleCat2018 =
Var(
"tauID('againstElectronMVA6category2018')", int, doc=
"Anti-electron MVA discriminator V6 category (2018)"),
132 idAntiEle2018 =
_tauId5WPMask(
"againstElectron%sMVA62018", doc=
"Anti-electron MVA discriminator V6 (2018)"),
134 _deepTauVars2017v2 = cms.PSet(
135 rawDeepTau2017v2VSe =
Var(
"tauID('byDeepTau2017v2VSeraw')", float, doc=
"byDeepTau2017v2VSe raw output discriminator (deepTau2017v2)", precision=10),
136 rawDeepTau2017v2VSmu =
Var(
"tauID('byDeepTau2017v2VSmuraw')", float, doc=
"byDeepTau2017v2VSmu raw output discriminator (deepTau2017v2)", precision=10),
137 rawDeepTau2017v2VSjet =
Var(
"tauID('byDeepTau2017v2VSjetraw')", float, doc=
"byDeepTau2017v2VSjet raw output discriminator (deepTau2017v2)", precision=10),
138 idDeepTau2017v2VSe =
_tauId8WPMask(
"by%sDeepTau2017v2VSe", doc=
"byDeepTau2017v2VSe ID working points (deepTau2017v2)"),
139 idDeepTau2017v2VSmu =
_tauId4WPMask(
"by%sDeepTau2017v2VSmu", doc=
"byDeepTau2017v2VSmu ID working points (deepTau2017v2)"),
140 idDeepTau2017v2VSjet =
_tauId8WPMask(
"by%sDeepTau2017v2VSjet", doc=
"byDeepTau2017v2VSjet ID working points (deepTau2017v2)"),
142 _deepTauVars2017v2p1 = cms.PSet(
143 rawDeepTau2017v2p1VSe =
Var(
"tauID('byDeepTau2017v2p1VSeraw')", float, doc=
"byDeepTau2017v2p1VSe raw output discriminator (deepTau2017v2p1)", precision=10),
144 rawDeepTau2017v2p1VSmu =
Var(
"tauID('byDeepTau2017v2p1VSmuraw')", float, doc=
"byDeepTau2017v2p1VSmu raw output discriminator (deepTau2017v2p1)", precision=10),
145 rawDeepTau2017v2p1VSjet =
Var(
"tauID('byDeepTau2017v2p1VSjetraw')", float, doc=
"byDeepTau2017v2p1VSjet raw output discriminator (deepTau2017v2p1)", precision=10),
146 idDeepTau2017v2p1VSe =
_tauId8WPMask(
"by%sDeepTau2017v2p1VSe", doc=
"byDeepTau2017v2p1VSe ID working points (deepTau2017v2p1)"),
147 idDeepTau2017v2p1VSmu =
_tauId4WPMask(
"by%sDeepTau2017v2p1VSmu", doc=
"byDeepTau2017v2p1VSmu ID working points (deepTau2017v2p1)"),
148 idDeepTau2017v2p1VSjet =
_tauId8WPMask(
"by%sDeepTau2017v2p1VSjet", doc=
"byDeepTau2017v2p1VSjet ID working points (deepTau2017v2p1)"),
151 _variablesMiniV2 = cms.PSet(
154 _mvaIsoVars2015Reduced,
158 _variablesMiniV1 = _variablesMiniV2.clone()
159 _variablesMiniV1.rawMVAoldDM =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10)
160 _variablesMiniV1.rawMVAoldDM2017v1 =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw2017v1')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v1)",precision=10)
161 _variablesMiniV1.idMVAoldDM =
_tauId6WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2015)")
162 _variablesMiniV1.idMVAoldDM2017v1 =
_tauId7WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT2017v1", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2017v1)")
163 _variables80X = cms.PSet(
168 tauTable.variables = cms.PSet(_variablesMiniV2,_deepTauVars2017v2)
170 for era
in [run2_miniAOD_devel,run2_tau_ul_2016,run2_tau_ul_2018]:
171 era.toModify(tauTable,
172 variables = cms.PSet(_variablesMiniV2,_deepTauVars2017v2p1)
174 for era
in [run2_nanoAOD_94X2016,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_102Xv1]:
175 era.toModify(tauTable,
176 variables = _variablesMiniV2
178 for era
in [run2_nanoAOD_94XMiniAODv1,]:
179 era.toModify(tauTable,
180 variables = _variablesMiniV1
182 run2_miniAOD_80XLegacy.toModify(tauTable,
183 variables = _variables80X
187 tauGenJets.GenParticles = cms.InputTag(
"prunedGenParticles")
188 tauGenJets.includeNeutrinos = cms.bool(
False)
190 genVisTaus = cms.EDProducer(
"GenVisTauProducer",
191 src = cms.InputTag(
"tauGenJetsSelectorAllHadrons"),
192 srcGenParticles = cms.InputTag(
"prunedGenParticles")
195 genVisTauTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
196 src = cms.InputTag(
"genVisTaus"),
197 cut = cms.string(
"pt > 10."),
198 name = cms.string(
"GenVisTau"),
199 doc = cms.string(
"gen hadronic taus "),
200 singleton = cms.bool(
False),
201 extension = cms.bool(
False),
202 variables = cms.PSet(
203 pt =
Var(
"pt", float,precision=8),
204 phi =
Var(
"phi", float,precision=8),
205 eta =
Var(
"eta", float,precision=8),
206 mass =
Var(
"mass", float,precision=8),
207 charge =
Var(
"charge", int),
208 status =
Var(
"status", int, doc=
"Hadronic tau decay mode. 0=OneProng0PiZero, 1=OneProng1PiZero, 2=OneProng2PiZero, 10=ThreeProng0PiZero, 11=ThreeProng1PiZero, 15=Other"),
209 genPartIdxMother =
Var(
"?numberOfMothers>0?motherRef(0).key():-1", int, doc=
"index of the mother particle"),
213 tausMCMatchLepTauForTable = cms.EDProducer(
"MCMatcher",
215 matched = cms.InputTag(
"finalGenParticles"),
216 mcPdgId = cms.vint32(11,13),
217 checkCharge = cms.bool(
False),
218 mcStatus = cms.vint32(),
219 maxDeltaR = cms.double(0.3),
220 maxDPtRel = cms.double(0.5),
221 resolveAmbiguities = cms.bool(
True),
222 resolveByMatchQuality = cms.bool(
True),
225 tausMCMatchHadTauForTable = cms.EDProducer(
"MCMatcher",
227 matched = cms.InputTag(
"genVisTaus"),
228 mcPdgId = cms.vint32(15),
229 checkCharge = cms.bool(
False),
230 mcStatus = cms.vint32(),
231 maxDeltaR = cms.double(0.3),
232 maxDPtRel = cms.double(1.),
233 resolveAmbiguities = cms.bool(
True),
234 resolveByMatchQuality = cms.bool(
True),
237 tauMCTable = cms.EDProducer(
"CandMCMatchTableProducer",
239 mcMap = cms.InputTag(
"tausMCMatchLepTauForTable"),
240 mcMapVisTau = cms.InputTag(
"tausMCMatchHadTauForTable"),
241 objName = tauTable.name,
242 objType = tauTable.name,
243 branchName = cms.string(
"genPart"),
244 docString = cms.string(
"MC matching to status==2 taus"),
248 tauSequence = cms.Sequence(patTauMVAIDsSeq + finalTaus)
249 _tauSequence80X = cms.Sequence(finalTaus)
250 run2_miniAOD_80XLegacy.toReplaceWith(tauSequence,_tauSequence80X)
251 tauTables = cms.Sequence(tauTable)
252 tauMC = cms.Sequence(tauGenJets + tauGenJetsSelectorAllHadrons + genVisTaus + genVisTauTable + 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)