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

References subParameterSets().

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

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

Definition at line 97 of file TauDiscriminatorTools.py.

References adaptTauDiscriminator().

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

Definition at line 45 of file TauDiscriminatorTools.py.

References edmIntegrityCheck.group.

Referenced by pfTools.reconfigurePF2PATTaus().

45 def recoTauTypeMapper(tauProducer):
46  return recoTauTypeMapperRegex.match(tauProducer).group(1)
47 
48 # 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 103 of file TauDiscriminatorTools.py.

References adaptTauDiscriminator().

103 def setTauSource(discriminator, newTauProducer):
104  ''' Same as adaptTauDiscriminator, kept for backwards compatibility'''
105  adaptTauDiscriminator(discriminator, newTauProducer)
106 
107 
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 36 of file TauDiscriminatorTools.py.

Referenced by adaptTauDiscriminator().

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

Variable Documentation

TauDiscriminatorTools.BooleanOperator

Definition at line 11 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.cut

Definition at line 6 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.leadPion

Definition at line 33 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.leadTrackFinding

Definition at line 4 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.noPrediscriminants

Definition at line 10 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.Producer

Definition at line 5 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.producerIsTauTypeMapper

Definition at line 49 of file TauDiscriminatorTools.py.

Referenced by pfTools.reconfigurePF2PATTaus().

TauDiscriminatorTools.recoTauTypeMapperRegex

Definition at line 44 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.requireLeadPion

Definition at line 31 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.requireLeadTrack

Definition at line 15 of file TauDiscriminatorTools.py.

TauDiscriminatorTools.requireLeadTrackCalo

Definition at line 21 of file TauDiscriminatorTools.py.