CMS 3D CMS Logo

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

Classes

class  AddTauCollection
 

Functions

def _buildIDSourcePSet
 
def _switchToPFTau
 
def applyPostfix
 
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 18 of file tauTools.py.

References _switchToPFTau().

Referenced by _switchToPFTau().

18 
19 def _buildIDSourcePSet(tauType, idSources, postfix =""):
20  """ Build a PSet defining the tau ID sources to embed into the pat::Tau """
21  output = cms.PSet()
22  for label, discriminator in idSources:
23  wp = -99
24  if ";" in discriminator: #read from PFTauDiscriminatorContainer
25  discriminator, wp_str = discriminator.split(";")
26  wp = int(wp_str)
27  id = cms.PSet()
28  id.inputTag = cms.InputTag(discriminator.replace(":", postfix + ":"))
29  id.provenanceConfigLabel=cms.string("")
30  id.idLabel=cms.string("")
31  setattr(output, label, id)
32  return output
def _buildIDSourcePSet
Definition: tauTools.py:18
def tauTools._switchToPFTau (   process,
  tauSource,
  pfTauType,
  idSources,
  patTauLabel = "",
  postfix = "" 
)
private
internal auxiliary function to switch to **any** PFTau collection

Definition at line 38 of file tauTools.py.

References _buildIDSourcePSet(), applyPostfix(), and print().

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

38 
39  postfix = ""):
40  """internal auxiliary function to switch to **any** PFTau collection"""
41  print(' switching PAT Tau input to: ', tauSource)
42 
43  applyPostfix(process, "tauMatch" + patTauLabel, postfix).src = tauSource
44  applyPostfix(process, "tauGenJetMatch" + patTauLabel, postfix).src = tauSource
45 
46  applyPostfix(process, "tauIsoDepositPFCandidates" + patTauLabel, postfix).src = tauSource
47  applyPostfix(process, "tauIsoDepositPFCandidates" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
48  applyPostfix(process, "tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).src = tauSource
49  applyPostfix(process, "tauIsoDepositPFChargedHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
50  applyPostfix(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).src = tauSource
51  applyPostfix(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
52  applyPostfix(process, "tauIsoDepositPFGammas" + patTauLabel, postfix).src = tauSource
53  applyPostfix(process, "tauIsoDepositPFGammas" + patTauLabel, postfix).ExtractorPSet.tauSource = tauSource
54 
55  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauSource = tauSource
56  # CV: reconstruction of tau lifetime information not enabled for tau collections other than 'hpsPFTauProducer' yet
57  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = ""
58  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauIDSources = _buildIDSourcePSet(pfTauType, idSources, postfix)
59 
60  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
61  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = preselection
62 
# Name mapping for classic tau ID sources (present for fixed and shrinkingCones)
def applyPostfix
Definition: tauTools.py:10
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def _buildIDSourcePSet
Definition: tauTools.py:18
def tauTools.applyPostfix (   process,
  label,
  postfix 
)

Definition at line 10 of file tauTools.py.

Referenced by _switchToPFTau(), and switchToPFTauHPS().

10 
11 def applyPostfix(process, label, postfix):
12  result = None
13  if hasattr(process, label+postfix):
14  result = getattr(process, label + postfix)
15  else:
16  raise ValueError("Error in <applyPostfix>: No module of name = %s attached to process !!" % (label + postfix))
17  return result
def applyPostfix
Definition: tauTools.py:10
def tauTools.switchToPFTauByType (   process,
  pfTauType = None,
  tauSource = cms.InputTag('hpsPFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 204 of file tauTools.py.

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

205  postfix = "" ):
206  mapping = {
207  'shrinkingConePFTau' : switchToPFTauShrinkingCone,
208  'fixedConePFTau' : switchToPFTauFixedCone,
209  'hpsPFTau' : switchToPFTauHPS
210  }
211  if not pfTauType in mapping.keys():
212  raise ValueError("Error in <switchToPFTauByType>: Undefined pfTauType = %s !!" % pfTauType)
213 
214  mapping[pfTauType](process, tauSource = tauSource,
215  patTauLabel = patTauLabel, postfix = postfix)
def tauTools.switchToPFTauFixedCone (   process,
  tauSource = cms.InputTag('fixedConePFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 164 of file tauTools.py.

References _switchToPFTau(), and switchToPFTauShrinkingCone().

165  postfix = ""):
166  fixedConeIDSources = copy.copy(classicTauIDSources)
167  fixedConeIDSources.extend(classicPFTauIDSources)
168 
169  _switchToPFTau(process, tauSource, 'fixedConePFTau', fixedConeIDSources,
170  patTauLabel = patTauLabel, postfix = postfix)
171 
# switch to PFTau collection produced for shrinking signal cone of size dR = 5.0/Et(PFTau)
def _switchToPFTau
Definition: tauTools.py:38
def tauTools.switchToPFTauHPS (   process,
  tauSource = cms.InputTag('hpsPFTauProducer'),
  patTauLabel = "",
  jecLevels = [],
  postfix = "" 
)

Definition at line 187 of file tauTools.py.

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

Referenced by switchToPFTauShrinkingCone().

188  postfix = ""):
189 
190  _switchToPFTau(process, tauSource, 'hpsPFTau', hpsTauIDSources,
191  patTauLabel = patTauLabel, postfix = postfix)
192 
193  # CV: enable tau lifetime information for HPS PFTaus
194  applyPostfix(process, "patTaus" + patTauLabel, postfix).tauTransverseImpactParameterSource = tauSource.value().replace("Producer", "TransverseImpactParameters")
195 
196  ## adapt cleanPatTaus
197  if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
198  getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = preselection
199 
# Select switcher by string
def applyPostfix
Definition: tauTools.py:10
def _switchToPFTau
Definition: tauTools.py:38
def tauTools.switchToPFTauShrinkingCone (   process,
  tauSource = cms.InputTag('shrinkingConePFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 175 of file tauTools.py.

References _switchToPFTau(), and switchToPFTauHPS().

Referenced by switchToPFTauFixedCone().

176  postfix = ""):
177  shrinkingIDSources = copy.copy(classicTauIDSources)
178  shrinkingIDSources.extend(classicPFTauIDSources)
179 
180  _switchToPFTau(process, tauSource, 'shrinkingConePFTau', shrinkingIDSources,
181  patTauLabel = patTauLabel, postfix = postfix)
182 
# switch to hadron-plus-strip(s) (HPS) PFTau collection
def _switchToPFTau
Definition: tauTools.py:38

Variable Documentation

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

Definition at line 73 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 63 of file tauTools.py.

list tauTools.hpsTauIDSources

Definition at line 81 of file tauTools.py.