def reconfigurePF2PATTaus(process, tauType='shrinkingConePFTau', pf2patSelection=["DiscriminationByIsolation", "DiscriminationByLeadingPionPtCut"], selectionDependsOn=["DiscriminationByLeadingTrackFinding"], producerFromType=lambda producer: producer+"Producer", postfix = ""): print "patTaus will be produced from taus of type: %s that pass %s" \ % (tauType, pf2patSelection) # Get the prototype of tau producer to make, i.e. fixedConePFTauProducer producerName = producerFromType(tauType) # Set as the source for the pf2pat taus (pfTaus) selector applyPostfix(process,"pfTaus", postfix).src = producerName+postfix # Start our pf2pat taus base sequence oldTauSansRefs = getattr(process,'pfTausProducerSansRefs'+postfix) oldTau = getattr(process,'pfTausProducer'+postfix) ## copy tau and setup it properly newTauSansRefs = None newTau = getattr(process,producerName+postfix).clone() ## adapted to new structure in RecoTauProducers PLEASE CHECK!!! if tauType=='shrinkingConePFTau': newTauSansRefs = getattr(process,producerName+"SansRefs").clone() newTauSansRefs.modifiers[1] = cms.PSet( pfTauTagInfoSrc = cms.InputTag("pfTauTagInfoProducer"+postfix), name = cms.string('pfTauTTIworkaround'+postfix), plugin = cms.string('RecoTauTagInfoWorkaroundModifer') ) newTau.modifiers[1] = newTauSansRefs.modifiers[1] newTauSansRefs.piZeroSrc = "pfJetsLegacyTaNCPiZeros"+postfix newTau.piZeroSrc = newTauSansRefs.piZeroSrc newTauSansRefs.builders[0].pfCandSrc = oldTauSansRefs.builders[0].pfCandSrc newTauSansRefs.jetRegionSrc = oldTauSansRefs.jetRegionSrc newTauSansRefs.jetSrc = oldTauSansRefs.jetSrc elif tauType=='fixedConePFTau': newTau.piZeroSrc = "pfJetsLegacyTaNCPiZeros"+postfix elif tauType=='hpsPFTau': newTau = getattr(process,'combinatoricRecoTaus'+postfix).clone() newTau.piZeroSrc="pfJetsLegacyHPSPiZeros"+postfix newTau.modifiers[3] = cms.PSet( pfTauTagInfoSrc = cms.InputTag("pfTauTagInfoProducer"+postfix), name = cms.string('pfTauTTIworkaround'+postfix), plugin = cms.string('RecoTauTagInfoWorkaroundModifer') ) from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet #cloneProcessingSnippet(process, process.produceHPSPFTaus, postfix) setattr(process,'produceHPSPFTaus'+postfix,cms.Sequence(applyPostfix(process,'hpsSelectionDiscriminator',postfix)+applyPostfix(process,'hpsPFTauProducerSansRefs',postfix)+applyPostfix(process,'hpsPFTauProducer',postfix))) massSearchReplaceParam(getattr(process,"produceHPSPFTaus"+postfix), "PFTauProducer", cms.InputTag("combinatoricRecoTaus"+postfix), cms.InputTag("pfTausBase"+postfix) ) massSearchReplaceParam(getattr(process,"produceHPSPFTaus"+postfix), "src", cms.InputTag("combinatoricRecoTaus"+postfix), cms.InputTag("pfTausBase"+postfix) ) ### Next three lines crash, oldTau does not have any of these attributes. Why?### #newTau.builders[0].pfCandSrc = oldTau.builders[0].pfCandSrc #newTau.jetRegionSrc = oldTau.jetRegionSrc #newTau.jetSrc = oldTau.jetSrc #newTau.builders[0].pfCandSrc = cms.InputTag("pfNoElectronJMEPFlow") #newTau.jetRegionSrc = cms.InputTag("pfTauPFJets08RegionPFlow") #newTau.jetSrc = cms.InputTag("pfJetsPFlow") # replace old tau producer by new one put it into baseSequence setattr(process,"pfTausBase"+postfix,newTau) if tauType=='shrinkingConePFTau': setattr(process,"pfTausBaseSansRefs"+postfix,newTauSansRefs) getattr(process,"pfTausBase"+postfix).src = "pfTausBaseSansRefs"+postfix baseSequence += getattr(process,"pfTausBaseSansRefs"+postfix) #make custom mapper to take postfix into account (could have gone with lambda of lambda but... ) def producerIsTauTypeMapperWithPostfix(tauProducer): return lambda x: producerIsTauTypeMapper(tauProducer)+x.group(1)+postfix def recoTauTypeMapperWithGroup(tauProducer): return "%s(.*)"%recoTauTypeMapper(tauProducer) # Get our prediscriminants for predisc in selectionDependsOn: # Get the prototype originalName = tauType+predisc # i.e. fixedConePFTauProducerDiscriminationByLeadingTrackFinding clonedName = "pfTausBase"+predisc+postfix clonedDisc = getattr(process, originalName).clone() setattr(process, clonedName, clonedDisc) tauCollectionToSelect = None if tauType != 'hpsPFTau' : tauCollectionToSelect = "pfTausBase"+postfix #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix) else: tauCollectionToSelect = "hpsPFTauProducer"+postfix # Adapt this discriminator for the cloned prediscriminators adaptTauDiscriminator(clonedDisc, newTauProducer="pfTausBase", oldTauTypeMapper=recoTauTypeMapperWithGroup, newTauTypeMapper=producerIsTauTypeMapperWithPostfix, preservePFTauProducer=True) clonedDisc.PFTauProducer = tauCollectionToSelect # Reconfigure the pf2pat PFTau selector discrimination sources getattr(process,"pfTaus" + postfix).discriminators = cms.VPSet() for selection in pf2patSelection: # Get our discriminator that will be used to select pfTaus originalName = tauType+selection clonedName = "pfTausBase"+selection+postfix clonedDisc = getattr(process, originalName).clone() setattr(process, clonedName, clonedDisc) tauCollectionToSelect = None if tauType != 'hpsPFTau' : tauCollectionToSelect = cms.InputTag("pfTausBase"+postfix) #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix) else: tauCollectionToSelect = cms.InputTag("hpsPFTauProducer"+postfix) #Adapt our cloned discriminator to the new prediscriminants adaptTauDiscriminator(clonedDisc, newTauProducer="pfTausBase", oldTauTypeMapper=recoTauTypeMapperWithGroup, newTauTypeMapper=producerIsTauTypeMapperWithPostfix, preservePFTauProducer=True) clonedDisc.PFTauProducer = tauCollectionToSelect # Add this selection to our pfTau selectors getattr(process,"pfTaus" + postfix).discriminators.append(cms.PSet( discriminator=cms.InputTag(clonedName), selectionCut=cms.double(0.5))) # Set the input of the final selector. if tauType != 'hpsPFTau': getattr(process,"pfTaus" + postfix).src = "pfTausBase"+postfix else: # If we are using HPS taus, we need to take the output of the clenaed # collection getattr(process,"pfTaus" + postfix).src = "hpsPFTauProducer"+postfix
def reconfigurePF2PATTaus( process, tauType='shrinkingConePFTau', pf2patSelection=[ "DiscriminationByIsolation", "DiscriminationByLeadingPionPtCut" ], selectionDependsOn=["DiscriminationByLeadingTrackFinding"], producerFromType=lambda producer: producer + "Producer", postfix=""): print "patTaus will be produced from taus of type: %s that pass %s" \ % (tauType, pf2patSelection) #get baseSequence baseSequence = getattr(process, "pfTausBaseSequence" + postfix) #clean baseSequence from old modules for oldBaseModuleName in baseSequence.moduleNames(): oldBaseModule = getattr(process, oldBaseModuleName) baseSequence.remove(oldBaseModule) # Get the prototype of tau producer to make, i.e. fixedConePFTauProducer producerName = producerFromType(tauType) # Set as the source for the pf2pat taus (pfTaus) selector applyPostfix(process, "pfTaus", postfix).src = producerName + postfix # Start our pf2pat taus base sequence oldTau = getattr(process, 'pfTausProducer' + postfix) ## copy tau and setup it properly newTau = getattr(process, producerName).clone() ## adapted to new structure in RecoTauProducers PLEASE CHECK!!! if tauType == 'shrinkingConePFTau': #Only shrCone tau has modifiers??? # like this, it should have it already definied?? newTau.modifiers[1] = cms.PSet( pfTauTagInfoSrc=cms.InputTag("pfTauTagInfoProducer" + postfix), name=cms.string('pfTauTTIworkaround' + postfix), plugin=cms.string('RecoTauTagInfoWorkaroundModifer')) newTau.piZeroSrc = "pfJetsLegacyTaNCPiZeros" + postfix elif tauType == 'fixedConePFTau': newTau.piZeroSrc = "pfJetsPiZeros" + postfix elif tauType == 'hpsPFTau': newTau = process.combinatoricRecoTaus.clone() newTau.piZeroSrc = "pfJetsLegacyHPSPiZeros" + postfix newTau.modifiers[2] = cms.PSet( pfTauTagInfoSrc=cms.InputTag("pfTauTagInfoProducer" + postfix), name=cms.string('pfTauTTIworkaround' + postfix), plugin=cms.string('RecoTauTagInfoWorkaroundModifer')) from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet cloneProcessingSnippet(process, process.produceHPSPFTaus, postfix) massSearchReplaceParam(getattr(process, "produceHPSPFTaus" + postfix), "PFTauProducer", cms.InputTag("combinatoricRecoTaus"), cms.InputTag("pfTausBase" + postfix)) getattr(process, "hpsPFTauProducer" + postfix).src = "pfTausBase" + postfix newTau.builders[0].pfCandSrc = oldTau.builders[0].pfCandSrc newTau.jetRegionSrc = oldTau.jetRegionSrc newTau.jetSrc = oldTau.jetSrc # replace old tau producer by new one put it into baseSequence setattr(process, "pfTausBase" + postfix, newTau) baseSequence += getattr(process, "pfTausBase" + postfix) if tauType == 'hpsPFTau': baseSequence += getattr(process, "produceHPSPFTaus" + postfix) #make custom mapper to take postfix into account (could have gone with lambda of lambda but... ) def producerIsTauTypeMapperWithPostfix(tauProducer): return lambda x: producerIsTauTypeMapper(tauProducer) + x.group( 1) + postfix def recoTauTypeMapperWithGroup(tauProducer): return "%s(.*)" % recoTauTypeMapper(tauProducer) # Get our prediscriminants for predisc in selectionDependsOn: # Get the prototype originalName = tauType + predisc # i.e. fixedConePFTauProducerDiscriminationByLeadingTrackFinding clonedName = "pfTausBase" + predisc + postfix clonedDisc = getattr(process, originalName).clone() # Register in our process setattr(process, clonedName, clonedDisc) baseSequence += getattr(process, clonedName) tauCollectionToSelect = None if tauType != 'hpsPFTau': tauCollectionToSelect = "pfTausBase" + postfix #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix) else: tauCollectionToSelect = "hpsPFTauProducer" + postfix # Adapt this discriminator for the cloned prediscriminators adaptTauDiscriminator( clonedDisc, newTauProducer="pfTausBase", oldTauTypeMapper=recoTauTypeMapperWithGroup, newTauTypeMapper=producerIsTauTypeMapperWithPostfix, preservePFTauProducer=True) clonedDisc.PFTauProducer = tauCollectionToSelect # Reconfigure the pf2pat PFTau selector discrimination sources applyPostfix(process, "pfTaus", postfix).discriminators = cms.VPSet() for selection in pf2patSelection: # Get our discriminator that will be used to select pfTaus originalName = tauType + selection clonedName = "pfTausBase" + selection + postfix clonedDisc = getattr(process, originalName).clone() # Register in our process setattr(process, clonedName, clonedDisc) tauCollectionToSelect = None if tauType != 'hpsPFTau': tauCollectionToSelect = cms.InputTag("pfTausBase" + postfix) #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix) else: tauCollectionToSelect = cms.InputTag("hpsPFTauProducer" + postfix) #Adapt our cloned discriminator to the new prediscriminants adaptTauDiscriminator( clonedDisc, newTauProducer="pfTausBase", oldTauTypeMapper=recoTauTypeMapperWithGroup, newTauTypeMapper=producerIsTauTypeMapperWithPostfix, preservePFTauProducer=True) clonedDisc.PFTauProducer = tauCollectionToSelect baseSequence += clonedDisc # Add this selection to our pfTau selectors applyPostfix(process, "pfTaus", postfix).discriminators.append( cms.PSet(discriminator=cms.InputTag(clonedName), selectionCut=cms.double(0.5))) # Set the input of the final selector. if tauType != 'hpsPFTau': applyPostfix(process, "pfTaus", postfix).src = "pfTausBase" + postfix else: # If we are using HPS taus, we need to take the output of the clenaed # collection applyPostfix(process, "pfTaus", postfix).src = "hpsPFTauProducer" + postfix
def reconfigurePF2PATTaus( process, tauType='shrinkingConePFTau', pf2patSelection=[ "DiscriminationByIsolation", "DiscriminationByLeadingPionPtCut" ], selectionDependsOn=["DiscriminationByLeadingTrackFinding"], producerFromType=lambda producer: producer + "Producer", postfix=""): print "patTaus will be produced from taus of type: %s that pass %s" \ % (tauType, pf2patSelection) # Get the prototype of tau producer to make, i.e. fixedConePFTauProducer producerName = producerFromType(tauType) # Set as the source for the pf2pat taus (pfTaus) selector applyPostfix(process, "pfTaus", postfix).src = producerName + postfix # Start our pf2pat taus base sequence oldTauSansRefs = getattr(process, 'pfTausProducerSansRefs' + postfix) oldTau = getattr(process, 'pfTausProducer' + postfix) ## copy tau and setup it properly newTauSansRefs = None newTau = getattr(process, producerName + postfix).clone() ## adapted to new structure in RecoTauProducers PLEASE CHECK!!! if tauType == 'shrinkingConePFTau': newTauSansRefs = getattr(process, producerName + "SansRefs").clone() newTauSansRefs.modifiers[1] = cms.PSet( pfTauTagInfoSrc=cms.InputTag("pfTauTagInfoProducer" + postfix), name=cms.string('pfTauTTIworkaround' + postfix), plugin=cms.string('RecoTauTagInfoWorkaroundModifer')) newTau.modifiers[1] = newTauSansRefs.modifiers[1] newTauSansRefs.piZeroSrc = "pfJetsLegacyTaNCPiZeros" + postfix newTau.piZeroSrc = newTauSansRefs.piZeroSrc newTauSansRefs.builders[0].pfCandSrc = oldTauSansRefs.builders[ 0].pfCandSrc newTauSansRefs.jetRegionSrc = oldTauSansRefs.jetRegionSrc newTauSansRefs.jetSrc = oldTauSansRefs.jetSrc elif tauType == 'fixedConePFTau': newTau.piZeroSrc = "pfJetsLegacyTaNCPiZeros" + postfix elif tauType == 'hpsPFTau': newTau = getattr(process, 'combinatoricRecoTaus' + postfix).clone() newTau.piZeroSrc = "pfJetsLegacyHPSPiZeros" + postfix newTau.modifiers[3] = cms.PSet( pfTauTagInfoSrc=cms.InputTag("pfTauTagInfoProducer" + postfix), name=cms.string('pfTauTTIworkaround' + postfix), plugin=cms.string('RecoTauTagInfoWorkaroundModifer')) from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet #cloneProcessingSnippet(process, process.produceHPSPFTaus, postfix, addToTask = True) setattr( process, 'produceHPSPFTaus' + postfix, cms.Sequence( applyPostfix(process, 'hpsSelectionDiscriminator', postfix) + applyPostfix(process, 'hpsPFTauProducerSansRefs', postfix) + applyPostfix(process, 'hpsPFTauProducer', postfix))) massSearchReplaceParam(getattr(process, "produceHPSPFTaus" + postfix), "PFTauProducer", cms.InputTag("combinatoricRecoTaus" + postfix), cms.InputTag("pfTausBase" + postfix)) massSearchReplaceParam(getattr(process, "produceHPSPFTaus" + postfix), "src", cms.InputTag("combinatoricRecoTaus" + postfix), cms.InputTag("pfTausBase" + postfix)) ### Next three lines crash, oldTau does not have any of these attributes. Why?### #newTau.builders[0].pfCandSrc = oldTau.builders[0].pfCandSrc #newTau.jetRegionSrc = oldTau.jetRegionSrc #newTau.jetSrc = oldTau.jetSrc #newTau.builders[0].pfCandSrc = cms.InputTag("pfNoElectronJME" + postfix) #newTau.jetRegionSrc = cms.InputTag("pfTauPFJets08Region" + postfix) #newTau.jetSrc = cms.InputTag("pfJetsPFBRECO" + postfix) # replace old tau producer by new one put it into baseSequence task = getPatAlgosToolsTask(process) addToProcessAndTask("pfTausBase" + postfix, newTau, process, task) if tauType == 'shrinkingConePFTau': addToProcessAndTask("pfTausBaseSansRefs" + postfix, newTauSansRefs, process, task) getattr(process, "pfTausBase" + postfix).src = "pfTausBaseSansRefs" + postfix baseSequence += getattr(process, "pfTausBaseSansRefs" + postfix) #make custom mapper to take postfix into account (could have gone with lambda of lambda but... ) def producerIsTauTypeMapperWithPostfix(tauProducer): return lambda x: producerIsTauTypeMapper(tauProducer) + x.group( 1) + postfix def recoTauTypeMapperWithGroup(tauProducer): return "%s(.*)" % recoTauTypeMapper(tauProducer) # Get our prediscriminants for predisc in selectionDependsOn: # Get the prototype originalName = tauType + predisc # i.e. fixedConePFTauProducerDiscriminationByLeadingTrackFinding clonedName = "pfTausBase" + predisc + postfix clonedDisc = getattr(process, originalName).clone() addToProcessAndTask(clonedName, clonedDisc, process, task) tauCollectionToSelect = None if tauType != 'hpsPFTau': tauCollectionToSelect = "pfTausBase" + postfix #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix) else: tauCollectionToSelect = "hpsPFTauProducer" + postfix # Adapt this discriminator for the cloned prediscriminators adaptTauDiscriminator( clonedDisc, newTauProducer="pfTausBase", oldTauTypeMapper=recoTauTypeMapperWithGroup, newTauTypeMapper=producerIsTauTypeMapperWithPostfix, preservePFTauProducer=True) clonedDisc.PFTauProducer = tauCollectionToSelect # Reconfigure the pf2pat PFTau selector discrimination sources getattr(process, "pfTaus" + postfix).discriminators = cms.VPSet() for selection in pf2patSelection: # Get our discriminator that will be used to select pfTaus originalName = tauType + selection clonedName = "pfTausBase" + selection + postfix clonedDisc = getattr(process, originalName).clone() addToProcessAndTask(clonedName, clonedDisc, process, task) tauCollectionToSelect = None if tauType != 'hpsPFTau': tauCollectionToSelect = cms.InputTag("pfTausBase" + postfix) #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix) else: tauCollectionToSelect = cms.InputTag("hpsPFTauProducer" + postfix) #Adapt our cloned discriminator to the new prediscriminants adaptTauDiscriminator( clonedDisc, newTauProducer="pfTausBase", oldTauTypeMapper=recoTauTypeMapperWithGroup, newTauTypeMapper=producerIsTauTypeMapperWithPostfix, preservePFTauProducer=True) clonedDisc.PFTauProducer = tauCollectionToSelect # Add this selection to our pfTau selectors getattr(process, "pfTaus" + postfix).discriminators.append( cms.PSet(discriminator=cms.InputTag(clonedName), selectionCut=cms.double(0.5))) # Set the input of the final selector. if tauType != 'hpsPFTau': getattr(process, "pfTaus" + postfix).src = "pfTausBase" + postfix else: # If we are using HPS taus, we need to take the output of the clenaed # collection getattr(process, "pfTaus" + postfix).src = "hpsPFTauProducer" + postfix
def reconfigurePF2PATTaus(process, tauType='shrinkingConePFTau', pf2patSelection=["DiscriminationByIsolation", "DiscriminationByLeadingPionPtCut"], selectionDependsOn=["DiscriminationByLeadingTrackFinding"], producerFromType=lambda producer: producer+"Producer", postfix = ""): print "patTaus will be produced from taus of type: %s that pass %s" \ % (tauType, pf2patSelection) #get baseSequence baseSequence = getattr(process,"pfTausBaseSequence"+postfix) #clean baseSequence from old modules for oldBaseModuleName in baseSequence.moduleNames(): oldBaseModule = getattr(process,oldBaseModuleName) baseSequence.remove(oldBaseModule) # Get the prototype of tau producer to make, i.e. fixedConePFTauProducer producerName = producerFromType(tauType) # Set as the source for the pf2pat taus (pfTaus) selector applyPostfix(process,"pfTaus", postfix).src = producerName+postfix # Start our pf2pat taus base sequence oldTau = getattr(process,'pfTausProducer'+postfix) ## copy tau and setup it properly newTau = getattr(process,producerName).clone() ## adapted to new structure in RecoTauProducers PLEASE CHECK!!! if tauType=='shrinkingConePFTau': #Only shrCone tau has modifiers??? # like this, it should have it already definied?? newTau.modifiers[1] = cms.PSet( pfTauTagInfoSrc = cms.InputTag("pfTauTagInfoProducer"+postfix), name = cms.string('pfTauTTIworkaround'+postfix), plugin = cms.string('RecoTauTagInfoWorkaroundModifer') ) newTau.piZeroSrc = "pfJetsLegacyTaNCPiZeros"+postfix elif tauType=='fixedConePFTau': #newTau.piZeroSrc = "pfJetsPiZeros"+postfix newTau.PFTauTagInfoProducer = cms.InputTag("pfTauTagInfoProducer"+postfix) elif tauType=='hpsPFTau': newTau = process.combinatoricRecoTaus.clone() newTau.piZeroSrc="pfJetsLegacyHPSPiZeros"+postfix newTau.modifiers[2] = cms.PSet( pfTauTagInfoSrc = cms.InputTag("pfTauTagInfoProducer"+postfix), name = cms.string('pfTauTTIworkaround'+postfix), plugin = cms.string('RecoTauTagInfoWorkaroundModifer') ) from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet cloneProcessingSnippet(process, process.produceHPSPFTaus, postfix) massSearchReplaceParam(getattr(process,"produceHPSPFTaus"+postfix), "PFTauProducer", cms.InputTag("combinatoricRecoTaus"), cms.InputTag("pfTausBase"+postfix) ) getattr(process,"hpsPFTauProducer"+postfix).src = "pfTausBase"+postfix if not tauType=='fixedConePFTau': newTau.builders[0].pfCandSrc = oldTau.builders[0].pfCandSrc newTau.jetSrc = oldTau.jetSrc # replace old tau producter by new one put it into baseSequence setattr(process,"pfTausBase"+postfix,newTau) baseSequence += getattr(process,"pfTausBase"+postfix) if tauType=='hpsPFTau': baseSequence += getattr(process,"produceHPSPFTaus"+postfix) #make custom mapper to take postfix into account (could have gone with lambda of lambda but... ) def producerIsTauTypeMapperWithPostfix(tauProducer): return lambda x: producerIsTauTypeMapper(tauProducer)+x.group(1)+postfix def recoTauTypeMapperWithGroup(tauProducer): return "%s(.*)"%recoTauTypeMapper(tauProducer) # Get our prediscriminants for predisc in selectionDependsOn: # Get the prototype originalName = tauType+predisc # i.e. fixedConePFTauProducerDiscriminationByLeadingTrackFinding clonedName = "pfTausBase"+predisc+postfix clonedDisc = getattr(process, originalName).clone() # Register in our process setattr(process, clonedName, clonedDisc) baseSequence += getattr(process, clonedName) if tauType != 'hpsPFTau' : clonedDisc.PFTauProducer = cms.InputTag(clonedDisc.PFTauProducer.value()+postfix) else: clonedDisc.PFTauProducer = cms.InputTag("hpsPFTauProducer"+postfix) # Adapt this discriminator for the cloned prediscriminators adaptTauDiscriminator(clonedDisc, newTauProducer="pfTausBase", oldTauTypeMapper=recoTauTypeMapperWithGroup, newTauTypeMapper=producerIsTauTypeMapperWithPostfix, preservePFTauProducer=True) clonedDisc.PFTauProducer = cms.InputTag("pfTausBase"+postfix) # Reconfigure the pf2pat PFTau selector discrimination sources applyPostfix(process,"pfTaus", postfix).discriminators = cms.VPSet() for selection in pf2patSelection: # Get our discriminator that will be used to select pfTaus originalName = tauType+selection clonedName = "pfTausBase"+selection+postfix clonedDisc = getattr(process, originalName).clone() # Register in our process setattr(process, clonedName, clonedDisc) if tauType != 'hpsPFTau' : clonedDisc.PFTauProducer = cms.InputTag(clonedDisc.PFTauProducer.value()+postfix) else: clonedDisc.PFTauProducer = cms.InputTag("hpsPFTauProducer"+postfix) # Adapt our cloned discriminator to the new prediscriminants adaptTauDiscriminator(clonedDisc, newTauProducer="pfTausBase", oldTauTypeMapper=recoTauTypeMapperWithGroup, newTauTypeMapper=producerIsTauTypeMapperWithPostfix, preservePFTauProducer=True) clonedDisc.PFTauProducer = cms.InputTag("pfTausBase"+postfix) baseSequence += clonedDisc # Add this selection to our pfTau selectors applyPostfix(process,"pfTaus", postfix).discriminators.append(cms.PSet( discriminator=cms.InputTag(clonedName), selectionCut=cms.double(0.5))) applyPostfix(process,"pfTaus", postfix).src = "pfTausBase"+postfix