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,
21 requireLeadTrackCalo = cms.PSet(
22 BooleanOperator = cms.string(
"and"),
24 Producer = cms.InputTag(
'caloRecoTauDiscriminationByLeadingTrackFinding'),
31 requireLeadPion = cms.PSet(
32 BooleanOperator = cms.string(
"and"),
33 leadPion = leadTrackFinding,
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)
44 recoTauTypeMapperRegex = re.compile(
"(\w*)Producer")
46 return recoTauTypeMapperRegex.match(tauProducer).
group(1)
49 producerIsTauTypeMapper =
lambda tauProducer: tauProducer
52 oldTauTypeMapper=recoTauTypeMapper, newTauTypeMapper=recoTauTypeMapper,
53 preservePFTauProducer =
False):
54 ''' Change a TauDiscriminator to use a different tau/prediscriminant sources
56 Tau discriminators use the following convention:
57 [tauType]DiscriminationByXXX
59 i.e. fixedConePFTauDiscriminationByIsolation,
60 allLayer1TausDiscriminationByIsolation, etc
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
69 shrinkingConePFTauProducer->shrinkingConePFTau
70 * producerIsTauTypeMapper
71 allLayer1Taus->allLayer1Taus
75 oldTauProducer = discriminator.PFTauProducer
76 if isinstance(newTauProducer, str):
77 newTauProducer = cms.InputTag(newTauProducer)
81 if not preservePFTauProducer:
82 discriminator.PFTauProducer = newTauProducer
84 oldTauType = oldTauTypeMapper(oldTauProducer.value())
85 newTauType = newTauTypeMapper(newTauProducer.value())
87 replacementRegex = re.compile(oldTauType)
91 oldProducer = prediscriminant.Producer.value()
94 prediscriminant.Producer = cms.InputTag(replacementRegex.sub(newTauType,
98 def fixer(discriminator):
99 if hasattr(discriminator,
"Prediscriminants"):
101 sequence.visit(fixer)
104 ''' Same as adaptTauDiscriminator, kept for backwards compatibility'''