Ejemplo n.º 1
0
combinatoricRecoTaus.chargedHadronSrc = cms.InputTag(
    "ak4PFJetsRecoTauChargedHadrons")
combinatoricRecoTaus.piZeroSrc = cms.InputTag("ak4PFJetsLegacyHPSPiZeros")

#-------------------------------------------------------------------------------
#------------------ PFTauTagInfo workaround ------------------------------------
#-------------------------------------------------------------------------------
# Build the PFTauTagInfos separately, then relink them into the taus.
from RecoTauTag.RecoTau.PFRecoTauTagInfoProducer_cfi import pfRecoTauTagInfoProducer
pfRecoTauTagInfoProducer = pfRecoTauTagInfoProducer.clone()
pfRecoTauTagInfoProducer.PFJetTracksAssociatorProducer = cms.InputTag(
    "ak4PFJetTracksAssociatorAtVertex")

from RecoJets.JetAssociationProducers.ak4JTA_cff import ak4JetTracksAssociatorAtVertexPF
ak4PFJetTracksAssociatorAtVertex = ak4JetTracksAssociatorAtVertexPF.clone()
ak4PFJetTracksAssociatorAtVertex.jets = PFRecoTauPFJetInputs.inputJetCollection
tautagInfoModifer = cms.PSet(
    name=cms.string("TTIworkaround"),
    plugin=cms.string("RecoTauTagInfoWorkaroundModifer"),
    pfTauTagInfoSrc=cms.InputTag("pfRecoTauTagInfoProducer"),
)
combinatoricRecoTaus.modifiers.append(tautagInfoModifer)

recoTauPileUpVertices = cms.EDFilter(
    "RecoTauPileUpVertexSelector",
    src=cms.InputTag("offlinePrimaryVertices"),
    minTrackSumPt=cms.double(5),
    filter=cms.bool(False),
)
Ejemplo n.º 2
0
#------------------ HPS Taus ---------------------------------------------------
#-------------------------------------------------------------------------------

from RecoTauTag.Configuration.HPSPFTaus_cff import *

combinatoricRecoTaus.piZeroSrc = cms.InputTag("ak4PFJetsLegacyHPSPiZeros")

#-------------------------------------------------------------------------------
#------------------ PFTauTagInfo workaround ------------------------------------
#-------------------------------------------------------------------------------
# Build the PFTauTagInfos separately, then relink them into the taus.
from RecoTauTag.RecoTau.PFRecoTauTagInfoProducer_cfi import \
        pfRecoTauTagInfoProducer
from RecoJets.JetAssociationProducers.ak4JTA_cff \
        import ak4JetTracksAssociatorAtVertexPF
ak4PFJetTracksAssociatorAtVertex = ak4JetTracksAssociatorAtVertexPF.clone()
ak4PFJetTracksAssociatorAtVertex.jets = PFRecoTauPFJetInputs.inputJetCollection
tautagInfoModifer = cms.PSet(
    name = cms.string("TTIworkaround"),
    plugin = cms.string("RecoTauTagInfoWorkaroundModifer"),
    pfTauTagInfoSrc = cms.InputTag("pfRecoTauTagInfoProducer"),
)
combinatoricRecoTaus.modifiers.append(tautagInfoModifer)

recoTauPileUpVertices = cms.EDFilter(
    "RecoTauPileUpVertexSelector",
    src = cms.InputTag("offlinePrimaryVertices"),
    minTrackSumPt = cms.double(5),
    filter = cms.bool(False),
)
from RecoTauTag.Configuration.HPSPFTaus_reminiAOD_cff import *

combinatoricRecoTaus76xReMiniAOD.chargedHadronSrc = cms.InputTag("ak4PFJetsRecoTauChargedHadrons76xReMiniAOD")
combinatoricRecoTaus76xReMiniAOD.piZeroSrc = cms.InputTag("ak4PFJetsLegacyHPSPiZeros76xReMiniAOD")

#-------------------------------------------------------------------------------
#------------------ PFTauTagInfo workaround ------------------------------------
#-------------------------------------------------------------------------------
# Build the PFTauTagInfos separately, then relink them into the taus.
from RecoTauTag.RecoTau.PFRecoTauTagInfoProducer_cfi import pfRecoTauTagInfoProducer
pfRecoTauTagInfoProducer76xReMiniAOD = pfRecoTauTagInfoProducer.clone()
pfRecoTauTagInfoProducer76xReMiniAOD.PFJetTracksAssociatorProducer = cms.InputTag("ak4PFJetTracksAssociatorAtVertex76xReMiniAOD")

from RecoJets.JetAssociationProducers.ak4JTA_cff import ak4JetTracksAssociatorAtVertexPF
ak4PFJetTracksAssociatorAtVertex76xReMiniAOD = ak4JetTracksAssociatorAtVertexPF.clone()
ak4PFJetTracksAssociatorAtVertex76xReMiniAOD.jets = PFRecoTauPFJetInputs.inputJetCollection
tautagInfoModifer76xReMiniAOD = cms.PSet(
    name = cms.string("TTIworkaround"),
    plugin = cms.string("RecoTauTagInfoWorkaroundModifer"),
    pfTauTagInfoSrc = cms.InputTag("pfRecoTauTagInfoProducer76xReMiniAOD"),
)
combinatoricRecoTaus76xReMiniAOD.modifiers.append(tautagInfoModifer76xReMiniAOD)

recoTauPileUpVertices76xReMiniAOD = cms.EDFilter("RecoTauPileUpVertexSelector",
    src = cms.InputTag("offlinePrimaryVertices"),
    minTrackSumPt = cms.double(5),
    filter = cms.bool(False),
)

