CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
tauTools Namespace Reference

Classes

class  AddTauCollection
 

Functions

def _buildIDSourcePSet
 
def _switchToPFTau
 
def applyPostfix
 
def switchToCaloTau
 
def switchToPFTauByType
 
def switchToPFTauFixedCone
 
def switchToPFTauHPS
 
def switchToPFTauHPS76xReMiniAOD
 
def switchToPFTauShrinkingCone
 

Variables

list classicPFTauIDSources
 
list classicTauIDSources
 
list hpsTauIDSources
 
list hpsTauIDSources76xReMiniAOD
 

Function Documentation

def tauTools._buildIDSourcePSet (   tauType,
  idSources,
  postfix = "" 
)
private
Build a PSet defining the tau ID sources to embed into the pat::Tau 

Definition at line 43 of file tauTools.py.

References _switchToPFTau().

Referenced by _switchToPFTau(), and switchToCaloTau().

43 
44 def _buildIDSourcePSet(tauType, idSources, postfix =""):
45  """ Build a PSet defining the tau ID sources to embed into the pat::Tau """
46  output = cms.PSet()
47  for label, discriminator in idSources:
48  if ":" in discriminator:
49  discr = discriminator.split(":")
50  setattr(output, label, cms.InputTag(tauType + discr[0] + postfix + ":" + discr[1]))
51  else:
52  setattr(output, label, cms.InputTag(tauType + discriminator + postfix))
53  return output
def _buildIDSourcePSet
Definition: tauTools.py:43
def tauTools._switchToPFTau (   process,
  tauSource,
  pfTauType,
  idSources,
  patTauLabel = "",
  postfix = "" 
)
private
internal auxiliary function to switch to **any** PFTau collection

Definition at line 59 of file tauTools.py.

References _buildIDSourcePSet(), and applyPostfix().

Referenced by _buildIDSourcePSet(), switchToPFTauFixedCone(), switchToPFTauHPS(), switchToPFTauHPS76xReMiniAOD(), and switchToPFTauShrinkingCone().

