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('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBnewDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBdR03oldDMwLT2017v2'))")
17 for era
in [eras.run2_nanoAOD_94XMiniAODv2, eras.run2_nanoAOD_94X2016]:
18 era.toModify(finalTaus,
19 cut = cms.string(
"pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT2015') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBnewDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBdR03oldDMwLT2017v2'))")
22 for era
in [eras.run2_nanoAOD_94XMiniAODv1,eras.run2_nanoAOD_92X]:
23 era.toModify(finalTaus,
24 cut = cms.string(
"pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT2017v1') || tauID('byVVLooseIsolationMVArun2v1DBoldDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBnewDMwLT2017v2') || tauID('byVVLooseIsolationMVArun2v1DBdR03oldDMwLT2017v2'))")
26 eras.run2_miniAOD_80XLegacy.toModify(finalTaus,
27 src = cms.InputTag(
"slimmedTaus"),
28 cut = cms.string(
"pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT'))")
33 return Var(
" + ".
join([
"%d * tauID('%s')" % (
pow(2,i), pattern % c)
for (i,c)
in enumerate(choices)]),
"uint8",
34 doc=doc+
": bitmask "+
", ".
join([
"%d = %s" % (
pow(2,i),c)
for (i,c)
in enumerate(choices)]))
36 return _tauIdWPMask(pattern,choices=(
"Loose",
"Tight"),doc=doc)
38 return _tauIdWPMask(pattern,choices=(
"Loose",
"Medium",
"Tight"),doc=doc)
40 return _tauIdWPMask(pattern,choices=(
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight"),doc=doc)
42 return _tauIdWPMask(pattern,choices=(
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),doc=doc)
44 return _tauIdWPMask(pattern,choices=(
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),doc=doc)
46 tauTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
47 src = cms.InputTag(
"linkedObjects",
"taus"),
49 name= cms.string(
"Tau"),
50 doc = cms.string(
"slimmedTaus after basic selection (" + finalTaus.cut.value()+
")"),
51 singleton = cms.bool(
False),
52 extension = cms.bool(
False),
53 variables = 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 idDecayMode =
Var(
"tauID('decayModeFinding')", bool),
58 idDecayModeNewDMs =
Var(
"tauID('decayModeFindingNewDMs')", bool),
60 leadTkPtOverTauPt =
Var(
"leadChargedHadrCand.pt/pt ",float, doc=
"pt of the leading track divided by tau pt",precision=10),
61 leadTkDeltaEta =
Var(
"leadChargedHadrCand.eta - eta ",float, doc=
"eta of the leading track, minus tau eta",precision=8),
62 leadTkDeltaPhi =
Var(
"deltaPhi(leadChargedHadrCand.phi, phi) ",float, doc=
"phi of the leading track, minus tau phi",precision=8),
64 dxy =
Var(
"leadChargedHadrCand().dxy()",float, doc=
"d_{xy} of lead track with respect to PV, in cm (with sign)",precision=10),
65 dz =
Var(
"leadChargedHadrCand().dz()",float, doc=
"d_{z} of lead track with respect to PV, in cm (with sign)",precision=14),
68 rawIso =
Var(
"tauID('byCombinedIsolationDeltaBetaCorrRaw3Hits')", float, doc =
"combined isolation (deltaBeta corrections)", precision=10),
69 rawIsodR03 =
Var(
"(tauID('chargedIsoPtSumdR03')+max(0.,tauID('neutralIsoPtSumdR03')-0.072*tauID('puCorrPtSum')))", float, doc =
"combined isolation (deltaBeta corrections, dR=0.3)", precision=10),
70 chargedIso =
Var(
"tauID('chargedIsoPtSum')", float, doc =
"charged isolation", precision=10),
71 neutralIso =
Var(
"tauID('neutralIsoPtSum')", float, doc =
"neutral (photon) isolation", precision=10),
72 puCorr =
Var(
"tauID('puCorrPtSum')", float, doc =
"pileup correction", precision=10),
73 photonsOutsideSignalCone =
Var(
"tauID('photonPtSumOutsideSignalCone')", float, doc =
"sum of photons outside signal cone", precision=10),
75 rawAntiEle =
Var(
"tauID('againstElectronMVA6Raw')", float, doc=
"Anti-electron MVA discriminator V6 raw output discriminator", precision=10),
76 rawAntiEleCat =
Var(
"tauID('againstElectronMVA6category')", int, doc=
"Anti-electron MVA discriminator V6 category"),
78 idAntiMu =
_tauId2WPMask(
"againstMuon%s3", doc=
"Anti-muon discriminator V3: "),
79 idAntiEle =
_tauId5WPMask(
"againstElectron%sMVA6", doc=
"Anti-electron MVA discriminator V6"),
87 _mvaIsoVars2015 = cms.PSet(
88 rawMVAoldDM =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
89 rawMVAnewDM =
Var(
"tauID('byIsolationMVArun2v1DBnewDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
90 rawMVAoldDMdR03 =
Var(
"tauID('byIsolationMVArun2v1DBdR03oldDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
91 idMVAnew =
_tauId6WPMask(
"by%sIsolationMVArun2v1DBnewDMwLT", doc=
"IsolationMVArun2v1DBnewDMwLT ID working point (2015)"),
92 idMVAoldDM =
_tauId6WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2015)"),
93 idMVAoldDMdR03 =
_tauId6WPMask(
"by%sIsolationMVArun2v1DBdR03oldDMwLT", doc=
"IsolationMVArun2v1DBoldDMdR0p3wLT ID working point (2015)")
95 _mvaIsoVars2015Reduced = cms.PSet(
96 rawMVAoldDM =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw2015')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
97 idMVAoldDM =
_tauId6WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT2015", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2015)"),
99 _mvaIsoVars2017v1 = cms.PSet(
100 rawMVAoldDM2017v1 =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v1)",precision=10),
101 idMVAoldDM2017v1 =
_tauId7WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2017v1)")
103 _mvaIsoVars2017v2 = cms.PSet(
104 rawMVAnewDM2017v2 =
Var(
"tauID('byIsolationMVArun2v1DBnewDMwLTraw2017v2')",float, doc=
"byIsolationMVArun2v1DBnewDMwLT raw output discriminator (2017v2)",precision=10),
105 rawMVAoldDM2017v2 =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw2017v2')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v2)",precision=10),
106 rawMVAoldDMdR032017v2 =
Var(
"tauID('byIsolationMVArun2v1DBdR03oldDMwLTraw2017v2')",float, doc=
"byIsolationMVArun2v1DBdR03oldDMwLT raw output discriminator (2017v2)",precision=10),
107 idMVAnewDM2017v2 =
_tauId7WPMask(
"by%sIsolationMVArun2v1DBnewDMwLT2017v2", doc=
"IsolationMVArun2v1DBnewDMwLT ID working point (2017v2)"),
108 idMVAoldDM2017v2 =
_tauId7WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT2017v2", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2017v2)"),
109 idMVAoldDMdR032017v2 =
_tauId7WPMask(
"by%sIsolationMVArun2v1DBdR03oldDMwLT2017v2", doc=
"IsolationMVArun2v1DBoldDMdR0p3wLT ID working point (2017v2)")
112 _variablesMiniV2 = cms.PSet(
113 tauTable.variables.clone(),
114 _mvaIsoVars2015Reduced,
118 _variablesMiniV1 = _variablesMiniV2.clone()
119 _variablesMiniV1.rawMVAoldDM =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10)
120 _variablesMiniV1.rawMVAoldDM2017v1 =
Var(
"tauID('byIsolationMVArun2v1DBoldDMwLTraw2017v1')",float, doc=
"byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v1)",precision=10)
121 _variablesMiniV1.idMVAoldDM =
_tauId6WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2015)")
122 _variablesMiniV1.idMVAoldDM2017v1 =
_tauId7WPMask(
"by%sIsolationMVArun2v1DBoldDMwLT2017v1", doc=
"IsolationMVArun2v1DBoldDMwLT ID working point (2017v1)")
123 _variables80X = cms.PSet(
124 tauTable.variables.clone(),
128 for era
in [eras.run2_nanoAOD_94X2016, eras.run2_nanoAOD_94XMiniAODv2]:
129 era.toModify(tauTable,
130 variables=_variablesMiniV2
132 for era
in [eras.run2_nanoAOD_94XMiniAODv1,eras.run2_nanoAOD_92X]:
133 era.toModify(tauTable,
134 variables = _variablesMiniV1
136 eras.run2_miniAOD_80XLegacy.toModify(tauTable,
137 variables = _variables80X
139 tauGenJets.GenParticles = cms.InputTag(
"prunedGenParticles")
140 tauGenJets.includeNeutrinos = cms.bool(
False)
142 genVisTaus = cms.EDProducer(
"GenVisTauProducer",
143 src = cms.InputTag(
"tauGenJetsSelectorAllHadrons"),
144 srcGenParticles = cms.InputTag(
"prunedGenParticles")
147 genVisTauTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
148 src = cms.InputTag(
"genVisTaus"),
149 cut = cms.string(
"pt > 10."),
150 name = cms.string(
"GenVisTau"),
151 doc = cms.string(
"gen hadronic taus "),
152 singleton = cms.bool(
False),
153 extension = cms.bool(
False),
154 variables = cms.PSet(
155 pt =
Var(
"pt", float,precision=8),
156 phi =
Var(
"phi", float,precision=8),
157 eta =
Var(
"eta", float,precision=8),
158 mass =
Var(
"mass", float,precision=8),
159 charge =
Var(
"charge", int),
160 status =
Var(
"status", int, doc=
"Hadronic tau decay mode. 0=OneProng0PiZero, 1=OneProng1PiZero, 2=OneProng2PiZero, 10=ThreeProng0PiZero, 11=ThreeProng1PiZero, 15=Other"),
161 genPartIdxMother =
Var(
"?numberOfMothers>0?motherRef(0).key():-1", int, doc=
"index of the mother particle"),
165 tausMCMatchLepTauForTable = cms.EDProducer(
"MCMatcher",
167 matched = cms.InputTag(
"finalGenParticles"),
168 mcPdgId = cms.vint32(11,13),
169 checkCharge = cms.bool(
False),
170 mcStatus = cms.vint32(1),
171 maxDeltaR = cms.double(0.3),
172 maxDPtRel = cms.double(0.5),
173 resolveAmbiguities = cms.bool(
True),
174 resolveByMatchQuality = cms.bool(
True),
177 tausMCMatchHadTauForTable = cms.EDProducer(
"MCMatcher",
179 matched = cms.InputTag(
"genVisTaus"),
180 mcPdgId = cms.vint32(15),
181 checkCharge = cms.bool(
False),
182 mcStatus = cms.vint32(),
183 maxDeltaR = cms.double(0.3),
184 maxDPtRel = cms.double(1.),
185 resolveAmbiguities = cms.bool(
True),
186 resolveByMatchQuality = cms.bool(
True),
189 tauMCTable = cms.EDProducer(
"CandMCMatchTableProducer",
191 mcMap = cms.InputTag(
"tausMCMatchLepTauForTable"),
192 mcMapVisTau = cms.InputTag(
"tausMCMatchHadTauForTable"),
193 objName = tauTable.name,
194 objType = tauTable.name,
195 branchName = cms.string(
"genPart"),
196 docString = cms.string(
"MC matching to status==2 taus"),
200 tauSequence = cms.Sequence(patTauMVAIDsSeq + finalTaus)
201 _tauSequence80X = cms.Sequence(finalTaus)
202 eras.run2_miniAOD_80XLegacy.toReplaceWith(tauSequence,_tauSequence80X)
203 tauTables = cms.Sequence(tauTable)
204 tauMC = cms.Sequence(tauGenJets + tauGenJetsSelectorAllHadrons + genVisTaus + genVisTauTable + tausMCMatchLepTauForTable + tausMCMatchHadTauForTable + tauMCTable)
def _tauId7WPMask(pattern, doc)
def _tauId5WPMask(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)
Power< A, B >::type pow(const A &a, const B &b)