recoTauCommonSequence76xReMiniAOD = cms.Sequence(
Ejemplo n.º 4
0
combinatoricRecoTaus76xReMiniAOD.chargedHadronSrc = cms.InputTag(
    "ak4PFJetsRecoTauChargedHadrons76xReMiniAOD")
combinatoricRecoTaus76xReMiniAOD.piZeroSrc = cms.InputTag(
    "ak4PFJetsLegacyHPSPiZeros76xReMiniAOD")

#-------------------------------------------------------------------------------
#------------------ PFTauTagInfo workaround ------------------------------------
#-------------------------------------------------------------------------------
# Build the PFTauTagInfos separately, then relink them into the taus.
from RecoTauTag.RecoTau.PFRecoTauTagInfoProducer_cfi import pfRecoTauTagInfoProducer
pfRecoTauTagInfoProducer76xReMiniAOD = pfRecoTauTagInfoProducer.clone()
pfRecoTauTagInfoProducer76xReMiniAOD.PFJetTracksAssociatorProducer = cms.InputTag(
    "ak4PFJetTracksAssociatorAtVertex76xReMiniAOD")

from RecoJets.JetAssociationProducers.ak4JTA_cff import ak4JetTracksAssociatorAtVertexPF
ak4PFJetTracksAssociatorAtVertex76xReMiniAOD = ak4JetTracksAssociatorAtVertexPF.clone(
)
ak4PFJetTracksAssociatorAtVertex76xReMiniAOD.jets = PFRecoTauPFJetInputs.inputJetCollection
tautagInfoModifer76xReMiniAOD = cms.PSet(
    name=cms.string("TTIworkaround"),
    plugin=cms.string("RecoTauTagInfoWorkaroundModifer"),
    pfTauTagInfoSrc=cms.InputTag("pfRecoTauTagInfoProducer76xReMiniAOD"),
)
combinatoricRecoTaus76xReMiniAOD.modifiers.append(
    tautagInfoModifer76xReMiniAOD)

recoTauPileUpVertices76xReMiniAOD = cms.EDFilter(
    "RecoTauPileUpVertexSelector",
    src=cms.InputTag("offlinePrimaryVertices"),
    minTrackSumPt=cms.double(5),
    filter=cms.bool(False),
)
Ejemplo n.º 5
0
combinatoricRecoTaus.modifiers.append(
    cms.PSet(name=cms.string("tau_mass"),
             plugin=cms.string("PFRecoTauMassPlugin"),
             verbosity=cms.int32(0)))

#-------------------------------------------------------------------------------
#------------------ PFTauTagInfo workaround ------------------------------------
#-------------------------------------------------------------------------------
# Build the PFTauTagInfos separately, then relink them into the taus.
from RecoTauTag.RecoTau.PFRecoTauTagInfoProducer_cfi import pfRecoTauTagInfoProducer

pfRecoTauTagInfoProducer = pfRecoTauTagInfoProducer.clone(
    PFJetTracksAssociatorProducer="ak4PFJetTracksAssociatorAtVertex")
from RecoJets.JetAssociationProducers.ak4JTA_cff import ak4JetTracksAssociatorAtVertexPF

ak4PFJetTracksAssociatorAtVertex = ak4JetTracksAssociatorAtVertexPF.clone(
    jets=PFRecoTauPFJetInputs.inputJetCollection)
tautagInfoModifer = cms.PSet(
    name=cms.string("TTIworkaround"),
    plugin=cms.string("RecoTauTagInfoWorkaroundModifer"),
    pfTauTagInfoSrc=cms.InputTag("pfRecoTauTagInfoProducer"),
)
combinatoricRecoTaus.modifiers.append(tautagInfoModifer)

recoTauPileUpVertices = cms.EDFilter(
    "RecoTauPileUpVertexSelector",
    src=cms.InputTag("offlinePrimaryVertices"),
    minTrackSumPt=cms.double(5),
    filter=cms.bool(False),
)

recoTauCommonTask = cms.Task(ak4PFJetTracksAssociatorAtVertex,
Ejemplo n.º 6
0
def customizePFPatLikeJetsROI(process, type="AK4PFCHS"):

    # set some default collection variables
    pfjets = "hltAK4PFJetsForBTag"
    PFDeepCSVTags = "hltDeepCombinedSecondaryVertexBPFPatROIJetTags"  #original pfDeepCSVJetTags
    PFDeepFlavourTags = "hltPFDeepFlavourROIJetTags"  #original pfDeepFlavourJetTagsSlimmedDeepFlavour
    payload = "AK4PFHLT"  #original AK4PFchs
    hltVertices = "hltVerticesPFFilterForBTag"  #original offlinePrimaryVertices
    rho = "hltFixedGridRhoFastjetAllForBTag"  #original fixedGridRhoFastjetAll

    siPixelClusters = "hltSiPixelClusters"  #original siPixelClusters
    ecalRecHit = "hltEcalRecHit"  #original ecalRecHit
    hbhereco = "hltHbhereco"  #original hbhereco
    hfreco = "hltHfreco"  #original hfreco
    horeco = "hltHoreco"  #original horeco
    rpcRecHits = "hltRpcRecHits"  #original rpcRecHits
    tracks = "hltMergedTracksForBTag"  #original generalTracks

    puppi = "hltPFPuppiROI"  #original puppi
    puppijets = "hltAK4PFPuppiJetsROI"  #original ak4PFJetsCHS
    payloadPuppi = "AK4PFPuppiHLT"  #original AK4PFchs
    PFPuppiDeepFlavourTags = "hltPFPuppiDeepFlavourROIJetTags"  #original pfDeepFlavourJetTagsSlimmedDeepFlavour
    PFPuppiDeepCSVTags = "hltDeepCombinedSecondaryVertexBPFPuppiPatROIJetTags"  #original pfDeepCSVJetTags

    particleFlow = "hltParticleFlowForBTag"  #original particleFlow
    beamSpot = "hltOnlineBeamSpot"  #original offlineBeamSpot

    # clone and modify the HLT BTV sequence/producers to remove the jet pt and eta selections from "jetsForBtag" and replace with pfjets
    process.hltDeepBLifetimePFPatROITagInfos = process.hltDeepBLifetimeTagInfosPFROI.clone(
        jets=cms.InputTag(pfjets))

    process.hltDeepSecondaryVertexPFPatROITagInfos = process.hltDeepSecondaryVertexTagInfosPFROI.clone(
        trackIPTagInfos=cms.InputTag("hltDeepBLifetimePFPatROITagInfos"))

    process.hltDeepCombinedSecondaryVertexBJetPatROITagInfos = process.hltDeepCombinedSecondaryVertexBJetTagsInfosROI.clone(
        svTagInfos=cms.InputTag("hltDeepSecondaryVertexPFPatROITagInfos"))

    process.hltDeepCombinedSecondaryVertexBPFPatROIJetTags = process.hltDeepCombinedSecondaryVertexBJetTagsPFROI.clone(
        src=cms.InputTag("hltDeepCombinedSecondaryVertexBJetPatROITagInfos"))

    process.HLTBtagDeepCSVSequencePFPatROI = cms.Sequence(
        process.hltVerticesPFForBTag + process.hltVerticesPFSelectorForBTag +
        process.hltVerticesPFFilterForBTag +
        process.hltDeepBLifetimePFPatROITagInfos +
        process.hltDeepInclusiveVertexFinderPFROI +
        process.hltDeepInclusiveSecondaryVerticesPFROI +
        process.hltDeepTrackVertexArbitratorPFROI +
        process.hltDeepInclusiveMergedVerticesPFROI +
        process.hltDeepSecondaryVertexPFPatROITagInfos +
        process.hltDeepCombinedSecondaryVertexBJetPatROITagInfos +
        process.hltDeepCombinedSecondaryVertexBPFPatROIJetTags)

    #
    #  same for puppi jets
    #
    process.hltDeepBLifetimePFPuppiPatROITagInfos = process.hltDeepBLifetimeTagInfosPFROI.clone(
        jets=cms.InputTag(puppijets))

    process.hltDeepSecondaryVertexPFPuppiPatROITagInfos = process.hltDeepSecondaryVertexTagInfosPFROI.clone(
        trackIPTagInfos=cms.InputTag("hltDeepBLifetimePFPuppiPatROITagInfos"),
        weights=cms.InputTag(puppi))

    process.hltDeepCombinedSecondaryVertexBPuppiJetPatROITagInfos = process.hltDeepCombinedSecondaryVertexBJetTagsInfosROI.clone(
        svTagInfos=cms.InputTag("hltDeepSecondaryVertexPFPuppiPatROITagInfos"))

    process.hltDeepCombinedSecondaryVertexBPFPuppiPatROIJetTags = process.hltDeepCombinedSecondaryVertexBJetTagsPFROI.clone(
        src=cms.InputTag(
            "hltDeepCombinedSecondaryVertexBPuppiJetPatROITagInfos"))

    process.HLTBtagDeepCSVSequencePFPuppiPatROI = cms.Sequence(
        process.hltVerticesPFForBTag + process.hltVerticesPFSelectorForBTag +
        process.hltVerticesPFFilterForBTag +
        process.hltDeepBLifetimePFPuppiPatROITagInfos +
        process.hltDeepInclusiveVertexFinderPFROI +
        process.hltDeepInclusiveSecondaryVerticesPFROI +
        process.hltDeepTrackVertexArbitratorPFROI +
        process.hltDeepInclusiveMergedVerticesPFROI +
        process.hltDeepSecondaryVertexPFPuppiPatROITagInfos +
        process.hltDeepCombinedSecondaryVertexBPuppiJetPatROITagInfos +
        process.hltDeepCombinedSecondaryVertexBPFPuppiPatROIJetTags)

    # create patJets  for ak4pfchs and all necessary missing inputs
    from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets
    process.hltPatJetsROI = patJets.clone(
        JetFlavourInfoSource=cms.InputTag("hltPatJetFlavourAssociationROI"),
        JetPartonMapSource=cms.InputTag(
            "hltPatJetFlavourAssociationLegacyROI"),
        addJetID=cms.bool(False),
        addTagInfos=cms.bool(True),
        discriminatorSources=cms.VInputTag(
            cms.InputTag(PFDeepCSVTags, "probb"),
            cms.InputTag(PFDeepCSVTags, "probc"),
            cms.InputTag(PFDeepCSVTags, "probudsg"),
            # cms.InputTag(PFDeepCSVTags,"probbb"), # hltDeepCSV: probb = probb +probbb
            cms.InputTag(PFDeepFlavourTags, "probb"),
            cms.InputTag(PFDeepFlavourTags, "probc"),
            cms.InputTag(PFDeepFlavourTags, "probg"),
            cms.InputTag(PFDeepFlavourTags, "problepb"),
            cms.InputTag(PFDeepFlavourTags, "probbb"),
            cms.InputTag(PFDeepFlavourTags, "probuds"),
        ),
        embedGenPartonMatch=cms.bool(False),
        genJetMatch=cms.InputTag("hltPatJetGenJetMatchROI"),
        genPartonMatch=cms.InputTag("hltPatJetPartonMatchROI"),
        jetChargeSource=cms.InputTag("hltPatJetChargeROI"),
        jetCorrFactorsSource=cms.VInputTag(
            cms.InputTag("hltPatJetCorrFactorsROI")),
        jetIDMap=cms.InputTag("hltAk4JetIDROI"),
        jetSource=cms.InputTag(pfjets),
        tagInfoSources=cms.VInputTag(
            cms.InputTag("hltDeepBLifetimePFPatROITagInfos"),
            cms.InputTag("hltDeepCombinedSecondaryVertexBJetPatROITagInfos"),
            cms.InputTag("hltDeepSecondaryVertexPFPatROITagInfos"),
            cms.InputTag("hltPFDeepFlavourROITagInfos"),
        ),
        trackAssociationSource=cms.InputTag(
            "hltAk4JetTracksAssociatorAtVertexPFROI"),
    )

    process.hltPatJetsPuppiROI = patJets.clone(
        JetFlavourInfoSource=cms.InputTag(
            "hltPatJetFlavourAssociationPuppiROI"),
        JetPartonMapSource=cms.InputTag(
            "hltPatJetFlavourAssociationLegacyPuppiROI"),
        addJetID=cms.bool(False),
        addTagInfos=cms.bool(True),
        discriminatorSources=cms.VInputTag(
            cms.InputTag(PFPuppiDeepCSVTags, "probb"),
            cms.InputTag(PFPuppiDeepCSVTags, "probc"),
            cms.InputTag(PFPuppiDeepCSVTags, "probudsg"),
            # cms.InputTag(PFPuppiDeepCSVTags,"probbb"), # hltDeepCSV: probb = probb +probbb
            cms.InputTag(PFPuppiDeepFlavourTags, "probb"),
            cms.InputTag(PFPuppiDeepFlavourTags, "probc"),
            cms.InputTag(PFPuppiDeepFlavourTags, "probg"),
            cms.InputTag(PFPuppiDeepFlavourTags, "problepb"),
            cms.InputTag(PFPuppiDeepFlavourTags, "probbb"),
            cms.InputTag(PFPuppiDeepFlavourTags, "probuds"),
        ),
        embedGenPartonMatch=cms.bool(False),
        genJetMatch=cms.InputTag("hltPatJetGenJetMatchPuppiROI"),
        genPartonMatch=cms.InputTag("hltPatJetPartonMatchPuppiROI"),
        jetChargeSource=cms.InputTag("patJetPuppiChargeROI"),
        jetCorrFactorsSource=cms.VInputTag(
            cms.InputTag("hltPatJetCorrFactorsPuppiROI")),
        jetIDMap=cms.InputTag("hltAk4JetID"),
        jetSource=cms.InputTag(puppijets),
        tagInfoSources=cms.VInputTag(
            cms.InputTag("hltDeepBLifetimePFPuppiPatROITagInfos"),
            cms.InputTag(
                "hltDeepCombinedSecondaryVertexBPuppiJetPatROITagInfos"),
            cms.InputTag("hltDeepSecondaryVertexPFPuppiPatROITagInfos"),
            cms.InputTag("hltPFPuppiDeepFlavourROITagInfos"),
        ),
        trackAssociationSource=cms.InputTag(
            "hltAk4JetTracksAssociatorAtVertexPFPuppiROI"),
    )

    # for patJets
    from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetFlavourAssociation, patJetPartons, patJetFlavourAssociationLegacy, patJetPartonAssociationLegacy, patJetPartonsLegacy
    process.hltPatJetFlavourAssociationROI = patJetFlavourAssociation.clone(
        bHadrons=cms.InputTag("hltPatJetPartons", "bHadrons"),
        cHadrons=cms.InputTag("hltPatJetPartons", "cHadrons"),
        jets=cms.InputTag(pfjets),
        leptons=cms.InputTag("hltPatJetPartons", "leptons"),
        partons=cms.InputTag("hltPatJetPartons", "physicsPartons"),
    )

    process.hltPatJetFlavourAssociationPuppiROI = patJetFlavourAssociation.clone(
        bHadrons=cms.InputTag("hltPatJetPartons", "bHadrons"),
        cHadrons=cms.InputTag("hltPatJetPartons", "cHadrons"),
        jets=cms.InputTag(puppijets),
        leptons=cms.InputTag("hltPatJetPartons", "leptons"),
        partons=cms.InputTag("hltPatJetPartons", "physicsPartons"),
        weights=cms.InputTag(puppi))

    process.hltPatJetPartonsROI = patJetPartons.clone()

    process.hltPatJetFlavourAssociationLegacyROI = patJetFlavourAssociationLegacy.clone(
        srcByReference=cms.InputTag("hltPatJetPartonAssociationLegacyROI"))
    process.hltPatJetFlavourAssociationLegacyPuppiROI = patJetFlavourAssociationLegacy.clone(
        srcByReference=cms.InputTag(
            "hltPatJetPartonAssociationLegacyPuppiROI"))

    process.hltPatJetPartonAssociationLegacyROI = patJetPartonAssociationLegacy.clone(
        jets=cms.InputTag(pfjets),
        partons=cms.InputTag("hltPatJetPartonsLegacyROI"))

    process.hltPatJetPartonAssociationLegacyPuppiROI = patJetPartonAssociationLegacy.clone(
        jets=cms.InputTag(puppijets),
        partons=cms.InputTag("hltPatJetPartonsLegacyROI"))

    process.hltPatJetPartonsLegacyROI = patJetPartonsLegacy.clone(
        src=cms.InputTag("genParticles"), )

    from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch
    process.hltPatJetGenJetMatchROI = patJetGenJetMatch.clone(
        matched=cms.InputTag("hltSlimmedGenJets"), src=cms.InputTag(pfjets))

    process.hltPatJetGenJetMatchPuppiROI = patJetGenJetMatch.clone(
        matched=cms.InputTag("hltSlimmedGenJets"), src=cms.InputTag(puppijets))

    from PhysicsTools.PatAlgos.slimming.slimmedGenJets_cfi import slimmedGenJets
    process.hltSlimmedGenJets = slimmedGenJets.clone(
        packedGenParticles=cms.InputTag("hltPackedGenParticles"),
        src=cms.InputTag("ak4GenJetsNoNu"))

    from PhysicsTools.PatAlgos.slimming.packedGenParticles_cfi import packedGenParticles
    process.hltPackedGenParticles = packedGenParticles.clone(
        inputCollection=cms.InputTag("hltPrunedGenParticlesWithStatusOne"),
        inputOriginal=cms.InputTag("genParticles"),
        map=cms.InputTag("hltPrunedGenParticles"),
    )

    from PhysicsTools.PatAlgos.slimming.genParticles_cff import prunedGenParticlesWithStatusOne
    from PhysicsTools.PatAlgos.slimming.prunedGenParticles_cfi import prunedGenParticles
    process.hltPrunedGenParticlesWithStatusOne = prunedGenParticlesWithStatusOne.clone(
        src=cms.InputTag("genParticles"))

    process.hltPrunedGenParticles = prunedGenParticles.clone(
        src=cms.InputTag("hltPrunedGenParticlesWithStatusOne"))

    from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetPartonMatch
    process.hltPatJetPartonMatchROI = patJetPartonMatch.clone(
        matched=cms.InputTag("hltPrunedGenParticles"),
        src=cms.InputTag(pfjets))

    process.hltPatJetPartonMatchPuppiROI = patJetPartonMatch.clone(
        matched=cms.InputTag("hltPrunedGenParticles"),
        src=cms.InputTag(puppijets))

    from PhysicsTools.PatAlgos.recoLayer0.jetTracksCharge_cff import patJetCharge
    process.hltPatJetChargeROI = patJetCharge.clone(
        src=cms.InputTag("hltAk4JetTracksAssociatorAtVertexPFROI"), )

    process.patJetPuppiChargeROI = patJetCharge.clone(
        src=cms.InputTag("hltAk4JetTracksAssociatorAtVertexPFPuppiROI"), )

    from RecoJets.JetAssociationProducers.ak4JTA_cff import ak4JetTracksAssociatorAtVertexPF
    process.hltAk4JetTracksAssociatorAtVertexPFROI = ak4JetTracksAssociatorAtVertexPF.clone(
        jets=cms.InputTag(pfjets),
        pvSrc=cms.InputTag(hltVertices),
        tracks=cms.InputTag(tracks),
    )

    process.hltAk4JetTracksAssociatorAtVertexPFPuppiROI = ak4JetTracksAssociatorAtVertexPF.clone(
        jets=cms.InputTag(puppijets),
        pvSrc=cms.InputTag(hltVertices),
        tracks=cms.InputTag(tracks),
    )

    from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
    process.hltPatJetCorrFactorsROI = patJetCorrFactors.clone(
        payload=cms.string(payload),
        primaryVertices=cms.InputTag(hltVertices),
        rho=cms.InputTag(rho),
        src=cms.InputTag(pfjets),
    )

    process.hltPatJetCorrFactorsPuppiROI = patJetCorrFactors.clone(
        payload=cms.string(payloadPuppi),
        primaryVertices=cms.InputTag(hltVertices),
        rho=cms.InputTag(rho),
        src=cms.InputTag(puppijets),
    )

    from RecoJets.JetProducers.ak4JetID_cfi import ak4JetID
    process.hltAk4JetIDROI = ak4JetID.clone(
        ebRecHitsColl=cms.InputTag(ecalRecHit, "EcalRecHitsEB"),
        eeRecHitsColl=cms.InputTag(ecalRecHit, "EcalRecHitsEE"),
        hbheRecHitsColl=cms.InputTag(hbhereco),
        hfRecHitsColl=cms.InputTag(hfreco),
        hoRecHitsColl=cms.InputTag(horeco),
        rpcRecHits=cms.InputTag(rpcRecHits),
        src=cms.InputTag("hltAK4CaloJets"),
    )

    #### TAGGERS
    # run DeepFlavour for HLT
    from RecoBTag.ONNXRuntime.pfDeepFlavourJetTags_cfi import pfDeepFlavourJetTags

    process.hltPFDeepFlavourROIJetTags = pfDeepFlavourJetTags.clone(
        src=cms.InputTag("hltPFDeepFlavourROITagInfos"))

    process.hltPFPuppiDeepFlavourROIJetTags = pfDeepFlavourJetTags.clone(
        src=cms.InputTag("hltPFPuppiDeepFlavourROITagInfos"))

    from RecoBTag.FeatureTools.pfDeepFlavourTagInfos_cfi import pfDeepFlavourTagInfos
    process.hltPFDeepFlavourROITagInfos = pfDeepFlavourTagInfos.clone(
        candidates=cms.InputTag(particleFlow),
        jets=cms.InputTag(pfjets),
        puppi_value_map=cms.InputTag(puppi),
        secondary_vertices=cms.InputTag(
            "hltDeepInclusiveSecondaryVerticesPFROI"),
        shallow_tag_infos=cms.InputTag(
            "hltDeepCombinedSecondaryVertexBJetPatROITagInfos"),
        vertex_associator=cms.InputTag("hltPrimaryVertexAssociationROI",
                                       "original"),
        vertices=cms.InputTag(hltVertices))

    process.hltPFPuppiDeepFlavourROITagInfos = pfDeepFlavourTagInfos.clone(
        candidates=cms.InputTag(particleFlow),
        jets=cms.InputTag(puppijets),
        puppi_value_map=cms.InputTag(puppi),
        secondary_vertices=cms.InputTag(
            "hltDeepInclusiveSecondaryVerticesPFROI"),
        shallow_tag_infos=cms.InputTag(
            "hltDeepCombinedSecondaryVertexBPuppiJetPatROITagInfos"),
        vertex_associator=cms.InputTag("hltPrimaryVertexAssociationPuppiROI",
                                       "original"),
        vertices=cms.InputTag(hltVertices))

    from RecoBTag.SecondaryVertex.candidateCombinedSecondaryVertexV2Computer_cfi import candidateCombinedSecondaryVertexV2Computer
    process.candidateCombinedSecondaryVertexV2Computer = candidateCombinedSecondaryVertexV2Computer.clone(
    )

    from PhysicsTools.PatAlgos.slimming.primaryVertexAssociation_cfi import primaryVertexAssociation
    process.hltPrimaryVertexAssociationROI = primaryVertexAssociation.clone(
        jets=cms.InputTag(pfjets),
        particles=cms.InputTag(particleFlow),
        vertices=cms.InputTag(hltVertices),
    )

    process.hltPrimaryVertexAssociationPuppiROI = primaryVertexAssociation.clone(
        jets=cms.InputTag(puppijets),
        particles=cms.InputTag(particleFlow),
        vertices=cms.InputTag(hltVertices),
    )

    #from RecoParticleFlow.PFProducer.chargedHadronPFTrackIsolation_cfi import chargedHadronPFTrackIsolation
    #process.hltChargedHadronPFTrackIsolationROI = chargedHadronPFTrackIsolation.clone(
    #    src = cms.InputTag(particleFlow)
    #)

    # create the final path
    process.MC_JetsMatchingPathROI = cms.Path(
        process.HLTAK4PFJetsSequenceForBTag *
        process.HLTBtagDeepCSVSequencePFPatROI *
        process.hltPrunedGenParticlesWithStatusOne *
        process.hltPrunedGenParticles * process.hltPackedGenParticles *
        process.hltPatJetPartonMatchROI * process.hltSlimmedGenJets *
        process.hltAk4JetIDROI * process.hltPatJetGenJetMatchROI *
        process.hltPatJetPartonsLegacyROI *
        process.hltPatJetPartonAssociationLegacyROI *
        process.hltPatJetFlavourAssociationLegacyROI *
        process.hltPatJetPartonsROI * process.hltPatJetFlavourAssociationROI *
        process.hltAk4JetTracksAssociatorAtVertexPFROI *
        process.hltPatJetChargeROI * process.hltPatJetCorrFactorsROI *
        process.hltPrimaryVertexAssociationROI
        # *process.hltChargedHadronPFTrackIsolationROI
        * process.hltPFDeepFlavourROITagInfos *
        process.hltPFDeepFlavourROIJetTags * process.hltPatJetsROI)

    process.MC_PuppiJetsMatchingPathROI = cms.Path(
        process.HLTAK4PFJetsSequenceForBTag *
        process.HLTAK4PFPuppiJetsSequenceROI *
        process.HLTBtagDeepCSVSequencePFPuppiPatROI *
        process.hltPrunedGenParticlesWithStatusOne *
        process.hltPrunedGenParticles * process.hltPackedGenParticles *
        process.hltPatJetPartonMatchPuppiROI * process.hltSlimmedGenJets *
        process.hltAk4JetIDROI * process.hltPatJetGenJetMatchPuppiROI *
        process.hltPatJetPartonsLegacyROI *
        process.hltPatJetPartonAssociationLegacyPuppiROI *
        process.hltPatJetFlavourAssociationLegacyPuppiROI *
        process.hltPatJetPartonsROI *
        process.hltPatJetFlavourAssociationPuppiROI *
        process.hltAk4JetTracksAssociatorAtVertexPFPuppiROI *
        process.patJetPuppiChargeROI * process.hltPatJetCorrFactorsPuppiROI *
        process.hltPrimaryVertexAssociationPuppiROI
        # *process.hltChargedHadronPFTrackIsolation
        * process.hltPFPuppiDeepFlavourROITagInfos *
        process.hltPFPuppiDeepFlavourROIJetTags * process.hltPatJetsPuppiROI)

    if process.schedule_():
        process.schedule.extend([process.MC_JetsMatchingPathROI])
        process.schedule.extend([process.MC_PuppiJetsMatchingPathROI])

    return process
def customizePFPatLikeJets(process, runCalo=True, runPuppi=True, runPF=True, roiReplace=False, roiReplaceCalo=False, isData=False):
    # set some default collection variables
    pfjets =                "hltAK4PFJets" if roiReplace==False else "hltAK4PFJetsROIForBTag"                                #original ak4PFJetsCHS
    puppijets =             "hltAK4PFPuppiJets"                                  #original ak4PFJetsCHS
    pfjetsCorrected =       "hltAK4PFJetsCorrected" if roiReplace==False else "hltAK4PFJetsCorrectedROIForBTag"                         #original ak4PFJetsCHS
    calojets =              "hltAK4CaloJets"                                #original ak4CaloJets
    # calojetsCutted =        "hltSelectorCentralJets30L1FastJeta2p5"
    calojetsCutted =        "hltSelectorCentralJets30L1FastJeta"
    PFDeepCSVTags =         "hltDeepCombinedSecondaryVertexBPFPatJetTags"   #original pfDeepCSVJetTags
    PFPuppiDeepCSVTags =    "hltDeepCombinedSecondaryVertexBPFPuppiPatJetTags"   #original pfDeepCSVJetTags
    CaloDeepCSVTags =       "hltDeepCombinedSecondaryVertexCaloPatBJetTags"
    PFDeepFlavourTags =     "hltPFDeepFlavourPatJetTags"                       #original pfDeepFlavourJetTagsSlimmedDeepFlavour
    PFPuppiDeepFlavourTags ="hltPFPuppiDeepFlavourJetTags"                       #original pfDeepFlavourJetTagsSlimmedDeepFlavour
    rho =                   "hltFixedGridRhoFastjetAll" if roiReplace==False else "hltFixedGridRhoFastjetAllROIForBTag"                     #original fixedGridRhoFastjetAll
    hltVertices =           "hltVerticesPFFilter" if roiReplace==False else "hltVerticesPFFilterROIForBTag"                           #original offlinePrimaryVertices
    siPixelClusters =       "hltSiPixelClusters"                            #original siPixelClusters
    ecalRecHit =            "hltEcalRecHit"                                 #original ecalRecHit
    hbhereco =              "hltHbhereco"                                   #original hbhereco
    hfreco =                "hltHfreco"                                     #original hfreco
    horeco =                "hltHoreco"                                     #original horeco
    rpcRecHits =            "hltRpcRecHits"                                 #original rpcRecHits
    # tracks =                "hltMergedTracks"                               #original generalTracks
    tracks =                "hltPFMuonMerging" if roiReplace==False else "hltPFMuonMergingROIForBTag"                               #original generalTracks
    # tracks =                "hltPixelTracks"                               #original generalTracks
    payload =               "AK4PFHLT"                                      #original AK4PFchs
    payloadPuppi =          "AK4PFPuppiHLT"                                      #original AK4PFchs
    particleFlow =          "hltParticleFlow" if roiReplace==False else "hltParticleFlowROIForBTag"                               #original particleFlow
    puppi =                 "hltPFPuppi"                                    #original puppi
    puppiNoLep =            "hltPFPuppiNoLep"                               #original puppiNoLep
    beamSpot =              "hltOnlineBeamSpot"                             #original offlineBeamSpot
    caloTower =             "hltTowerMakerForAll"

    # clone and modify the HLT BTV sequence/producers to remove the jet pt and eta selections from "jetsForBtag" and replace with pfjets
    if roiReplace==False:
        process.hltDeepCombinedSecondaryVertexBPFPatJetTags = process.hltDeepCombinedSecondaryVertexBJetTagsPF.clone(
            src = cms.InputTag( "hltDeepCombinedSecondaryVertexBJetPatTagInfos" )
        )
        process.hltDeepCombinedSecondaryVertexBJetPatTagInfos = process.hltDeepCombinedSecondaryVertexBJetTagsInfos.clone(
            svTagInfos = cms.InputTag( "hltDeepSecondaryVertexPFPatTagInfos" )
        )
        process.hltDeepSecondaryVertexPFPatTagInfos = process.hltDeepSecondaryVertexTagInfosPF.clone(
            trackIPTagInfos = cms.InputTag( "hltDeepBLifetimePFPatTagInfos" )
        )
        process.hltDeepBLifetimePFPatTagInfos = process.hltDeepBLifetimeTagInfosPF.clone(
            jets = cms.InputTag( pfjets)
        )
    else:
        process.hltDeepCombinedSecondaryVertexBPFPatJetTags = process.hltDeepCombinedSecondaryVertexBJetTagsPFROIForBTag.clone(
            src = cms.InputTag( "hltDeepCombinedSecondaryVertexBJetPatTagInfos" )
        )
        process.hltDeepCombinedSecondaryVertexBJetPatTagInfos = process.hltDeepCombinedSecondaryVertexBJetTagsInfosROIForBTag.clone(
            svTagInfos = cms.InputTag( "hltDeepSecondaryVertexPFPatTagInfos" )
        )
        process.hltDeepSecondaryVertexPFPatTagInfos = process.hltDeepSecondaryVertexTagInfosPFROIForBTag.clone(
            trackIPTagInfos = cms.InputTag( "hltDeepBLifetimePFPatTagInfos" )
        )
        process.hltDeepBLifetimePFPatTagInfos = process.hltDeepBLifetimeTagInfosPFROIForBTag.clone(
            jets = cms.InputTag( pfjets)
        )
    if roiReplace==False:
        process.HLTBtagDeepCSVSequencePFPat = cms.Sequence(
            process.hltVerticesPF
            + process.hltVerticesPFSelector
            + process.hltVerticesPFFilter
            + process.hltDeepBLifetimePFPatTagInfos
            + process.hltDeepInclusiveVertexFinderPF
            + process.hltDeepInclusiveSecondaryVerticesPF
            + process.hltDeepTrackVertexArbitratorPF
            + process.hltDeepInclusiveMergedVerticesPF
            + process.hltDeepSecondaryVertexPFPatTagInfos
            + process.hltDeepCombinedSecondaryVertexBJetPatTagInfos
            + process.hltDeepCombinedSecondaryVertexBPFPatJetTags
        )
    else:
        process.HLTBtagDeepCSVSequencePFPat = cms.Sequence(
            process.hltVerticesPFROIForBTag
            + process.hltVerticesPFSelectorROIForBTag
            + process.hltVerticesPFFilterROIForBTag
            + process.hltDeepBLifetimePFPatTagInfos
            + process.hltDeepInclusiveVertexFinderPFROIForBTag
            + process.hltDeepInclusiveSecondaryVerticesPFROIForBTag
            + process.hltDeepTrackVertexArbitratorPFROIForBTag
            + process.hltDeepInclusiveMergedVerticesPFROIForBTag
            + process.hltDeepSecondaryVertexPFPatTagInfos
            + process.hltDeepCombinedSecondaryVertexBJetPatTagInfos
            + process.hltDeepCombinedSecondaryVertexBPFPatJetTags
        )

    # do the same for PuppiJets

    process.hltDeepCombinedSecondaryVertexBPFPuppiPatJetTags = process.hltDeepCombinedSecondaryVertexBJetTagsPF.clone(
        src = cms.InputTag( "hltDeepCombinedSecondaryVertexBPuppiJetPatTagInfos" )
    )
    process.hltDeepCombinedSecondaryVertexBPuppiJetPatTagInfos = process.hltDeepCombinedSecondaryVertexBJetTagsInfos.clone(
        svTagInfos = cms.InputTag( "hltDeepSecondaryVertexPFPuppiPatTagInfos" )
    )
    process.hltDeepSecondaryVertexPFPuppiPatTagInfos = process.hltDeepSecondaryVertexTagInfosPF.clone(
        trackIPTagInfos = cms.InputTag( "hltDeepBLifetimePFPuppiPatTagInfos" ),
        weights = cms.InputTag(puppi)
    )
    process.hltDeepBLifetimePFPuppiPatTagInfos = process.hltDeepBLifetimeTagInfosPF.clone(
        jets = cms.InputTag( puppijets )
    )
    process.HLTBtagDeepCSVSequencePFPuppiPat = cms.Sequence(
        process.hltVerticesPF
        + process.hltVerticesPFSelector
        + process.hltVerticesPFFilter
        + process.hltDeepBLifetimePFPuppiPatTagInfos
        + process.hltDeepInclusiveVertexFinderPF
        + process.hltDeepInclusiveSecondaryVerticesPF
        + process.hltDeepTrackVertexArbitratorPF
        + process.hltDeepInclusiveMergedVerticesPF
        + process.hltDeepSecondaryVertexPFPuppiPatTagInfos
        + process.hltDeepCombinedSecondaryVertexBPuppiJetPatTagInfos
        + process.hltDeepCombinedSecondaryVertexBPFPuppiPatJetTags
    )

    # do the same for caloJets
    # if roiReplace==False:
    if roiReplaceCalo==False:
        process.hltDeepCombinedSecondaryVertexCaloPatBJetTags = process.hltDeepCombinedSecondaryVertexBJetTagsCalo.clone(
            src = cms.InputTag("hltDeepCombinedSecondaryVertexBJetCaloPatTagInfos"),
        )

        process.hltDeepCombinedSecondaryVertexBJetCaloPatTagInfos = process.hltDeepCombinedSecondaryVertexBJetTagsInfosCalo.clone(
            svTagInfos = cms.InputTag("hltInclusiveSecondaryVertexFinderPatTagInfos")
        )
        process.hltInclusiveSecondaryVertexFinderPatTagInfos = process.hltInclusiveSecondaryVertexFinderTagInfos.clone(
            trackIPTagInfos = cms.InputTag("hltImpactParameterPatTagInfos"),
        )

        process.hltImpactParameterPatTagInfos = process.hltImpactParameterTagInfos.clone(
            jetTracks = cms.InputTag("hltFastPixelBLifetimeL3AssociatorPat"),
        )

        # process.hltSelectorCentralJets20L1FastJeta2p5 = process.hltSelectorCentralJets30L1FastJeta.clone(
        #     etaMax = cms.double(2.5),
        #     etaMin = cms.double(-2.5),
        #     src = cms.InputTag("hltSelectorJets20L1FastJet")
        # )

        # process.hltSelectorJets20L1FastJet = process.hltSelectorJets30L1FastJet.clone(
        #     etMin = cms.double(20.0),
        # )

        # process.hltSelector8CentralJetsL1FastJet202p5 = cms.EDFilter("LargestEtCaloJetSelector",
        #     filter = cms.bool(False),
        #     maxNumber = cms.uint32(8),
        #     src = cms.InputTag("hltSelectorCentralJets20L1FastJeta2p5")
        # )

        process.hltFastPixelBLifetimeL3AssociatorPat = process.hltFastPixelBLifetimeL3Associator.clone(
            jets = cms.InputTag(calojetsCutted),
            tracks = cms.InputTag("hltMergedTracksForBTag" if roiReplaceCalo==False else "hltMergedTracksROIForBTag"),
        )

        process.HLTBtagDeepCSVSequenceCaloPat = cms.Sequence(
            # process.hltSelectorJets20L1FastJet
            process.hltSelectorJets30L1FastJet
            # +process.hltSelectorCentralJets20L1FastJeta2p5
            +process.hltSelectorCentralJets30L1FastJeta
            +process.hltSelector8CentralJetsL1FastJet
            # +process.hltSelector8CentralJetsL1FastJet202p5
            +process.HLTTrackReconstructionForBTag
            +process.hltVerticesL3
            # +process.hltVerticesL3Selector
            # +process.hltVerticesL3Filter
            +process.hltFastPixelBLifetimeL3AssociatorPat
            +process.hltImpactParameterPatTagInfos
            +process.hltInclusiveVertexFinder
            +process.hltInclusiveSecondaryVertices
            +process.hltTrackVertexArbitrator
            +process.hltInclusiveMergedVertices
            +process.hltInclusiveSecondaryVertexFinderPatTagInfos
            +process.hltDeepCombinedSecondaryVertexBJetCaloPatTagInfos
            +process.hltDeepCombinedSecondaryVertexCaloPatBJetTags
        )
    else:
        process.hltDeepCombinedSecondaryVertexCaloPatBJetTags = process.hltDeepCombinedSecondaryVertexBJetTagsCaloROIForBTag.clone(
            src = cms.InputTag("hltDeepCombinedSecondaryVertexBJetCaloPatTagInfos"),
        )

        process.hltDeepCombinedSecondaryVertexBJetCaloPatTagInfos = process.hltDeepCombinedSecondaryVertexBJetTagsInfosCaloROIForBTag.clone(
            svTagInfos = cms.InputTag("hltInclusiveSecondaryVertexFinderPatTagInfos")
        )
        process.hltInclusiveSecondaryVertexFinderPatTagInfos = process.hltInclusiveSecondaryVertexFinderTagInfosROIForBTag.clone(
            trackIPTagInfos = cms.InputTag("hltImpactParameterPatTagInfos"),
        )

        process.hltImpactParameterPatTagInfos = process.hltImpactParameterTagInfosROIForBTag.clone(
            jetTracks = cms.InputTag("hltFastPixelBLifetimeL3AssociatorPat"),
        )

        # process.hltSelector8CentralJetsL1FastJet202p5 = cms.EDFilter("LargestEtCaloJetSelector",
        #     filter = cms.bool(False),
        #     maxNumber = cms.uint32(8),
        #     src = cms.InputTag("hltSelectorCentralJets20L1FastJeta2p5")
        # )

        # process.hltSelectorCentralJets20L1FastJeta2p5 = process.hltSelectorCentralJets30L1FastJeta.clone(
        #     etaMax = cms.double(2.5),
        #     etaMin = cms.double(-2.5),
        #     src = cms.InputTag("hltSelectorJets20L1FastJet")
        # )

        # process.hltSelectorJets20L1FastJet = process.hltSelectorJets30L1FastJet.clone(
        #     etMin = cms.double(20.0),
        #     src = cms.InputTag("hltAK4CaloJetsCorrectedIDPassed")
        # )

        process.hltFastPixelBLifetimeL3AssociatorPat = process.hltFastPixelBLifetimeL3AssociatorROIForBTag.clone(
            jets = cms.InputTag(calojetsCutted),
            tracks = cms.InputTag("hltMergedTracksForBTag" if roiReplaceCalo==False else "hltMergedTracksROIForBTag"),
        )

        process.HLTBtagDeepCSVSequenceCaloPat = cms.Sequence(
            # process.hltSelectorJets20L1FastJet
            process.hltSelectorJets30L1FastJet
            # +process.hltSelectorCentralJets20L1FastJeta2p5
            +process.hltSelectorCentralJets30L1FastJeta
            +process.hltSelector8CentralJetsL1FastJet
            # +process.hltSelector8CentralJetsL1FastJet202p5
            +process.HLTTrackReconstructionForBTag
            +process.hltVerticesL3ROIForBTag
            +process.hltVerticesL3SelectorROIForBTag
            +process.hltVerticesL3FilterROIForBTag
            +process.hltFastPixelBLifetimeL3AssociatorPat
            +process.hltImpactParameterPatTagInfos
            +process.hltInclusiveVertexFinderROIForBTag
            +process.hltInclusiveSecondaryVerticesROIForBTag
            +process.hltTrackVertexArbitratorROIForBTag
            +process.hltInclusiveMergedVerticesROIForBTag
            +process.hltInclusiveSecondaryVertexFinderPatTagInfos
            +process.hltDeepCombinedSecondaryVertexBJetCaloPatTagInfos
            +process.hltDeepCombinedSecondaryVertexCaloPatBJetTags
        )


    # create patJets  for ak4pfchs and all necessary missing inputs
    from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets
    process.hltPatJets = patJets.clone(
        JetFlavourInfoSource = cms.InputTag("hltPatJetFlavourAssociation") if not isData else cms.InputTag(""),
        JetPartonMapSource = cms.InputTag("hltPatJetFlavourAssociationLegacy") if not isData else cms.InputTag(""),
        addJetID = cms.bool(False),
        addTagInfos = cms.bool(True),
        addGenJetMatch = cms.bool(True) if not isData else cms.bool(False),
        addGenPartonMatch = cms.bool(True) if not isData else cms.bool(False),
        addJetFlavourInfo = cms.bool(True) if not isData else cms.bool(False),
        addPartonJetMatch = cms.bool(True) if not isData else cms.bool(False),
        discriminatorSources = cms.VInputTag(
            cms.InputTag(PFDeepCSVTags,"probb"),cms.InputTag(PFDeepCSVTags,"probc"),cms.InputTag(PFDeepCSVTags,"probudsg"),
            # cms.InputTag(PFDeepCSVTags,"probbb"), # hltDeepCSV: probb = probb +probbb
            cms.InputTag(PFDeepFlavourTags,"probb"), cms.InputTag(PFDeepFlavourTags,"probc"), cms.InputTag(PFDeepFlavourTags,"probg"),
            cms.InputTag(PFDeepFlavourTags,"problepb"), cms.InputTag(PFDeepFlavourTags,"probbb"), cms.InputTag(PFDeepFlavourTags,"probuds"),
        ),
        embedGenPartonMatch = cms.bool(False),
        genJetMatch = cms.InputTag("hltPatJetGenJetMatch") if not isData else cms.InputTag(""),
        genPartonMatch = cms.InputTag("hltPatJetPartonMatch") if not isData else cms.InputTag(""),
        jetChargeSource = cms.InputTag("hltPatJetCharge"),
        jetCorrFactorsSource = cms.VInputTag(cms.InputTag("hltPatJetCorrFactors")),
        jetIDMap = cms.InputTag("hltAk4JetID"),
        jetSource = cms.InputTag(pfjets),
        tagInfoSources = cms.VInputTag(
            cms.InputTag("hltDeepBLifetimePFPatTagInfos"),
            cms.InputTag("hltDeepCombinedSecondaryVertexBJetPatTagInfos"),
            cms.InputTag("hltDeepSecondaryVertexPFPatTagInfos"),
            cms.InputTag("hltPFDeepFlavourPatTagInfos"),
        ),
        trackAssociationSource = cms.InputTag("hltAk4JetTracksAssociatorAtVertexPF"),
    )
    process.hltPatJetsPuppi = patJets.clone(
        JetFlavourInfoSource = cms.InputTag("hltPatJetFlavourAssociationPuppi") if not isData else cms.InputTag(""),
        JetPartonMapSource = cms.InputTag("hltPatJetFlavourAssociationLegacyPuppi") if not isData else cms.InputTag(""),
        addJetID = cms.bool(False),
        addTagInfos = cms.bool(True),
        addGenJetMatch = cms.bool(True) if not isData else cms.bool(False),
        addGenPartonMatch = cms.bool(True) if not isData else cms.bool(False),
        addJetFlavourInfo = cms.bool(True) if not isData else cms.bool(False),
        addPartonJetMatch = cms.bool(True) if not isData else cms.bool(False),
        discriminatorSources = cms.VInputTag(
            cms.InputTag(PFPuppiDeepCSVTags,"probb"),cms.InputTag(PFPuppiDeepCSVTags,"probc"),cms.InputTag(PFPuppiDeepCSVTags,"probudsg"),
            # cms.InputTag(PFPuppiDeepCSVTags,"probbb"), # hltDeepCSV: probb = probb +probbb
            cms.InputTag(PFPuppiDeepFlavourTags,"probb"), cms.InputTag(PFPuppiDeepFlavourTags,"probc"), cms.InputTag(PFPuppiDeepFlavourTags,"probg"),
            cms.InputTag(PFPuppiDeepFlavourTags,"problepb"), cms.InputTag(PFPuppiDeepFlavourTags,"probbb"), cms.InputTag(PFPuppiDeepFlavourTags,"probuds"),
        ),
        embedGenPartonMatch = cms.bool(False),
        genJetMatch = cms.InputTag("hltPatJetGenJetMatchPuppi") if not isData else cms.InputTag(""),
        genPartonMatch = cms.InputTag("hltPatJetPartonMatchPuppi") if not isData else cms.InputTag(""),
        jetChargeSource = cms.InputTag("patJetPuppiCharge"),
        jetCorrFactorsSource = cms.VInputTag(cms.InputTag("hltPatJetCorrFactorsPuppi")),
        jetIDMap = cms.InputTag("hltAk4JetID"),
        jetSource = cms.InputTag(puppijets),
        tagInfoSources = cms.VInputTag(
            cms.InputTag("hltDeepBLifetimePFPuppiPatTagInfos"),
            cms.InputTag("hltDeepCombinedSecondaryVertexBPuppiJetPatTagInfos"),
            cms.InputTag("hltDeepSecondaryVertexPFPuppiPatTagInfos"),
            cms.InputTag("hltPFPuppiDeepFlavourTagInfos"),
        ),
        trackAssociationSource = cms.InputTag("hltAk4JetTracksAssociatorAtVertexPFPuppi"),
    )
    process.hltPatJetsCalo = patJets.clone(
        JetFlavourInfoSource = cms.InputTag("hltPatJetFlavourAssociationCalo") if not isData else cms.InputTag(""),
        JetPartonMapSource = cms.InputTag("hltPatJetFlavourAssociationLegacyCalo") if not isData else cms.InputTag(""),
        addAssociatedTracks = cms.bool(True),
        addBTagInfo = cms.bool(True),
        addDiscriminators = cms.bool(True),
        addEfficiencies = cms.bool(False),
        embedCaloTowers = cms.bool(True),
        addGenJetMatch = cms.bool(True) if not isData else cms.bool(False),
        addGenPartonMatch = cms.bool(True) if not isData else cms.bool(False),
        addJetCharge = cms.bool(False),
        addJetCorrFactors = cms.bool(False),
        addJetFlavourInfo = cms.bool(True) if not isData else cms.bool(False),
        addPartonJetMatch = cms.bool(False),
        addJetID = cms.bool(False),
        addTagInfos = cms.bool(True),
        discriminatorSources = cms.VInputTag(
            cms.InputTag(CaloDeepCSVTags,"probb"),cms.InputTag(CaloDeepCSVTags,"probc"),cms.InputTag(CaloDeepCSVTags,"probudsg"),
            # # cms.InputTag(PFDeepCSVTags,"probbb"), # hltDeepCSV: probb = probb +probbb
        ),
        embedGenPartonMatch = cms.bool(False),
        genJetMatch = cms.InputTag("hltPatJetGenJetMatchCalo") if not isData else cms.InputTag(""),
        genPartonMatch = cms.InputTag("hltPatJetPartonMatchCalo") if not isData else cms.InputTag(""),
        # jetChargeSource = cms.InputTag("hltPatJetCharge"),
        # jetCorrFactorsSource = cms.VInputTag(cms.InputTag("hltPatJetCorrFactors")),
        # jetIDMap = cms.InputTag("hltAk4JetID"),
        jetSource = cms.InputTag(calojetsCutted),
        tagInfoSources = cms.VInputTag(
            cms.InputTag("hltImpactParameterPatTagInfos"),
            cms.InputTag("hltDeepCombinedSecondaryVertexBJetCaloPatTagInfos"),
            cms.InputTag("hltInclusiveSecondaryVertexFinderPatTagInfos"),
            # cms.InputTag("hltImpactParameterTagInfos"),
            # cms.InputTag("hltInclusiveSecondaryVertexFinderTagInfos"),
            # cms.InputTag("hltDeepCombinedSecondaryVertexBJetTagsInfoCalo"),
            # cms.InputTag("hltDeepSecondaryVertexPFPuppiPatTagInfos"),
        ),
        trackAssociationSource = cms.InputTag("hltAk4JetTracksAssociatorAtVertexCalo"),
    )

    # for patJets
    from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetFlavourAssociation,patJetPartons,patJetFlavourAssociationLegacy,patJetPartonAssociationLegacy,patJetPartonsLegacy
    process.hltPatJetFlavourAssociation = patJetFlavourAssociation.clone(
        bHadrons = cms.InputTag("hltPatJetPartons","bHadrons"),
        cHadrons = cms.InputTag("hltPatJetPartons","cHadrons"),
        jets = cms.InputTag(pfjets),
        leptons = cms.InputTag("hltPatJetPartons","leptons"),
        partons = cms.InputTag("hltPatJetPartons","physicsPartons"),
    )
    process.hltPatJetFlavourAssociationPuppi = patJetFlavourAssociation.clone(
        bHadrons = cms.InputTag("hltPatJetPartons","bHadrons"),
        cHadrons = cms.InputTag("hltPatJetPartons","cHadrons"),
        jets = cms.InputTag(puppijets),
        leptons = cms.InputTag("hltPatJetPartons","leptons"),
        partons = cms.InputTag("hltPatJetPartons","physicsPartons"),
        weights = cms.InputTag(puppi)
    )
    process.hltPatJetFlavourAssociationCalo = patJetFlavourAssociation.clone(
        bHadrons = cms.InputTag("hltPatJetPartons","bHadrons"),
        cHadrons = cms.InputTag("hltPatJetPartons","cHadrons"),
        jets = cms.InputTag(calojetsCutted),
        leptons = cms.InputTag("hltPatJetPartons","leptons"),
        partons = cms.InputTag("hltPatJetPartons","physicsPartons"),
    )
    process.hltPatJetPartons = patJetPartons.clone()

    process.hltPatJetFlavourAssociationLegacy = patJetFlavourAssociationLegacy.clone(
        srcByReference = cms.InputTag("hltPatJetPartonAssociationLegacy")
    )
    process.hltPatJetFlavourAssociationLegacyCalo = patJetFlavourAssociationLegacy.clone(
        srcByReference = cms.InputTag("hltPatJetPartonAssociationLegacyCalo")
    )
    process.hltPatJetFlavourAssociationLegacyPuppi = patJetFlavourAssociationLegacy.clone(
        srcByReference = cms.InputTag("hltPatJetPartonAssociationLegacyPuppi")
    )

    process.hltPatJetPartonAssociationLegacy = patJetPartonAssociationLegacy.clone(
        jets = cms.InputTag(pfjets),
        partons = cms.InputTag("hltPatJetPartonsLegacy")
    )
    process.hltPatJetPartonAssociationLegacyPuppi = patJetPartonAssociationLegacy.clone(
        jets = cms.InputTag(puppijets),
        partons = cms.InputTag("hltPatJetPartonsLegacy")
    )
    process.hltPatJetPartonAssociationLegacyCalo = patJetPartonAssociationLegacy.clone(
        jets = cms.InputTag(calojetsCutted),
        partons = cms.InputTag("hltPatJetPartonsLegacy")
    )

    process.hltPatJetPartonsLegacy = patJetPartonsLegacy.clone(
        src = cms.InputTag("genParticles"),
    )

    from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch
    process.hltPatJetGenJetMatch = patJetGenJetMatch.clone(
        matched = cms.InputTag("hltSlimmedGenJets"),
        src = cms.InputTag(pfjets)
    )
    process.hltPatJetGenJetMatchPuppi = patJetGenJetMatch.clone(
        matched = cms.InputTag("hltSlimmedGenJets"),
        src = cms.InputTag(puppijets)
    )
    process.hltPatJetGenJetMatchCalo = patJetGenJetMatch.clone(
        matched = cms.InputTag("hltSlimmedGenJets"),
        src = cms.InputTag(calojetsCutted)
    )

    from PhysicsTools.PatAlgos.slimming.slimmedGenJets_cfi import slimmedGenJets
    process.hltSlimmedGenJets = slimmedGenJets.clone(
        packedGenParticles = cms.InputTag("hltPackedGenParticles"),
        src = cms.InputTag("ak4GenJetsNoNu")
    )

    from PhysicsTools.PatAlgos.slimming.packedGenParticles_cfi import packedGenParticles
    process.hltPackedGenParticles = packedGenParticles.clone(
        inputCollection = cms.InputTag("hltPrunedGenParticlesWithStatusOne"),
        inputOriginal = cms.InputTag("genParticles"),
        map = cms.InputTag("hltPrunedGenParticles"),
    )

    from PhysicsTools.PatAlgos.slimming.genParticles_cff import prunedGenParticlesWithStatusOne
    from PhysicsTools.PatAlgos.slimming.prunedGenParticles_cfi import prunedGenParticles
    process.hltPrunedGenParticlesWithStatusOne = prunedGenParticlesWithStatusOne.clone(
        src = cms.InputTag("genParticles")
    )

    process.hltPrunedGenParticles = prunedGenParticles.clone(
        src = cms.InputTag("hltPrunedGenParticlesWithStatusOne")
    )

    from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetPartonMatch
    process.hltPatJetPartonMatch = patJetPartonMatch.clone(
        matched = cms.InputTag("hltPrunedGenParticles"),
        src = cms.InputTag(pfjets)
    )
    process.hltPatJetPartonMatchPuppi = patJetPartonMatch.clone(
        matched = cms.InputTag("hltPrunedGenParticles"),
        src = cms.InputTag(puppijets)
    )
    process.hltPatJetPartonMatchCalo = patJetPartonMatch.clone(
        matched = cms.InputTag("hltPrunedGenParticles"),
        src = cms.InputTag(calojetsCutted)
    )

    from PhysicsTools.PatAlgos.recoLayer0.jetTracksCharge_cff import patJetCharge
    process.hltPatJetCharge = patJetCharge.clone(
        src = cms.InputTag("hltAk4JetTracksAssociatorAtVertexPF"),
    )
    process.patJetPuppiCharge = patJetCharge.clone(
        src = cms.InputTag("hltAk4JetTracksAssociatorAtVertexPFPuppi"),
    )

    from RecoJets.JetAssociationProducers.ak4JTA_cff import ak4JetTracksAssociatorAtVertexPF
    process.hltAk4JetTracksAssociatorAtVertexPF = ak4JetTracksAssociatorAtVertexPF.clone(
        jets = cms.InputTag(pfjets),
        pvSrc = cms.InputTag(hltVertices),
        tracks = cms.InputTag(tracks),
    )
    process.hltAk4JetTracksAssociatorAtVertexPFPuppi = ak4JetTracksAssociatorAtVertexPF.clone(
        jets = cms.InputTag(puppijets),
        pvSrc = cms.InputTag(hltVertices),
        tracks = cms.InputTag(tracks),
    )
    process.hltAk4JetTracksAssociatorAtVertexCalo = ak4JetTracksAssociatorAtVertexPF.clone(
        jets = cms.InputTag(calojetsCutted),
        # pvSrc = cms.InputTag(hltVertices),
        # pvSrc = cms.InputTag("hltVerticesL3" if roiReplace==False else "hltVerticesL3ROIForBTag"),
        pvSrc = cms.InputTag("hltVerticesL3" if roiReplaceCalo==False else "hltVerticesL3FilterROIForBTag"),
        # pvSrc = cms.InputTag("hltVerticesL3Filter" if roiReplaceCalo==False else "hltVerticesL3FilterROIForBTag"),
        # tracks = cms.InputTag(tracks),
        tracks = cms.InputTag("hltMergedTracksForBTag" if roiReplaceCalo==False else "hltMergedTracksROIForBTag"),
    )

    from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi  import patJetCorrFactors
    process.hltPatJetCorrFactors = patJetCorrFactors.clone(
        payload = cms.string(payload),
        primaryVertices = cms.InputTag(hltVertices),
        rho = cms.InputTag(rho),
        src = cms.InputTag(pfjets),
    )
    process.hltPatJetCorrFactorsPuppi = patJetCorrFactors.clone(
        payload = cms.string(payloadPuppi),
        primaryVertices = cms.InputTag(hltVertices),
        rho = cms.InputTag(rho),
        src = cms.InputTag(puppijets),
    )

    from RecoJets.JetProducers.ak4JetID_cfi import ak4JetID
    process.hltAk4JetID = ak4JetID.clone(
        ebRecHitsColl = cms.InputTag(ecalRecHit,"EcalRecHitsEB"),
        eeRecHitsColl = cms.InputTag(ecalRecHit,"EcalRecHitsEE"),
        hbheRecHitsColl = cms.InputTag(hbhereco),
        hfRecHitsColl = cms.InputTag(hfreco),
        hoRecHitsColl = cms.InputTag(horeco),
        rpcRecHits = cms.InputTag(rpcRecHits),
        src = cms.InputTag(calojets),
    )



    #### TAGGERS
    # run DeepFlavour for HLT
    # from RecoBTag.ONNXRuntime.pfDeepFlavourJetTags_cfi import pfDeepFlavourJetTags
    # process.hltPFDeepFlavourJetTags = pfDeepFlavourJetTags.clone(
    #     src = cms.InputTag("hltPFDeepFlavourTagInfos")
    # )
    # process.hltPFPuppiDeepFlavourJetTags = pfDeepFlavourJetTags.clone(
    #     src = cms.InputTag("hltPFPuppiDeepFlavourTagInfos")
    # )
    # from RecoBTag.FeatureTools.pfDeepFlavourTagInfos_cfi import pfDeepFlavourTagInfos
    # process.hltPFDeepFlavourTagInfos = pfDeepFlavourTagInfos.clone(
    #     candidates = cms.InputTag(particleFlow),
    #     jets = cms.InputTag(pfjets),
    #     fallback_puppi_weight = cms.bool(True),
    #     puppi_value_map = cms.InputTag(""),
    #     secondary_vertices = cms.InputTag("hltDeepInclusiveSecondaryVerticesPF"),
    #     shallow_tag_infos = cms.InputTag("hltDeepCombinedSecondaryVertexBJetPatTagInfos"),
    #     vertex_associator = cms.InputTag("hltPrimaryVertexAssociation","original"),
    #     vertices = cms.InputTag(hltVertices)
    # )
    # process.hltPFPuppiDeepFlavourTagInfos = pfDeepFlavourTagInfos.clone(
    #     candidates = cms.InputTag(particleFlow),
    #     jets = cms.InputTag(puppijets),
    #     puppi_value_map = cms.InputTag(puppi),
    #     secondary_vertices = cms.InputTag("hltDeepInclusiveSecondaryVerticesPF"),
    #     shallow_tag_infos = cms.InputTag("hltDeepCombinedSecondaryVertexBPuppiJetPatTagInfos"),
    #     vertex_associator = cms.InputTag("hltPrimaryVertexAssociationPuppi","original"),
    #     vertices = cms.InputTag(hltVertices)
    # )
    if roiReplace==False:
        process.hltPrimaryVertexAssociationPat = process.hltPrimaryVertexAssociation.clone(
            jets = cms.InputTag(pfjets),
        )

        process.hltPFDeepFlavourPatTagInfos = process.hltPFDeepFlavourTagInfos.clone(
            jets = cms.InputTag(pfjets),
            shallow_tag_infos = cms.InputTag("hltDeepCombinedSecondaryVertexBJetPatTagInfos"),
            vertex_associator = cms.InputTag("hltPrimaryVertexAssociationPat","original"),
        )

        process.hltPFDeepFlavourPatJetTags = process.hltPFDeepFlavourJetTags.clone(
            src = cms.InputTag("hltPFDeepFlavourPatTagInfos")
        )
    else:
        process.hltPrimaryVertexAssociationPat = process.hltPrimaryVertexAssociationROIForBTag.clone(
            jets = cms.InputTag(pfjets),
        )

        process.hltPFDeepFlavourPatTagInfos = process.hltPFDeepFlavourTagInfosROIForBTag.clone(
            jets = cms.InputTag(pfjets),
            shallow_tag_infos = cms.InputTag("hltDeepCombinedSecondaryVertexBJetPatTagInfos"),
            vertex_associator = cms.InputTag("hltPrimaryVertexAssociationPat","original"),
        )

        process.hltPFDeepFlavourPatJetTags = process.hltPFDeepFlavourJetTagsROIForBTag.clone(
            src = cms.InputTag("hltPFDeepFlavourPatTagInfos")
        )

    from RecoBTag.SecondaryVertex.candidateCombinedSecondaryVertexV2Computer_cfi import candidateCombinedSecondaryVertexV2Computer
    process.candidateCombinedSecondaryVertexV2Computer = candidateCombinedSecondaryVertexV2Computer.clone()

    # from PhysicsTools.PatAlgos.slimming.primaryVertexAssociation_cfi import primaryVertexAssociation
    # process.hltPrimaryVertexAssociation = primaryVertexAssociation.clone(
    #     jets = cms.InputTag(pfjets),
    #     particles = cms.InputTag(particleFlow),
    #     vertices = cms.InputTag(hltVertices),
    # )
    # process.hltPrimaryVertexAssociationPuppi = primaryVertexAssociation.clone(
    #     jets = cms.InputTag(puppijets),
    #     particles = cms.InputTag(particleFlow),
    #     vertices = cms.InputTag(hltVertices),
    # )
    if roiReplace==False:
        process.HLTBtagDeepJetSequencePFPat = cms.Sequence(
            process.hltVerticesPF
            + process.hltVerticesPFSelector
            + process.hltVerticesPFFilter
            + process.hltDeepBLifetimePFPatTagInfos
            + process.hltDeepInclusiveVertexFinderPF
            + process.hltDeepInclusiveSecondaryVerticesPF
            + process.hltDeepTrackVertexArbitratorPF
            + process.hltDeepInclusiveMergedVerticesPF
            + process.hltDeepSecondaryVertexPFPatTagInfos
            + process.hltDeepCombinedSecondaryVertexBJetPatTagInfos
            + process.hltPrimaryVertexAssociationPat
            + process.hltPFDeepFlavourPatTagInfos
            + process.hltPFDeepFlavourPatJetTags
        )
    else:
        process.HLTBtagDeepJetSequencePFPat = cms.Sequence(
            process.hltVerticesPFROIForBTag
            + process.hltVerticesPFSelectorROIForBTag
            + process.hltVerticesPFFilterROIForBTag
            + process.hltDeepBLifetimePFPatTagInfos
            + process.hltDeepInclusiveVertexFinderPFROIForBTag
            + process.hltDeepInclusiveSecondaryVerticesPFROIForBTag
            + process.hltDeepTrackVertexArbitratorPFROIForBTag
            + process.hltDeepInclusiveMergedVerticesPFROIForBTag
            + process.hltDeepSecondaryVertexPFPatTagInfos
            + process.hltDeepCombinedSecondaryVertexBJetPatTagInfos
            + process.hltPrimaryVertexAssociationPat
            + process.hltPFDeepFlavourPatTagInfos
            + process.hltPFDeepFlavourPatJetTags
        )





    # create the final path
    if runPF:
        if roiReplace==False:
            process.MC_JetsMatchingPath = cms.Path(
                process.HLTBeginSequence
                +process.HLTAK4PFJetsSequence
                +process.HLTBtagDeepCSVSequencePFPat
                +process.hltPrunedGenParticlesWithStatusOne
                +process.hltPrunedGenParticles
                +process.hltPackedGenParticles
                +process.hltPatJetPartonMatch
                +process.hltSlimmedGenJets
                +process.hltAk4JetID
                +process.hltPatJetGenJetMatch
                +process.hltPatJetPartonsLegacy
                +process.hltPatJetPartonAssociationLegacy
                +process.hltPatJetFlavourAssociationLegacy
                +process.hltPatJetPartons
                +process.hltPatJetFlavourAssociation
                +process.hltAk4JetTracksAssociatorAtVertexPF
                +process.hltPatJetCharge
                +process.hltPatJetCorrFactors

                # +process.hltPrimaryVertexAssociationPat
                # +process.hltPFDeepFlavourPatTagInfos
                # +process.hltPFDeepFlavourPatJetTags
                + process.HLTBtagDeepJetSequencePFPat

                +process.hltPatJets
                +process.HLTEndSequence
            )
            if isData:
                process.MC_JetsMatchingPath = cms.Path(
                    process.HLTBeginSequence
                    +process.HLTAK4PFJetsSequence
                    +process.HLTBtagDeepCSVSequencePFPat
                    # +process.hltPrunedGenParticlesWithStatusOne
                    # +process.hltPrunedGenParticles
                    # +process.hltPackedGenParticles
                    # +process.hltPatJetPartonMatch
                    # +process.hltSlimmedGenJets
                    +process.hltAk4JetID
                    # +process.hltPatJetGenJetMatch
                    # +process.hltPatJetPartonsLegacy
                    # +process.hltPatJetPartonAssociationLegacy
                    # +process.hltPatJetFlavourAssociationLegacy
                    # +process.hltPatJetPartons
                    # +process.hltPatJetFlavourAssociation
                    +process.hltAk4JetTracksAssociatorAtVertexPF
                    +process.hltPatJetCharge
                    +process.hltPatJetCorrFactors

                    # +process.hltPrimaryVertexAssociationPat
                    # +process.hltPFDeepFlavourPatTagInfos
                    # +process.hltPFDeepFlavourPatJetTags
                    + process.HLTBtagDeepJetSequencePFPat

                    +process.hltPatJets
                    +process.HLTEndSequence
                )
        else:
            process.MC_JetsMatchingPath = cms.Path(
                process.HLTBeginSequence
                +process.HLTAK4PFJetsSequenceROIForBTag
                +process.HLTBtagDeepCSVSequencePFPat
                +process.hltPrunedGenParticlesWithStatusOne
                +process.hltPrunedGenParticles
                +process.hltPackedGenParticles
                +process.hltPatJetPartonMatch
                +process.hltSlimmedGenJets
                +process.hltAk4JetID
                +process.hltPatJetGenJetMatch
                +process.hltPatJetPartonsLegacy
                +process.hltPatJetPartonAssociationLegacy
                +process.hltPatJetFlavourAssociationLegacy
                +process.hltPatJetPartons
                +process.hltPatJetFlavourAssociation
                +process.hltAk4JetTracksAssociatorAtVertexPF
                +process.hltPatJetCharge
                +process.hltPatJetCorrFactors

                # +process.hltPrimaryVertexAssociationPat
                # +process.hltPFDeepFlavourPatTagInfos
                # +process.hltPFDeepFlavourPatJetTags
                + process.HLTBtagDeepJetSequencePFPat

                +process.hltPatJets
                +process.HLTEndSequence
            )
            if isData:
                process.MC_JetsMatchingPath = cms.Path(
                    process.HLTBeginSequence
                    +process.HLTAK4PFJetsSequenceROIForBTag
                    +process.HLTBtagDeepCSVSequencePFPat
                    # +process.hltPrunedGenParticlesWithStatusOne
                    # +process.hltPrunedGenParticles
                    # +process.hltPackedGenParticles
                    # +process.hltPatJetPartonMatch
                    # +process.hltSlimmedGenJets
                    +process.hltAk4JetID
                    # +process.hltPatJetGenJetMatch
                    # +process.hltPatJetPartonsLegacy
                    # +process.hltPatJetPartonAssociationLegacy
                    # +process.hltPatJetFlavourAssociationLegacy
                    # +process.hltPatJetPartons
                    # +process.hltPatJetFlavourAssociation
                    +process.hltAk4JetTracksAssociatorAtVertexPF
                    +process.hltPatJetCharge
                    +process.hltPatJetCorrFactors

                    # +process.hltPrimaryVertexAssociationPat
                    # +process.hltPFDeepFlavourPatTagInfos
                    # +process.hltPFDeepFlavourPatJetTags
                    + process.HLTBtagDeepJetSequencePFPat

                    +process.hltPatJets
                    +process.HLTEndSequence
                )

    if runPuppi:
        process.MC_PuppiJetsMatchingPath = cms.Path(
            process.HLTBeginSequence
            +process.HLTAK4PFPuppiJetsSequence
            +process.HLTBtagDeepCSVSequencePFPuppiPat
            +process.hltPrunedGenParticlesWithStatusOne
            +process.hltPrunedGenParticles
            +process.hltPackedGenParticles
            +process.hltPatJetPartonMatchPuppi
            +process.hltSlimmedGenJets
            +process.hltAk4JetID
            +process.hltPatJetGenJetMatchPuppi
            +process.hltPatJetPartonsLegacy
            +process.hltPatJetPartonAssociationLegacyPuppi
            +process.hltPatJetFlavourAssociationLegacyPuppi
            +process.hltPatJetPartons
            +process.hltPatJetFlavourAssociationPuppi
            +process.hltAk4JetTracksAssociatorAtVertexPFPuppi
            +process.patJetPuppiCharge
            +process.hltPatJetCorrFactorsPuppi

            +process.hltPrimaryVertexAssociationPuppi
            +process.hltPFPuppiDeepFlavourTagInfos
            +process.hltPFPuppiDeepFlavourJetTags

            +process.hltPatJetsPuppi
            +process.HLTEndSequence
        )

    if runCalo:
        process.MC_CaloJetsMatchingPath = cms.Path(
            process.HLTBeginSequence
            # +process.HLTAK4CaloJetsCorrectionSequence
            +process.HLTAK4CaloJetsSequence
            +process.HLTBtagDeepCSVSequenceCaloPat
            +process.hltPrunedGenParticlesWithStatusOne
            +process.hltPrunedGenParticles
            +process.hltPackedGenParticles
            +process.hltPatJetPartonMatchCalo
            +process.hltSlimmedGenJets
            +process.hltPatJetGenJetMatchCalo
            +process.hltPatJetPartonsLegacy
            +process.hltPatJetPartons
            +process.hltPatJetPartonAssociationLegacyCalo
            +process.hltPatJetFlavourAssociationLegacyCalo
            +process.hltPatJetFlavourAssociationCalo
            +process.hltAk4JetTracksAssociatorAtVertexCalo

            +process.hltPatJetsCalo
            +process.HLTEndSequence
        )
        if isData:
            process.MC_CaloJetsMatchingPath = cms.Path(
                process.HLTBeginSequence
                # +process.HLTAK4CaloJetsCorrectionSequence
                +process.HLTAK4CaloJetsSequence
                +process.HLTBtagDeepCSVSequenceCaloPat
                # +process.hltPrunedGenParticlesWithStatusOne
                # +process.hltPrunedGenParticles
                # +process.hltPackedGenParticles
                # +process.hltPatJetPartonMatchCalo
                # +process.hltSlimmedGenJets
                # +process.hltPatJetGenJetMatchCalo
                # +process.hltPatJetPartonsLegacy
                # +process.hltPatJetPartons
                # +process.hltPatJetPartonAssociationLegacyCalo
                # +process.hltPatJetFlavourAssociationLegacyCalo
                # +process.hltPatJetFlavourAssociationCalo
                +process.hltAk4JetTracksAssociatorAtVertexCalo

                +process.hltPatJetsCalo
                +process.HLTEndSequence
            )

    if process.schedule_():
        if runPF: process.schedule.extend([process.MC_JetsMatchingPath])
        if runCalo: process.schedule.extend([process.MC_CaloJetsMatchingPath])
        if runPuppi: process.schedule.extend([process.MC_PuppiJetsMatchingPath])

    return process