59 
60  postfix = ""):
61  """internal auxiliary function to switch to **any** PFTau collection"""
62  print ' switching PAT Tau input to: ', tauSource
63 
64  applyPostfix(process, "tauMatch" + patTauLabel, postfix).src = tauSource
65  applyPostfix(process, "tauGenJetMatch" + patTauLabel, postfix).src = tauSource
66 
67  applyPostfix(process, "tauIsoDepositPFCandidates" + patTauLabel, postfix).src = tauSource
68  applyPostfix(process, "tauIsoDepositPFCandidates" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
69  applyPostfix(process, "tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).src = tauSource
70  applyPostfix(process, "tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
71  applyPostfix(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).src = tauSource
72  applyPostfix(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
73  applyPostfix(process, "tauIsoDepositPFGammas" + patTauLabel, postfix).src = tauSource
74  applyPostfix(process, "tauIsoDepositPFGammas" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
75 
76  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauSource = tauSource
77  # CV: reconstruction of tau lifetime information not enabled for tau collections other than 'hpsPFTauProducer' yet
78  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = ""
79  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = _buildIDSourcePSet(pfTauType, idSources, postfix)
80 
81  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
82  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
83  'tauID("leadingTrackFinding") > 0.5 & tauID("leadingPionPtCut") > 0.5 & tauID("byIsolationUsingLeadingPion") > 0.5' \
84  + ' & tauID("againstMuon") > 0.5 & tauID("againstElectron") > 0.5' \
85  + ' & (signalPFChargedHadrCands.size() = 1 | signalPFChargedHadrCands.size() = 3)'
86 
# Name mapping for classic tau ID sources (present for fixed and shrinkingCones)
def applyPostfix
Definition: tauTools.py:8
def _buildIDSourcePSet
Definition: tauTools.py:43
def tauTools.applyPostfix (   process,
  label,
  postfix 
)

Definition at line 8 of file tauTools.py.

References switchToCaloTau().

Referenced by _switchToPFTau(), switchToCaloTau(), switchToPFTauHPS(), and switchToPFTauHPS76xReMiniAOD().

8 
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 
# switch to CaloTau collection
def applyPostfix
Definition: tauTools.py:8
def tauTools.switchToCaloTau (   process,
  tauSource = cms.InputTag('caloRecoTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 20 of file tauTools.py.

References _buildIDSourcePSet(), and applyPostfix().

Referenced by applyPostfix(), and tauTools.AddTauCollection.toolCode().

20 
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 = \
41  'tauID("leadingTrackFinding") > 0.5 & tauID("leadingTrackPtCut") > 0.5' \
42  + ' & tauID("byIsolation") > 0.5 & tauID("againstElectron") > 0.5 & (signalTracks.size() = 1 | signalTracks.size() = 3)'
def applyPostfix
Definition: tauTools.py:8
def _buildIDSourcePSet
Definition: tauTools.py:43
def tauTools.switchToPFTauByType (   process,
  pfTauType = None,
  tauSource = cms.InputTag('hpsPFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 351 of file tauTools.py.

Referenced by pfTools.adaptPFTaus(), switchToPFTauHPS76xReMiniAOD(), and tauTools.AddTauCollection.toolCode().

352  postfix = "" ):
353  mapping = {
354  'shrinkingConePFTau' : switchToPFTauShrinkingCone,
355  'fixedConePFTau' : switchToPFTauFixedCone,
356  'hpsPFTau' : switchToPFTauHPS,
357  'caloRecoTau' : switchToCaloTau
358  }
359  if not pfTauType in mapping.keys():
360  raise ValueError("Error in <switchToPFTauByType>: Undefined pfTauType = %s !!" % pfTauType)
361 
362  mapping[pfTauType](process, tauSource = tauSource,
363  patTauLabel = patTauLabel, postfix = postfix)
def tauTools.switchToPFTauFixedCone (   process,
  tauSource = cms.InputTag('fixedConePFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 286 of file tauTools.py.

References _switchToPFTau(), and switchToPFTauShrinkingCone().

287  postfix = ""):
288  fixedConeIDSources = copy.copy(classicTauIDSources)
289  fixedConeIDSources.extend(classicPFTauIDSources)
290 
291  _switchToPFTau(process, tauSource, 'fixedConePFTau', fixedConeIDSources,
292  patTauLabel = patTauLabel, postfix = postfix)
293 
# switch to PFTau collection produced for shrinking signal cone of size dR = 5.0/Et(PFTau)
def _switchToPFTau
Definition: tauTools.py:59
def tauTools.switchToPFTauHPS (   process,
  tauSource = cms.InputTag('hpsPFTauProducer'),
  patTauLabel = "",
  jecLevels = [],
  postfix = "" 
)

Definition at line 309 of file tauTools.py.

References _switchToPFTau(), applyPostfix(), python.rootplot.root2matplotlib.replace(), and switchToPFTauHPS76xReMiniAOD().

Referenced by switchToPFTauShrinkingCone().

310  postfix = ""):
311 
312  _switchToPFTau(process, tauSource, 'hpsPFTau', hpsTauIDSources,
313  patTauLabel = patTauLabel, postfix = postfix)
314 
315  # CV: enable tau lifetime information for HPS PFTaus
316  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = tauSource.value().replace("Producer", "TransverseImpactParameters")
317 
318  ## adapt cleanPatTaus
319  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
320  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
321  'pt > 18 & abs(eta) < 2.3 & tauID("decayModeFinding") > 0.5 & tauID("byLooseCombinedIsolationDeltaBetaCorr3Hits") > 0.5' \
322  + ' & tauID("againstMuonTight3") > 0.5 & tauID("againstElectronVLooseMVA5") > 0.5'
323 
324 #--------------------------------------------------------------------------------
325 # CV: function called by PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py
# to add old and new tau ID discriminators for CMSSW 7_6_x reminiAOD v2
def applyPostfix
Definition: tauTools.py:8
def _switchToPFTau
Definition: tauTools.py:59
def tauTools.switchToPFTauHPS76xReMiniAOD (   process,
  tauSource = cms.InputTag('hpsPFTauProducer76xReMiniAOD'),
  patTauLabel = "",
  jecLevels = [],
  postfix = "" 
)

Definition at line 330 of file tauTools.py.

References _switchToPFTau(), applyPostfix(), python.rootplot.root2matplotlib.replace(), and switchToPFTauByType().

Referenced by miniAOD_tools.miniAOD_customizeCommon(), and switchToPFTauHPS().

331  postfix = ""):
332 
333  _switchToPFTau(process, tauSource, 'hpsPFTau', hpsTauIDSources76xReMiniAOD,
334  patTauLabel = patTauLabel, postfix = postfix)
335 
336  # CV: enable tau lifetime information for HPS PFTaus
337  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = tauSource.value().replace("Producer", "TransverseImpactParameters")
338 
339  ## adapt cleanPatTaus
340  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
341  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
342  'pt > 18 & abs(eta) < 2.3 & tauID("decayModeFinding") > 0.5 & tauID("byLooseCombinedIsolationDeltaBetaCorr3Hits") > 0.5' \
343  + ' & tauID("againstMuonTight3") > 0.5 & tauID("againstElectronVLooseMVA6") > 0.5'
344 #--------------------------------------------------------------------------------
345 
346 
# Select switcher by string
def applyPostfix
Definition: tauTools.py:8
def _switchToPFTau
Definition: tauTools.py:59
def tauTools.switchToPFTauShrinkingCone (   process,
  tauSource = cms.InputTag('shrinkingConePFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 297 of file tauTools.py.

References _switchToPFTau(), and switchToPFTauHPS().

Referenced by switchToPFTauFixedCone().

298  postfix = ""):
299  shrinkingIDSources = copy.copy(classicTauIDSources)
300  shrinkingIDSources.extend(classicPFTauIDSources)
301 
302  _switchToPFTau(process, tauSource, 'shrinkingConePFTau', shrinkingIDSources,
303  patTauLabel = patTauLabel, postfix = postfix)
304 
# switch to hadron-plus-strip(s) (HPS) PFTau collection
def _switchToPFTau
Definition: tauTools.py:59

Variable Documentation

list tauTools.classicPFTauIDSources
Initial value:
1 = [
2  ("leadingPionPtCut", "DiscriminationByLeadingPionPtCut"),
3  ("trackIsolationUsingLeadingPion", "DiscriminationByTrackIsolationUsingLeadingPion"),
4  ("ecalIsolationUsingLeadingPion", "DiscriminationByECALIsolationUsingLeadingPion"),
5  ("byIsolationUsingLeadingPion", "DiscriminationByIsolationUsingLeadingPion")
6 ]

Definition at line 97 of file tauTools.py.

list tauTools.classicTauIDSources
Initial value:
1 = [
2  ("leadingTrackFinding", "DiscriminationByLeadingTrackFinding"),
3  ("leadingTrackPtCut", "DiscriminationByLeadingTrackPtCut"),
4  ("trackIsolation", "DiscriminationByTrackIsolation"),
5  ("ecalIsolation", "DiscriminationByECALIsolation"),
6  ("byIsolation", "DiscriminationByIsolation"),
7  ("againstElectron", "DiscriminationAgainstElectron"),
8  ("againstMuon", "DiscriminationAgainstMuon")
9 ]

Definition at line 87 of file tauTools.py.

list tauTools.hpsTauIDSources

Definition at line 105 of file tauTools.py.

list tauTools.hpsTauIDSources76xReMiniAOD

Definition at line 178 of file tauTools.py.