1 import FWCore.ParameterSet.Config
as cms
4 leadTrackFinding = cms.PSet(
5 Producer = cms.InputTag(
'pfRecoTauDiscriminationByLeadingTrackFinding'),
10 noPrediscriminants = cms.PSet(
11 BooleanOperator = cms.string(
"and"),
15 requireLeadTrack = cms.PSet(
16 BooleanOperator = cms.string(
"and"),
17 leadTrack = leadTrackFinding,
22 requireLeadPion = cms.PSet(
23 BooleanOperator = cms.string(
"and"),
24 leadPion = leadTrackFinding,
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)
35 recoTauTypeMapperRegex = re.compile(
"(\w*)Producer")
37 return recoTauTypeMapperRegex.match(tauProducer).
group(1)
40 producerIsTauTypeMapper =
lambda tauProducer: tauProducer
43 oldTauTypeMapper=recoTauTypeMapper, newTauTypeMapper=recoTauTypeMapper,
44 preservePFTauProducer = False):
45 ''' Change a TauDiscriminator to use a different tau/prediscriminant sources
47 Tau discriminators use the following convention:
48 [tauType]DiscriminationByXXX
50 i.e. fixedConePFTauDiscriminationByIsolation,
51 allLayer1TausDiscriminationByIsolation, etc
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
60 shrinkingConePFTauProducer->shrinkingConePFTau
61 * producerIsTauTypeMapper
62 allLayer1Taus->allLayer1Taus
66 oldTauProducer = discriminator.PFTauProducer
67 if isinstance(newTauProducer, str):
68 newTauProducer = cms.InputTag(newTauProducer)
72 if not preservePFTauProducer:
73 discriminator.PFTauProducer = newTauProducer
75 oldTauType = oldTauTypeMapper(oldTauProducer.value())
76 newTauType = newTauTypeMapper(newTauProducer.value())
78 replacementRegex = re.compile(oldTauType)
82 oldProducer = prediscriminant.Producer.value()
85 prediscriminant.Producer = cms.InputTag(replacementRegex.sub(newTauType,
89 def fixer(discriminator):
90 if hasattr(discriminator,
"Prediscriminants"):
95 ''' Same as adaptTauDiscriminator, kept for backwards compatibility'''