CMS 3D CMS Logo

Classes | Functions | Variables
tauTools Namespace Reference

Classes

class  AddTauCollection
 

Functions

def _buildIDSourcePSet (tauType, idSources, postfix="")
 
def _switchToPFTau (process, tauSource, pfTauType, idSources, patTauLabel="", postfix="")
 
def applyPostfix (process, label, postfix)
 
def switchToPFTauByType (process, pfTauType=None, tauSource=cms.InputTag('hpsPFTauProducer'), patTauLabel="", postfix="")
 
def switchToPFTauFixedCone (process, tauSource=cms.InputTag('fixedConePFTauProducer'), patTauLabel="", postfix="")
 
def switchToPFTauHPS (process, tauSource=cms.InputTag('hpsPFTauProducer'), patTauLabel="", jecLevels=[], postfix="")
 
def switchToPFTauShrinkingCone (process, tauSource=cms.InputTag('shrinkingConePFTauProducer'), patTauLabel="", postfix="")
 

Variables

 classicPFTauIDSources
 
 classicTauIDSources
 
 hpsTauIDSources
 

Function Documentation

◆ _buildIDSourcePSet()

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(), and createfilelist.int.

Referenced by _switchToPFTau().

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

◆ _switchToPFTau()

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

◆ applyPostfix()

def tauTools.applyPostfix (   process,
  label,
  postfix 
)

Definition at line 10 of file tauTools.py.

Referenced by _switchToPFTau(), and switchToPFTauHPS().

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

◆ switchToPFTauByType()

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().

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

◆ switchToPFTauFixedCone()

def tauTools.switchToPFTauFixedCone (   process,
  tauSource = cms.InputTag('fixedConePFTauProducer'),
  patTauLabel = "",
  postfix = "" 
)

Definition at line 164 of file tauTools.py.

References _switchToPFTau(), and switchToPFTauShrinkingCone().

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

◆ switchToPFTauHPS()

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().

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

◆ switchToPFTauShrinkingCone()

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().

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

Variable Documentation

◆ classicPFTauIDSources

tauTools.classicPFTauIDSources

Definition at line 73 of file tauTools.py.

◆ classicTauIDSources

tauTools.classicTauIDSources

Definition at line 63 of file tauTools.py.

◆ hpsTauIDSources

tauTools.hpsTauIDSources

Definition at line 81 of file tauTools.py.