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
 
 requireLeadTrackCalo
 

Function Documentation

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

References subParameterSets().

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

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

Definition at line 98 of file TauDiscriminatorTools.py.

References adaptTauDiscriminator().

98 def adaptTauDiscriminatorSequence(sequence, **kwargs):
99  def fixer(discriminator):
100  if hasattr(discriminator, "Prediscriminants"):
101  adaptTauDiscriminator(discriminator, **kwargs)
102  sequence.visit(fixer)
103 
def adaptTauDiscriminatorSequence(sequence, kwargs)
def adaptTauDiscriminator(discriminator, newTauProducer='shrinkingConePFTauProducer', oldTauTypeMapper=recoTauTypeMapper, newTauTypeMapper=recoTauTypeMapper, preservePFTauProducer=False)
def TauDiscriminatorTools.recoTauTypeMapper (   tauProducer)

Definition at line 46 of file TauDiscriminatorTools.py.

References edmIntegrityCheck.group.

Referenced by pfTools.reconfigurePF2PATTaus().

46 def recoTauTypeMapper(tauProducer):
47  return recoTauTypeMapperRegex.match(tauProducer).group(1)
48 
49 # For taus where the producer name is the type, like "allLayer1Taus", etc
def recoTauTypeMapper(tauProducer)
def TauDiscriminatorTools.setTauSource (   discriminator,
  newTauProducer 
)
Same as adaptTauDiscriminator, kept for backwards compatibility

Definition at line 104 of file TauDiscriminatorTools.py.

References adaptTauDiscriminator().

104 def setTauSource(discriminator, newTauProducer):
105  ''' Same as adaptTauDiscriminator, kept for backwards compatibility'''
106  adaptTauDiscriminator(discriminator, newTauProducer)
107 
108 
def setTauSource(discriminator, newTauProducer)
def adaptTauDiscriminator(discriminator, newTauProducer='shrinkingConePFTauProducer', oldTauTypeMapper=recoTauTypeMapper, newTauTypeMapper=recoTauTypeMapper, preservePFTauProducer=False)
def TauDiscriminatorTools.subParameterSets (   pSet)
Generator to return all sub-PSets in a PSet 

Definition at line 37 of file TauDiscriminatorTools.py.

Referenced by adaptTauDiscriminator().

37 def subParameterSets(pSet):
38  ''' Generator to return all sub-PSets in a PSet '''
39  for name, value in six.iteritems(pSet.parameters_()):
40  if isinstance(value, cms.PSet):
41  yield getattr(pSet, name)
42 
43 # For RECO type taus, where the tau producer is [tauType]Producer

Variable Documentation

TauDiscriminatorTools.BooleanOperator

Definition at line 12 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.cut

Definition at line 7 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.leadPion

Definition at line 34 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.leadTrackFinding

Definition at line 5 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.noPrediscriminants

Definition at line 11 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.Producer

Definition at line 6 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.producerIsTauTypeMapper

Definition at line 50 of file TauDiscriminatorTools.py.

Referenced by pfTools.reconfigurePF2PATTaus().

TauDiscriminatorTools.recoTauTypeMapperRegex

Definition at line 45 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.requireLeadPion

Definition at line 32 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.requireLeadTrack

Definition at line 16 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.requireLeadTrackCalo