def addDiscardedPFCandidates(process, inputCollection, verbose=False):
    process.primaryVertexAssociationDiscardedCandidates = process.primaryVertexAssociation.clone(
        particles=inputCollection, )
    process.packedPFCandidatesDiscarded = process.packedPFCandidates.clone(
        inputCollection=inputCollection,
        PuppiNoLepSrc=cms.InputTag(""),
        PuppiSrc=cms.InputTag(""),
        secondaryVerticesForWhiteList=cms.VInputTag(),
        vertexAssociator=cms.InputTag(
            "primaryVertexAssociationDiscardedCandidates", "original"))
    addKeepStatement(
        process,
        "keep patPackedCandidates_packedPFCandidates_*_*",
        ["keep patPackedCandidates_packedPFCandidatesDiscarded_*_*"],
        verbose=verbose)
    # Now make the mixed map for rekeying
    from PhysicsTools.PatAlgos.slimming.packedPFCandidateRefMixer_cfi import packedPFCandidateRefMixer
    process.oldPFCandToPackedOrDiscarded = packedPFCandidateRefMixer.clone(
        pf2pf=cms.InputTag(inputCollection.moduleLabel),
        pf2packed=cms.VInputTag(cms.InputTag("packedPFCandidates"),
                                cms.InputTag("packedPFCandidatesDiscarded")))
    # Fix slimmed muon keying
    process.slimmedMuons.pfCandidates = cms.VInputTag(
        cms.InputTag(inputCollection.moduleLabel), inputCollection)
    process.slimmedMuons.packedPFCandidates = cms.VInputTag(
        cms.InputTag("packedPFCandidates"),
        cms.InputTag("packedPFCandidatesDiscarded"))
def addDiscardedPFCandidates(process, inputCollection, verbose=False):

    task = getPatAlgosToolsTask(process)

    process.primaryVertexAssociationDiscardedCandidates = process.primaryVertexAssociation.clone(
        particles = inputCollection,
        )
    task.add(process.primaryVertexAssociationDiscardedCandidates)
    process.packedPFCandidatesDiscarded = process.packedPFCandidates.clone(
        inputCollection = inputCollection,
        PuppiNoLepSrc = cms.InputTag(""),
        PuppiSrc = cms.InputTag(""),
        secondaryVerticesForWhiteList = cms.VInputTag(),
        vertexAssociator = cms.InputTag("primaryVertexAssociationDiscardedCandidates","original")
        )
    task.add(process.packedPFCandidatesDiscarded)
    addKeepStatement(process, "keep patPackedCandidates_packedPFCandidates_*_*",
                             ["keep patPackedCandidates_packedPFCandidatesDiscarded_*_*"],
                              verbose=verbose)
    # Now make the mixed map for rekeying
    from PhysicsTools.PatAlgos.slimming.packedPFCandidateRefMixer_cfi import packedPFCandidateRefMixer
    process.oldPFCandToPackedOrDiscarded = packedPFCandidateRefMixer.clone(
        pf2pf = cms.InputTag(inputCollection.moduleLabel),
        pf2packed = cms.VInputTag(cms.InputTag("packedPFCandidates"), cms.InputTag("packedPFCandidatesDiscarded"))
    )
    task.add(process.oldPFCandToPackedOrDiscarded)
    # Fix slimmed muon keying
    process.slimmedMuons.pfCandidates = cms.VInputTag(cms.InputTag(inputCollection.moduleLabel), inputCollection)
    process.slimmedMuons.packedPFCandidates = cms.VInputTag(cms.InputTag("packedPFCandidates"), cms.InputTag("packedPFCandidatesDiscarded"))
  
    #MM point to uncleaned collection for hadronic taus, to avoid remaking them
    #no impact expected, as no muons are included here
    process.slimmedTaus.packedPFCandidates=cms.InputTag("packedPFCandidatesBackup")
def addDiscardedPFCandidates(process, inputCollection, verbose=False):
    process.primaryVertexAssociationDiscardedCandidates = process.primaryVertexAssociation.clone(
        particles = inputCollection,
        )
    process.packedPFCandidatesDiscarded = process.packedPFCandidates.clone(
        inputCollection = inputCollection,
        PuppiNoLepSrc = cms.InputTag(""),
        PuppiSrc = cms.InputTag(""),
        secondaryVerticesForWhiteList = cms.VInputTag(),
        vertexAssociator = cms.InputTag("primaryVertexAssociationDiscardedCandidates","original")
        )
    addKeepStatement(process, "keep patPackedCandidates_packedPFCandidates_*_*",
                             ["keep patPackedCandidates_packedPFCandidatesDiscarded_*_*"],
                              verbose=verbose)
    # Now make the mixed map for rekeying
    from PhysicsTools.PatAlgos.slimming.packedPFCandidateRefMixer_cfi import packedPFCandidateRefMixer
    process.oldPFCandToPackedOrDiscarded = packedPFCandidateRefMixer.clone(
        pf2pf = cms.InputTag(inputCollection.moduleLabel),
        pf2packed = cms.VInputTag(cms.InputTag("packedPFCandidates"), cms.InputTag("packedPFCandidatesDiscarded"))
    )
    # Fix slimmed muon keying
    process.slimmedMuons.pfCandidates = cms.VInputTag(cms.InputTag(inputCollection.moduleLabel), inputCollection)
    process.slimmedMuons.packedPFCandidates = cms.VInputTag(cms.InputTag("packedPFCandidates"), cms.InputTag("packedPFCandidatesDiscarded"))