CMS 3D CMS Logo

Functions | Variables
TauDiscriminatorTools Namespace Reference

Functions

def adaptTauDiscriminator (discriminator, newTauProducer='shrinkingConePFTauProducer', oldTauTypeMapper=recoTauTypeMapper, newTauTypeMapper=recoTauTypeMapper, preservePFTauProducer=False)
 
def adaptTauDiscriminatorSequence (sequence, kwargs)
 
def recoTauTypeMapper (tauProducer)
 
def setTauSource (discriminator, newTauProducer)
 
def subParameterSets (pSet)
 

Variables

 BooleanOperator
 
 cut
 
 leadPion
 
 leadTrack
 
 leadTrackFinding
 
 noPrediscriminants
 
 Producer
 
 producerIsTauTypeMapper
 
 recoTauTypeMapperRegex
 
 requireLeadPion
 
 requireLeadTrack
 

Function Documentation

◆ adaptTauDiscriminator()

def TauDiscriminatorTools.adaptTauDiscriminator (   discriminator,
  newTauProducer = 'shrinkingConePFTauProducer',
  oldTauTypeMapper = recoTauTypeMapper,
  newTauTypeMapper = recoTauTypeMapper,
  preservePFTauProducer = False 
)
Change a TauDiscriminator to use a different tau/prediscriminant sources

Tau discriminators use the following convention: 
     [tauType]DiscriminationByXXX

i.e. fixedConePFTauDiscriminationByIsolation,
allLayer1TausDiscriminationByIsolation, etc

However, the mapping of tauType to tau producer name is not constant.  In
RECO, the form is [tauType]Producer.  In PAT, the producer is just named
[tauType].  To manage this oldTauTypeMapper and newTauTypeMapper are
functions with signature f(str) that translate a TauProducer name (like
shrinkingConePFTauProducer) to its type (shrinkingConePFTau).  Two types of
mapping are provided, 
     * recoTauTypeMapper
           shrinkingConePFTauProducer->shrinkingConePFTau
     * producerIsTauTypeMapper
           allLayer1Taus->allLayer1Taus

Definition at line 44 of file TauDiscriminatorTools.py.

References subParameterSets().

Referenced by adaptTauDiscriminatorSequence(), pfTools.reconfigurePF2PATTaus(), and setTauSource().

44  preservePFTauProducer = False):
45  ''' Change a TauDiscriminator to use a different tau/prediscriminant sources
46 
47  Tau discriminators use the following convention:
48  [tauType]DiscriminationByXXX
49 
50  i.e. fixedConePFTauDiscriminationByIsolation,
51  allLayer1TausDiscriminationByIsolation, etc
52 
53  However, the mapping of tauType to tau producer name is not constant. In
54  RECO, the form is [tauType]Producer. In PAT, the producer is just named
55  [tauType]. To manage this oldTauTypeMapper and newTauTypeMapper are
56  functions with signature f(str) that translate a TauProducer name (like
57  shrinkingConePFTauProducer) to its type (shrinkingConePFTau). Two types of
58  mapping are provided,
59  * recoTauTypeMapper
60  shrinkingConePFTauProducer->shrinkingConePFTau
61  * producerIsTauTypeMapper
62  allLayer1Taus->allLayer1Taus
63 
64  '''
65 
66  oldTauProducer = discriminator.PFTauProducer
67  if isinstance(newTauProducer, str):
68  newTauProducer = cms.InputTag(newTauProducer)
69 
70  # This is useful for the PF2PAT case where you wish to set the producer name
71  # seperately
72  if not preservePFTauProducer:
73  discriminator.PFTauProducer = newTauProducer
74 
75  oldTauType = oldTauTypeMapper(oldTauProducer.value())
76  newTauType = newTauTypeMapper(newTauProducer.value())
77 
78  replacementRegex = re.compile(oldTauType)
79 
80  # Adapt all the prediscriminants
81  for prediscriminant in subParameterSets(discriminator.Prediscriminants):
82  oldProducer = prediscriminant.Producer.value()
83  # Replace the old tau type by the new tau type in the prediscrimant
84  # producer
85  prediscriminant.Producer = cms.InputTag(replacementRegex.sub(newTauType,
86  oldProducer))
87 

◆ adaptTauDiscriminatorSequence()

