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 switchToPFTauShrinkingCone
 

Variables

list classicPFTauIDSources
 
list classicTauIDSources
 
list hpsTauIDSources
 

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 41 of file tauTools.py.

References _switchToPFTau().

Referenced by _switchToPFTau(), and switchToCaloTau().

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
def _buildIDSourcePSet
Definition: tauTools.py:41
def tauTools._switchToPFTau (   process,
  tauSource,
  pfTauType,
  idSources,
  patTauLabel = "",
  postfix = "" 
)
private
internal auxiliary function to switch to **any** PFTau collection

Definition at line 57 of file tauTools.py.

References _buildIDSourcePSet(), and applyPostfix().

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

57 
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  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = _buildIDSourcePSet(pfTauType, idSources, postfix)
76 
77  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
78  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
79  'tauID("leadingTrackFinding") > 0.5 & tauID("leadingPionPtCut") > 0.5 & tauID("byIsolationUsingLeadingPion") > 0.5' \
80  + ' & tauID("againstMuon") > 0.5 & tauID("againstElectron") > 0.5' \
81  + ' & (signalPFChargedHadrCands.size() = 1 | signalPFChargedHadrCands.size() = 3)'
82 
# Name mapping for classic tau ID sources (present for fixed and shrinkingCones)
def applyPostfix
Definition: tauTools.py:8
def _buildIDSourcePSet
Definition: tauTools.py:41
def tauTools.applyPostfix (   process,
  label,
  postfix 
)

Definition at line 8 of file tauTools.py.

References switchToCaloTau().

Referenced by _switchToPFTau(), and switchToCaloTau().

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  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = _buildIDSourcePSet('caloRecoTau', classicTauIDSources, postfix)
29 
30  ## Isolation is somewhat an issue, so we start just by turning it off
31  print "NO PF Isolation will be computed for CaloTau (this could be improved later)"
32  applyPostfix(process, "patTaus" + patTauLabel, postfix).isolation = cms.PSet()
33  applyPostfix(process, "patTaus" + patTauLabel, postfix).isoDeposits = cms.PSet()
34  applyPostfix(process, "patTaus" + patTauLabel, postfix).userIsolation = cms.PSet()
35 
36  ## adapt cleanPatTaus
37  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
38  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
39  'tauID("leadingTrackFinding") > 0.5 & tauID("leadingTrackPtCut") > 0.5' \
40  + ' & 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:41
def tauTools.switchToPFTauByType (   process,
  pfTauType = None,
  tauSource = cms.InputTag('hpsPFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 184 of file tauTools.py.

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

185  postfix = "" ):
186  mapping = {
187  'shrinkingConePFTau' : switchToPFTauShrinkingCone,
188  'fixedConePFTau' : switchToPFTauFixedCone,
189  'hpsPFTau' : switchToPFTauHPS,
190  'caloRecoTau' : switchToCaloTau
191  }
192  if not pfTauType in mapping.keys():
193  raise ValueError("Error in <switchToPFTauByType>: Undefined pfTauType = %s !!" % pfTauType)
194 
195  mapping[pfTauType](process, tauSource = tauSource,
196  patTauLabel = patTauLabel, postfix = postfix)
def tauTools.switchToPFTauFixedCone (   process,
  tauSource = cms.InputTag('fixedConePFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 145 of file tauTools.py.

References _switchToPFTau(), and switchToPFTauShrinkingCone().

146  postfix = ""):
147  fixedConeIDSources = copy.copy(classicTauIDSources)
148  fixedConeIDSources.extend(classicPFTauIDSources)
149 
150  _switchToPFTau(process, tauSource, 'fixedConePFTau', fixedConeIDSources,
151  patTauLabel = patTauLabel, postfix = postfix)
152 
# switch to PFTau collection produced for shrinking signal cone of size dR = 5.0/Et(PFTau)
def _switchToPFTau
Definition: tauTools.py:57
def tauTools.switchToPFTauHPS (   process,
  tauSource = cms.InputTag('hpsPFTauProducer'),
  patTauLabel = "",
  jecLevels = [],
  postfix = "" 
)

Definition at line 168 of file tauTools.py.

References _switchToPFTau(), and switchToPFTauByType().

Referenced by switchToPFTauShrinkingCone().

169  postfix = ""):
170 
171  _switchToPFTau(process, tauSource, 'hpsPFTau', hpsTauIDSources,
172  patTauLabel = patTauLabel, postfix = postfix)
173 
174  ## adapt cleanPatTaus
175  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
176  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
177  'pt > 15 & abs(eta) < 2.3 & tauID("decayModeFinding") > 0.5 & tauID("byLooseIsolation") > 0.5' \
178  + ' & tauID("againstMuonTight") > 0.5 & tauID("againstElectronLoose") > 0.5'
179 
# Select switcher by string
def _switchToPFTau
Definition: tauTools.py:57
def tauTools.switchToPFTauShrinkingCone (   process,
  tauSource = cms.InputTag('shrinkingConePFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 156 of file tauTools.py.

References _switchToPFTau(), and switchToPFTauHPS().

Referenced by switchToPFTauFixedCone().

157  postfix = ""):
158  shrinkingIDSources = copy.copy(classicTauIDSources)
159  shrinkingIDSources.extend(classicPFTauIDSources)
160 
161  _switchToPFTau(process, tauSource, 'shrinkingConePFTau', shrinkingIDSources,
162  patTauLabel = patTauLabel, postfix = postfix)
163 
# switch to hadron-plus-strip(s) (HPS) PFTau collection
def _switchToPFTau
Definition: tauTools.py:57

Variable Documentation

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

Definition at line 92 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") ]

Definition at line 83 of file tauTools.py.

list tauTools.hpsTauIDSources

Definition at line 99 of file tauTools.py.