1 import FWCore.ParameterSet.Config
as cms
5 leadTrackFinding = cms.PSet(
6 Producer = cms.InputTag(
'pfRecoTauDiscriminationByLeadingTrackFinding'),
11 noPrediscriminants = cms.PSet(
12 BooleanOperator = cms.string(
"and"),
16 requireLeadTrack = cms.PSet(
17 BooleanOperator = cms.string(
"and"),
18 leadTrack = leadTrackFinding,
23 requireLeadPion = cms.PSet(
24 BooleanOperator = cms.string(
"and"),
25 leadPion = leadTrackFinding,
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)
36 recoTauTypeMapperRegex = re.compile(
"(\w*)Producer")
38 return recoTauTypeMapperRegex.match(tauProducer).
group(1)
41 producerIsTauTypeMapper =
lambda tauProducer: tauProducer
44 oldTauTypeMapper=recoTauTypeMapper, newTauTypeMapper=recoTauTypeMapper,
45 preservePFTauProducer = False):
46 ''' Change a TauDiscriminator to use a different tau/prediscriminant sources
48 Tau discriminators use the following convention:
49 [tauType]DiscriminationByXXX
51 i.e. fixedConePFTauDiscriminationByIsolation,
52 allLayer1TausDiscriminationByIsolation, etc
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
61 shrinkingConePFTauProducer->shrinkingConePFTau
62 * producerIsTauTypeMapper
63 allLayer1Taus->allLayer1Taus
67 oldTauProducer = discriminator.PFTauProducer
68 if isinstance(newTauProducer, str):
69 newTauProducer = cms.InputTag(newTauProducer)
73 if not preservePFTauProducer:
74 discriminator.PFTauProducer = newTauProducer
76 oldTauType = oldTauTypeMapper(oldTauProducer.value())
77 newTauType = newTauTypeMapper(newTauProducer.value())
79 replacementRegex = re.compile(oldTauType)
83 oldProducer = prediscriminant.Producer.value()
86 prediscriminant.Producer = cms.InputTag(replacementRegex.sub(newTauType,
90 def fixer(discriminator):
91 if hasattr(discriminator,
"Prediscriminants"):
96 ''' Same as adaptTauDiscriminator, kept for backwards compatibility'''