def TauDiscriminatorTools.adaptTauDiscriminatorSequence (   sequence,
  kwargs 
)

Definition at line 88 of file TauDiscriminatorTools.py.

References adaptTauDiscriminator().

88 def adaptTauDiscriminatorSequence(sequence, **kwargs):
89  def fixer(discriminator):
90  if hasattr(discriminator, "Prediscriminants"):
91  adaptTauDiscriminator(discriminator, **kwargs)
92  sequence.visit(fixer)
93 
def adaptTauDiscriminatorSequence(sequence, kwargs)
def adaptTauDiscriminator(discriminator, newTauProducer='shrinkingConePFTauProducer', oldTauTypeMapper=recoTauTypeMapper, newTauTypeMapper=recoTauTypeMapper, preservePFTauProducer=False)

◆ recoTauTypeMapper()

def TauDiscriminatorTools.recoTauTypeMapper (   tauProducer)

Definition at line 36 of file TauDiscriminatorTools.py.

References watchdog.group.

Referenced by pfTools.reconfigurePF2PATTaus().

36 def recoTauTypeMapper(tauProducer):
37  return recoTauTypeMapperRegex.match(tauProducer).group(1)
38 
39 # For taus where the producer name is the type, like "allLayer1Taus", etc
def recoTauTypeMapper(tauProducer)

◆ setTauSource()

def TauDiscriminatorTools.setTauSource (   discriminator,
  newTauProducer 
)
Same as adaptTauDiscriminator, kept for backwards compatibility

Definition at line 94 of file TauDiscriminatorTools.py.

References adaptTauDiscriminator().

94 def setTauSource(discriminator, newTauProducer):
95  ''' Same as adaptTauDiscriminator, kept for backwards compatibility'''
96  adaptTauDiscriminator(discriminator, newTauProducer)
97 
98 
def setTauSource(discriminator, newTauProducer)
def adaptTauDiscriminator(discriminator, newTauProducer='shrinkingConePFTauProducer', oldTauTypeMapper=recoTauTypeMapper, newTauTypeMapper=recoTauTypeMapper, preservePFTauProducer=False)

◆ subParameterSets()

def TauDiscriminatorTools.subParameterSets (   pSet)
Generator to return all sub-PSets in a PSet 

Definition at line 27 of file TauDiscriminatorTools.py.

References mps_monitormerge.items.

Referenced by adaptTauDiscriminator().

27 def subParameterSets(pSet):
28  ''' Generator to return all sub-PSets in a PSet '''
29  for name, value in pSet.parameters_().items():
30  if isinstance(value, cms.PSet):
31  yield getattr(pSet, name)
32 
33 # For RECO type taus, where the tau producer is [tauType]Producer

Variable Documentation

◆ BooleanOperator

TauDiscriminatorTools.BooleanOperator

Definition at line 11 of file TauDiscriminatorTools.py.

◆ cut

TauDiscriminatorTools.cut

Definition at line 6 of file TauDiscriminatorTools.py.

◆ leadPion

TauDiscriminatorTools.leadPion

Definition at line 24 of file TauDiscriminatorTools.py.

◆ leadTrack

TauDiscriminatorTools.leadTrack

Definition at line 17 of file TauDiscriminatorTools.py.

◆ leadTrackFinding

TauDiscriminatorTools.leadTrackFinding

Definition at line 4 of file TauDiscriminatorTools.py.

◆ noPrediscriminants

TauDiscriminatorTools.noPrediscriminants

Definition at line 10 of file TauDiscriminatorTools.py.

◆ Producer

TauDiscriminatorTools.Producer

Definition at line 5 of file TauDiscriminatorTools.py.

◆ producerIsTauTypeMapper

TauDiscriminatorTools.producerIsTauTypeMapper

Definition at line 40 of file TauDiscriminatorTools.py.

Referenced by pfTools.reconfigurePF2PATTaus().

◆ recoTauTypeMapperRegex

TauDiscriminatorTools.recoTauTypeMapperRegex

Definition at line 35 of file TauDiscriminatorTools.py.

◆ requireLeadPion

TauDiscriminatorTools.requireLeadPion

Definition at line 22 of file TauDiscriminatorTools.py.

◆ requireLeadTrack

TauDiscriminatorTools.requireLeadTrack

Definition at line 15 of file TauDiscriminatorTools.py.