CMS 3D CMS Logo

tauTools.py
Go to the documentation of this file.
1 from __future__ import print_function
2 import FWCore.ParameterSet.Config as cms
3 
5 from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
8 
9 # applyPostFix function adapted to unscheduled mode
10 def applyPostfix(process, label, postfix):
11  result = None
12  if hasattr(process, label+postfix):
13  result = getattr(process, label + postfix)
14  else:
15  raise ValueError("Error in <applyPostfix>: No module of name = %s attached to process !!" % (label + postfix))
16  return result
17 
18 # switch to CaloTau collection
19 def switchToCaloTau(process,
20  tauSource = cms.InputTag('caloRecoTauProducer'),
21  patTauLabel = "",
22  postfix = ""):
23  print(' switching PAT Tau input to: ', tauSource)
24 
25  applyPostfix(process, "tauMatch" + patTauLabel, postfix).src = tauSource
26  applyPostfix(process, "tauGenJetMatch"+ patTauLabel, postfix).src = tauSource
27 
28  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauSource = tauSource
29  # CV: reconstruction of tau lifetime information not implemented for CaloTaus yet
30  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = ""
31  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = _buildIDSourcePSet('caloRecoTau', classicTauIDSources, postfix)
32 
33  ## Isolation is somewhat an issue, so we start just by turning it off
34  print("NO PF Isolation will be computed for CaloTau (this could be improved later)")
35  applyPostfix(process, "patTaus" + patTauLabel, postfix).isolation = cms.PSet()
36  applyPostfix(process, "patTaus" + patTauLabel, postfix).isoDeposits = cms.PSet()
37  applyPostfix(process, "patTaus" + patTauLabel, postfix).userIsolation = cms.PSet()
38 
39  ## adapt cleanPatTaus
40  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
41  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = preselection
42 
43 def _buildIDSourcePSet(tauType, idSources, postfix =""):
44  """ Build a PSet defining the tau ID sources to embed into the pat::Tau """
45  output = cms.PSet()
46  for label, discriminator in idSources:
47  if ":" in discriminator:
48  discr = discriminator.split(":")
49  setattr(output, label, cms.InputTag(tauType + discr[0] + postfix + ":" + discr[1]))
50  else:
51  setattr(output, label, cms.InputTag(tauType + discriminator + postfix))
52  return output
53 
54 def _switchToPFTau(process,
55  tauSource,
56  pfTauType,
57  idSources,
58  patTauLabel = "",
59  postfix = ""):
60  """internal auxiliary function to switch to **any** PFTau collection"""
61  print(' switching PAT Tau input to: ', tauSource)
62 
63  applyPostfix(process, "tauMatch" + patTauLabel, postfix).src = tauSource
64  applyPostfix(process, "tauGenJetMatch" + patTauLabel, postfix).src = tauSource
65 
66  applyPostfix(process, "tauIsoDepositPFCandidates" + patTauLabel, postfix).src = tauSource
67  applyPostfix(process, "tauIsoDepositPFCandidates" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
68  applyPostfix(process, "tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).src = tauSource
69  applyPostfix(process, "tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
70  applyPostfix(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).src = tauSource
71  applyPostfix(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
72  applyPostfix(process, "tauIsoDepositPFGammas" + patTauLabel, postfix).src = tauSource
73  applyPostfix(process, "tauIsoDepositPFGammas" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
74 
75  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauSource = tauSource
76  # CV: reconstruction of tau lifetime information not enabled for tau collections other than 'hpsPFTauProducer' yet
77  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = ""
78  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = _buildIDSourcePSet(pfTauType, idSources, postfix)
79 
80  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
81  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = preselection
82 
83 # Name mapping for classic tau ID sources (present for fixed and shrinkingCones)
84 classicTauIDSources = [
85  ("leadingTrackFinding", "DiscriminationByLeadingTrackFinding"),
86  ("leadingTrackPtCut", "DiscriminationByLeadingTrackPtCut"),
87  ("trackIsolation", "DiscriminationByTrackIsolation"),
88  ("ecalIsolation", "DiscriminationByECALIsolation"),
89  ("byIsolation", "DiscriminationByIsolation"),
90  ("againstElectron", "DiscriminationAgainstElectron"),
91  ("againstMuon", "DiscriminationAgainstMuon")
92 ]
93 
94 classicPFTauIDSources = [
95  ("leadingPionPtCut", "DiscriminationByLeadingPionPtCut"),
96  ("trackIsolationUsingLeadingPion", "DiscriminationByTrackIsolationUsingLeadingPion"),
97  ("ecalIsolationUsingLeadingPion", "DiscriminationByECALIsolationUsingLeadingPion"),
98  ("byIsolationUsingLeadingPion", "DiscriminationByIsolationUsingLeadingPion")
99 ]
100 
101 # Hadron-plus-strip(s) (HPS) Tau Discriminators
102 hpsTauIDSources = [
103  ("decayModeFindingNewDMs", "DiscriminationByDecayModeFindingNewDMs"),
104  ("decayModeFinding", "DiscriminationByDecayModeFinding"), # CV: kept for backwards compatibility
105  ("byLooseCombinedIsolationDeltaBetaCorr3Hits", "DiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits"),
106  ("byMediumCombinedIsolationDeltaBetaCorr3Hits", "DiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits"),
107  ("byTightCombinedIsolationDeltaBetaCorr3Hits", "DiscriminationByTightCombinedIsolationDBSumPtCorr3Hits"),
108  ("byCombinedIsolationDeltaBetaCorrRaw3Hits", "DiscriminationByRawCombinedIsolationDBSumPtCorr3Hits"),
109  ("byLooseCombinedIsolationDeltaBetaCorr3HitsdR03", "DiscriminationByLooseCombinedIsolationDBSumPtCorr3HitsdR03"),
110  ("byMediumCombinedIsolationDeltaBetaCorr3HitsdR03", "DiscriminationByMediumCombinedIsolationDBSumPtCorr3HitsdR03"),
111  ("byTightCombinedIsolationDeltaBetaCorr3HitsdR03", "DiscriminationByTightCombinedIsolationDBSumPtCorr3HitsdR03"),
112  ("byPhotonPtSumOutsideSignalCone", "DiscriminationByPhotonPtSumOutsideSignalCone"),
113  ("chargedIsoPtSum", "ChargedIsoPtSum"),
114  ("neutralIsoPtSum", "NeutralIsoPtSum"),
115  ("puCorrPtSum", "PUcorrPtSum"),
116  ("neutralIsoPtSumWeight", "NeutralIsoPtSumWeight"),
117  ("footprintCorrection", "FootprintCorrection"),
118  ("photonPtSumOutsideSignalCone", "PhotonPtSumOutsideSignalCone"),
119  ("againstMuonLoose3", "DiscriminationByLooseMuonRejection3"),
120  ("againstMuonTight3", "DiscriminationByTightMuonRejection3"),
121  ("byIsolationMVArun2v1DBoldDMwLTraw", "DiscriminationByIsolationMVArun2v1DBoldDMwLTraw"),
122  ("byVVLooseIsolationMVArun2v1DBoldDMwLT", "DiscriminationByVVLooseIsolationMVArun2v1DBoldDMwLT"),
123  ("byVLooseIsolationMVArun2v1DBoldDMwLT", "DiscriminationByVLooseIsolationMVArun2v1DBoldDMwLT"),
124  ("byLooseIsolationMVArun2v1DBoldDMwLT", "DiscriminationByLooseIsolationMVArun2v1DBoldDMwLT"),
125  ("byMediumIsolationMVArun2v1DBoldDMwLT", "DiscriminationByMediumIsolationMVArun2v1DBoldDMwLT"),
126  ("byTightIsolationMVArun2v1DBoldDMwLT", "DiscriminationByTightIsolationMVArun2v1DBoldDMwLT"),
127  ("byVTightIsolationMVArun2v1DBoldDMwLT", "DiscriminationByVTightIsolationMVArun2v1DBoldDMwLT"),
128  ("byVVTightIsolationMVArun2v1DBoldDMwLT", "DiscriminationByVVTightIsolationMVArun2v1DBoldDMwLT"),
129  ("byIsolationMVArun2v1DBnewDMwLTraw", "DiscriminationByIsolationMVArun2v1DBnewDMwLTraw"),
130  ("byVVLooseIsolationMVArun2v1DBnewDMwLT", "DiscriminationByVVLooseIsolationMVArun2v1DBnewDMwLT"),
131  ("byVLooseIsolationMVArun2v1DBnewDMwLT", "DiscriminationByVLooseIsolationMVArun2v1DBnewDMwLT"),
132  ("byLooseIsolationMVArun2v1DBnewDMwLT", "DiscriminationByLooseIsolationMVArun2v1DBnewDMwLT"),
133  ("byMediumIsolationMVArun2v1DBnewDMwLT", "DiscriminationByMediumIsolationMVArun2v1DBnewDMwLT"),
134  ("byTightIsolationMVArun2v1DBnewDMwLT", "DiscriminationByTightIsolationMVArun2v1DBnewDMwLT"),
135  ("byVTightIsolationMVArun2v1DBnewDMwLT", "DiscriminationByVTightIsolationMVArun2v1DBnewDMwLT"),
136  ("byVVTightIsolationMVArun2v1DBnewDMwLT", "DiscriminationByVVTightIsolationMVArun2v1DBnewDMwLT"),
137  ("byIsolationMVArun2v1PWoldDMwLTraw", "DiscriminationByIsolationMVArun2v1PWoldDMwLTraw"),
138  ("byVLooseIsolationMVArun2v1PWoldDMwLT", "DiscriminationByVLooseIsolationMVArun2v1PWoldDMwLT"),
139  ("byLooseIsolationMVArun2v1PWoldDMwLT", "DiscriminationByLooseIsolationMVArun2v1PWoldDMwLT"),
140  ("byMediumIsolationMVArun2v1PWoldDMwLT", "DiscriminationByMediumIsolationMVArun2v1PWoldDMwLT"),
141  ("byTightIsolationMVArun2v1PWoldDMwLT", "DiscriminationByTightIsolationMVArun2v1PWoldDMwLT"),
142  ("byVTightIsolationMVArun2v1PWoldDMwLT", "DiscriminationByVTightIsolationMVArun2v1PWoldDMwLT"),
143  ("byVVTightIsolationMVArun2v1PWoldDMwLT", "DiscriminationByVVTightIsolationMVArun2v1PWoldDMwLT"),
144  ("byIsolationMVArun2v1PWnewDMwLTraw", "DiscriminationByIsolationMVArun2v1PWnewDMwLTraw"),
145  ("byVLooseIsolationMVArun2v1PWnewDMwLT", "DiscriminationByVLooseIsolationMVArun2v1PWnewDMwLT"),
146  ("byLooseIsolationMVArun2v1PWnewDMwLT", "DiscriminationByLooseIsolationMVArun2v1PWnewDMwLT"),
147  ("byMediumIsolationMVArun2v1PWnewDMwLT", "DiscriminationByMediumIsolationMVArun2v1PWnewDMwLT"),
148  ("byTightIsolationMVArun2v1PWnewDMwLT", "DiscriminationByTightIsolationMVArun2v1PWnewDMwLT"),
149  ("byVTightIsolationMVArun2v1PWnewDMwLT", "DiscriminationByVTightIsolationMVArun2v1PWnewDMwLT"),
150  ("byVVTightIsolationMVArun2v1PWnewDMwLT", "DiscriminationByVVTightIsolationMVArun2v1PWnewDMwLT"),
151  ("chargedIsoPtSumdR03", "ChargedIsoPtSumdR03"),
152  ("neutralIsoPtSumdR03", "NeutralIsoPtSumdR03"),
153  ("neutralIsoPtSumWeightdR03", "NeutralIsoPtSumWeightdR03"),
154  ("footprintCorrectiondR03", "FootprintCorrectiondR03"),
155  ("photonPtSumOutsideSignalConedR03", "PhotonPtSumOutsideSignalConedR03"),
156  ("byIsolationMVArun2v1DBdR03oldDMwLTraw", "DiscriminationByIsolationMVArun2v1DBdR03oldDMwLTraw"),
157  ("byVVLooseIsolationMVArun2v1DBdR03oldDMwLT", "DiscriminationByVVLooseIsolationMVArun2v1DBdR03oldDMwLT"),
158  ("byVLooseIsolationMVArun2v1DBdR03oldDMwLT", "DiscriminationByVLooseIsolationMVArun2v1DBdR03oldDMwLT"),
159  ("byLooseIsolationMVArun2v1DBdR03oldDMwLT", "DiscriminationByLooseIsolationMVArun2v1DBdR03oldDMwLT"),
160  ("byMediumIsolationMVArun2v1DBdR03oldDMwLT", "DiscriminationByMediumIsolationMVArun2v1DBdR03oldDMwLT"),
161  ("byTightIsolationMVArun2v1DBdR03oldDMwLT", "DiscriminationByTightIsolationMVArun2v1DBdR03oldDMwLT"),
162  ("byVTightIsolationMVArun2v1DBdR03oldDMwLT", "DiscriminationByVTightIsolationMVArun2v1DBdR03oldDMwLT"),
163  ("byVVTightIsolationMVArun2v1DBdR03oldDMwLT", "DiscriminationByVVTightIsolationMVArun2v1DBdR03oldDMwLT"),
164  ("byIsolationMVArun2v1PWdR03oldDMwLTraw", "DiscriminationByIsolationMVArun2v1PWdR03oldDMwLTraw"),
165  ("byVLooseIsolationMVArun2v1PWdR03oldDMwLT", "DiscriminationByVLooseIsolationMVArun2v1PWdR03oldDMwLT"),
166  ("byLooseIsolationMVArun2v1PWdR03oldDMwLT", "DiscriminationByLooseIsolationMVArun2v1PWdR03oldDMwLT"),
167  ("byMediumIsolationMVArun2v1PWdR03oldDMwLT", "DiscriminationByMediumIsolationMVArun2v1PWdR03oldDMwLT"),
168  ("byTightIsolationMVArun2v1PWdR03oldDMwLT", "DiscriminationByTightIsolationMVArun2v1PWdR03oldDMwLT"),
169  ("byVTightIsolationMVArun2v1PWdR03oldDMwLT", "DiscriminationByVTightIsolationMVArun2v1PWdR03oldDMwLT"),
170  ("byVVTightIsolationMVArun2v1PWdR03oldDMwLT", "DiscriminationByVVTightIsolationMVArun2v1PWdR03oldDMwLT"),
171  ("againstElectronMVA6Raw", "DiscriminationByMVA6rawElectronRejection"),
172  ("againstElectronMVA6category", "DiscriminationByMVA6rawElectronRejection:category"),
173  ("againstElectronVLooseMVA6", "DiscriminationByMVA6VLooseElectronRejection"),
174  ("againstElectronLooseMVA6", "DiscriminationByMVA6LooseElectronRejection"),
175  ("againstElectronMediumMVA6", "DiscriminationByMVA6MediumElectronRejection"),
176  ("againstElectronTightMVA6", "DiscriminationByMVA6TightElectronRejection"),
177  ("againstElectronVTightMVA6", "DiscriminationByMVA6VTightElectronRejection"),
178  ("againstElectronDeadECAL", "DiscriminationByDeadECALElectronRejection"),
179 ]
180 
181 # switch to PFTau collection produced for fixed dR = 0.07 signal cone size
182 def switchToPFTauFixedCone(process,
183  tauSource = cms.InputTag('fixedConePFTauProducer'),
184  patTauLabel = "",
185  postfix = ""):
186  fixedConeIDSources = copy.copy(classicTauIDSources)
187  fixedConeIDSources.extend(classicPFTauIDSources)
188 
189  _switchToPFTau(process, tauSource, 'fixedConePFTau', fixedConeIDSources,
190  patTauLabel = patTauLabel, postfix = postfix)
191 
192 # switch to PFTau collection produced for shrinking signal cone of size dR = 5.0/Et(PFTau)
193 def switchToPFTauShrinkingCone(process,
194  tauSource = cms.InputTag('shrinkingConePFTauProducer'),
195  patTauLabel = "",
196  postfix = ""):
197  shrinkingIDSources = copy.copy(classicTauIDSources)
198  shrinkingIDSources.extend(classicPFTauIDSources)
199 
200  _switchToPFTau(process, tauSource, 'shrinkingConePFTau', shrinkingIDSources,
201  patTauLabel = patTauLabel, postfix = postfix)
202 
203 # switch to hadron-plus-strip(s) (HPS) PFTau collection
204 def switchToPFTauHPS(process,
205  tauSource = cms.InputTag('hpsPFTauProducer'),
206  patTauLabel = "",
207  jecLevels = [],
208  postfix = ""):
209 
210  _switchToPFTau(process, tauSource, 'hpsPFTau', hpsTauIDSources,
211  patTauLabel = patTauLabel, postfix = postfix)
212 
213  # CV: enable tau lifetime information for HPS PFTaus
214  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = tauSource.value().replace("Producer", "TransverseImpactParameters")
215 
216  ## adapt cleanPatTaus
217  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
218  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = preselection
219 
220 # Select switcher by string
221 def switchToPFTauByType(process,
222  pfTauType = None,
223  tauSource = cms.InputTag('hpsPFTauProducer'),
224  patTauLabel = "",
225  postfix = "" ):
226  mapping = {
227  'shrinkingConePFTau' : switchToPFTauShrinkingCone,
228  'fixedConePFTau' : switchToPFTauFixedCone,
229  'hpsPFTau' : switchToPFTauHPS,
230  'caloRecoTau' : switchToCaloTau
231  }
232  if not pfTauType in mapping.keys():
233  raise ValueError("Error in <switchToPFTauByType>: Undefined pfTauType = %s !!" % pfTauType)
234 
235  mapping[pfTauType](process, tauSource = tauSource,
236  patTauLabel = patTauLabel, postfix = postfix)
237 
239 
240  """ Add a new collection of taus. Takes the configuration from the
241  already configured standard tau collection as starting point;
242  replaces before calling addTauCollection will also affect the
243  new tau collections
244  """
245  _label='addTauCollection'
246  _defaultParameters=dicttypes.SortedKeysDict()
247  def __init__(self):
248  ConfigToolBase.__init__(self)
249  self.addParameter(self._defaultParameters, 'tauCollection',
250  self._defaultValue, 'Input tau collection', cms.InputTag)
251  self.addParameter(self._defaultParameters, 'algoLabel',
252  self._defaultValue, "label to indicate the tau algorithm (e.g.'hps')", str)
253  self.addParameter(self._defaultParameters, 'typeLabel',
254  self._defaultValue, "label to indicate the type of constituents (either 'PFTau' or 'Tau')", str)
255  self.addParameter(self._defaultParameters, 'doPFIsoDeposits',
256  True, "run sequence for computing particle-flow based IsoDeposits")
257  self.addParameter(self._defaultParameters, 'standardAlgo',
258  "hps", "standard algorithm label of the collection from which the clones " \
259  + "for the new tau collection will be taken from " \
260  + "(note that this tau collection has to be available in the event before hand)")
261  self.addParameter(self._defaultParameters, 'standardType',
262  "PFTau", "standard constituent type label of the collection from which the clones " \
263  + " for the new tau collection will be taken from "\
264  + "(note that this tau collection has to be available in the event before hand)")
265 
266  self._parameters=copy.deepcopy(self._defaultParameters)
267  self._comment = ""
268 
270  return self._defaultParameters
271 
272  def __call__(self,process,
273  tauCollection = None,
274  algoLabel = None,
275  typeLabel = None,
276  doPFIsoDeposits = None,
277  jetCorrLabel = None,
278  standardAlgo = None,
279  standardType = None):
280 
281  if tauCollection is None:
282  tauCollection = self._defaultParameters['tauCollection'].value
283  if algoLabel is None:
284  algoLabel = self._defaultParameters['algoLabel'].value
285  if typeLabel is None:
286  typeLabel = self._defaultParameters['typeLabel'].value
287  if doPFIsoDeposits is None:
288  doPFIsoDeposits = self._defaultParameters['doPFIsoDeposits'].value
289  if standardAlgo is None:
290  standardAlgo = self._defaultParameters['standardAlgo'].value
291  if standardType is None:
292  standardType = self._defaultParameters['standardType'].value
293 
294  self.setParameter('tauCollection', tauCollection)
295  self.setParameter('algoLabel', algoLabel)
296  self.setParameter('typeLabel', typeLabel)
297  self.setParameter('doPFIsoDeposits', doPFIsoDeposits)
298  self.setParameter('standardAlgo', standardAlgo)
299  self.setParameter('standardType', standardType)
300 
301  self.apply(process)
302 
303  def toolCode(self, process):
304  tauCollection = self._parameters['tauCollection'].value
305  algoLabel = self._parameters['algoLabel'].value
306  typeLabel = self._parameters['typeLabel'].value
307  doPFIsoDeposits = self._parameters['doPFIsoDeposits'].value
308  standardAlgo = self._parameters['standardAlgo'].value
309  standardType = self._parameters['standardType'].value
310 
311  ## disable computation of particle-flow based IsoDeposits
312  ## in case tau is of CaloTau type
313  if typeLabel == 'Tau':
314  print("NO PF Isolation will be computed for CaloTau (this could be improved later)")
315  doPFIsoDeposits = False
316 
317  ## create old module label from standardAlgo
318  ## and standardType and return
319  def oldLabel(prefix = ''):
320  if prefix == '':
321  return "patTaus"
322  else:
323  return prefix + "PatTaus"
324 
325  ## capitalize first character of appended part
326  ## when creating new module label
327  ## (giving e.g. "patTausCaloRecoTau")
328  def capitalize(label):
329  return label[0].capitalize() + label[1:]
330 
331  ## create new module label from old module
332  ## label and return
333  def newLabel(oldLabel):
334  newLabel = oldLabel
335  if ( oldLabel.find(standardAlgo) >= 0 and oldLabel.find(standardType) >= 0 ):
336  oldLabel = oldLabel.replace(standardAlgo, algoLabel).replace(standardType, typeLabel)
337  else:
338  oldLabel = oldLabel + capitalize(algoLabel + typeLabel)
339  return oldLabel
340 
341  ## clone module and add it to the patDefaultSequence
342  def addClone(hook, **replaceStatements):
343  ## create a clone of the hook with corresponding
344  ## parameter replacements
345  newModule = getattr(process, hook).clone(**replaceStatements)
346 
347  ## clone module for computing particle-flow IsoDeposits
348  def addPFIsoDepositClone(hook, **replaceStatements):
349  newModule = getattr(process, hook).clone(**replaceStatements)
350  newModuleIsoDepositExtractor = getattr(newModule, "ExtractorPSet")
351  setattr(newModuleIsoDepositExtractor, "tauSource", getattr(newModule, "src"))
352 
353  ## add a clone of patTaus
354  addClone(oldLabel(), tauSource = tauCollection)
355 
356  ## add a clone of selectedPatTaus
357  addClone(oldLabel('selected'), src = cms.InputTag(newLabel(oldLabel())))
358 
359  ## add a clone of cleanPatTaus
360  addClone(oldLabel('clean'), src=cms.InputTag(newLabel(oldLabel('selected'))))
361 
362  ## get attributes of new module
363  newTaus = getattr(process, newLabel(oldLabel()))
364 
365  ## add a clone of gen tau matching
366  addClone('tauMatch', src = tauCollection)
367  addClone('tauGenJetMatch', src = tauCollection)
368 
369  ## add a clone of IsoDeposits computed based on particle-flow
370  if doPFIsoDeposits:
371  addPFIsoDepositClone('tauIsoDepositPFCandidates', src = tauCollection)
372  addPFIsoDepositClone('tauIsoDepositPFChargedHadrons', src = tauCollection)
373  addPFIsoDepositClone('tauIsoDepositPFNeutralHadrons', src = tauCollection)
374  addPFIsoDepositClone('tauIsoDepositPFGammas', src = tauCollection)
375 
376  ## fix label for input tag
377  def fixInputTag(x):
378  x.setModuleLabel(newLabel(x.moduleLabel))
379 
380  ## provide patTau inputs with individual labels
381  fixInputTag(newTaus.genParticleMatch)
382  fixInputTag(newTaus.genJetMatch)
383  fixInputTag(newTaus.isoDeposits.pfAllParticles)
384  fixInputTag(newTaus.isoDeposits.pfNeutralHadron)
385  fixInputTag(newTaus.isoDeposits.pfChargedHadron)
386  fixInputTag(newTaus.isoDeposits.pfGamma)
387  fixInputTag(newTaus.userIsolation.pfAllParticles.src)
388  fixInputTag(newTaus.userIsolation.pfNeutralHadron.src)
389  fixInputTag(newTaus.userIsolation.pfChargedHadron.src)
390  fixInputTag(newTaus.userIsolation.pfGamma.src)
391 
392  ## set discriminators
393  ## (using switchTauCollection functions)
394  oldTaus = getattr(process, oldLabel())
395  if typeLabel == 'Tau':
396  switchToCaloTau(process,
397  tauSource = getattr(newTaus, "tauSource"),
398  patTauLabel = capitalize(algoLabel + typeLabel))
399  else:
400  switchToPFTauByType(process, pfTauType = algoLabel + typeLabel,
401  tauSource = getattr(newTaus, "tauSource"),
402  patTauLabel = capitalize(algoLabel + typeLabel))
403 
404 addTauCollection=AddTauCollection()
def _buildIDSourcePSet(tauType, idSources, postfix="")
Definition: tauTools.py:43
def replace(string, replacements)
def switchToPFTauShrinkingCone(process, tauSource=cms.InputTag('shrinkingConePFTauProducer'), patTauLabel="", postfix="")
Definition: tauTools.py:196
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def switchToCaloTau(process, tauSource=cms.InputTag('caloRecoTauProducer'), patTauLabel="", postfix="")
Definition: tauTools.py:22
def __call__(self, process, tauCollection=None, algoLabel=None, typeLabel=None, doPFIsoDeposits=None, jetCorrLabel=None, standardAlgo=None, standardType=None)
Definition: tauTools.py:279
def switchToPFTauByType(process, pfTauType=None, tauSource=cms.InputTag('hpsPFTauProducer'), patTauLabel="", postfix="")
Definition: tauTools.py:225
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def switchToPFTauHPS(process, tauSource=cms.InputTag('hpsPFTauProducer'), patTauLabel="", jecLevels=[], postfix="")
Definition: tauTools.py:208
def toolCode(self, process)
Definition: tauTools.py:303
def getDefaultParameters(self)
Definition: tauTools.py:269
def _switchToPFTau(process, tauSource, pfTauType, idSources, patTauLabel="", postfix="")
Definition: tauTools.py:59
def switchToPFTauFixedCone(process, tauSource=cms.InputTag('fixedConePFTauProducer'), patTauLabel="", postfix="")
Definition: tauTools.py:185
def applyPostfix(process, label, postfix)
Definition: tauTools.py:10