CMS 3D CMS Logo

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