1 import FWCore.ParameterSet.Config
as cms
4 from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi
import simpleCandidateFlatTableProducer
17 from RecoTauTag.RecoTau.tauIdWPsDefs
import WORKING_POINTS_v2p5
19 finalTaus = cms.EDFilter(
"PATTauRefSelector",
20 src = cms.InputTag(
"slimmedTaus"),
21 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'))")
24 run3_nanoAOD_124.toModify(
26 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"]))
30 def _tauIdWPMask(pattern, choices, doc="", from_raw=False, wp_thrs=None):
32 assert wp_thrs
is not None,
"wp_thrs argument in _tauIdWPMask() is None, expect it to be dict-like" 35 for wp_name
in choices:
36 if not isinstance(wp_thrs[wp_name], float):
37 raise TypeError(
"Threshold for WP=%s is not a float number." % wp_name)
38 wp_definition =
"test_bit(tauID('{}')-{}+1,0)".
format(pattern, wp_thrs[wp_name])
39 var_definition.append(wp_definition)
40 var_definition =
" + ".
join(var_definition)
42 var_definition =
" + ".
join([
"tauID('%s')" % (pattern % c)
for c
in choices])
44 doc = doc +
": "+
", ".
join([
"%d = %s" % (i,c)
for (i,c)
in enumerate(choices, start=1)])
45 return Var(var_definition,
"uint8", doc=doc)
48 tauTable = simpleCandidateFlatTableProducer.clone(
49 src = cms.InputTag(
"linkedObjects",
"taus"),
50 name= cms.string(
"Tau"),
51 doc = cms.string(
"slimmedTaus after basic selection (" + finalTaus.cut.value()+
")")
54 _tauVarsBase = cms.PSet(P4Vars,
55 charge =
Var(
"charge", int, doc=
"electric charge"),
56 jetIdx =
Var(
"?hasUserCand('jet')?userCand('jet').key():-1", int, doc=
"index of the associated jet (-1 if none)"),
57 eleIdx =
Var(
"?overlaps('electrons').size()>0?overlaps('electrons')[0].key():-1", int, doc=
"index of first matching electron"),
58 muIdx =
Var(
"?overlaps('muons').size()>0?overlaps('muons')[0].key():-1", int, doc=
"index of first matching muon"),
59 svIdx1 =
Var(
"?overlaps('vertices').size()>0?overlaps('vertices')[0].key():-1", int, doc=
"index of first matching secondary vertex"),
60 svIdx2 =
Var(
"?overlaps('vertices').size()>1?overlaps('vertices')[1].key():-1", int, doc=
"index of second matching secondary vertex"),
61 nSVs =
Var(
"?hasOverlaps('vertices')?overlaps('vertices').size():0", int, doc=
"number of secondary vertices in the tau"),
62 decayMode =
Var(
"decayMode()",int),
63 idDecayModeOldDMs =
Var(
"tauID('decayModeFinding')", bool),
65 leadTkPtOverTauPt =
Var(
"leadChargedHadrCand.pt/pt ",float, doc=
"pt of the leading track divided by tau pt",precision=10),
66 leadTkDeltaEta =
Var(
"leadChargedHadrCand.eta - eta ",float, doc=
"eta of the leading track, minus tau eta",precision=8),
67 leadTkDeltaPhi =
Var(
"deltaPhi(leadChargedHadrCand.phi, phi) ",float, doc=
"phi of the leading track, minus tau phi",precision=8),
69 dxy =
Var(
"leadChargedHadrCand().dxy()",float, doc=
"d_{xy} of lead track with respect to PV, in cm (with sign)",precision=10),
70 dz =
Var(
"leadChargedHadrCand().dz()",float, doc=
"d_{z} of lead track with respect to PV, in cm (with sign)",precision=14),
73 rawIso =
Var(
"tauID('byCombinedIsolationDeltaBetaCorrRaw3Hits')", float, doc =
"combined isolation (deltaBeta corrections)", precision=10),
74 rawIsodR03 =
Var(
"(tauID('chargedIsoPtSumdR03')+max(0.,tauID('neutralIsoPtSumdR03')-0.072*tauID('puCorrPtSum')))", float, doc =
"combined isolation (deltaBeta corrections, dR=0.3)", precision=10),
75 chargedIso =
Var(
"tauID('chargedIsoPtSum')", float, doc =
"charged isolation", precision=10),
76 neutralIso =
Var(
"tauID('neutralIsoPtSum')", float, doc =
"neutral (photon) isolation", precision=10),
77 puCorr =
Var(
"tauID('puCorrPtSum')", float, doc =
"pileup correction", precision=10),
78 photonsOutsideSignalCone =
Var(
"tauID('photonPtSumOutsideSignalCone')", float, doc =
"sum of photons outside signal cone", precision=10),
80 idAntiMu =
_tauIdWPMask(
"againstMuon%s3", choices=(
"Loose",
"Tight"), doc=
"Anti-muon discriminator V3: "),
81 idAntiEleDeadECal =
Var(
"tauID('againstElectronDeadECAL')", bool, doc =
"Anti-electron dead-ECal discriminator"),
85 _deepTauVars2017v2p1 = cms.PSet(
86 rawDeepTau2017v2p1VSe =
Var(
"tauID('byDeepTau2017v2p1VSeraw')", float, doc=
"byDeepTau2017v2p1VSe raw output discriminator (deepTau2017v2p1)", precision=10),
87 rawDeepTau2017v2p1VSmu =
Var(
"tauID('byDeepTau2017v2p1VSmuraw')", float, doc=
"byDeepTau2017v2p1VSmu raw output discriminator (deepTau2017v2p1)", precision=10),
88 rawDeepTau2017v2p1VSjet =
Var(
"tauID('byDeepTau2017v2p1VSjetraw')", float, doc=
"byDeepTau2017v2p1VSjet raw output discriminator (deepTau2017v2p1)", precision=10),
90 choices=(
"VVVLoose",
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
91 doc=
"byDeepTau2017v2p1VSe ID working points (deepTau2017v2p1)"),
93 choices=(
"VLoose",
"Loose",
"Medium",
"Tight"),
94 doc=
"byDeepTau2017v2p1VSmu ID working points (deepTau2017v2p1)"),
96 choices=(
"VVVLoose",
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
97 doc=
"byDeepTau2017v2p1VSjet ID working points (deepTau2017v2p1)"),
99 _deepTauVars2018v2p5 = cms.PSet(
100 rawDeepTau2018v2p5VSe =
Var(
"tauID('byDeepTau2018v2p5VSeraw')", float, doc=
"byDeepTau2018v2p5VSe raw output discriminator (deepTau2018v2p5)", precision=10),
101 rawDeepTau2018v2p5VSmu =
Var(
"tauID('byDeepTau2018v2p5VSmuraw')", float, doc=
"byDeepTau2018v2p5VSmu raw output discriminator (deepTau2018v2p5)", precision=10),
102 rawDeepTau2018v2p5VSjet =
Var(
"tauID('byDeepTau2018v2p5VSjetraw')", float, doc=
"byDeepTau2018v2p5VSjet raw output discriminator (deepTau2018v2p5)", precision=10),
104 choices=(
"VVVLoose",
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
105 doc=
"byDeepTau2018v2p5VSe ID working points (deepTau2018v2p5)"),
107 choices=(
"VLoose",
"Loose",
"Medium",
"Tight"),
108 doc=
"byDeepTau2018v2p5VSmu ID working points (deepTau2018v2p5)"),
110 choices=(
"VVVLoose",
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
111 doc=
"byDeepTau2018v2p5VSjet ID working points (deepTau2018v2p5)"),
114 _variablesMiniV2 = cms.PSet(
116 _deepTauVars2017v2p1,
120 tauTable.variables = _variablesMiniV2
122 run3_nanoAOD_124.toModify(
124 idDeepTau2018v2p5VSe =
_tauIdWPMask(
"byDeepTau2018v2p5VSeraw",
125 choices=(
"VVVLoose",
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
126 doc=
"byDeepTau2018v2p5VSe ID working points (deepTau2018v2p5)",
127 from_raw=
True, wp_thrs=WORKING_POINTS_v2p5[
"e"]),
128 idDeepTau2018v2p5VSmu =
_tauIdWPMask(
"byDeepTau2018v2p5VSmuraw",
129 choices=(
"VLoose",
"Loose",
"Medium",
"Tight"),
130 doc=
"byDeepTau2018v2p5VSmu ID working points (deepTau2018v2p5)",
131 from_raw=
True, wp_thrs=WORKING_POINTS_v2p5[
"mu"]),
132 idDeepTau2018v2p5VSjet =
_tauIdWPMask(
"byDeepTau2018v2p5VSjetraw",
133 choices=(
"VVVLoose",
"VVLoose",
"VLoose",
"Loose",
"Medium",
"Tight",
"VTight",
"VVTight"),
134 doc=
"byDeepTau2018v2p5VSjet ID working points (deepTau2018v2p5)",
135 from_raw=
True, wp_thrs=WORKING_POINTS_v2p5[
"jet"])
139 tauGenJetsForNano = tauGenJets.clone(
140 GenParticles =
"finalGenParticles",
141 includeNeutrinos =
False 144 tauGenJetsSelectorAllHadronsForNano = tauGenJetsSelectorAllHadrons.clone(
145 src =
"tauGenJetsForNano" 148 genVisTaus = cms.EDProducer(
"GenVisTauProducer",
149 src = cms.InputTag(
"tauGenJetsSelectorAllHadronsForNano"),
150 srcGenParticles = cms.InputTag(
"finalGenParticles")
153 genVisTauTable = simpleCandidateFlatTableProducer.clone(
154 src = cms.InputTag(
"genVisTaus"),
155 cut = cms.string(
"pt > 10."),
156 name = cms.string(
"GenVisTau"),
157 doc = cms.string(
"gen hadronic taus "),
158 variables = cms.PSet(
159 pt =
Var(
"pt", float,precision=8),
160 phi =
Var(
"phi", float,precision=8),
161 eta =
Var(
"eta", float,precision=8),
162 mass =
Var(
"mass", float,precision=8),
163 charge =
Var(
"charge", int),
164 status =
Var(
"status", int, doc=
"Hadronic tau decay mode. 0=OneProng0PiZero, 1=OneProng1PiZero, 2=OneProng2PiZero, 10=ThreeProng0PiZero, 11=ThreeProng1PiZero, 15=Other"),
165 genPartIdxMother =
Var(
"?numberOfMothers>0?motherRef(0).key():-1", int, doc=
"index of the mother particle"),
169 tausMCMatchLepTauForTable = cms.EDProducer(
"MCMatcher",
171 matched = cms.InputTag(
"finalGenParticles"),
172 mcPdgId = cms.vint32(11,13),
173 checkCharge = cms.bool(
False),
174 mcStatus = cms.vint32(),
175 maxDeltaR = cms.double(0.3),
176 maxDPtRel = cms.double(0.5),
177 resolveAmbiguities = cms.bool(
True),
178 resolveByMatchQuality = cms.bool(
True),
181 tausMCMatchHadTauForTable = cms.EDProducer(
"MCMatcher",
183 matched = cms.InputTag(
"genVisTaus"),
184 mcPdgId = cms.vint32(15),
185 checkCharge = cms.bool(
False),
186 mcStatus = cms.vint32(),
187 maxDeltaR = cms.double(0.3),
188 maxDPtRel = cms.double(1.),
189 resolveAmbiguities = cms.bool(
True),
190 resolveByMatchQuality = cms.bool(
True),
193 tauMCTable = cms.EDProducer(
"CandMCMatchTableProducer",
195 mcMap = cms.InputTag(
"tausMCMatchLepTauForTable"),
196 mcMapVisTau = cms.InputTag(
"tausMCMatchHadTauForTable"),
197 objName = tauTable.name,
198 objType = tauTable.name,
199 branchName = cms.string(
"genPart"),
200 docString = cms.string(
"MC matching to status==2 taus"),
204 tauTask = cms.Task(finalTaus)
205 tauTablesTask = cms.Task(tauTable)
207 genTauTask = cms.Task(tauGenJetsForNano,tauGenJetsSelectorAllHadronsForNano,genVisTaus,genVisTauTable)
208 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)