CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
tauTools.py
Go to the documentation of this file.
2 
5 from PhysicsTools.PatAlgos.tools.helpers import applyPostfix
6 from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
8 
9 def redoPFTauDiscriminators(process,
10  oldPFTauLabel = cms.InputTag('shrinkingConePFTauProducer'),
11  newPFTauLabel = cms.InputTag('shrinkingConePFTauProducer'),
12  tauType = 'shrinkingConePFTau', postfix = ""):
13  print 'Tau discriminators: ', oldPFTauLabel, '->', newPFTauLabel
14  print 'Tau type: ', tauType
15  #oldPFTauLabel.setModuleLabel(oldPFTauLabel.getModuleLabel()+postfix)
16  tauSrc = 'PFTauProducer'
17 
18  tauDiscriminationSequence = None
19 
20  if tauType == 'hpsPFTau':
21  process.patHPSPFTauDiscrimination = process.produceAndDiscriminateHPSPFTaus.copy()
22  # remove producers
23  for iname in process.patHPSPFTauDiscrimination.moduleNames():
24  if not (iname.find("DiscriminationBy")>-1 or iname.find("DiscriminationAgainst")>-1):
25  process.patHPSPFTauDiscrimination.remove(getattr(process,iname) )
26  tauDiscriminationSequence = cloneProcessingSnippet(process, process.patHPSPFTauDiscrimination, postfix)
27 
28  elif tauType == 'hpsTancTaus': #to be checked if correct
29  process.patHPSTaNCPFTauDiscrimination = process.hpsTancTauInitialSequence.copy()
30  process.patHPSTaNCPFTauDiscrimination *= process.hpsTancTauDiscriminantSequence
31  # remove producers
32  for iname in process.patHPSTaNCPFTauDiscrimination.moduleNames():
33  if not (iname.find("DiscriminationBy")>-1 or iname.find("DiscriminationAgainst")>-1):
34  process.patHPSTaNCPFTauDiscrimination.remove(getattr(process,iname) )
35  tauDiscriminationSequence = cloneProcessingSnippet(process, process.patHPSTaNCPFTauDiscrimination, postfix)
36 
37  elif tauType == 'fixedConePFTau':
38  process.patFixedConePFTauDiscrimination = process.produceAndDiscriminateFixedConePFTaus.copy()
39  # remove producers
40  for iname in process.patFixedConePFTauDiscrimination.moduleNames():
41  if not (iname.find("DiscriminationBy")>-1 or iname.find("DiscriminationAgainst")>-1):
42  process.patFixedConePFTauDiscrimination.remove(getattr(process,iname) )
43  tauDiscriminationSequence = cloneProcessingSnippet(process, process.patFixedConePFTauDiscrimination, postfix)
44 
45  elif tauType == 'shrinkingConePFTau': #shr cone with TaNC
46  process.patShrinkingConePFTauDiscrimination = process.produceAndDiscriminateShrinkingConePFTaus.copy()
47  process.patShrinkingConePFTauDiscrimination *= process.produceShrinkingConeDiscriminationByTauNeuralClassifier
48  # remove producers
49  for iname in process.patShrinkingConePFTauDiscrimination.moduleNames():
50  if not (iname.find("DiscriminationBy")>-1 or iname.find("DiscriminationAgainst")>-1):
51  process.patShrinkingConePFTauDiscrimination.remove(getattr(process,iname) )
52  tauDiscriminationSequence = cloneProcessingSnippet(process, process.patShrinkingConePFTauDiscrimination, postfix)
53 
54  elif tauType == 'caloTau':
55  # fill calo sequence by discriminants
56  process.patCaloTauDiscrimination = process.tautagging.copy()
57  # remove producers
58  for iname in process.patCaloTauDiscrimination.moduleNames():
59  if not (iname.find("DiscriminationBy")>-1 or iname.find("DiscriminationAgainst")>-1):
60  process.patCaloTauDiscrimination.remove(getattr(process,iname) )
61  tauDiscriminationSequence = cloneProcessingSnippet(process, process.patCaloTauDiscrimination, postfix)
62  tauSrc = 'CaloTauProducer'
63  else:
64  raise StandardError, "Unkown tauType: '%s'"%tauType
65 
66  applyPostfix(process,"patDefaultSequence",postfix).replace(
67  applyPostfix(process,"patTaus",postfix),
68  tauDiscriminationSequence*applyPostfix(process,"patTaus",postfix)
69  )
70 
71  massSearchReplaceParam(tauDiscriminationSequence, tauSrc, oldPFTauLabel, newPFTauLabel)
72 
73 # switch to CaloTau collection
74 def switchToCaloTau(process,
75  pfTauLabelOld = cms.InputTag('shrinkingConePFTauProducer'),
76  pfTauLabelNew = cms.InputTag('caloRecoTauProducer'),
77  patTauLabel = "",
78  postfix = ""):
79  print ' Taus: ', pfTauLabelOld, '->', pfTauLabelNew
80 
81  caloTauLabel = pfTauLabelNew
82  applyPostfix(process, "tauMatch" + patTauLabel, postfix).src = caloTauLabel
83  applyPostfix(process, "tauGenJetMatch"+ patTauLabel, postfix).src = caloTauLabel
84 
85  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauSource = caloTauLabel
86  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = _buildIDSourcePSet('caloRecoTau', classicTauIDSources, postfix)
87 # applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = cms.PSet(
88 # leadingTrackFinding = cms.InputTag("caloRecoTauDiscriminationByLeadingTrackFinding" + postfix),
89 # leadingTrackPtCut = cms.InputTag("caloRecoTauDiscriminationByLeadingTrackPtCut" + postfix),
90 # trackIsolation = cms.InputTag("caloRecoTauDiscriminationByTrackIsolation" + postfix),
91 # ecalIsolation = cms.InputTag("caloRecoTauDiscriminationByECALIsolation" + postfix),
92 # byIsolation = cms.InputTag("caloRecoTauDiscriminationByIsolation" + postfix),
93 # againstElectron = cms.InputTag("caloRecoTauDiscriminationAgainstElectron" + postfix),
94 # againstMuon = cms.InputTag("caloRecoTauDiscriminationAgainstMuon" + postfix)
95 # )
96  ## Isolation is somewhat an issue, so we start just by turning it off
97  print "NO PF Isolation will be computed for CaloTau (this could be improved later)"
98  applyPostfix(process, "patTaus" + patTauLabel, postfix).isolation = cms.PSet()
99  applyPostfix(process, "patTaus" + patTauLabel, postfix).isoDeposits = cms.PSet()
100  applyPostfix(process, "patTaus" + patTauLabel, postfix).userIsolation = cms.PSet()
101 
102  ## adapt cleanPatTaus
103  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
104  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
105  'tauID("leadingTrackFinding") > 0.5 & tauID("leadingTrackPtCut") > 0.5' \
106  + ' & tauID("byIsolation") > 0.5 & tauID("againstElectron") > 0.5 & (signalTracks.size() = 1 | signalTracks.size() = 3)'
107 
108 def _buildIDSourcePSet(pfTauType, idSources, postfix =""):
109  """ Build a PSet defining the tau ID sources to embed into the pat::Tau """
110  output = cms.PSet()
111  for label, discriminator in idSources:
112  setattr(output, label, cms.InputTag(pfTauType + discriminator + postfix))
113  return output
114 
115 def _switchToPFTau(process,
116  pfTauLabelOld,
117  pfTauLabelNew,
118  pfTauType,
119  idSources,
120  patTauLabel = "",
121  postfix = ""):
122  """internal auxiliary function to switch to **any** PFTau collection"""
123  print ' Taus: ', pfTauLabelOld, '->', pfTauLabelNew
124 
125  applyPostfix(process, "tauMatch" + patTauLabel, postfix).src = pfTauLabelNew
126  applyPostfix(process, "tauGenJetMatch" + patTauLabel, postfix).src = pfTauLabelNew
127 
128  applyPostfix(process, "tauIsoDepositPFCandidates" + patTauLabel, postfix).src = pfTauLabelNew
129  applyPostfix(process, "tauIsoDepositPFCandidates" + patTauLabel, postfix).ExtractorPSet.tauSource = pfTauLabelNew
130  applyPostfix(process, "tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).src = pfTauLabelNew
131  applyPostfix(process, "tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = pfTauLabelNew
132  applyPostfix(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).src = pfTauLabelNew
133  applyPostfix(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = pfTauLabelNew
134  applyPostfix(process, "tauIsoDepositPFGammas" + patTauLabel, postfix).src = pfTauLabelNew
135  applyPostfix(process, "tauIsoDepositPFGammas" + patTauLabel, postfix).ExtractorPSet.tauSource = pfTauLabelNew
136 
137  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauSource = pfTauLabelNew
138  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = _buildIDSourcePSet(pfTauType, idSources, postfix)
139 
140  applyPostfix(process, "cleanPatTaus" + patTauLabel, postfix).preselection = \
141  'tauID("leadingTrackFinding") > 0.5 & tauID("leadingPionPtCut") > 0.5 & tauID("byIsolationUsingLeadingPion") > 0.5' \
142  + ' & tauID("againstMuon") > 0.5 & tauID("againstElectron") > 0.5' \
143  + ' & (signalPFChargedHadrCands.size() = 1 | signalPFChargedHadrCands.size() = 3)'
144 
145 # Name mapping for classic tau ID sources (present for fixed and shrinkingCones)
146 classicTauIDSources = [
147  ("leadingTrackFinding", "DiscriminationByLeadingTrackFinding"),
148  ("leadingTrackPtCut", "DiscriminationByLeadingTrackPtCut"),
149  ("trackIsolation", "DiscriminationByTrackIsolation"),
150  ("ecalIsolation", "DiscriminationByECALIsolation"),
151  ("byIsolation", "DiscriminationByIsolation"),
152  ("againstElectron", "DiscriminationAgainstElectron"),
153  ("againstMuon", "DiscriminationAgainstMuon") ]
154 
155 classicPFTauIDSources = [
156  ("leadingPionPtCut", "DiscriminationByLeadingPionPtCut"),
157  ("trackIsolationUsingLeadingPion", "DiscriminationByTrackIsolationUsingLeadingPion"),
158  ("ecalIsolationUsingLeadingPion", "DiscriminationByECALIsolationUsingLeadingPion"),
159  ("byIsolationUsingLeadingPion", "DiscriminationByIsolationUsingLeadingPion")]
160 
161 # Tau Neural Classifier Discriminators
162 tancTauIDSources = [
163  ("byTaNC", "DiscriminationByTaNC"),
164  ("byTaNCfrOnePercent", "DiscriminationByTaNCfrOnePercent"),
165  ("byTaNCfrHalfPercent", "DiscriminationByTaNCfrHalfPercent"),
166  ("byTaNCfrQuarterPercent", "DiscriminationByTaNCfrQuarterPercent"),
167  ("byTaNCfrTenthPercent", "DiscriminationByTaNCfrTenthPercent") ]
168 
169 # Hadron-plus-strip(s) (HPS) Tau Discriminators
170 hpsTauIDSources = [
171  ("leadingTrackFinding", "DiscriminationByDecayModeFinding"),
172  ("byLooseIsolation", "DiscriminationByLooseIsolation"),
173  ("byMediumIsolation", "DiscriminationByMediumIsolation"),
174  ("byTightIsolation", "DiscriminationByTightIsolation"),
175  ("againstElectron", "DiscriminationAgainstElectron"),
176  ("againstMuon", "DiscriminationAgainstMuon")]
177 
178 # Discriminators of new HPS + TaNC combined Tau id. algorithm
179 hpsTancTauIDSources = [
180  ("leadingTrackFinding", "DiscriminationByLeadingTrackFinding"),
181  ("leadingTrackPtCut", "DiscriminationByLeadingTrackPtCut"),
182  ("leadingPionPtCut", "DiscriminationByLeadingPionPtCut"),
183  ("byTaNCraw", "DiscriminationByTancRaw"),
184  ("byTaNC", "DiscriminationByTanc"),
185  ("byTaNCvloose", "DiscriminationByTancVLoose"),
186  ("byTaNCloose", "DiscriminationByTancLoose"),
187  ("byTaNCmedium", "DiscriminationByTancMedium"),
188  ("byTaNCtight", "DiscriminationByTancTight"),
189  ("byDecayMode", "DiscriminationByDecayModeSelection"),
190  ("byHPSvloose", "DiscriminationByVLooseIsolation"),
191  ("byHPSloose", "DiscriminationByLooseIsolation"),
192  ("byHPSmedium", "DiscriminationByMediumIsolation"),
193  ("byHPStight", "DiscriminationByTightIsolation"),
194  ("againstElectron", "DiscriminationAgainstElectron"),
195  ("againstMuon", "DiscriminationAgainstMuon"),
196  ("againstCaloMuon", "DiscriminationAgainstCaloMuon") ]
197 
198 # switch to PFTau collection produced for fixed dR = 0.07 signal cone size
199 def switchToPFTauFixedCone(process,
200  pfTauLabelOld = cms.InputTag('shrinkingConePFTauProducer'),
201  pfTauLabelNew = cms.InputTag('fixedConePFTauProducer'),
202  patTauLabel = "",
203  postfix = ""):
204  fixedConeIDSources = copy.copy(classicTauIDSources)
205  fixedConeIDSources.extend(classicPFTauIDSources)
206 
207  _switchToPFTau(process, pfTauLabelOld, pfTauLabelNew, 'fixedConePFTau', fixedConeIDSources,
208  patTauLabel = patTauLabel, postfix = postfix)
209 
210 # switch to PFTau collection produced for shrinking signal cone of size dR = 5.0/Et(PFTau)
211 def switchToPFTauShrinkingCone(process,
212  pfTauLabelOld = cms.InputTag('shrinkingConePFTauProducer'),
213  pfTauLabelNew = cms.InputTag('shrinkingConePFTauProducer'),
214  patTauLabel = "",
215  postfix = ""):
216  shrinkingIDSources = copy.copy(classicTauIDSources)
217  shrinkingIDSources.extend(classicPFTauIDSources)
218  # Only shrinkingCone has associated TaNC discriminators, so add them here
219  shrinkingIDSources.extend(tancTauIDSources)
220 
221  _switchToPFTau(process, pfTauLabelOld, pfTauLabelNew, 'shrinkingConePFTau', shrinkingIDSources,
222  patTauLabel = patTauLabel, postfix = postfix)
223 
224 # switch to hadron-plus-strip(s) (HPS) PFTau collection
225 def switchToPFTauHPS(process,
226  pfTauLabelOld = cms.InputTag('shrinkingConePFTauProducer'),
227  pfTauLabelNew = cms.InputTag('hpsPFTauProducer'),
228  patTauLabel = "",
229  postfix = ""):
230  _switchToPFTau(process, pfTauLabelOld, pfTauLabelNew, 'hpsPFTau', hpsTauIDSources,
231  patTauLabel = patTauLabel, postfix = postfix)
232 
233  ## adapt cleanPatTaus
234  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
235  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
236  'pt > 15 & abs(eta) < 2.3 & tauID("leadingTrackFinding") > 0.5 & tauID("byLooseIsolation") > 0.5' \
237  + ' & tauID("againstMuon") > 0.5 & tauID("againstElectron") > 0.5'
238 
239 # switch to hadron-plus-strip(s) (HPS) PFTau collection
240 def switchToPFTauHPSpTaNC(process,
241  pfTauLabelOld = cms.InputTag('shrinkingConePFTauProducer'),
242  pfTauLabelNew = cms.InputTag('hpsTancTaus'),
243  patTauLabel = "",
244  postfix = ""):
245  _switchToPFTau(process, pfTauLabelOld, pfTauLabelNew, 'hpsTancTaus', hpsTancTauIDSources,
246  patTauLabel = patTauLabel, postfix = postfix)
247 
248  ## adapt cleanPatTaus
249  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
250  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
251  'pt > 15 & abs(eta) < 2.3 & tauID("leadingPionPtCut") > 0.5 & tauID("byHPSloose") > 0.5' \
252  + ' & tauID("againstMuon") > 0.5 & tauID("againstElectron") > 0.5'
253 
254 # Select switcher by string
255 def switchToPFTauByType(process,
256  pfTauType = None,
257  pfTauLabelNew = None,
258  pfTauLabelOld = cms.InputTag('shrinkingConePFTauProducer'),
259  patTauLabel = "",
260  postfix = "" ):
261  mapping = { 'shrinkingConePFTau' : switchToPFTauShrinkingCone,
262  'fixedConePFTau' : switchToPFTauFixedCone,
263  'hpsPFTau' : switchToPFTauHPS,
264  'caloRecoTau' : switchToCaloTau,
265  'hpsTancPFTau' : switchToPFTauHPSpTaNC }
266  mapping[pfTauType](process, pfTauLabelOld = pfTauLabelOld, pfTauLabelNew = pfTauLabelNew,
267  patTauLabel = patTauLabel, postfix = postfix)
268 
269 # switch to PFTau collection that was default in PAT production in CMSSW_3_1_x release series
270 def switchTo31Xdefaults(process):
271  switchToPFTauFixedCone(process)
272  process.cleanPatTaus.preselection = cms.string('tauID("byIsolation") > 0')
273 
274 class AddTauCollection(ConfigToolBase):
275 
276  """ Add a new collection of taus. Takes the configuration from the
277  already configured standard tau collection as starting point;
278  replaces before calling addTauCollection will also affect the
279  new tau collections
280  """
281  _label='addTauCollection'
282  _defaultParameters=dicttypes.SortedKeysDict()
283  def __init__(self):
284  ConfigToolBase.__init__(self)
285  self.addParameter(self._defaultParameters, 'tauCollection',
286  self._defaultValue, 'Input tau collection', cms.InputTag)
287  self.addParameter(self._defaultParameters, 'algoLabel',
288  self._defaultValue, "label to indicate the tau algorithm (e.g.'shrinkingCone')", str)
289  self.addParameter(self._defaultParameters, 'typeLabel',
290  self._defaultValue, "label to indicate the type of constituents (either 'PFTau' or 'Tau')", str)
291  self.addParameter(self._defaultParameters, 'doPFIsoDeposits',
292  True, "run sequence for computing particle-flow based IsoDeposits")
293  self.addParameter(self._defaultParameters, 'standardAlgo',
294  "shrinkingCone", "standard algorithm label of the collection from which the clones " \
295  + "for the new tau collection will be taken from " \
296  + "(note that this tau collection has to be available in the event before hand)")
297  self.addParameter(self._defaultParameters, 'standardType',
298  "PFTau", "standard constituent type label of the collection from which the clones " \
299  + " for the new tau collection will be taken from "\
300  + "(note that this tau collection has to be available in the event before hand)")
301 
302  self._parameters=copy.deepcopy(self._defaultParameters)
303  self._comment = ""
304 
306  return self._defaultParameters
307 
308  def __call__(self,process,
309  tauCollection = None,
310  algoLabel = None,
311  typeLabel = None,
312  doPFIsoDeposits = None,
313  standardAlgo = None,
314  standardType = None):
315 
316  if tauCollection is None:
317  tauCollection = self._defaultParameters['tauCollection'].value
318  if algoLabel is None:
319  algoLabel = self._defaultParameters['algoLabel'].value
320  if typeLabel is None:
321  typeLabel = self._defaultParameters['typeLabel'].value
322  if doPFIsoDeposits is None:
323  doPFIsoDeposits = self._defaultParameters['doPFIsoDeposits'].value
324  if standardAlgo is None:
325  standardAlgo = self._defaultParameters['standardAlgo'].value
326  if standardType is None:
327  standardType = self._defaultParameters['standardType'].value
328 
329  self.setParameter('tauCollection', tauCollection)
330  self.setParameter('algoLabel', algoLabel)
331  self.setParameter('typeLabel', typeLabel)
332  self.setParameter('doPFIsoDeposits', doPFIsoDeposits)
333  self.setParameter('standardAlgo', standardAlgo)
334  self.setParameter('standardType', standardType)
335 
336  self.apply(process)
337 
338  def toolCode(self, process):
339  tauCollection = self._parameters['tauCollection'].value
340  algoLabel = self._parameters['algoLabel'].value
341  typeLabel = self._parameters['typeLabel'].value
342  doPFIsoDeposits = self._parameters['doPFIsoDeposits'].value
343  standardAlgo = self._parameters['standardAlgo'].value
344  standardType = self._parameters['standardType'].value
345 
346  ## disable computation of particle-flow based IsoDeposits
347  ## in case tau is of CaloTau type
348  if typeLabel == 'Tau':
349 # print "NO PF Isolation will be computed for CaloTau (this could be improved later)"
350  doPFIsoDeposits = False
351 
352  ## create old module label from standardAlgo
353  ## and standardType and return
354  def oldLabel(prefix = ''):
355  if prefix == '':
356  return "patTaus"
357  else:
358  return prefix + "PatTaus"
359 
360  ## capitalize first character of appended part
361  ## when creating new module label
362  ## (giving e.g. "patTausCaloRecoTau")
363  def capitalize(label):
364  return label[0].capitalize() + label[1:]
365 
366  ## create new module label from old module
367  ## label and return
368  def newLabel(oldLabel):
369  newLabel = oldLabel
370  if ( oldLabel.find(standardAlgo) >= 0 and oldLabel.find(standardType) >= 0 ):
371  oldLabel = oldLabel.replace(standardAlgo, algoLabel).replace(standardType, typeLabel)
372  else:
373  oldLabel = oldLabel + capitalize(algoLabel + typeLabel)
374  return oldLabel
375 
376  ## clone module and add it to the patDefaultSequence
377  def addClone(hook, **replaceStatements):
378  ## create a clone of the hook with corresponding
379  ## parameter replacements
380  newModule = getattr(process, hook).clone(**replaceStatements)
381  ## add the module to the sequence
382  addModuleToSequence(hook, newModule)
383 
384  ## clone module for computing particle-flow IsoDeposits
385  def addPFIsoDepositClone(hook, **replaceStatements):
386  newModule = getattr(process, hook).clone(**replaceStatements)
387  newModuleIsoDepositExtractor = getattr(newModule, "ExtractorPSet")
388  setattr(newModuleIsoDepositExtractor, "tauSource", getattr(newModule, "src"))
389  addModuleToSequence(hook, newModule)
390 
391  ## add module to the patDefaultSequence
392  def addModuleToSequence(hook, newModule):
393  hookModule = getattr(process, hook)
394  ## add the new module with standardAlgo &
395  ## standardType replaced in module label
396  setattr(process, newLabel(hook), newModule)
397  ## add new module to default sequence
398  ## just behind the hookModule
399  process.patDefaultSequence.replace( hookModule, hookModule*newModule )
400 
401  ## add a clone of patTaus
402  addClone(oldLabel(), tauSource = tauCollection)
403 
404  ## add a clone of selectedPatTaus
405  addClone(oldLabel('selected'), src = cms.InputTag(newLabel(oldLabel())))
406 
407  ## add a clone of cleanPatTaus
408  addClone(oldLabel('clean'), src=cms.InputTag(newLabel(oldLabel('selected'))))
409 
410  ## get attributes of new module
411  newTaus = getattr(process, newLabel(oldLabel()))
412 
413  ## add a clone of gen tau matching
414  addClone('tauMatch', src = tauCollection)
415  addClone('tauGenJetMatch', src = tauCollection)
416 
417  ## add a clone of IsoDeposits computed based on particle-flow
418  if doPFIsoDeposits:
419  addPFIsoDepositClone('tauIsoDepositPFCandidates', src = tauCollection)
420  addPFIsoDepositClone('tauIsoDepositPFChargedHadrons', src = tauCollection)
421  addPFIsoDepositClone('tauIsoDepositPFNeutralHadrons', src = tauCollection)
422  addPFIsoDepositClone('tauIsoDepositPFGammas', src = tauCollection)
423 
424  ## fix label for input tag
425  def fixInputTag(x): x.setModuleLabel(newLabel(x.moduleLabel))
426 
427  ## provide patTau inputs with individual labels
428  fixInputTag(newTaus.genParticleMatch)
429  fixInputTag(newTaus.genJetMatch)
430  fixInputTag(newTaus.isoDeposits.pfAllParticles)
431  fixInputTag(newTaus.isoDeposits.pfNeutralHadron)
432  fixInputTag(newTaus.isoDeposits.pfChargedHadron)
433  fixInputTag(newTaus.isoDeposits.pfGamma)
434  fixInputTag(newTaus.userIsolation.pfAllParticles.src)
435  fixInputTag(newTaus.userIsolation.pfNeutralHadron.src)
436  fixInputTag(newTaus.userIsolation.pfChargedHadron.src)
437  fixInputTag(newTaus.userIsolation.pfGamma.src)
438 
439  ## set discriminators
440  ## (using switchTauCollection functions)
441  oldTaus = getattr(process, oldLabel())
442 # if typeLabel == 'Tau':
443 # switchToCaloTau(process,
444 # pfTauLabel = getattr(oldTaus, "tauSource"),
445 # caloTauLabel = getattr(newTaus, "tauSource"),
446 # patTauLabel = capitalize(algoLabel + typeLabel))
447 # else:
448  switchToPFTauByType(process, pfTauType = algoLabel + typeLabel,
449  pfTauLabelNew = getattr(newTaus, "tauSource"),
450  pfTauLabelOld = getattr(oldTaus, "tauSource"),
451  patTauLabel = capitalize(algoLabel + typeLabel))
452 
453 addTauCollection=AddTauCollection()
def switchToPFTauFixedCone
Definition: tauTools.py:203
def replace
Definition: linker.py:10
def cloneProcessingSnippet
Definition: helpers.py:257
def _switchToPFTau
Definition: tauTools.py:121
def redoPFTauDiscriminators
Definition: tauTools.py:12
def switchToCaloTau
Definition: tauTools.py:78
def applyPostfix
Helpers to perform some technically boring tasks like looking for all modules with a given parameter ...
Definition: helpers.py:6
def massSearchReplaceParam
Definition: helpers.py:200
def _buildIDSourcePSet
Definition: tauTools.py:108
def switchToPFTauHPSpTaNC
Definition: tauTools.py:244
def switchToPFTauHPS
Definition: tauTools.py:229
T * clone(const T *tp)
Definition: Ptr.h:42
def switchTo31Xdefaults
Definition: tauTools.py:270
def switchToPFTauShrinkingCone
Definition: tauTools.py:215
def switchToPFTauByType
Definition: tauTools.py:260