CMS 3D CMS Logo

taus_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
3 from PhysicsTools.JetMCAlgos.TauGenJets_cfi import tauGenJets
4 from PhysicsTools.JetMCAlgos.TauGenJetsDecayModeSelectorAllHadrons_cfi import tauGenJetsSelectorAllHadrons
5 
6 
9 
10 
11 
12 # Original DeepTau v2p5 in 12_4_X doesn't include WPs in MINIAOD
13 # Import thresholds here to define WPs manually from raw scores
14 from RecoTauTag.RecoTau.tauIdWPsDefs import WORKING_POINTS_v2p5
15 
16 finalTaus = cms.EDFilter("PATTauRefSelector",
17  src = cms.InputTag("slimmedTaus"),
18  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'))")
19 )
20 
21 for era in [run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1]:
22  era.toModify(finalTaus,
23  src = cms.InputTag("slimmedTausUpdated"),
24  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'))")
25  )
26 for era in [run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_92X]:
27  era.toModify(finalTaus,
28  src = cms.InputTag("slimmedTausUpdated"),
29  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'))")
30  )
31 run2_miniAOD_80XLegacy.toModify(finalTaus,
32  cut = cms.string("pt > 18 && tauID('decayModeFindingNewDMs') && (tauID('byLooseCombinedIsolationDeltaBetaCorr3Hits') || tauID('byVLooseIsolationMVArun2v1DBoldDMwLT') || tauID('byVLooseIsolationMVArun2v1DBnewDMwLT') || tauID('byVLooseIsolationMVArun2v1DBdR03oldDMwLT'))")
33  )
34 
35 
36 def _tauIdWPMask(pattern, choices, doc="", from_raw=False, wp_thrs=None):
37  if from_raw:
38  assert wp_thrs is not None, "wp_thrs argument in _tauIdWPMask() is None, expect it to be dict-like"
39 
40  var_definition = []
41  for wp_name in choices:
42  if not isinstance(wp_thrs[wp_name], float):
43  raise TypeError("Threshold for WP=%s is not a float number." % wp_name)
44  wp_definition = "test_bit(tauID('{}')-{}+1,0)".format(pattern, wp_thrs[wp_name])
45  var_definition.append(wp_definition)
46  var_definition = " + ".join(var_definition)
47  else:
48  var_definition = " + ".join(["tauID('%s')" % (pattern % c) for c in choices])
49 
50  doc = doc + ": "+", ".join(["%d = %s" % (i,c) for (i,c) in enumerate(choices, start=1)])
51  return Var(var_definition, "uint8", doc=doc)
52 
53 tauTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
54  src = cms.InputTag("linkedObjects","taus"),
55  cut = cms.string(""), #we should not filter on cross linked collections
56  name= cms.string("Tau"),
57  doc = cms.string("slimmedTaus after basic selection (" + finalTaus.cut.value()+")"),
58  singleton = cms.bool(False), # the number of entries is variable
59  extension = cms.bool(False), # this is the main table for the taus
60  variables = cms.PSet() # PSet defined below in era dependent way
61 )
62 _tauVarsBase = cms.PSet(P4Vars,
63  charge = Var("charge", int, doc="electric charge"),
64  jetIdx = Var("?hasUserCand('jet')?userCand('jet').key():-1", int, doc="index of the associated jet (-1 if none)"),
65  decayMode = Var("decayMode()",int),
66  idDecayModeOldDMs = Var("tauID('decayModeFinding')", bool),
67 
68  leadTkPtOverTauPt = Var("leadChargedHadrCand.pt/pt ",float, doc="pt of the leading track divided by tau pt",precision=10),
69  leadTkDeltaEta = Var("leadChargedHadrCand.eta - eta ",float, doc="eta of the leading track, minus tau eta",precision=8),
70  leadTkDeltaPhi = Var("deltaPhi(leadChargedHadrCand.phi, phi) ",float, doc="phi of the leading track, minus tau phi",precision=8),
71 
72  dxy = Var("leadChargedHadrCand().dxy()",float, doc="d_{xy} of lead track with respect to PV, in cm (with sign)",precision=10),
73  dz = Var("leadChargedHadrCand().dz()",float, doc="d_{z} of lead track with respect to PV, in cm (with sign)",precision=14),
74 
75  # these are too many, we may have to suppress some
76  rawIso = Var( "tauID('byCombinedIsolationDeltaBetaCorrRaw3Hits')", float, doc = "combined isolation (deltaBeta corrections)", precision=10),
77  rawIsodR03 = Var( "(tauID('chargedIsoPtSumdR03')+max(0.,tauID('neutralIsoPtSumdR03')-0.072*tauID('puCorrPtSum')))", float, doc = "combined isolation (deltaBeta corrections, dR=0.3)", precision=10),
78  chargedIso = Var( "tauID('chargedIsoPtSum')", float, doc = "charged isolation", precision=10),
79  neutralIso = Var( "tauID('neutralIsoPtSum')", float, doc = "neutral (photon) isolation", precision=10),
80  puCorr = Var( "tauID('puCorrPtSum')", float, doc = "pileup correction", precision=10),
81  photonsOutsideSignalCone = Var( "tauID('photonPtSumOutsideSignalCone')", float, doc = "sum of photons outside signal cone", precision=10),
82 
83  idAntiMu = _tauIdWPMask("againstMuon%s3", choices=("Loose","Tight"), doc= "Anti-muon discriminator V3: "),
84  idAntiEleDeadECal = Var("tauID('againstElectronDeadECAL')", bool, doc = "Anti-electron dead-ECal discriminator"),
85 
86 # isoCI3hit = Var( "tauID("byCombinedIsolationDeltaBetaCorrRaw3Hits")" doc="byCombinedIsolationDeltaBetaCorrRaw3Hits raw output discriminator"),
87 # photonOutsideSigCone = Var( "tauID("photonPtSumOutsideSignalCone")" doc="photonPtSumOutsideSignalCone raw output discriminator"),
88 
89 )
90 
91 _mvaIsoVars2015 = cms.PSet(
92  rawMVAnewDM = Var( "tauID('byIsolationMVArun2v1DBnewDMwLTraw')",float, doc="byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
93  rawMVAoldDM = Var( "tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc="byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
94  rawMVAoldDMdR03 = Var( "tauID('byIsolationMVArun2v1DBdR03oldDMwLTraw')",float, doc="byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
95  idMVAnewDM = _tauIdWPMask( "by%sIsolationMVArun2v1DBnewDMwLT", choices=("VLoose","Loose","Medium","Tight","VTight","VVTight"), doc="IsolationMVArun2v1DBnewDMwLT ID working point (2015)"),
96  idMVAoldDM = _tauIdWPMask( "by%sIsolationMVArun2v1DBoldDMwLT", choices=("VLoose","Loose","Medium","Tight","VTight","VVTight"), doc="IsolationMVArun2v1DBoldDMwLT ID working point (2015)"),
97  idMVAoldDMdR03 = _tauIdWPMask( "by%sIsolationMVArun2v1DBdR03oldDMwLT", choices=("VLoose","Loose","Medium","Tight","VTight","VVTight"), doc="IsolationMVArun2v1DBoldDMdR0p3wLT ID working point (2015)")
98 )
99 _mvaIsoVars2015Reduced = cms.PSet(
100  rawMVAoldDM = Var( "tauID('byIsolationMVArun2v1DBoldDMwLTraw2015')",float, doc="byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10),
101  idMVAoldDM = _tauIdWPMask( "by%sIsolationMVArun2v1DBoldDMwLT2015", choices=("VLoose","Loose","Medium","Tight","VTight","VVTight"), doc="IsolationMVArun2v1DBoldDMwLT ID working point (2015)"),
102 )
103 _mvaIsoVars2017v1 = cms.PSet(
104  rawMVAoldDM2017v1 = Var( "tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc="byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v1)",precision=10),
105  idMVAoldDM2017v1 = _tauIdWPMask( "by%sIsolationMVArun2v1DBoldDMwLT", choices=("VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"), doc="IsolationMVArun2v1DBoldDMwLT ID working point (2017v1)")
106 )
107 _mvaIsoVars2017v2 = cms.PSet(
108  rawMVAnewDM2017v2 = Var( "tauID('byIsolationMVArun2v1DBnewDMwLTraw2017v2')",float, doc="byIsolationMVArun2v1DBnewDMwLT raw output discriminator (2017v2)",precision=10),
109  rawMVAoldDM2017v2 = Var( "tauID('byIsolationMVArun2v1DBoldDMwLTraw2017v2')",float, doc="byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v2)",precision=10),
110  rawMVAoldDMdR032017v2 = Var( "tauID('byIsolationMVArun2v1DBdR03oldDMwLTraw2017v2')",float, doc="byIsolationMVArun2v1DBdR03oldDMwLT raw output discriminator (2017v2)",precision=10),
111  idMVAnewDM2017v2 = _tauIdWPMask( "by%sIsolationMVArun2v1DBnewDMwLT2017v2",
112  choices=("VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),
113  doc="IsolationMVArun2v1DBnewDMwLT ID working point (2017v2)"),
114  idMVAoldDM2017v2 = _tauIdWPMask( "by%sIsolationMVArun2v1DBoldDMwLT2017v2",
115  choices=("VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),
116  doc="IsolationMVArun2v1DBoldDMwLT ID working point (2017v2)"),
117  idMVAoldDMdR032017v2 = _tauIdWPMask( "by%sIsolationMVArun2v1DBdR03oldDMwLT2017v2",
118  choices=("VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),
119  doc="IsolationMVArun2v1DBoldDMdR0p3wLT ID working point (2017v2)")
120 )
121 _mvaAntiEVars2015 = cms.PSet(
122  rawAntiEle = Var("tauID('againstElectronMVA6Raw')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator (2015)", precision=10),
123  rawAntiEleCat = Var("tauID('againstElectronMVA6category')", int, doc="Anti-electron MVA discriminator V6 category (2015"),
124  idAntiEle = _tauIdWPMask("againstElectron%sMVA6", choices=("VLoose","Loose","Medium","Tight","VTight"), doc= "Anti-electron MVA discriminator V6 (2015)"),
125 )
126 _deepTauVars2017v2p1 = cms.PSet(
127  rawDeepTau2017v2p1VSe = Var("tauID('byDeepTau2017v2p1VSeraw')", float, doc="byDeepTau2017v2p1VSe raw output discriminator (deepTau2017v2p1)", precision=10),
128  rawDeepTau2017v2p1VSmu = Var("tauID('byDeepTau2017v2p1VSmuraw')", float, doc="byDeepTau2017v2p1VSmu raw output discriminator (deepTau2017v2p1)", precision=10),
129  rawDeepTau2017v2p1VSjet = Var("tauID('byDeepTau2017v2p1VSjetraw')", float, doc="byDeepTau2017v2p1VSjet raw output discriminator (deepTau2017v2p1)", precision=10),
130  idDeepTau2017v2p1VSe = _tauIdWPMask("by%sDeepTau2017v2p1VSe",
131  choices=("VVVLoose","VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),
132  doc="byDeepTau2017v2p1VSe ID working points (deepTau2017v2p1)"),
133  idDeepTau2017v2p1VSmu = _tauIdWPMask("by%sDeepTau2017v2p1VSmu",
134  choices=("VLoose", "Loose", "Medium", "Tight"),
135  doc="byDeepTau2017v2p1VSmu ID working points (deepTau2017v2p1)"),
136  idDeepTau2017v2p1VSjet = _tauIdWPMask("by%sDeepTau2017v2p1VSjet",
137  choices=("VVVLoose","VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),
138  doc="byDeepTau2017v2p1VSjet ID working points (deepTau2017v2p1)"),
139 )
140 _deepTauVars2018v2p5 = cms.PSet(
141  rawDeepTau2018v2p5VSe = Var("tauID('byDeepTau2018v2p5VSeraw')", float, doc="byDeepTau2018v2p5VSe raw output discriminator (deepTau2018v2p5)", precision=10),
142  rawDeepTau2018v2p5VSmu = Var("tauID('byDeepTau2018v2p5VSmuraw')", float, doc="byDeepTau2018v2p5VSmu raw output discriminator (deepTau2018v2p5)", precision=10),
143  rawDeepTau2018v2p5VSjet = Var("tauID('byDeepTau2018v2p5VSjetraw')", float, doc="byDeepTau2018v2p5VSjet raw output discriminator (deepTau2018v2p5)", precision=10),
144  idDeepTau2018v2p5VSe = _tauIdWPMask("by%sDeepTau2018v2p5VSe",
145  choices=("VVVLoose","VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),
146  doc="byDeepTau2018v2p5VSe ID working points (deepTau2018v2p5)"),
147  idDeepTau2018v2p5VSmu = _tauIdWPMask("by%sDeepTau2018v2p5VSmu",
148  choices=("VLoose", "Loose", "Medium", "Tight"),
149  doc="byDeepTau2018v2p5VSmu ID working points (deepTau2018v2p5)"),
150  idDeepTau2018v2p5VSjet = _tauIdWPMask("by%sDeepTau2018v2p5VSjet",
151  choices=("VVVLoose","VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),
152  doc="byDeepTau2018v2p5VSjet ID working points (deepTau2018v2p5)"),
153 )
154 
155 _variablesMiniV2 = cms.PSet(
156  _tauVarsBase,
157  _deepTauVars2017v2p1,
158  _deepTauVars2018v2p5
159 )
160 _variablesMiniV1 = cms.PSet(
161  _variablesMiniV2,
162  _mvaIsoVars2017v2
163 )
164 _variablesMiniV1.rawMVAoldDM = Var( "tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc="byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10)
165 _variablesMiniV1.rawMVAoldDM2017v1 = Var( "tauID('byIsolationMVArun2v1DBoldDMwLTraw2017v1')",float, doc="byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v1)",precision=10)
166 _variablesMiniV1.idMVAoldDM = _tauIdWPMask( "by%sIsolationMVArun2v1DBoldDMwLT",
167  choices=("VLoose","Loose","Medium","Tight","VTight","VVTight"),
168  doc="IsolationMVArun2v1DBoldDMwLT ID working point (2015)")
169 _variablesMiniV1.idMVAoldDM2017v1 = _tauIdWPMask( "by%sIsolationMVArun2v1DBoldDMwLT2017v1",
170  choices=("VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),
171  doc="IsolationMVArun2v1DBoldDMwLT ID working point (2017v1)")
172 _variables80X = cms.PSet(
173  _tauVarsBase,
174  _mvaAntiEVars2015,
175  _mvaIsoVars2015
176 )
177 
178 tauTable.variables = _variablesMiniV2
179 
180 (run2_nanoAOD_92X | run2_nanoAOD_94XMiniAODv2 | run2_nanoAOD_94X2016 | run2_nanoAOD_102Xv1 | run2_nanoAOD_106Xv1).toModify(tauTable,
181  variables = cms.PSet(tauTable.variables, _mvaIsoVars2015Reduced, _mvaIsoVars2017v1, _mvaIsoVars2017v2)
182  )
183 for era in [run2_nanoAOD_94XMiniAODv1,]:
184  era.toModify(tauTable,
185  variables = _variablesMiniV1
186  )
187 run2_miniAOD_80XLegacy.toModify(tauTable,
188  variables = _variables80X
189 )
190 for era in [run2_nanoAOD_92X, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, \
191  run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1]:
192  era.toModify(tauTable.variables,
193  rawAntiEle2018 = Var("tauID('againstElectronMVA6Raw2018')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator (2018)", precision=10),
194  rawAntiEleCat2018 = Var("tauID('againstElectronMVA6category2018')", int, doc="Anti-electron MVA discriminator V6 category (2018)"),
195  idAntiEle2018 = _tauIdWPMask("againstElectron%sMVA62018", choices=("VLoose","Loose","Medium","Tight","VTight"), doc= "Anti-electron MVA discriminator V6 (2018)"),
196  rawAntiEle = Var("tauID('againstElectronMVA6Raw')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator (2015)", precision=10),
197  rawAntiEleCat = Var("tauID('againstElectronMVA6category')", int, doc="Anti-electron MVA discriminator V6 category (2015"),
198  idAntiEle = _tauIdWPMask("againstElectron%sMVA6", choices=("VLoose","Loose","Medium","Tight","VTight"), doc= "Anti-electron MVA discriminator V6 (2015)")
199  )
200 
201 for era in [run2_miniAOD_80XLegacy, run2_nanoAOD_92X, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, \
202  run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1]:
203  era.toModify(tauTable.variables,
204  idDecayMode = Var("tauID('decayModeFinding')", bool),
205  idDecayModeNewDMs = Var("tauID('decayModeFindingNewDMs')", bool),
206  idDecayModeOldDMs = None
207  )
208 run2_miniAOD_80XLegacy.toModify(tauTable.variables,
209  idAntiEleDeadECal = None)
210 for era in [run2_nanoAOD_92X, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, \
211  run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1]:
212  era.toModify(tauTable.variables,
213  idAntiEleDeadECal = Var("tauID('againstElectronDeadECALForNano')", bool, doc = "Anti-electron dead-ECal discriminator"),
214  )
215 (run2_nanoAOD_92X | run2_nanoAOD_94XMiniAODv1| run2_nanoAOD_94XMiniAODv2 | \
216  run2_nanoAOD_94X2016 | run2_nanoAOD_102Xv1 | run2_nanoAOD_106Xv1
217 ).toModify(tauTable.variables,
218  rawDeepTau2018v2p5VSe = None,
219  rawDeepTau2018v2p5VSmu = None,
220  rawDeepTau2018v2p5VSjet = None,
221  idDeepTau2018v2p5VSe = None,
222  idDeepTau2018v2p5VSmu = None,
223  idDeepTau2018v2p5VSjet = None
224  )
225 
226 tauGenJetsForNano = tauGenJets.clone(
227  GenParticles = "finalGenParticles",
228  includeNeutrinos = False
229 )
230 
231 tauGenJetsSelectorAllHadronsForNano = tauGenJetsSelectorAllHadrons.clone(
232  src = "tauGenJetsForNano"
233 )
234 
235 genVisTaus = cms.EDProducer("GenVisTauProducer",
236  src = cms.InputTag("tauGenJetsSelectorAllHadronsForNano"),
237  srcGenParticles = cms.InputTag("finalGenParticles")
238 )
239 
240 genVisTauTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
241  src = cms.InputTag("genVisTaus"),
242  cut = cms.string("pt > 10."),
243  name = cms.string("GenVisTau"),
244  doc = cms.string("gen hadronic taus "),
245  singleton = cms.bool(False), # the number of entries is variable
246  extension = cms.bool(False), # this is the main table for generator level hadronic tau decays
247  variables = cms.PSet(
248  pt = Var("pt", float,precision=8),
249  phi = Var("phi", float,precision=8),
250  eta = Var("eta", float,precision=8),
251  mass = Var("mass", float,precision=8),
252  charge = Var("charge", int),
253  status = Var("status", int, doc="Hadronic tau decay mode. 0=OneProng0PiZero, 1=OneProng1PiZero, 2=OneProng2PiZero, 10=ThreeProng0PiZero, 11=ThreeProng1PiZero, 15=Other"),
254  genPartIdxMother = Var("?numberOfMothers>0?motherRef(0).key():-1", int, doc="index of the mother particle"),
255  )
256 )
257 
258 tausMCMatchLepTauForTable = cms.EDProducer("MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR
259  src = tauTable.src, # final reco collection
260  matched = cms.InputTag("finalGenParticles"), # final mc-truth particle collection
261  mcPdgId = cms.vint32(11,13), # one or more PDG ID (11 = electron, 13 = muon); absolute values (see below)
262  checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge
263  mcStatus = cms.vint32(), # PYTHIA status code (1 = stable, 2 = shower, 3 = hard scattering)
264  maxDeltaR = cms.double(0.3), # Minimum deltaR for the match
265  maxDPtRel = cms.double(0.5), # Minimum deltaPt/Pt for the match
266  resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object
267  resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first
268 )
269 
270 tausMCMatchHadTauForTable = cms.EDProducer("MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR
271  src = tauTable.src, # final reco collection
272  matched = cms.InputTag("genVisTaus"), # generator level hadronic tau decays
273  mcPdgId = cms.vint32(15), # one or more PDG ID (15 = tau); absolute values (see below)
274  checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge
275  mcStatus = cms.vint32(), # CV: no *not* require certain status code for matching (status code corresponds to decay mode for hadronic tau decays)
276  maxDeltaR = cms.double(0.3), # Maximum deltaR for the match
277  maxDPtRel = cms.double(1.), # Maximum deltaPt/Pt for the match
278  resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object
279  resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first
280 )
281 
282 tauMCTable = cms.EDProducer("CandMCMatchTableProducer",
283  src = tauTable.src,
284  mcMap = cms.InputTag("tausMCMatchLepTauForTable"),
285  mcMapVisTau = cms.InputTag("tausMCMatchHadTauForTable"),
286  objName = tauTable.name,
287  objType = tauTable.name, #cms.string("Tau"),
288  branchName = cms.string("genPart"),
289  docString = cms.string("MC matching to status==2 taus"),
290 )
291 
292 
293 tauTask = cms.Task(finalTaus)
294 
295 for era in [run2_nanoAOD_92X, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, \
296  run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1]:
297  era.toReplaceWith(tauTask, cms.Task(patTauMVAIDsTask,finalTaus))
298 
299 tauTablesTask = cms.Task(tauTable)
300 
301 genTauTask = cms.Task(tauGenJetsForNano,tauGenJetsSelectorAllHadronsForNano,genVisTaus,genVisTauTable)
302 tauMCTask = cms.Task(genTauTask,tausMCMatchLepTauForTable,tausMCMatchHadTauForTable,tauMCTable)
303 
Updated tau collection with MVA-based tau-Ids rerun ####### Used only in some eras.
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
Definition: common_cff.py:20
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def _tauIdWPMask(pattern, choices, doc="", from_raw=False, wp_thrs=None)
Tables for final output and docs ##########################.
Definition: taus_cff.py:36