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 43 of file TauDiscriminatorTools.py.

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

References subParameterSets().

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

◆ adaptTauDiscriminatorSequence()

def TauDiscriminatorTools.adaptTauDiscriminatorSequence (   sequence,
**  kwargs 
)

Definition at line 89 of file TauDiscriminatorTools.py.

89 def adaptTauDiscriminatorSequence(sequence, **kwargs):
90  def fixer(discriminator):
91  if hasattr(discriminator, "Prediscriminants"):
92  adaptTauDiscriminator(discriminator, **kwargs)
93  sequence.visit(fixer)
94 

References adaptTauDiscriminator().

◆ recoTauTypeMapper()

def TauDiscriminatorTools.recoTauTypeMapper (   tauProducer)

Definition at line 37 of file TauDiscriminatorTools.py.

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

References watchdog.group.

Referenced by pfTools.reconfigurePF2PATTaus().

◆ setTauSource()

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

Definition at line 95 of file TauDiscriminatorTools.py.

95 def setTauSource(discriminator, newTauProducer):
96  ''' Same as adaptTauDiscriminator, kept for backwards compatibility'''
97  adaptTauDiscriminator(discriminator, newTauProducer)
98 

References adaptTauDiscriminator().

◆ subParameterSets()

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

Definition at line 28 of file TauDiscriminatorTools.py.

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

Referenced by adaptTauDiscriminator().

Variable Documentation

◆ BooleanOperator

TauDiscriminatorTools.BooleanOperator

Definition at line 12 of file TauDiscriminatorTools.py.

◆ cut

TauDiscriminatorTools.cut

Definition at line 7 of file TauDiscriminatorTools.py.

◆ leadPion

TauDiscriminatorTools.leadPion

Definition at line 25 of file TauDiscriminatorTools.py.

◆ leadTrack

TauDiscriminatorTools.leadTrack

Definition at line 18 of file TauDiscriminatorTools.py.

◆ leadTrackFinding

TauDiscriminatorTools.leadTrackFinding

Definition at line 5 of file TauDiscriminatorTools.py.

◆ noPrediscriminants

TauDiscriminatorTools.noPrediscriminants

Definition at line 11 of file TauDiscriminatorTools.py.

◆ Producer

TauDiscriminatorTools.Producer

Definition at line 6 of file TauDiscriminatorTools.py.

◆ producerIsTauTypeMapper

TauDiscriminatorTools.producerIsTauTypeMapper

Definition at line 41 of file TauDiscriminatorTools.py.

Referenced by pfTools.reconfigurePF2PATTaus().

◆ recoTauTypeMapperRegex

TauDiscriminatorTools.recoTauTypeMapperRegex

Definition at line 36 of file TauDiscriminatorTools.py.

◆ requireLeadPion

TauDiscriminatorTools.requireLeadPion

Definition at line 23 of file TauDiscriminatorTools.py.

◆ requireLeadTrack

TauDiscriminatorTools.requireLeadTrack

Definition at line 16 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.adaptTauDiscriminator
def adaptTauDiscriminator(discriminator, newTauProducer='shrinkingConePFTauProducer', oldTauTypeMapper=recoTauTypeMapper, newTauTypeMapper=recoTauTypeMapper, preservePFTauProducer=False)
Definition: TauDiscriminatorTools.py:43
TauDiscriminatorTools.setTauSource
def setTauSource(discriminator, newTauProducer)
Definition: TauDiscriminatorTools.py:95
TauDiscriminatorTools.recoTauTypeMapper
def recoTauTypeMapper(tauProducer)
Definition: TauDiscriminatorTools.py:37
TauDiscriminatorTools.adaptTauDiscriminatorSequence
def adaptTauDiscriminatorSequence(sequence, **kwargs)
Definition: TauDiscriminatorTools.py:89
TauDiscriminatorTools.subParameterSets
def subParameterSets(pSet)
Definition: TauDiscriminatorTools.py:28
watchdog.group
group
Definition: watchdog.py:82