Пример #1
0
import FWCore.ParameterSet.Config as cms

from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch, patJetPartonMatch
from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets

from HeavyIonsAnalysis.JetAnalysis.inclusiveJetAnalyzer_cff import *
from HeavyIonsAnalysis.JetAnalysis.bTaggers_cff import *

from RecoJets.JetProducers.JetIDParams_cfi import *
from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness

akCsSoftDrop2PFmatch = patJetGenJetMatch.clone(
    src=cms.InputTag("akCsSoftDrop2PFJets"),
    matched=cms.InputTag("ak2HiSignalGenJets"),
    resolveByMatchQuality=cms.bool(True),
    maxDeltaR=0.2)

akCsSoftDrop2PFmatchGroomed = patJetGenJetMatch.clone(
    src=cms.InputTag("akSoftDrop2HiSignalGenJets"),
    matched=cms.InputTag("ak2HiSignalGenJets"),
    resolveByMatchQuality=cms.bool(True),
    maxDeltaR=0.2)

akCsSoftDrop2PFparton = patJetPartonMatch.clone(
    src=cms.InputTag("akCsSoftDrop2PFJets"),
    matched=cms.InputTag("hiSignalGenParticles"))

akCsSoftDrop2PFcorr = patJetCorrFactors.clone(
    useNPV=cms.bool(False),
    useRho=cms.bool(False),
Пример #2
0
import FWCore.ParameterSet.Config as cms

from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch, patJetPartonMatch
from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets

from HeavyIonsAnalysis.JetAnalysis.inclusiveJetAnalyzer_cff import *
from HeavyIonsAnalysis.JetAnalysis.bTaggers_cff import *

from RecoJets.JetProducers.JetIDParams_cfi import *
from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness

akCs3PFmatch = patJetGenJetMatch.clone(src=cms.InputTag("akCs3PFJets"),
                                       matched=cms.InputTag("ak3GenJets"),
                                       resolveByMatchQuality=cms.bool(True),
                                       maxDeltaR=0.3)

akCs3PFmatchGroomed = patJetGenJetMatch.clone(
    src=cms.InputTag("ak3GenJets"),
    matched=cms.InputTag("ak3GenJets"),
    resolveByMatchQuality=cms.bool(True),
    maxDeltaR=0.3)

akCs3PFparton = patJetPartonMatch.clone(src=cms.InputTag("akCs3PFJets"),
                                        matched=cms.InputTag("genParticles"))

akCs3PFcorr = patJetCorrFactors.clone(useNPV=cms.bool(False),
                                      useRho=cms.bool(False),
                                      levels=cms.vstring('L2Relative'),
                                      src=cms.InputTag("akCs3PFJets"),
                                      payload="AK3PF")
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
Пример #4
0
import FWCore.ParameterSet.Config as cms

from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch, patJetPartonMatch
from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets

from HeavyIonsAnalysis.JetAnalysis.inclusiveJetAnalyzer_cff import *
from HeavyIonsAnalysis.JetAnalysis.bTaggers_cff import *

from RecoJets.JetProducers.JetIDParams_cfi import *
from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness

akFlowPuCs4PFmatch = patJetGenJetMatch.clone(
    src=cms.InputTag("akFlowPuCs4PFJets"),
    matched=cms.InputTag("ak4HiSignalGenJets"),
    resolveByMatchQuality=cms.bool(True),
    maxDeltaR=0.4)

akFlowPuCs4PFmatchGroomed = patJetGenJetMatch.clone(
    src=cms.InputTag("ak4HiSignalGenJets"),
    matched=cms.InputTag("ak4HiSignalGenJets"),
    resolveByMatchQuality=cms.bool(True),
    maxDeltaR=0.4)

akFlowPuCs4PFparton = patJetPartonMatch.clone(
    src=cms.InputTag("akFlowPuCs4PFJets"),
    matched=cms.InputTag("hiSignalGenParticles"))

akFlowPuCs4PFcorr = patJetCorrFactors.clone(
    useNPV=cms.bool(False),
    useRho=cms.bool(False),
Пример #5
0
import FWCore.ParameterSet.Config as cms

from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch, patJetPartonMatch
from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets

from HeavyIonsAnalysis.JetAnalysis.inclusiveJetAnalyzer_cff import *
from HeavyIonsAnalysis.JetAnalysis.bTaggers_cff import *

from RecoJets.JetProducers.JetIDParams_cfi import *
from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness

akPu3Calomatch = patJetGenJetMatch.clone(
    src = cms.InputTag("akPu3CaloJets"),
    matched = cms.InputTag("ak3GenJets"),
    resolveByMatchQuality = cms.bool(False),
    maxDeltaR = 0.3
    )

akPu3CalomatchGroomed = patJetGenJetMatch.clone(
    src = cms.InputTag("ak3GenJets"),
    matched = cms.InputTag("ak3GenJets"),
    resolveByMatchQuality = cms.bool(False),
    maxDeltaR = 0.3
    )

akPu3Caloparton = patJetPartonMatch.clone(
    src = cms.InputTag("akPu3CaloJets"),
    matched = cms.InputTag("genParticles"))

akPu3Calocorr = patJetCorrFactors.clone(
Пример #6
0
#Matching
from PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi import selectedHadronsAndPartons
from PhysicsTools.JetMCAlgos.AK4PFJetsMCFlavourInfos_cfi import ak4JetFlavourInfos
myak4JetFlavourInfos = ak4JetFlavourInfos.clone(jets = cms.InputTag("ak4PFJetsCHS"))

#Get gen jet collection for real jets
ak4GenJetsForPUid = cms.EDFilter("GenJetSelector",
                                 src = cms.InputTag("ak4GenJets"),
                                 cut = cms.string('pt > 8.'),
                                 filter = cms.bool(False)
                                 )
#do reco gen - reco matching
from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch
newpatJetGenJetMatch = patJetGenJetMatch.clone(
    src = cms.InputTag("ak4PFJetsCHS"),
    matched = cms.InputTag("ak4GenJetsForPUid"),
    maxDeltaR = cms.double(0.25),
    resolveAmbiguities = cms.bool(True)
)

# Module execution for MC
from Validation.RecoB.bTagAnalysis_cfi import *
bTagValidation.jetMCSrc = 'myak4JetFlavourInfos'
bTagValidation.ptRanges = cms.vdouble(0.0)
bTagValidation.etaRanges = cms.vdouble(0.0)
bTagValidation.doJetID = True
bTagValidation.doJEC = True
bTagValidation.JECsource = cms.string("ak4PFCHSL1FastL2L3")
bTagValidation.genJetsMatched = cms.InputTag("newpatJetGenJetMatch")
#to run on fastsim
prebTagSequenceMC = cms.Sequence(ak4GenJetsForPUid*newpatJetGenJetMatch*selectedHadronsAndPartons*myak4JetFlavourInfos)
bTagPlotsMC = cms.Sequence(bTagValidation)
Пример #7
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
Пример #8
0
import FWCore.ParameterSet.Config as cms

from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch, patJetPartonMatch
from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets

from HeavyIonsAnalysis.JetAnalysis.inclusiveJetAnalyzer_cff import *
from HeavyIonsAnalysis.JetAnalysis.bTaggers_cff import *

from RecoJets.JetProducers.JetIDParams_cfi import *
from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness

akSoftDropZ05B156PFmatch = patJetGenJetMatch.clone(
    src=cms.InputTag("akSoftDropZ05B156PFJets"),
    matched=cms.InputTag("ak6HiSignalGenJets"),
    resolveByMatchQuality=cms.bool(False),
    maxDeltaR=0.6)

akSoftDropZ05B156PFmatchGroomed = patJetGenJetMatch.clone(
    src=cms.InputTag("akSoftDropZ05B156HiSignalGenJets"),
    matched=cms.InputTag("ak6HiSignalGenJets"),
    resolveByMatchQuality=cms.bool(False),
    maxDeltaR=0.6)

akSoftDropZ05B156PFparton = patJetPartonMatch.clone(
    src=cms.InputTag("akSoftDropZ05B156PFJets"),
    matched=cms.InputTag("hiSignalGenParticles"))

akSoftDropZ05B156PFcorr = patJetCorrFactors.clone(
    useNPV=cms.bool(False),
    useRho=cms.bool(False),
Пример #9
0
    def toolCode(self, process):
        """
        Tool code implementation
        """
        ## initialize parameters
        labelName='patJets'+self._parameters['labelName'].value
        postfix=self._parameters['postfix'].value
        jetSource=self._parameters['jetSource'].value
        algo=self._parameters['algo'].value
        jetCorrections=self._parameters['jetCorrections'].value
        btagDiscriminators=list(self._parameters['btagDiscriminators'].value)
        btagInfos=list(self._parameters['btagInfos'].value)
        jetTrackAssociation=self._parameters['jetTrackAssociation'].value
        outputModules=list(self._parameters['outputModules'].value)

        ## a list of all producer modules, which are already known to process
        knownModules = process.producerNames().split()
        ## determine whether btagging information is required or not
        if btagDiscriminators.count('None')>0:
            btagDiscriminators.remove('None')
        if btagInfos.count('None')>0:
            btagInfos.remove('None')
        bTagging=(len(btagDiscriminators)>0 or len(btagInfos)>0)
        ## construct postfix label for auxiliary modules; this postfix
        ## label will start with a capitalized first letter following
        ## the CMS nameing conventions and for improved readablility
        _labelName=labelName[:1].upper()+labelName[1:]
	#_labelName=labelName
        ## determine jet algorithm from jetSource; supported algo types
        ## are ak, kt, sc, ic. This loop expects that the algo type is
        ## followed by a single integer corresponding to the opening
        ## angle parameter dR times 10 (examples ak5, kt4, kt6, ...)
        _algo=algo
	#jetSource=cms.InputTag("ak5PFJets")
        for x in ["ak", "kt", "sc", "ic"]:
            if jetSource.getModuleLabel().lower().find(x)>-1:
                _algo=jetSource.getModuleLabel()[jetSource.getModuleLabel().lower().find(x):jetSource.getModuleLabel().lower().find(x)+3]
	#print _algo
        ## add new patJets to process (keep instance for later further modifications)
        from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets
        if labelName in knownModules :
            _newPatJets=getattr(process, labelName+postfix)
            _newPatJets.jetSource=jetSource
        else :
            #setattr(process, labelName, patJets.clone(jetSource=jetSource))
            setattr(process, labelName+postfix, patJets.clone(jetSource=jetSource))
            _newPatJets=getattr(process, labelName+postfix)
            knownModules.append(labelName+postfix)
        ## add new selectedPatJets to process
        from PhysicsTools.PatAlgos.selectionLayer1.jetSelector_cfi import selectedPatJets
        if 'selected'+_labelName+postfix in knownModules :
            _newSelectedPatJets=getattr(process, 'selected'+_labelName+postfix)
            _newSelectedPatJets.src=labelName+postfix
        else :
            setattr(process, 'selected'+_labelName+postfix, selectedPatJets.clone(src=labelName+postfix))
            knownModules.append('selected'+_labelName+postfix)

        ## set postfix label to '' if there is no labelName given. In this case all
        ## modules should keep there names w/o postfixes. This will cover the case
        ## of switchJectCollection
        if self._parameters['labelName'].value == '' :
            _labelName = ''

	## add new patJetPartonMatch to process
        from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetPartonMatch
        if 'patJetPartonMatch'+_labelName+postfix in knownModules :
            _newPatJetPartonMatch=getattr(process, 'patJetPartonMatch'+_labelName+postfix)
            _newPatJetPartonMatch.src=jetSource
        else :
            setattr(process, 'patJetPartonMatch'+_labelName+postfix, patJetPartonMatch.clone(src=jetSource))
            knownModules.append('patJetPartonMatch'+_labelName+postfix)
        ## add new patJetGenJetMatch to process
        from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch
        if 'patJetGenJetMatch'+_labelName+postfix in knownModules :
            _newPatJetGenJetMatch=getattr(process, 'patJetGenJetMatch'+_labelName+postfix)
            _newPatJetGenJetMatch.src=jetSource
            _newPatJetGenJetMatch.matched=_algo.lower()+'GenJets'+postfix
        else :
            setattr(process, 'patJetGenJetMatch'+_labelName+postfix, patJetGenJetMatch.clone(src=jetSource, matched=_algo+'GenJets'))
            knownModules.append('patJetGenJetMatch'+_labelName+postfix)
        ## add new patJetPartonAssociation to process
        from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetPartonAssociation
        if 'patJetPartonAssociation'+_labelName+postfix in knownModules :
            _newPatJetPartonAssociation=getattr(process, 'patJetPartonAssociation'+_labelName+postfix, patJetPartonAssociation.clone(jets=jetSource))
            _newPatJetPartonAssociation.jets=jetSource
        else :
            setattr(process, 'patJetPartonAssociation'+_labelName+postfix, patJetPartonAssociation.clone(jets=jetSource))
            knownModules.append('patJetPartonAssociation'+_labelName+postfix)
        ## add new patJetPartonAssociation to process
        from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetFlavourAssociation
        if 'patJetFlavourAssociation'+_labelName+postfix in knownModules :
            _newPatJetFlavourAssociation=getattr(process, 'patJetFlavourAssociation'+_labelName+postfix, patJetFlavourAssociation.clone(srcByReference='patJetPartonAssociation'+_labelName+postfix))
            _newPatJetFlavourAssociation.srcByReference='patJetPartonAssociation'+_labelName+postfix
        else:
            setattr(process, 'patJetFlavourAssociation'+_labelName+postfix, patJetFlavourAssociation.clone(srcByReference='patJetPartonAssociation'+_labelName+postfix))
            knownModules.append('patJetFlavourAssociation'+_labelName+postfix)
        ## modify new patJets collection accordingly
        _newPatJets.genJetMatch.setModuleLabel('patJetGenJetMatch'+_labelName+postfix)
        _newPatJets.genPartonMatch.setModuleLabel('patJetPartonMatch'+_labelName+postfix)
        _newPatJets.JetPartonMapSource.setModuleLabel('patJetFlavourAssociation'+_labelName+postfix)

        ## add jetTrackAssociation for btagging (or jetTracksAssociation only) if required by user
        if (jetTrackAssociation or bTagging):
            ## add new jetTracksAssociationAtVertex to process
            from RecoJets.JetAssociationProducers.ak5JTA_cff import ak5JetTracksAssociatorAtVertex
            if 'jetTracksAssociationAtVertex'+_labelName+postfix in knownModules :
                _newJetTracksAssociationAtVertex=getattr(process, 'jetTracksAssociatorAtVertex'+_labelName+postfix)
                _newJetTracksAssociationAtVertex.jets=jetSource
            else:
                setattr(process, 'jetTracksAssociatorAtVertex'+_labelName+postfix, ak5JetTracksAssociatorAtVertex.clone(jets=jetSource))
                knownModules.append('jetTracksAssociationAtVertex'+_labelName+postfix)
            ## add new patJetCharge to process
            from PhysicsTools.PatAlgos.recoLayer0.jetTracksCharge_cff import patJetCharge
            if 'patJetCharge'+_labelName+postfix in knownModules :
                _newPatJetCharge=getattr(process, 'patJetCharge'+_labelName+postfix)
                _newPatJetCharge.src='jetTracksAssociatorAtVertex'+_labelName+postfix
            else:
                setattr(process, 'patJetCharge'+_labelName+postfix, patJetCharge.clone(src = 'jetTracksAssociatorAtVertex'+_labelName+postfix))
                knownModules.append('patJetCharge'+_labelName+postfix)
            ## modify new patJets collection accordingly
            _newPatJets.addAssociatedTracks=True
            _newPatJets.trackAssociationSource=cms.InputTag('jetTracksAssociatorAtVertex'+_labelName+postfix)
            _newPatJets.addJetCharge=True
            _newPatJets.jetChargeSource=cms.InputTag('patJetCharge'+_labelName+postfix)
        else:
            ## modify new patJets collection accordingly
            _newPatJets.addAssociatedTracks=False
            _newPatJets.trackAssociationSource=''
            _newPatJets.addJetCharge=False
            _newPatJets.jetChargeSource=''
        ## run btagging if required by user
        if (bTagging):
            ## expand tagInfos to what is explicitely required by user + implicit
            ## requirements that come in from one or the other discriminator
            requiredTagInfos = list(btagInfos)
            for btagDiscr in btagDiscriminators :
                for requiredTagInfo in supportedBtagDiscr[btagDiscr] :
                    tagInfoCovered = False
                    for tagInfo in requiredTagInfos :
                        if requiredTagInfo == tagInfo :
                            tagInfoCovered = True
                            break
                    if not tagInfoCovered :
                        requiredTagInfos.append(requiredTagInfo)
            ## load sequences and setups needed fro btagging
	    ## This loads all available btagger, but the ones we need are added to the process by hand lader. Only needed to get the ESProducer. Needs improvement
            #loadWithPostFix(process,"RecoBTag.Configuration.RecoBTag_cff",postfix)
            process.load("RecoBTag.Configuration.RecoBTag_cff")
	    #addESProducers(process,'RecoBTag.Configuration.RecoBTag_cff')
            import RecoBTag.Configuration.RecoBTag_cff as btag

            ## prepare setups for simple secondary vertex infos
            setattr(process, "simpleSecondaryVertex2Trk", simpleSecondaryVertex2Trk)
            ## prepare setups for transient tracks
            setattr(process, "TransientTrackBuilderESProducer", TransientTrackBuilderESProducer)
            ## setup all required btagInfos : we give a dedicated treatment for all five different
            ## types of tagINfos here. A common treatment is possible but might require a more
            ## general approach anyway in coordination with the btaggin POG.
            for btagInfo in requiredTagInfos :
                if 'impactParameterTagInfos' in btagInfo :
                    setattr(process, btagInfo+_labelName+postfix, btag.impactParameterTagInfos.clone(jetTracks = cms.InputTag('jetTracksAssociatorAtVertex'+_labelName+postfix)))
                if 'secondaryVertexTagInfos' in btagInfo :
                    setattr(process, btagInfo+_labelName+postfix, btag.secondaryVertexTagInfos.clone(trackIPTagInfos = cms.InputTag('impactParameterTagInfos'+_labelName+postfix)))
                if 'secondaryVertexNegativeTagInfos' in btagInfo :
                    setattr(process, btagInfo+_labelName+postfix, btag.secondaryVertexNegativeTagInfos.clone(trackIPTagInfos = cms.InputTag('impactParameterTagInfos'+_labelName+postfix)))
                if 'softElectronTagInfos' in btagInfo :
                    setattr(process, btagInfo+_labelName+postfix, btag.softElectronTagInfos.clone(jets = cms.InputTag(_newJetCollection)))
                if 'softMuonTagInfos' in btagInfo :
                    setattr(process, btagInfo+_labelName+postfix, btag.softMuonTagInfos.clone(jets = cms.InputTag(_newJetCollection)))
            ## setup all required btagDiscriminators
            for btagDiscr in btagDiscriminators :
                setattr(process, btagDiscr+_labelName+postfix, getattr(btag, btagDiscr).clone(tagInfos = cms.VInputTag( *[ cms.InputTag(x+_labelName+postfix) for x in supportedBtagDiscr[btagDiscr] ] )))
            ## replace corresponding tags for pat jet production
            _newPatJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(x+_labelName+postfix) for x in btagInfos ] )
            _newPatJets.discriminatorSources = cms.VInputTag( *[ cms.InputTag(x+_labelName+postfix) for x in btagDiscriminators ] )
        else:
            _newPatJets.addBTagInfo = False
            ## adjust output module; these collections will be empty anyhow, but we do it to stay clean
            for outputModule in outputModules:
                    if hasattr(process,outputModule):
                        getattr(process,outputModule).outputCommands.append("drop *_"+'selected'+_labelName+postfix+"_tagInfos_*")

        ## add jet correction factors if required by user
        if (jetCorrections != None):
            ## check for the correct format
            if type(jetCorrections) != type(('PAYLOAD-LABEL',['CORRECTION-LEVEL-A','CORRECTION-LEVEL-B'], 'MET-LABEL')):
                raise ValueError, "In addJetCollection: 'jetCorrections' must be 'None' (as a python value w/o quotation marks), or of type ('PAYLOAD-LABEL', ['CORRECTION-LEVEL-A', \
                'CORRECTION-LEVEL-B', ...], 'MET-LABEL'). Note that 'MET-LABEL' can be set to 'None' (as a string in quotation marks) in case you do not want to apply MET(Type1) \
                corrections."
            ## determine type of jet constituents from jetSource; supported
            ## jet constituent types are calo, pf, jpt, for pf also particleflow
            ## is aloowed as part of the jetSource label, which might be used
            ## in CommonTools.ParticleFlow
            _type="NONE"
            if jetCorrections[0].count('PF')>0:
                _type='PF'
            elif jetCorrections[0].count('Calo')>0:
                _type='Calo'
            elif jetCorrections[0].count('JPT')>0:
                _type='JPT'
            else:
                raise TypeError, "In addJetCollection: Jet energy corrections are only supported for PF, JPT and Calo jets."
            from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
            if 'patJetCorrFactors'+_labelName+postfix in knownModules :
                _newPatJetCorrFactors=getattr(process, 'patJetCorrFactors'+_labelName+postfix)
                _newPatJetCorrFactors.src=jetSource
            else :

                setattr(process, 'patJetCorrFactors'+_labelName+postfix, patJetCorrFactors.clone(src=jetSource))
                _newPatJetCorrFactors=getattr(process, "patJetCorrFactors"+_labelName+postfix)
            _newPatJetCorrFactors.payload=jetCorrections[0]
            _newPatJetCorrFactors.levels=jetCorrections[1]
            ## check whether L1Offset or L1FastJet is part of levels
            error=False
            for x in jetCorrections[1]:
                if x == 'L1Offset' :
                    if not error :
                        _newPatJetCorrFactors.useNPV=True
                        _newPatJetCorrFactors.primaryVertices='offlinePrimaryVertices'
                        ## we set this to True now as a L1 correction type should appear only once
                        ## otherwise levels is miss configured
                        error=True
                    else:
                        raise ValueError, "In addJetCollection: Correction levels for jet energy corrections are miss configured. An L1 correction type should appear not more than \
                        once. Check the list of correction levels you requested to be applied: ", jetCorrections[1]
                if x == 'L1FastJet' :
                    if not error :
                        if _type == "JPT" :
                            raise TypeError, "In addJetCollection: L1FastJet corrections are only supported for PF and Calo jets."
                        ## configure module
                        _newPatJetCorrFactors.useRho=True
                        _newPatJetCorrFactors.rho=cms.InputTag('kt6'+_type+'Jets', 'rho')
                        ## we set this to True now as a L1 correction type should appear only once
                        ## otherwise levels is miss configured
                        error=True
                    else:
                        raise ValueError, "In addJetCollection: Correction levels for jet energy corrections are miss configured. An L1 correction type should appear not more than \
                        once. Check the list of correction levels you requested to be applied: ", jetCorrections[1]
            _newPatJets.jetCorrFactorsSource=cms.VInputTag(cms.InputTag('patJetCorrFactors'+_labelName+postfix))
            ## configure MET(Type1) corrections
            if jetCorrections[2].lower() != 'none' and jetCorrections[2] != '':
                if not jetCorrections[2].lower() == 'type-1' and not jetCorrections[2].lower() == 'type-2':
                    raise valueError, "In addJetCollection: Wrong choice of MET corrections for new jet collection. Possible choices are None (or empty string), Type-1, Type-2 (i.e.\
                    Type-1 and Type-2 corrections applied). This choice is not case sensitive. Your choice was: ", jetCorrections[2]
                if _type == "JPT":
                    raise ValueError, "In addJecCollection: MET(type1) corrections are not supported for JPTJets. Please set the MET-LABEL to \"None\" (as string in quatiation \
                    marks) and use raw tcMET together with JPTJets."
                ## set up jet correctors for MET corrections
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL1Fastjet
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL1Offset
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL2Relative
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL3Absolute
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFResidual

                setattr(process, jetCorrections[0]+'L1FastJet', ak5PFL1Fastjet.clone(algorithm=jetCorrections[0], srcRho=cms.InputTag('kt6'+_type+'Jets','rho')))
                setattr(process, jetCorrections[0]+'L1Offset', ak5PFL1Offset.clone(algorithm=jetCorrections[0]))
                setattr(process, jetCorrections[0]+'L2Relative', ak5PFL2Relative.clone(algorithm=jetCorrections[0]))
                setattr(process, jetCorrections[0]+'L3Absolute', ak5PFL3Absolute.clone(algorithm=jetCorrections[0]))
                setattr(process, jetCorrections[0]+'L2L3Residual', ak5PFResidual.clone(algorithm=jetCorrections[0]))
                setattr(process, jetCorrections[0]+'CombinedCorrector', cms.ESProducer( 'JetCorrectionESChain', correctors = cms.vstring()))
                for x in jetCorrections[1]:
                    if x != 'L1FastJet' and x != 'L1Offset' and x != 'L2Relative' and x != 'L3Absolute' and x != 'L2L3Residual':
                        raise ValueError, 'In addJetCollection: Unsupported JEC for MET(Type1). Currently supported jet correction levels are L1FastJet, L1Offset, L2Relative, \
                        L3Asolute, L2L3Residual. Requested was:', x
                    else:
                        getattr(process, jetCorrections[0]+'CombinedCorrector').correctors.append(jetCorrections[0]+x)

                ## set up MET(Type1) correction modules
                if _type == 'Calo':
                    from JetMETCorrections.Type1MET.caloMETCorrections_cff import caloJetMETcorr
                    from JetMETCorrections.Type1MET.caloMETCorrections_cff import caloType1CorrectedMet
                    from JetMETCorrections.Type1MET.caloMETCorrections_cff import caloType1p2CorrectedMet
                    setattr(process,jetCorrections[0]+'JetMETcorr'+postfix, caloJetMETcorr.clone(src=jetSource,srcMET = "corMetGlobalMuons",jetCorrections = cms.string(jetCorrections[0]+'CombinedCorrector'+postfix)))
                    setattr(process,jetCorrections[0]+'Type1CorMet'+postfix, caloType1CorrectedMet.clone(src = "corMetGlobalMuons"+postfix,srcType1Corrections = cms.VInputTag(cms.InputTag(jetCorrections[0]+'JetMETcorr'+postfix, 'type1'))))
                    setattr(process,jetCorrections[0]+'Type1p2CorMet'+postfix,caloType1p2CorrectedMet.clone(src = "corMetGlobalMuons"+postfix,srcType1Corrections = cms.VInputTag(cms.InputTag(jetCorrections[0]+'JetMETcorr'+postfix, 'type1')),srcUnclEnergySums = cms.VInputTag(cms.InputTag(jetCorrections[0]+'JetMETcorr'+postfix, 'type2'),cms.InputTag(jetCorrections[0]+'JetMETcorr'+postfix, 'offset'),cms.InputTag('muonCaloMETcorr'+postfix))))

                elif _type == 'PF':
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfCandsNotInJet
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfJetMETcorr
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfCandMETcorr
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfType1CorrectedMet
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfType1p2CorrectedMet
                    setattr(process,jetCorrections[0]+'CandsNotInJet'+postfix,pfCandsNotInJet.clone(topCollection = jetSource))
                    setattr(process,jetCorrections[0]+'CandMETcorr'+postfix, pfCandMETcorr.clone(src = cms.InputTag(jetCorrections[0]+'CandsNotInJet'+postfix)))
                    setattr(process,jetCorrections[0]+'JetMETcorr'+postfix, pfJetMETcorr.clone(src = jetSource))
                    setattr(process,jetCorrections[0]+'Type1CorMet'+postfix, pfType1CorrectedMet.clone(srcType1Corrections = cms.VInputTag(cms.InputTag(jetCorrections[0]+'JetMETcorr'+postfix, 'type1'))))
                    setattr(process,jetCorrections[0]+'Type1p2CorMet'+postfix, pfType1p2CorrectedMet.clone(srcType1Corrections = cms.VInputTag(cms.InputTag(jetCorrections[0]+'JetMETcorr'+postfix, 'type1')),srcUnclEnergySums = cms.VInputTag(cms.InputTag(jetCorrections[0]+'JetMETcorr'+postfix, 'type2'),cms.InputTag(jetCorrections[0]+'JetMETcorr'+postfix, 'offset'),cms.InputTag(jetCorrections[0]+'CandMETcorr'+postfix))))

                ## common configuration for Calo and PF
                if ('L1FastJet' in jetCorrections[1] or 'L1Fastjet' in jetCorrections[1]):
                    getattr(process,jetCorrections[0]+'JetMETcorr'+postfix).offsetCorrLabel = cms.string(jetCorrections[0]+'L1FastJet')
                elif ('L1Offset' in jetCorrections[1]):
                    getattr(process,jetCorrections[0]+'JetMETcorr'+postfix).offsetCorrLabel = cms.string(jetCorrections[0]+'L1Offset')
                else:
                    getattr(process,jetCorrections[0]+'JetMETcorr'+postfix).offsetCorrLabel = cms.string('')

                from PhysicsTools.PatAlgos.producersLayer1.metProducer_cfi import patMETs
                if jetCorrections[2].lower() == 'type-1':
                    setattr(process, 'patMETs'+_labelName+postfix, patMETs.clone(metSource = cms.InputTag(jetCorrections[0]+'Type1CorMet'+postfix), addMuonCorrections = False))
                elif jetCorrections[2].lower() == 'type-1':
                    setattr(process, 'patMETs'+_labelName+postfix, patMETs.clone(metSource = cms.InputTag(jetCorrections[0]+'Type1p2CorMet'+postfix), addMuonCorrections = False))
        else:
            ## switch jetCorrFactors off
            _newPatJets.addJetCorrFactors=False
Пример #10
0
def makeFatJets(process, isData, label, candidates, ptMin=100.):
    """
    @param label: AK8PFchs, CA15PFPuppi, etc.
    """

    matches = re.match('(AK|CA)([0-9]+)PF(.+)', label)
    if not matches:
        raise RuntimeError('Unknown algo label ' + label)

    algo = matches.group(1) + matches.group(2)

    # set up radius and algoName from the input label
    radius = float(matches.group(2)) * 0.1
    if matches.group(1) == 'CA':
        algoName = 'CambridgeAachen'
    elif matches.group(1) == 'AK':
        algoName = 'AntiKt'

    pu = matches.group(3)

    if pu == 'chs':
        jecLabel = 'AK8PFchs'  # regardless of jet algo
    elif pu == 'Puppi':
        jecLabel = 'AK8PFPuppi'  # regardless of jet algo
    else:
        raise RuntimeError('Unknown PU mitigation ' + pu)

    sdZcut, sdBeta = sdParams(radius)

    sequence = cms.Sequence()

    # Callable object that adds the second argument to process and sequence with label attached as suffix
    addattr = AddAttr(process, sequence, label)

    ########################################
    ##           REMAKE JETS              ##
    ########################################

    pfJets = addattr(
        'pfJets',
        ak4PFJets.clone(jetAlgorithm=cms.string(algoName),
                        rParam=cms.double(radius),
                        src=cms.InputTag(candidates),
                        jetPtMin=cms.double(ptMin)))

    pfJetsSoftDrop = addattr(
        'pfJetsSoftDrop',
        ak4PFJets.clone(jetAlgorithm=cms.string(algoName),
                        rParam=cms.double(radius),
                        src=cms.InputTag(candidates),
                        jetPtMin=cms.double(ptMin),
                        useSoftDrop=cms.bool(True),
                        R0=cms.double(radius),
                        zcut=cms.double(sdZcut),
                        beta=cms.double(sdBeta),
                        writeCompound=cms.bool(True),
                        useExplicitGhosts=cms.bool(True),
                        jetCollInstanceName=cms.string("SubJets")))
    subjets = cms.InputTag(pfJetsSoftDrop.getModuleLabel(), 'SubJets')

    pfJetsPruned = addattr(
        'pfJetsPruned',
        ak4PFJets.clone(
            jetAlgorithm=cms.string(algoName),
            rParam=cms.double(radius),
            src=cms.InputTag(candidates),
            jetPtMin=cms.double(ptMin),
            usePruning=cms.bool(True),
            useExplicitGhosts=cms.bool(True),
            writeCompound=cms.bool(True),
            zcut=cms.double(0.1),  # no idea if these parameters are correct
            rcut_factor=cms.double(0.5),
            nFilt=cms.int32(2),
            jetCollInstanceName=cms.string("SubJets")))

    ########################################
    ##           SUBSTRUCTURE             ##
    #######################################

    Njettiness = addattr(
        'Njettiness',
        nJettinessAdder_cfi.Njettiness.clone(src=pfJets,
                                             R0=cms.double(radius),
                                             Njets=cms.vuint32(1, 2, 3, 4)))

    sdKinematics = addattr(
        'sdKinematics',
        cms.EDProducer('RecoJetDeltaRValueMapProducer',
                       src=pfJets,
                       matched=pfJetsSoftDrop,
                       distMax=cms.double(radius),
                       values=cms.vstring('mass'),
                       valueLabels=cms.vstring('Mass')))

    prunedKinematics = addattr(
        'prunedKinematics',
        cms.EDProducer('RecoJetDeltaRValueMapProducer',
                       src=pfJets,
                       matched=pfJetsPruned,
                       distMax=cms.double(radius),
                       values=cms.vstring('mass'),
                       valueLabels=cms.vstring('Mass')))

    ### subjet qg-tagging ###

    subQGTag = addattr(
        'subQGTag',
        QGTagger.clone(srcJets=subjets, jetsLabel=cms.string('QGL_AK4PFchs')))

    ### subjet b-tagging ###

    # sets up process.pfCombinedInclusiveSecondaryVertexV2BJetTags(label)Subjets (and necessary inputs)
    sequence += setupBTag(
        process,
        jetCollection=subjets,
        suffix=label + 'Subjets',
        vsuffix='',
        tags=['pfCombinedInclusiveSecondaryVertexV2BJetTags'])

    ########################################
    ##          MAKE PAT JETS             ##
    ########################################

    ## MAIN JET ##

    jecLevels = ['L1FastJet', 'L2Relative', 'L3Absolute']
    if isData:
        jecLevels.append('L2L3Residual')

    jetCorrFactors = addattr(
        'jetCorrFactors',
        jetUpdater_cff.patJetCorrFactors.clone(src=pfJets,
                                               payload=jecLabel,
                                               levels=jecLevels,
                                               primaryVertices=pvSource))

    if not isData:
        genJetMatch = addattr(
            'genJetMatch',
            patJetGenJetMatch.clone(src=pfJets,
                                    maxDeltaR=radius,
                                    matched='genJetsNoNu' + algo))

    patJets = addattr(
        'patJets',
        jetProducer_cfi.patJets.clone(jetSource=pfJets,
                                      addJetCorrFactors=True,
                                      addBTagInfo=False,
                                      addAssociatedTracks=False,
                                      addJetCharge=False,
                                      addGenPartonMatch=False,
                                      addGenJetMatch=(not isData),
                                      getJetMCFlavour=False,
                                      addJetFlavourInfo=False))
    patJetsMod = addattr.last
    patJetsMod.jetCorrFactorsSource = [jetCorrFactors]
    if not isData:
        patJetsMod.genJetMatch = genJetMatch

    for tau in ['tau1', 'tau2', 'tau3', 'tau4']:
        patJetsMod.userData.userFloats.src.append(Njettiness.getModuleLabel() +
                                                  ':' + tau)

    patJetsMod.userData.userFloats.src.append(sdKinematics.getModuleLabel() +
                                              ':Mass')
    patJetsMod.userData.userFloats.src.append(
        prunedKinematics.getModuleLabel() + ':Mass')

    selectedPatJets = addattr(
        'selectedPatJets',
        jetSelector_cfi.selectedPatJets.clone(src=patJets,
                                              cut='abs(eta) < 2.5'))

    ## SOFT DROP ##

    patJetsSoftDrop = addattr(
        'patJetsSoftDrop',
        jetProducer_cfi._patJets.clone(jetSource=pfJetsSoftDrop,
                                       addJetCorrFactors=False,
                                       addBTagInfo=False,
                                       addAssociatedTracks=False,
                                       addJetCharge=False,
                                       addGenPartonMatch=False,
                                       addGenJetMatch=False,
                                       getJetMCFlavour=False,
                                       addJetFlavourInfo=False))

    selectedPatJetsSoftDrop = addattr(
        'selectedPatJetsSoftDrop',
        jetSelector_cfi.selectedPatJets.clone(src=patJetsSoftDrop,
                                              cut='abs(eta) < 2.5'))

    if not isData:
        genSubjetsMatch = addattr(
            'genSubjetMatch',
            patJetGenJetMatch.clone(src=subjets,
                                    maxDeltaR=0.4,
                                    matched='genJetsNoNuSoftDrop' + algo +
                                    ':SubJets'))

    patSubjets = addattr(
        'patSubjets',
        jetProducer_cfi._patJets.clone(
            jetSource=subjets,
            addJetCorrFactors=False,
            addBTagInfo=True,
            discriminatorSources=[
                'pfCombinedInclusiveSecondaryVertexV2BJetTags' + label +
                'Subjets'
            ],
            addAssociatedTracks=False,
            addJetCharge=False,
            addGenPartonMatch=False,
            addGenJetMatch=(not isData),
            getJetMCFlavour=False,
            addJetFlavourInfo=False))
    patSubjetsMod = addattr.last
    patSubjetsMod.userData.userFloats.src.append(
        cms.InputTag(subQGTag.getModuleLabel(), 'qgLikelihood'))
    if not isData:
        patSubjetsMod.genJetMatch = genSubjetsMatch

    ## MERGE SUBJETS BACK ##
    jetMerger = addattr(
        'jetMerger',
        cms.EDProducer("BoostedJetMerger",
                       jetSrc=selectedPatJetsSoftDrop,
                       subjetSrc=patSubjets))

    ## PACK ##
    addattr(
        'packedPatJets',
        cms.EDProducer("JetSubstructurePacker",
                       jetSrc=selectedPatJets,
                       distMax=cms.double(radius),
                       algoTags=cms.VInputTag(jetMerger),
                       algoLabels=cms.vstring('SoftDrop'),
                       fixDaughters=cms.bool(False)))

    return sequence
Пример #11
0
from PhysicsTools.JetMCAlgos.HadronAndPartonSelector_cfi import selectedHadronsAndPartons
from PhysicsTools.JetMCAlgos.AK4PFJetsMCFlavourInfos_cfi import ak4JetFlavourInfos
myak4JetFlavourInfos = ak4JetFlavourInfos.clone(
    jets="ak4PFJetsCHS",
    partons="selectedHadronsAndPartons:algorithmicPartons",
    hadronFlavourHasPriority=True)

#Get gen jet collection for real jets
ak4GenJetsForPUid = cms.EDFilter("GenJetSelector",
                                 src=cms.InputTag("ak4GenJets"),
                                 cut=cms.string('pt > 8.'),
                                 filter=cms.bool(False))
#do reco gen - reco matching
from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch
newpatJetGenJetMatch = patJetGenJetMatch.clone(src="ak4PFJetsCHS",
                                               matched="ak4GenJetsForPUid",
                                               maxDeltaR=0.25,
                                               resolveAmbiguities=True)

from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
pp_on_AA.toModify(newpatJetGenJetMatch, src="akCs4PFJets")

# Module execution for MC
from Validation.RecoB.bTagAnalysis_cfi import *
bTagValidation.jetMCSrc = 'myak4JetFlavourInfos'
bTagValidation.ptRanges = cms.vdouble(0.0)
bTagValidation.etaRanges = cms.vdouble(0.0)
bTagValidation.doJetID = True
bTagValidation.doJEC = True
bTagValidation.genJetsMatched = cms.InputTag("newpatJetGenJetMatch")
#to run on fastsim
prebTagSequenceMC = cms.Sequence(ak4GenJetsForPUid * newpatJetGenJetMatch *
Пример #12
0
def makeJets(process, isData, label, candidates, suffix):
    """
    Light-weight version of pat addJetCollection.
    @labels: e.g. 'AK4PFPuppi'
    """

    sequence = cms.Sequence()

    addattr = AddAttr(process, sequence, suffix)

    ak4PFJets = addattr('ak4PFJets',
        ak4PFJetsPuppi.clone(
            src = candidates,
            doAreaFastjet = True
        )
    )

    jecLevels= ['L1FastJet',  'L2Relative', 'L3Absolute']
    if isData:
        jecLevels.append('L2L3Residual')

    jetCorrFactors = addattr('jetCorrFactors',
        patJetCorrFactors.clone(
            src = ak4PFJets,
            payload = label,
            levels = jecLevels,
            primaryVertices = pvSource
        )
    )

    # btag should always use standard PF collection
    sequence += initBTag(process, '', pfSource, pvSource)

    sequence += setupBTag(
        process,
        jetCollection = ak4PFJets,
        suffix = suffix,
        vsuffix = '',
        muons = muons,
        electrons = electrons,
        tags = ['pfCombinedInclusiveSecondaryVertexV2BJetTags']
    )

    if not isData:
        genJetMatch = addattr('genJetMatch',
            patJetGenJetMatch.clone(
                src = ak4PFJets,
                maxDeltaR = 0.4,
                matched = genJets
            )
        )

    allPatJets = addattr('patJets',
        patJets.clone(
            jetSource = ak4PFJets,
            addJetCorrFactors = True,
            jetCorrFactorsSource = [jetCorrFactors],
            addBTagInfo = True,
            discriminatorSources = [cms.InputTag('pfCombinedInclusiveSecondaryVertexV2BJetTags' + suffix)],
            addAssociatedTracks = False,
            addJetCharge = False,
            addGenPartonMatch = False,
            addGenJetMatch = (not isData),
            getJetMCFlavour = False,
            addJetFlavourInfo = False
        )
    )

    if not isData:
        addattr.last.genJetMatch = genJetMatch

    selectedJets = addattr('selectedJets',
        selectedPatJets.clone(
            src = allPatJets,
            cut = 'pt > 15'
        )
    )

    addattr('slimmedJets',
        slimmedJets.clone(
            src = selectedJets,
            rekeyDaughters = '0'
        )
    )

    return sequence
Пример #13
0
def makeJets(process, isData, label, candidates, suffix):
    """
    Light-weight version of pat addJetCollection.
    @labels: e.g. 'AK4PFPuppi'
    """

    sequence = cms.Sequence()

    addattr = AddAttr(process, sequence, suffix)

    jets = addattr('ak4PFJets',
                   ak4PFJets.clone(src=candidates, doAreaFastjet=True))

    jecLevels = ['L1FastJet', 'L2Relative', 'L3Absolute']
    if isData:
        jecLevels.append('L2L3Residual')

    jetCorrFactors = addattr(
        'jetCorrFactors',
        patJetCorrFactors.clone(src=jets,
                                payload=label,
                                levels=jecLevels,
                                primaryVertices=pvSource))

    # btag should always use standard PF collection
    sequence += initBTag(process, '', pfSource, pvSource)

    sequence += setupBTag(process,
                          jetCollection=jets,
                          suffix=suffix,
                          vsuffix='',
                          muons=muons,
                          electrons=electrons,
                          tags=[
                              'pfCombinedInclusiveSecondaryVertexV2BJetTags',
                              'pfCombinedMVAV2BJetTags', 'pfDeepCSVJetTags',
                              'pfDeepCMVAJetTags'
                          ])

    qgTagger = addattr('QGTagger', QGTagger.clone(srcJets=jets))

    if not isData:
        genJetMatch = addattr(
            'genJetMatch',
            patJetGenJetMatch.clone(src=jets, maxDeltaR=0.4, matched=genJets))


    allPatJets = addattr('patJets',
        patJets.clone(
            jetSource = jets,
            addJetCorrFactors = True,
            jetCorrFactorsSource = [jetCorrFactors],
            addBTagInfo = True,
            discriminatorSources = [
                cms.InputTag('pfCombinedInclusiveSecondaryVertexV2BJetTags' + suffix),
                cms.InputTag('pfCombinedMVAV2BJetTags' + suffix),
                ] + \
                sum([[cms.InputTag('pfDeepCSVJetTags' + suffix, 'prob' + prob),
                      cms.InputTag('pfDeepCMVAJetTags' + suffix, 'prob' + prob)]
                       #                     for prob in ['udsg', 'b', 'c', 'bb', 'cc']],
                     for prob in ['udsg', 'b', 'c', 'bb']],
                    []),
            addAssociatedTracks = False,
            addJetCharge = False,
            addGenPartonMatch = False,
            addGenJetMatch = (not isData),
            getJetMCFlavour = False,
            addJetFlavourInfo = False
        )
    )

    addattr.last.userData.userFloats.src = [
        qgTagger.getModuleLabel() + ':qgLikelihood'
    ]
    addattr.last.userData.userFloats.labelPostfixesToStrip = cms.vstring(
        suffix)

    if not isData:
        addattr.last.genJetMatch = genJetMatch

    selectedJets = addattr(
        'selectedJets', selectedPatJets.clone(src=allPatJets, cut='pt > 15'))

    addattr('slimmedJets',
            slimmedJets.clone(src=selectedJets, rekeyDaughters='0'))

    return sequence
Пример #14
0
import FWCore.ParameterSet.Config as cms

from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch, patJetPartonMatch
from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets

from HeavyIonsAnalysis.JetAnalysis.inclusiveJetAnalyzer_cff import *
from HeavyIonsAnalysis.JetAnalysis.bTaggers_cff import *

from RecoJets.JetProducers.JetIDParams_cfi import *
from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness

akPu6PFmatch = patJetGenJetMatch.clone(
    src = cms.InputTag("akPu6PFJets"),
    matched = cms.InputTag("ak6HiCleanedGenJets"),
    resolveByMatchQuality = cms.bool(False),
    maxDeltaR = 0.6
    )

akPu6PFmatchGroomed = patJetGenJetMatch.clone(
    src = cms.InputTag("ak6HiGenJets"),
    matched = cms.InputTag("ak6HiCleanedGenJets"),
    resolveByMatchQuality = cms.bool(False),
    maxDeltaR = 0.6
    )

akPu6PFparton = patJetPartonMatch.clone(
    src = cms.InputTag("akPu6PFJets"),
    matched = cms.InputTag("cleanedPartons"))

akPu6PFcorr = patJetCorrFactors.clone(
Пример #15
0
import FWCore.ParameterSet.Config as cms

from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch, patJetPartonMatch
from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets

from HeavyIonsAnalysis.JetAnalysis.inclusiveJetAnalyzer_cff import *
from HeavyIonsAnalysis.JetAnalysis.bTaggers_cff import *

from RecoJets.JetProducers.JetIDParams_cfi import *
from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness

akFlowPuCs2PFmatch = patJetGenJetMatch.clone(
    src=cms.InputTag("akFlowPuCs2PFJets"),
    matched=cms.InputTag("ak2HiCleanedGenJets"),
    resolveByMatchQuality=cms.bool(True),
    maxDeltaR=0.2)

akFlowPuCs2PFmatchGroomed = patJetGenJetMatch.clone(
    src=cms.InputTag("ak2HiGenJets"),
    matched=cms.InputTag("ak2HiCleanedGenJets"),
    resolveByMatchQuality=cms.bool(True),
    maxDeltaR=0.2)

akFlowPuCs2PFparton = patJetPartonMatch.clone(
    src=cms.InputTag("akFlowPuCs2PFJets"),
    matched=cms.InputTag("cleanedPartons"))

akFlowPuCs2PFcorr = patJetCorrFactors.clone(
    useNPV=cms.bool(False),
    useRho=cms.bool(False),
Пример #16
0
import FWCore.ParameterSet.Config as cms

from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch, patJetPartonMatch
from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets

from HeavyIonsAnalysis.JetAnalysis.inclusiveJetAnalyzer_cff import *
from HeavyIonsAnalysis.JetAnalysis.bTaggers_cff import *

from RecoJets.JetProducers.JetIDParams_cfi import *
from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness

akPuSoftDropZ05B151PFmatch = patJetGenJetMatch.clone(
    src=cms.InputTag("akPuSoftDropZ05B151PFJets"),
    matched=cms.InputTag("ak1HiCleanedGenJets"),
    resolveByMatchQuality=cms.bool(False),
    maxDeltaR=0.1)

akPuSoftDropZ05B151PFmatchGroomed = patJetGenJetMatch.clone(
    src=cms.InputTag("akSoftDropZ05B151HiGenJets"),
    matched=cms.InputTag("ak1HiCleanedGenJets"),
    resolveByMatchQuality=cms.bool(False),
    maxDeltaR=0.1)

akPuSoftDropZ05B151PFparton = patJetPartonMatch.clone(
    src=cms.InputTag("akPuSoftDropZ05B151PFJets"),
    matched=cms.InputTag("cleanedPartons"))

akPuSoftDropZ05B151PFcorr = patJetCorrFactors.clone(
    useNPV=cms.bool(False),
    useRho=cms.bool(False),
Пример #17
0
bTagPlotsDATA = cms.Sequence(bTagAnalysis)

########## MC ############
#Matching
from PhysicsTools.JetMCAlgos.CaloJetsMCFlavour_cfi import *
AK4byRef.jets = cms.InputTag("ak4PFJetsCHS")
#Get gen jet collection for real jets
ak4GenJetsForPUid = cms.EDFilter("GenJetSelector",
                                 src=cms.InputTag("ak4GenJets"),
                                 cut=cms.string('pt > 8.'),
                                 filter=cms.bool(False))
#do reco gen - reco matching
from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch
newpatJetGenJetMatch = patJetGenJetMatch.clone(
    src=cms.InputTag("ak4PFJetsCHS"),
    matched=cms.InputTag("ak4GenJetsForPUid"),
    maxDeltaR=cms.double(0.25),
    resolveAmbiguities=cms.bool(True))

# Module execution for MC
from Validation.RecoB.bTagAnalysis_cfi import *
bTagValidation.jetMCSrc = 'AK4byValAlgo'
bTagValidation.ptRanges = cms.vdouble(0.0)
bTagValidation.etaRanges = cms.vdouble(0.0)
bTagValidation.doJetID = True
bTagValidation.doJEC = True
bTagValidation.JECsource = cms.string("ak4PFCHSL1FastL2L3")
bTagValidation.genJetsMatched = cms.InputTag("newpatJetGenJetMatch")
#to run on fastsim
prebTagSequenceMC = cms.Sequence(ak4GenJetsForPUid * newpatJetGenJetMatch *
                                 myPartons * AK4Flavour)
Пример #18
0
import FWCore.ParameterSet.Config as cms

from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch, patJetPartonMatch
from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets

from HeavyIonsAnalysis.JetAnalysis.inclusiveJetAnalyzer_cff import *
from HeavyIonsAnalysis.JetAnalysis.bTaggers_cff import *

from RecoJets.JetProducers.JetIDParams_cfi import *
from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness

akFlowPuCsSoftDropZ05B151PFmatch = patJetGenJetMatch.clone(
    src=cms.InputTag("akFlowPuCsSoftDropZ05B151PFJets"),
    matched=cms.InputTag("ak1GenJets"),
    resolveByMatchQuality=cms.bool(True),
    maxDeltaR=0.1)

akFlowPuCsSoftDropZ05B151PFmatchGroomed = patJetGenJetMatch.clone(
    src=cms.InputTag("akSoftDropZ05B151GenJets"),
    matched=cms.InputTag("ak1GenJets"),
    resolveByMatchQuality=cms.bool(True),
    maxDeltaR=0.1)

akFlowPuCsSoftDropZ05B151PFparton = patJetPartonMatch.clone(
    src=cms.InputTag("akFlowPuCsSoftDropZ05B151PFJets"),
    matched=cms.InputTag("genParticles"))

akFlowPuCsSoftDropZ05B151PFcorr = patJetCorrFactors.clone(
    useNPV=cms.bool(False),
    useRho=cms.bool(False),
Пример #19
0
import FWCore.ParameterSet.Config as cms

from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch, patJetPartonMatch
from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets

from HeavyIonsAnalysis.JetAnalysis.inclusiveJetAnalyzer_cff import *
from HeavyIonsAnalysis.JetAnalysis.bTaggers_cff import *

from RecoJets.JetProducers.JetIDParams_cfi import *
from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness

akPuSoftDrop2PFmatch = patJetGenJetMatch.clone(
    src=cms.InputTag("akPuSoftDrop2PFJets"),
    matched=cms.InputTag("ak2GenJets"),
    resolveByMatchQuality=cms.bool(False),
    maxDeltaR=0.2)

akPuSoftDrop2PFmatchGroomed = patJetGenJetMatch.clone(
    src=cms.InputTag("akSoftDrop2GenJets"),
    matched=cms.InputTag("ak2GenJets"),
    resolveByMatchQuality=cms.bool(False),
    maxDeltaR=0.2)

akPuSoftDrop2PFparton = patJetPartonMatch.clone(
    src=cms.InputTag("akPuSoftDrop2PFJets"),
    matched=cms.InputTag("genParticles"))

akPuSoftDrop2PFcorr = patJetCorrFactors.clone(
    useNPV=cms.bool(False),
    useRho=cms.bool(False),
Пример #20
0
import FWCore.ParameterSet.Config as cms

from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch, patJetPartonMatch
from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets

from HeavyIonsAnalysis.JetAnalysis.inclusiveJetAnalyzer_cff import *
from HeavyIonsAnalysis.JetAnalysis.bTaggers_cff import *

from RecoJets.JetProducers.JetIDParams_cfi import *
from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness

ak1PFmatch = patJetGenJetMatch.clone(
    src=cms.InputTag("ak1PFJets"),
    matched=cms.InputTag("ak1HiSignalGenJets"),
    resolveByMatchQuality=cms.bool(False),
    maxDeltaR=0.1)

ak1PFmatchGroomed = patJetGenJetMatch.clone(
    src=cms.InputTag("ak1HiSignalGenJets"),
    matched=cms.InputTag("ak1HiSignalGenJets"),
    resolveByMatchQuality=cms.bool(False),
    maxDeltaR=0.1)

ak1PFparton = patJetPartonMatch.clone(
    src=cms.InputTag("ak1PFJets"),
    matched=cms.InputTag("hiSignalGenParticles"))

ak1PFcorr = patJetCorrFactors.clone(useNPV=cms.bool(False),
                                    useRho=cms.bool(False),
                                    levels=cms.vstring('L2Relative'),
Пример #21
0
import FWCore.ParameterSet.Config as cms

from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch, patJetPartonMatch
from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets

from HeavyIonsAnalysis.JetAnalysis.inclusiveJetAnalyzer_cff import *
from HeavyIonsAnalysis.JetAnalysis.bTaggers_cff import *

from RecoJets.JetProducers.JetIDParams_cfi import *
from RecoJets.JetProducers.nJettinessAdder_cfi import Njettiness

akCsSoftDrop3PFmatch = patJetGenJetMatch.clone(
    src=cms.InputTag("akCsSoftDrop3PFJets"),
    matched=cms.InputTag("ak3HiCleanedGenJets"),
    resolveByMatchQuality=cms.bool(True),
    maxDeltaR=0.3)

akCsSoftDrop3PFmatchGroomed = patJetGenJetMatch.clone(
    src=cms.InputTag("akSoftDrop3HiGenJets"),
    matched=cms.InputTag("ak3HiCleanedGenJets"),
    resolveByMatchQuality=cms.bool(True),
    maxDeltaR=0.3)

akCsSoftDrop3PFparton = patJetPartonMatch.clone(
    src=cms.InputTag("akCsSoftDrop3PFJets"),
    matched=cms.InputTag("cleanedPartons"))

akCsSoftDrop3PFcorr = patJetCorrFactors.clone(
    useNPV=cms.bool(False),
    useRho=cms.bool(False),
Пример #22
0
    def toolCode(self, process):
        """
        Tool code implementation
        """
        ## initialize parameters
        labelName = "patJets" + self._parameters["labelName"].value
        postfix = self._parameters["postfix"].value
        jetSource = self._parameters["jetSource"].value
        algo = self._parameters["algo"].value
        jetCorrections = self._parameters["jetCorrections"].value
        btagDiscriminators = list(self._parameters["btagDiscriminators"].value)
        btagInfos = list(self._parameters["btagInfos"].value)
        jetTrackAssociation = self._parameters["jetTrackAssociation"].value
        outputModules = list(self._parameters["outputModules"].value)

        ## a list of all producer modules, which are already known to process
        knownModules = process.producerNames().split()
        ## determine whether btagging information is required or not
        if btagDiscriminators.count("None") > 0:
            btagDiscriminators.remove("None")
        if btagInfos.count("None") > 0:
            btagInfos.remove("None")
        bTagging = len(btagDiscriminators) > 0 or len(btagInfos) > 0
        ## construct postfix label for auxiliary modules; this postfix
        ## label will start with a capitalized first letter following
        ## the CMS nameing conventions and for improved readablility
        _labelName = labelName[:1].upper() + labelName[1:]
        # _labelName=labelName
        ## determine jet algorithm from jetSource; supported algo types
        ## are ak, kt, sc, ic. This loop expects that the algo type is
        ## followed by a single integer corresponding to the opening
        ## angle parameter dR times 10 (examples ak5, kt4, kt6, ...)
        _algo = algo
        # jetSource=cms.InputTag("ak5PFJets")
        for x in ["ak", "kt", "sc", "ic"]:
            if jetSource.getModuleLabel().lower().find(x) > -1:
                _algo = jetSource.getModuleLabel()[
                    jetSource.getModuleLabel().lower().find(x) : jetSource.getModuleLabel().lower().find(x) + 3
                ]
        # print _algo
        ## add new patJets to process (keep instance for later further modifications)
        from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets

        if labelName in knownModules:
            _newPatJets = getattr(process, labelName + postfix)
            _newPatJets.jetSource = jetSource
        else:
            # setattr(process, labelName, patJets.clone(jetSource=jetSource))
            setattr(process, labelName + postfix, patJets.clone(jetSource=jetSource))
            _newPatJets = getattr(process, labelName + postfix)
            knownModules.append(labelName + postfix)
        ## add new selectedPatJets to process
        from PhysicsTools.PatAlgos.selectionLayer1.jetSelector_cfi import selectedPatJets

        if "selected" + _labelName + postfix in knownModules:
            _newSelectedPatJets = getattr(process, "selected" + _labelName + postfix)
            _newSelectedPatJets.src = labelName + postfix
        else:
            setattr(process, "selected" + _labelName + postfix, selectedPatJets.clone(src=labelName + postfix))
            knownModules.append("selected" + _labelName + postfix)

        ## set postfix label to '' if there is no labelName given. In this case all
        ## modules should keep there names w/o postfixes. This will cover the case
        ## of switchJectCollection
        if self._parameters["labelName"].value == "":
            _labelName = ""

        ## add new patJetPartonMatch to process
        from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetPartonMatch

        if "patJetPartonMatch" + _labelName + postfix in knownModules:
            _newPatJetPartonMatch = getattr(process, "patJetPartonMatch" + _labelName + postfix)
            _newPatJetPartonMatch.src = jetSource
        else:
            setattr(process, "patJetPartonMatch" + _labelName + postfix, patJetPartonMatch.clone(src=jetSource))
            knownModules.append("patJetPartonMatch" + _labelName + postfix)
        ## add new patJetGenJetMatch to process
        from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch

        if "patJetGenJetMatch" + _labelName + postfix in knownModules:
            _newPatJetGenJetMatch = getattr(process, "patJetGenJetMatch" + _labelName + postfix)
            _newPatJetGenJetMatch.src = jetSource
            _newPatJetGenJetMatch.matched = _algo.lower() + "GenJets" + postfix
        else:
            setattr(
                process,
                "patJetGenJetMatch" + _labelName + postfix,
                patJetGenJetMatch.clone(src=jetSource, matched=_algo + "GenJets"),
            )
            knownModules.append("patJetGenJetMatch" + _labelName + postfix)
        ## add new patJetPartonAssociation to process
        from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetPartonAssociation

        if "patJetPartonAssociation" + _labelName + postfix in knownModules:
            _newPatJetPartonAssociation = getattr(
                process, "patJetPartonAssociation" + _labelName + postfix, patJetPartonAssociation.clone(jets=jetSource)
            )
            _newPatJetPartonAssociation.jets = jetSource
        else:
            setattr(
                process, "patJetPartonAssociation" + _labelName + postfix, patJetPartonAssociation.clone(jets=jetSource)
            )
            knownModules.append("patJetPartonAssociation" + _labelName + postfix)
        ## add new patJetPartonAssociation to process
        from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetFlavourAssociation

        if "patJetFlavourAssociation" + _labelName + postfix in knownModules:
            _newPatJetFlavourAssociation = getattr(
                process,
                "patJetFlavourAssociation" + _labelName + postfix,
                patJetFlavourAssociation.clone(srcByReference="patJetPartonAssociation" + _labelName + postfix),
            )
            _newPatJetFlavourAssociation.srcByReference = "patJetPartonAssociation" + _labelName + postfix
        else:
            setattr(
                process,
                "patJetFlavourAssociation" + _labelName + postfix,
                patJetFlavourAssociation.clone(srcByReference="patJetPartonAssociation" + _labelName + postfix),
            )
            knownModules.append("patJetFlavourAssociation" + _labelName + postfix)
        ## modify new patJets collection accordingly
        _newPatJets.genJetMatch.setModuleLabel("patJetGenJetMatch" + _labelName + postfix)
        _newPatJets.genPartonMatch.setModuleLabel("patJetPartonMatch" + _labelName + postfix)
        _newPatJets.JetPartonMapSource.setModuleLabel("patJetFlavourAssociation" + _labelName + postfix)

        ## add jetTrackAssociation for btagging (or jetTracksAssociation only) if required by user
        if jetTrackAssociation or bTagging:
            ## add new jetTracksAssociationAtVertex to process
            from RecoJets.JetAssociationProducers.ak5JTA_cff import ak5JetTracksAssociatorAtVertex

            if "jetTracksAssociationAtVertex" + _labelName + postfix in knownModules:
                _newJetTracksAssociationAtVertex = getattr(
                    process, "jetTracksAssociatorAtVertex" + _labelName + postfix
                )
                _newJetTracksAssociationAtVertex.jets = jetSource
            else:
                setattr(
                    process,
                    "jetTracksAssociatorAtVertex" + _labelName + postfix,
                    ak5JetTracksAssociatorAtVertex.clone(jets=jetSource),
                )
                knownModules.append("jetTracksAssociationAtVertex" + _labelName + postfix)
            ## add new patJetCharge to process
            from PhysicsTools.PatAlgos.recoLayer0.jetTracksCharge_cff import patJetCharge

            if "patJetCharge" + _labelName + postfix in knownModules:
                _newPatJetCharge = getattr(process, "patJetCharge" + _labelName + postfix)
                _newPatJetCharge.src = "jetTracksAssociatorAtVertex" + _labelName + postfix
            else:
                setattr(
                    process,
                    "patJetCharge" + _labelName + postfix,
                    patJetCharge.clone(src="jetTracksAssociatorAtVertex" + _labelName + postfix),
                )
                knownModules.append("patJetCharge" + _labelName + postfix)
            ## modify new patJets collection accordingly
            _newPatJets.addAssociatedTracks = True
            _newPatJets.trackAssociationSource = cms.InputTag("jetTracksAssociatorAtVertex" + _labelName + postfix)
            _newPatJets.addJetCharge = True
            _newPatJets.jetChargeSource = cms.InputTag("patJetCharge" + _labelName + postfix)
        else:
            ## modify new patJets collection accordingly
            _newPatJets.addAssociatedTracks = False
            _newPatJets.trackAssociationSource = ""
            _newPatJets.addJetCharge = False
            _newPatJets.jetChargeSource = ""
        ## run btagging if required by user
        if bTagging:
            ## expand tagInfos to what is explicitely required by user + implicit
            ## requirements that come in from one or the other discriminator
            requiredTagInfos = list(btagInfos)
            for btagDiscr in btagDiscriminators:
                for requiredTagInfo in supportedBtagDiscr[btagDiscr]:
                    tagInfoCovered = False
                    for tagInfo in requiredTagInfos:
                        if requiredTagInfo == tagInfo:
                            tagInfoCovered = True
                            break
                    if not tagInfoCovered:
                        requiredTagInfos.append(requiredTagInfo)
            ## load sequences and setups needed fro btagging
            ## This loads all available btagger, but the ones we need are added to the process by hand lader. Only needed to get the ESProducer. Needs improvement
            # loadWithPostFix(process,"RecoBTag.Configuration.RecoBTag_cff",postfix)
            process.load("RecoBTag.Configuration.RecoBTag_cff")
            # addESProducers(process,'RecoBTag.Configuration.RecoBTag_cff')
            import RecoBTag.Configuration.RecoBTag_cff as btag

            ## prepare setups for simple secondary vertex infos
            setattr(process, "simpleSecondaryVertex2Trk", simpleSecondaryVertex2Trk)
            ## prepare setups for transient tracks
            setattr(process, "TransientTrackBuilderESProducer", TransientTrackBuilderESProducer)
            ## setup all required btagInfos : we give a dedicated treatment for all five different
            ## types of tagINfos here. A common treatment is possible but might require a more
            ## general approach anyway in coordination with the btaggin POG.
            for btagInfo in requiredTagInfos:
                if "impactParameterTagInfos" in btagInfo:
                    setattr(
                        process,
                        btagInfo + _labelName + postfix,
                        btag.impactParameterTagInfos.clone(
                            jetTracks=cms.InputTag("jetTracksAssociatorAtVertex" + _labelName + postfix)
                        ),
                    )
                if "secondaryVertexTagInfos" in btagInfo:
                    setattr(
                        process,
                        btagInfo + _labelName + postfix,
                        btag.secondaryVertexTagInfos.clone(
                            trackIPTagInfos=cms.InputTag("impactParameterTagInfos" + _labelName + postfix)
                        ),
                    )
                if "secondaryVertexNegativeTagInfos" in btagInfo:
                    setattr(
                        process,
                        btagInfo + _labelName + postfix,
                        btag.secondaryVertexNegativeTagInfos.clone(
                            trackIPTagInfos=cms.InputTag("impactParameterTagInfos" + _labelName + postfix)
                        ),
                    )
                if "softElectronTagInfos" in btagInfo:
                    setattr(
                        process,
                        btagInfo + _labelName + postfix,
                        btag.softElectronTagInfos.clone(jets=cms.InputTag(_newJetCollection)),
                    )
                if "softMuonTagInfos" in btagInfo:
                    setattr(
                        process,
                        btagInfo + _labelName + postfix,
                        btag.softMuonTagInfos.clone(jets=cms.InputTag(_newJetCollection)),
                    )
            ## setup all required btagDiscriminators
            for btagDiscr in btagDiscriminators:
                setattr(
                    process,
                    btagDiscr + _labelName + postfix,
                    getattr(btag, btagDiscr).clone(
                        tagInfos=cms.VInputTag(
                            *[cms.InputTag(x + _labelName + postfix) for x in supportedBtagDiscr[btagDiscr]]
                        )
                    ),
                )
            ## replace corresponding tags for pat jet production
            _newPatJets.tagInfoSources = cms.VInputTag(*[cms.InputTag(x + _labelName + postfix) for x in btagInfos])
            _newPatJets.discriminatorSources = cms.VInputTag(
                *[cms.InputTag(x + _labelName + postfix) for x in btagDiscriminators]
            )
        else:
            _newPatJets.addBTagInfo = False
            ## adjust output module; these collections will be empty anyhow, but we do it to stay clean
            for outputModule in outputModules:
                if hasattr(process, outputModule):
                    getattr(process, outputModule).outputCommands.append(
                        "drop *_" + "selected" + _labelName + postfix + "_tagInfos_*"
                    )

        ## add jet correction factors if required by user
        if jetCorrections != None:
            ## check for the correct format
            if type(jetCorrections) != type(
                ("PAYLOAD-LABEL", ["CORRECTION-LEVEL-A", "CORRECTION-LEVEL-B"], "MET-LABEL")
            ):
                raise ValueError, "In addJetCollection: 'jetCorrections' must be 'None' (as a python value w/o quotation marks), or of type ('PAYLOAD-LABEL', ['CORRECTION-LEVEL-A', \
                'CORRECTION-LEVEL-B', ...], 'MET-LABEL'). Note that 'MET-LABEL' can be set to 'None' (as a string in quotation marks) in case you do not want to apply MET(Type1) \
                corrections."
            ## determine type of jet constituents from jetSource; supported
            ## jet constituent types are calo, pf, jpt, for pf also particleflow
            ## is aloowed as part of the jetSource label, which might be used
            ## in CommonTools.ParticleFlow
            _type = "NONE"
            if jetCorrections[0].count("PF") > 0:
                _type = "PF"
            elif jetCorrections[0].count("Calo") > 0:
                _type = "Calo"
            elif jetCorrections[0].count("JPT") > 0:
                _type = "JPT"
            else:
                raise TypeError, "In addJetCollection: Jet energy corrections are only supported for PF, JPT and Calo jets."
            from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors

            if "patJetCorrFactors" + _labelName + postfix in knownModules:
                _newPatJetCorrFactors = getattr(process, "patJetCorrFactors" + _labelName + postfix)
                _newPatJetCorrFactors.src = jetSource
            else:

                setattr(process, "patJetCorrFactors" + _labelName + postfix, patJetCorrFactors.clone(src=jetSource))
                _newPatJetCorrFactors = getattr(process, "patJetCorrFactors" + _labelName + postfix)
            _newPatJetCorrFactors.payload = jetCorrections[0]
            _newPatJetCorrFactors.levels = jetCorrections[1]
            ## check whether L1Offset or L1FastJet is part of levels
            error = False
            for x in jetCorrections[1]:
                if x == "L1Offset":
                    if not error:
                        _newPatJetCorrFactors.useNPV = True
                        _newPatJetCorrFactors.primaryVertices = "offlinePrimaryVertices"
                        ## we set this to True now as a L1 correction type should appear only once
                        ## otherwise levels is miss configured
                        error = True
                    else:
                        raise ValueError, "In addJetCollection: Correction levels for jet energy corrections are miss configured. An L1 correction type should appear not more than \
                        once. Check the list of correction levels you requested to be applied: ", jetCorrections[
                            1
                        ]
                if x == "L1FastJet":
                    if not error:
                        if _type == "JPT":
                            raise TypeError, "In addJetCollection: L1FastJet corrections are only supported for PF and Calo jets."
                        ## configure module
                        _newPatJetCorrFactors.useRho = True
                        _newPatJetCorrFactors.rho = cms.InputTag("kt6" + _type + "Jets", "rho")
                        ## we set this to True now as a L1 correction type should appear only once
                        ## otherwise levels is miss configured
                        error = True
                    else:
                        raise ValueError, "In addJetCollection: Correction levels for jet energy corrections are miss configured. An L1 correction type should appear not more than \
                        once. Check the list of correction levels you requested to be applied: ", jetCorrections[
                            1
                        ]
            _newPatJets.jetCorrFactorsSource = cms.VInputTag(cms.InputTag("patJetCorrFactors" + _labelName + postfix))
            ## configure MET(Type1) corrections
            if jetCorrections[2].lower() != "none" and jetCorrections[2] != "":
                if not jetCorrections[2].lower() == "type-1" and not jetCorrections[2].lower() == "type-2":
                    raise valueError, "In addJetCollection: Wrong choice of MET corrections for new jet collection. Possible choices are None (or empty string), Type-1, Type-2 (i.e.\
                    Type-1 and Type-2 corrections applied). This choice is not case sensitive. Your choice was: ", jetCorrections[
                        2
                    ]
                if _type == "JPT":
                    raise ValueError, 'In addJecCollection: MET(type1) corrections are not supported for JPTJets. Please set the MET-LABEL to "None" (as string in quatiation \
                    marks) and use raw tcMET together with JPTJets.'
                ## set up jet correctors for MET corrections
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL1Fastjet
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL1Offset
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL2Relative
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL3Absolute
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFResidual

                setattr(
                    process,
                    jetCorrections[0] + "L1FastJet",
                    ak5PFL1Fastjet.clone(
                        algorithm=jetCorrections[0], srcRho=cms.InputTag("kt6" + _type + "Jets", "rho")
                    ),
                )
                setattr(process, jetCorrections[0] + "L1Offset", ak5PFL1Offset.clone(algorithm=jetCorrections[0]))
                setattr(process, jetCorrections[0] + "L2Relative", ak5PFL2Relative.clone(algorithm=jetCorrections[0]))
                setattr(process, jetCorrections[0] + "L3Absolute", ak5PFL3Absolute.clone(algorithm=jetCorrections[0]))
                setattr(process, jetCorrections[0] + "L2L3Residual", ak5PFResidual.clone(algorithm=jetCorrections[0]))
                setattr(
                    process,
                    jetCorrections[0] + "CombinedCorrector",
                    cms.ESProducer("JetCorrectionESChain", correctors=cms.vstring()),
                )
                for x in jetCorrections[1]:
                    if (
                        x != "L1FastJet"
                        and x != "L1Offset"
                        and x != "L2Relative"
                        and x != "L3Absolute"
                        and x != "L2L3Residual"
                    ):
                        raise ValueError, "In addJetCollection: Unsupported JEC for MET(Type1). Currently supported jet correction levels are L1FastJet, L1Offset, L2Relative, \
                        L3Asolute, L2L3Residual. Requested was:", x
                    else:
                        getattr(process, jetCorrections[0] + "CombinedCorrector").correctors.append(
                            jetCorrections[0] + x
                        )

                ## set up MET(Type1) correction modules
                if _type == "Calo":
                    from JetMETCorrections.Type1MET.caloMETCorrections_cff import caloJetMETcorr
                    from JetMETCorrections.Type1MET.caloMETCorrections_cff import caloType1CorrectedMet
                    from JetMETCorrections.Type1MET.caloMETCorrections_cff import caloType1p2CorrectedMet

                    setattr(
                        process,
                        jetCorrections[0] + "JetMETcorr" + postfix,
                        caloJetMETcorr.clone(
                            src=jetSource,
                            srcMET="corMetGlobalMuons",
                            jetCorrections=cms.string(jetCorrections[0] + "CombinedCorrector" + postfix),
                        ),
                    )
                    setattr(
                        process,
                        jetCorrections[0] + "Type1CorMet" + postfix,
                        caloType1CorrectedMet.clone(
                            src="corMetGlobalMuons" + postfix,
                            srcType1Corrections=cms.VInputTag(
                                cms.InputTag(jetCorrections[0] + "JetMETcorr" + postfix, "type1")
                            ),
                        ),
                    )
                    setattr(
                        process,
                        jetCorrections[0] + "Type1p2CorMet" + postfix,
                        caloType1p2CorrectedMet.clone(
                            src="corMetGlobalMuons" + postfix,
                            srcType1Corrections=cms.VInputTag(
                                cms.InputTag(jetCorrections[0] + "JetMETcorr" + postfix, "type1")
                            ),
                            srcUnclEnergySums=cms.VInputTag(
                                cms.InputTag(jetCorrections[0] + "JetMETcorr" + postfix, "type2"),
                                cms.InputTag(jetCorrections[0] + "JetMETcorr" + postfix, "offset"),
                                cms.InputTag("muonCaloMETcorr" + postfix),
                            ),
                        ),
                    )

                elif _type == "PF":
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfCandsNotInJet
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfJetMETcorr
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfCandMETcorr
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfType1CorrectedMet
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfType1p2CorrectedMet

                    setattr(
                        process,
                        jetCorrections[0] + "CandsNotInJet" + postfix,
                        pfCandsNotInJet.clone(topCollection=jetSource),
                    )
                    setattr(
                        process,
                        jetCorrections[0] + "CandMETcorr" + postfix,
                        pfCandMETcorr.clone(src=cms.InputTag(jetCorrections[0] + "CandsNotInJet" + postfix)),
                    )
                    setattr(process, jetCorrections[0] + "JetMETcorr" + postfix, pfJetMETcorr.clone(src=jetSource))
                    setattr(
                        process,
                        jetCorrections[0] + "Type1CorMet" + postfix,
                        pfType1CorrectedMet.clone(
                            srcType1Corrections=cms.VInputTag(
                                cms.InputTag(jetCorrections[0] + "JetMETcorr" + postfix, "type1")
                            )
                        ),
                    )
                    setattr(
                        process,
                        jetCorrections[0] + "Type1p2CorMet" + postfix,
                        pfType1p2CorrectedMet.clone(
                            srcType1Corrections=cms.VInputTag(
                                cms.InputTag(jetCorrections[0] + "JetMETcorr" + postfix, "type1")
                            ),
                            srcUnclEnergySums=cms.VInputTag(
                                cms.InputTag(jetCorrections[0] + "JetMETcorr" + postfix, "type2"),
                                cms.InputTag(jetCorrections[0] + "JetMETcorr" + postfix, "offset"),
                                cms.InputTag(jetCorrections[0] + "CandMETcorr" + postfix),
                            ),
                        ),
                    )

                ## common configuration for Calo and PF
                if "L1FastJet" in jetCorrections[1] or "L1Fastjet" in jetCorrections[1]:
                    getattr(process, jetCorrections[0] + "JetMETcorr" + postfix).offsetCorrLabel = cms.string(
                        jetCorrections[0] + "L1FastJet"
                    )
                elif "L1Offset" in jetCorrections[1]:
                    getattr(process, jetCorrections[0] + "JetMETcorr" + postfix).offsetCorrLabel = cms.string(
                        jetCorrections[0] + "L1Offset"
                    )
                else:
                    getattr(process, jetCorrections[0] + "JetMETcorr" + postfix).offsetCorrLabel = cms.string("")

                from PhysicsTools.PatAlgos.producersLayer1.metProducer_cfi import patMETs

                if jetCorrections[2].lower() == "type-1":
                    setattr(
                        process,
                        "patMETs" + _labelName + postfix,
                        patMETs.clone(
                            metSource=cms.InputTag(jetCorrections[0] + "Type1CorMet" + postfix),
                            addMuonCorrections=False,
                        ),
                    )
                elif jetCorrections[2].lower() == "type-1":
                    setattr(
                        process,
                        "patMETs" + _labelName + postfix,
                        patMETs.clone(
                            metSource=cms.InputTag(jetCorrections[0] + "Type1p2CorMet" + postfix),
                            addMuonCorrections=False,
                        ),
                    )
        else:
            ## switch jetCorrFactors off
            _newPatJets.addJetCorrFactors = False
Пример #23
0
    cut=cms.string(
        "abs(pdgId) != 2101 &&abs(pdgId) != 2103 && abs(pdgId) != 2203  && abs(pdgId) != 1103 "
    ))
## Define GenJets
from RecoJets.JetProducers.ak4GenJets_cfi import ak4GenJets
process.ak4GenJetsNoNuNEW = ak4GenJets.clone(
    src='packedGenParticlesForJetsNoNuNEW')
process.ak4GenJetsWithNuNEW = ak4GenJets.clone(
    src='packedGenParticlesForJetsWithNuNEW')
#I didn't manage to create a new jet collection on top of MINIAOD with the matching to this updated gen jet collection
#Work around: do the matching by hand
#Now redo the matching. The patJetGenJetMatch produces a matching between the gen jets and the reco jets.
from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch

process.patJetGenJetMatchUpdate = patJetGenJetMatch.clone(
    src=cms.InputTag(CHSJetCollectionName),
    matched=cms.InputTag("ak4GenJetsNoNuNEW"))
process.patJetGenJetMatchUpdatePuppi = patJetGenJetMatch.clone(
    src=cms.InputTag("slimmedJetsPuppi"),
    matched=cms.InputTag("ak4GenJetsNoNuNEW"))
process.patJetGenWithNuJetMatchUpdate = patJetGenJetMatch.clone(
    src=cms.InputTag(CHSJetCollectionName),
    matched=cms.InputTag("ak4GenJetsWithNuNEW"))
process.patJetGenWithNuJetMatchUpdatePuppi = patJetGenJetMatch.clone(
    src=cms.InputTag("slimmedJetsPuppi"),
    matched=cms.InputTag("ak4GenJetsWithNuNEW"))
process.patJetGenJetMatchUpdateCalo = patJetGenJetMatch.clone(
    src=cms.InputTag("slimmedCaloJets"),
    matched=cms.InputTag("ak4GenJetsNoNuNEW"))

#Update MET