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,
22 requireLeadTrackCalo = cms.PSet(
23 BooleanOperator = cms.string(
"and"),
25 Producer = cms.InputTag(
'caloRecoTauDiscriminationByLeadingTrackFinding'),
32 requireLeadPion = cms.PSet(
33 BooleanOperator = cms.string(
"and"),
34 leadPion = leadTrackFinding,
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)
45 recoTauTypeMapperRegex = re.compile(
"(\w*)Producer")
47 return recoTauTypeMapperRegex.match(tauProducer).
group(1)
50 producerIsTauTypeMapper =
lambda tauProducer: tauProducer
53 oldTauTypeMapper=recoTauTypeMapper, newTauTypeMapper=recoTauTypeMapper,
54 preservePFTauProducer =
False):
55 ''' Change a TauDiscriminator to use a different tau/prediscriminant sources 57 Tau discriminators use the following convention: 58 [tauType]DiscriminationByXXX 60 i.e. fixedConePFTauDiscriminationByIsolation, 61 allLayer1TausDiscriminationByIsolation, etc 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 70 shrinkingConePFTauProducer->shrinkingConePFTau 71 * producerIsTauTypeMapper 72 allLayer1Taus->allLayer1Taus 76 oldTauProducer = discriminator.PFTauProducer
77 if isinstance(newTauProducer, str):
78 newTauProducer = cms.InputTag(newTauProducer)
82 if not preservePFTauProducer:
83 discriminator.PFTauProducer = newTauProducer
85 oldTauType = oldTauTypeMapper(oldTauProducer.value())
86 newTauType = newTauTypeMapper(newTauProducer.value())
88 replacementRegex = re.compile(oldTauType)
92 oldProducer = prediscriminant.Producer.value()
95 prediscriminant.Producer = cms.InputTag(replacementRegex.sub(newTauType,
99 def fixer(discriminator):
100 if hasattr(discriminator,
"Prediscriminants"):
102 sequence.visit(fixer)
105 ''' Same as adaptTauDiscriminator, kept for backwards compatibility'''