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('byDeepTau2018v2p5VSjetraw') > {}))".format(WORKING_POINTS_v2p5["jet"]["VVVLoose"]))
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("byDeepTau2018v2p5VSeraw",
145  choices=("VVVLoose","VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),
146  doc="byDeepTau2018v2p5VSe ID working points (deepTau2018v2p5)",
147  from_raw=True, wp_thrs=WORKING_POINTS_v2p5["e"]),
148  idDeepTau2018v2p5VSmu = _tauIdWPMask("byDeepTau2018v2p5VSmuraw",
149  choices=("VLoose", "Loose", "Medium", "Tight"),
150  doc="byDeepTau2018v2p5VSmu ID working points (deepTau2018v2p5)",
151  from_raw=True, wp_thrs=WORKING_POINTS_v2p5["mu"]),
152  idDeepTau2018v2p5VSjet = _tauIdWPMask("byDeepTau2018v2p5VSjetraw",
153  choices=("VVVLoose","VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),
154  doc="byDeepTau2018v2p5VSjet ID working points (deepTau2018v2p5)",
155  from_raw=True, wp_thrs=WORKING_POINTS_v2p5["jet"]),
156 )
157 
158 _variablesMiniV2 = cms.PSet(
159  _tauVarsBase,
160  _deepTauVars2017v2p1,
161  _deepTauVars2018v2p5
162 )
163 _variablesMiniV1 = cms.PSet(
164  _variablesMiniV2,
165  _mvaIsoVars2017v2
166 )
167 _variablesMiniV1.rawMVAoldDM = Var( "tauID('byIsolationMVArun2v1DBoldDMwLTraw')",float, doc="byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2015)",precision=10)
168 _variablesMiniV1.rawMVAoldDM2017v1 = Var( "tauID('byIsolationMVArun2v1DBoldDMwLTraw2017v1')",float, doc="byIsolationMVArun2v1DBoldDMwLT raw output discriminator (2017v1)",precision=10)
169 _variablesMiniV1.idMVAoldDM = _tauIdWPMask( "by%sIsolationMVArun2v1DBoldDMwLT",
170  choices=("VLoose","Loose","Medium","Tight","VTight","VVTight"),
171  doc="IsolationMVArun2v1DBoldDMwLT ID working point (2015)")
172 _variablesMiniV1.idMVAoldDM2017v1 = _tauIdWPMask( "by%sIsolationMVArun2v1DBoldDMwLT2017v1",
173  choices=("VVLoose","VLoose","Loose","Medium","Tight","VTight","VVTight"),
174  doc="IsolationMVArun2v1DBoldDMwLT ID working point (2017v1)")
175 _variables80X = cms.PSet(
176  _tauVarsBase,
177  _mvaAntiEVars2015,
178  _mvaIsoVars2015
179 )
180 
181 tauTable.variables = _variablesMiniV2
182 
183 (run2_nanoAOD_92X | run2_nanoAOD_94XMiniAODv2 | run2_nanoAOD_94X2016 | run2_nanoAOD_102Xv1 | run2_nanoAOD_106Xv1).toModify(tauTable,
184  variables = cms.PSet(tauTable.variables, _mvaIsoVars2015Reduced, _mvaIsoVars2017v1, _mvaIsoVars2017v2)
185  )
186 for era in [run2_nanoAOD_94XMiniAODv1,]:
187  era.toModify(tauTable,
188  variables = _variablesMiniV1
189  )
190 run2_miniAOD_80XLegacy.toModify(tauTable,
191  variables = _variables80X
192 )
193 for era in [run2_nanoAOD_92X, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, \
194  run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1]:
195  era.toModify(tauTable.variables,
196  rawAntiEle2018 = Var("tauID('againstElectronMVA6Raw2018')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator (2018)", precision=10),
197  rawAntiEleCat2018 = Var("tauID('againstElectronMVA6category2018')", int, doc="Anti-electron MVA discriminator V6 category (2018)"),
198  idAntiEle2018 = _tauIdWPMask("againstElectron%sMVA62018", choices=("VLoose","Loose","Medium","Tight","VTight"), doc= "Anti-electron MVA discriminator V6 (2018)"),
199  rawAntiEle = Var("tauID('againstElectronMVA6Raw')", float, doc= "Anti-electron MVA discriminator V6 raw output discriminator (2015)", precision=10),
200  rawAntiEleCat = Var("tauID('againstElectronMVA6category')", int, doc="Anti-electron MVA discriminator V6 category (2015"),
201  idAntiEle = _tauIdWPMask("againstElectron%sMVA6", choices=("VLoose","Loose","Medium","Tight","VTight"), doc= "Anti-electron MVA discriminator V6 (2015)")
202  )
203 
204 for era in [run2_miniAOD_80XLegacy, run2_nanoAOD_92X, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, \
205  run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1]:
206  era.toModify(tauTable.variables,
207  idDecayMode = Var("tauID('decayModeFinding')", bool),
208  idDecayModeNewDMs = Var("tauID('decayModeFindingNewDMs')", bool),
209  idDecayModeOldDMs = None
210  )
211 run2_miniAOD_80XLegacy.toModify(tauTable.variables,
212  idAntiEleDeadECal = None)
213 for era in [run2_nanoAOD_92X, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, \
214  run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1]:
215  era.toModify(tauTable.variables,
216  idAntiEleDeadECal = Var("tauID('againstElectronDeadECALForNano')", bool, doc = "Anti-electron dead-ECal discriminator"),
217  )
218 (run2_nanoAOD_92X | run2_nanoAOD_94XMiniAODv1| run2_nanoAOD_94XMiniAODv2 | \
219  run2_nanoAOD_94X2016 | run2_nanoAOD_102Xv1 | run2_nanoAOD_106Xv1
220 ).toModify(tauTable.variables,
221  rawDeepTau2018v2p5VSe = None,
222  rawDeepTau2018v2p5VSmu = None,
223  rawDeepTau2018v2p5VSjet = None,
224  idDeepTau2018v2p5VSe = None,
225  idDeepTau2018v2p5VSmu = None,
226  idDeepTau2018v2p5VSjet = None
227  )
228 
229 tauGenJetsForNano = tauGenJets.clone(
230  GenParticles = "finalGenParticles",
231  includeNeutrinos = False
232 )
233 
234 tauGenJetsSelectorAllHadronsForNano = tauGenJetsSelectorAllHadrons.clone(
235  src = "tauGenJetsForNano"
236 )
237 
238 genVisTaus = cms.EDProducer("GenVisTauProducer",
239  src = cms.InputTag("tauGenJetsSelectorAllHadronsForNano"),
240  srcGenParticles = cms.InputTag("finalGenParticles")
241 )
242 
243 genVisTauTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
244  src = cms.InputTag("genVisTaus"),
245  cut = cms.string("pt > 10."),
246  name = cms.string("GenVisTau"),
247  doc = cms.string("gen hadronic taus "),
248  singleton = cms.bool(False), # the number of entries is variable
249  extension = cms.bool(False), # this is the main table for generator level hadronic tau decays
250  variables = cms.PSet(
251  pt = Var("pt", float,precision=8),
252  phi = Var("phi", float,precision=8),
253  eta = Var("eta", float,precision=8),
254  mass = Var("mass", float,precision=8),
255  charge = Var("charge", int),
256  status = Var("status", int, doc="Hadronic tau decay mode. 0=OneProng0PiZero, 1=OneProng1PiZero, 2=OneProng2PiZero, 10=ThreeProng0PiZero, 11=ThreeProng1PiZero, 15=Other"),
257  genPartIdxMother = Var("?numberOfMothers>0?motherRef(0).key():-1", int, doc="index of the mother particle"),
258  )
259 )
260 
261 tausMCMatchLepTauForTable = cms.EDProducer("MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR
262  src = tauTable.src, # final reco collection
263  matched = cms.InputTag("finalGenParticles"), # final mc-truth particle collection
264  mcPdgId = cms.vint32(11,13), # one or more PDG ID (11 = electron, 13 = muon); absolute values (see below)
265  checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge
266  mcStatus = cms.vint32(), # PYTHIA status code (1 = stable, 2 = shower, 3 = hard scattering)
267  maxDeltaR = cms.double(0.3), # Minimum deltaR for the match
268  maxDPtRel = cms.double(0.5), # Minimum deltaPt/Pt for the match
269  resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object
270  resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first
271 )
272 
273 tausMCMatchHadTauForTable = cms.EDProducer("MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR
274  src = tauTable.src, # final reco collection
275  matched = cms.InputTag("genVisTaus"), # generator level hadronic tau decays
276  mcPdgId = cms.vint32(15), # one or more PDG ID (15 = tau); absolute values (see below)
277  checkCharge = cms.bool(False), # True = require RECO and MC objects to have the same charge
278  mcStatus = cms.vint32(), # CV: no *not* require certain status code for matching (status code corresponds to decay mode for hadronic tau decays)
279  maxDeltaR = cms.double(0.3), # Maximum deltaR for the match
280  maxDPtRel = cms.double(1.), # Maximum deltaPt/Pt for the match
281  resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object
282  resolveByMatchQuality = cms.bool(True), # False = just match input in order; True = pick lowest deltaR pair first
283 )
284 
285 tauMCTable = cms.EDProducer("CandMCMatchTableProducer",
286  src = tauTable.src,
287  mcMap = cms.InputTag("tausMCMatchLepTauForTable"),
288  mcMapVisTau = cms.InputTag("tausMCMatchHadTauForTable"),
289  objName = tauTable.name,
290  objType = tauTable.name, #cms.string("Tau"),
291  branchName = cms.string("genPart"),
292  docString = cms.string("MC matching to status==2 taus"),
293 )
294 
295 
296 tauTask = cms.Task(finalTaus)
297 
298 for era in [run2_nanoAOD_92X, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, \
299  run2_nanoAOD_94X2016, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1]:
300  era.toReplaceWith(tauTask, cms.Task(patTauMVAIDsTask,finalTaus))
301 
302 tauTablesTask = cms.Task(tauTable)
303 
304 genTauTask = cms.Task(tauGenJetsForNano,tauGenJetsSelectorAllHadronsForNano,genVisTaus,genVisTauTable)
305 tauMCTask = cms.Task(genTauTask,tausMCMatchLepTauForTable,tausMCMatchHadTauForTable,tauMCTable)
306 
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