def addFatJet(process): from RecoJets.JetProducers.ak5PFJets_cfi import ak5PFJets process.ca8PFJetsCHS = ak5PFJets.clone( src = 'pfNoPileUp', jetPtMin = cms.double(10.0), doAreaFastjet = cms.bool(True), rParam = cms.double(0.8), jetAlgorithm = cms.string("CambridgeAachen"), ) jetSource = 'ca8PFJetsCHS' # corrections from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors process.patJetCorrFactorsCA8CHS = patJetCorrFactors.clone() process.patJetCorrFactorsCA8CHS.src = jetSource # will need to add L2L3 corrections in the cfg process.patJetCorrFactorsCA8CHS.levels = ['L1FastJet', 'L2Relative', 'L3Absolute'] process.patJetCorrFactorsCA8CHS.payload = 'AK7PFchs' process.patJetCorrFactorsCA8CHS.useRho = True # pat jet from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets process.patJetsCA8CHS = patJets.clone() process.patJetsCA8CHS.jetSource = jetSource process.patJetsCA8CHS.addJetCharge = False process.patJetsCA8CHS.embedCaloTowers = False process.patJetsCA8CHS.embedPFCandidates = False process.patJetsCA8CHS.addAssociatedTracks = False process.patJetsCA8CHS.addBTagInfo = False process.patJetsCA8CHS.addDiscriminators = False process.patJetsCA8CHS.getJetMCFlavour = False process.patJetsCA8CHS.jetCorrFactorsSource = cms.VInputTag(cms.InputTag('patJetCorrFactorsCA8CHS')) process.patJetsCA8CHS.genPartonMatch = cms.InputTag('patJetPartonMatchCA8CHS') process.patJetsCA8CHS.genJetMatch = cms.InputTag('patJetGenJetMatchCA8CHS') from PhysicsTools.PatAlgos.selectionLayer1.jetSelector_cfi import selectedPatJets process.selectedPatJetsCA8CHS = selectedPatJets.clone() process.selectedPatJetsCA8CHS.src = 'patJetsCA8CHS' process.selectedPatJetsCA8CHS.cut = 'pt()>20' #process.jetMCSequenceCA8CHS = cms.Sequence( #process.patJetPartonMatchCA8CHS + #process.genParticlesForJetsNoNu + #process.ca8GenJetsNoNu + #process.patJetGenJetMatchCA8CHS #) process.PATJetSequenceCA8CHS = cms.Sequence( process.ca8PFJetsCHS + #process.jetMCSequenceCA8CHS + process.patJetCorrFactorsCA8CHS #process.patJetsCA8CHS + #process.selectedPatJetsCA8CHS ) process.PATJetPathCA8CHS = cms.Path ( process.PATJetSequenceCA8CHS )
process.ak5CalopatJets = patJets.clone(jetSource = cms.InputTag("ak5CaloJets"), addGenPartonMatch = cms.bool(True), embedGenPartonMatch = cms.bool(True), embedGenJetMatch = cms.bool(True), addGenJetMatch = cms.bool(True), genPartonMatch = cms.InputTag("ak5CaloPartonMatch"), genJetMatch = cms.InputTag("ak5CaloGenMatchJets"), # jetIDMap = cms.InputTag("ak5CaloJetID"), jetIDMap = cms.InputTag("ak5JetID"), addJetCorrFactors = cms.bool(True), jetCorrFactorsSource = cms.VInputTag(cms.InputTag("ak5CaloJetCorrFactors") ), getJetMCFlavour = cms.bool(True), JetPartonMapSource = cms.InputTag("ak5CaloJetFlavourAssociation"), addAssociatedTracks = cms.bool(True), trackAssociationSource = cms.InputTag("ak5JetTracksAssociatorAtVertex"), addJetCharge = cms.bool(True), jetChargeSource = cms.InputTag("ak5CaloJetCharge"), # btag information addBTagInfo = cms.bool(False), ## master switch addDiscriminators = cms.bool(False), ## addition btag discriminator # embedding of RECO items (do not use on AOD input!) embedCaloTowers = cms.bool(True) )
akFlowPuCsSoftDrop1PFpatJetsWithBtagging = patJets.clone( jetSource = cms.InputTag("akFlowPuCsSoftDrop1PFJets"), genJetMatch = cms.InputTag("akFlowPuCsSoftDrop1PFmatch"), genPartonMatch = cms.InputTag("akFlowPuCsSoftDrop1PFparton"), jetCorrFactorsSource = cms.VInputTag(cms.InputTag("akFlowPuCsSoftDrop1PFcorr")), JetPartonMapSource = cms.InputTag("akFlowPuCsSoftDrop1PFPatJetFlavourAssociationLegacy"), JetFlavourInfoSource = cms.InputTag("akFlowPuCsSoftDrop1PFPatJetFlavourAssociation"), trackAssociationSource = cms.InputTag("akFlowPuCsSoftDrop1PFJetTracksAssociatorAtVertex"), useLegacyJetMCFlavour = True, discriminatorSources = cms.VInputTag( cms.InputTag("akFlowPuCsSoftDrop1PFSimpleSecondaryVertexHighEffBJetTags"), cms.InputTag("akFlowPuCsSoftDrop1PFSimpleSecondaryVertexHighPurBJetTags"), cms.InputTag("akFlowPuCsSoftDrop1PFCombinedSecondaryVertexBJetTags"), cms.InputTag("akFlowPuCsSoftDrop1PFCombinedSecondaryVertexV2BJetTags"), cms.InputTag("akFlowPuCsSoftDrop1PFJetBProbabilityBJetTags"), cms.InputTag("akFlowPuCsSoftDrop1PFJetProbabilityBJetTags"), # cms.InputTag("akFlowPuCsSoftDrop1PFSoftPFMuonByPtBJetTags"), # cms.InputTag("akFlowPuCsSoftDrop1PFSoftPFMuonByIP3dBJetTags"), cms.InputTag("akFlowPuCsSoftDrop1PFTrackCountingHighEffBJetTags"), cms.InputTag("akFlowPuCsSoftDrop1PFTrackCountingHighPurBJetTags"), ), tagInfoSources = cms.VInputTag(cms.InputTag("akFlowPuCsSoftDrop1PFImpactParameterTagInfos"),cms.InputTag("akFlowPuCsSoftDrop1PFSecondaryVertexTagInfos")), jetIDMap = cms.InputTag("akFlowPuCsSoftDrop1PFJetID"), addBTagInfo = True, addTagInfos = True, addDiscriminators = True, addAssociatedTracks = True, addJetCharge = False, addJetID = False, getJetMCFlavour = True, addGenPartonMatch = True, addGenJetMatch = True, embedGenJetMatch = True, embedGenPartonMatch = True, # embedCaloTowers = False, # embedPFCandidates = True )
ak8GenJetsPrunedLinks = cms.EDProducer( "RecoJetDeltaRValueMapProducer", src=cms.InputTag("ak8GenJets"), matched=cms.InputTag("ak8GenJetsPruned"), distMax=cms.double(0.8), value=cms.string('mass')) from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets as patJets goodJets = patJets.clone(jetSource="ak8GenJets", embedCaloTowers=cms.bool(False), embedPFCandidates=cms.bool(False), addJetCorrFactors=cms.bool(False), addBTagInfo=cms.bool(False), addDiscriminators=cms.bool(False), addAssociatedTracks=cms.bool(False), addJetCharge=cms.bool(False), addJetID=cms.bool(False), addGenPartonMatch=cms.bool(False), addGenJetMatch=cms.bool(False), getJetMCFlavour=cms.bool(False)) goodJets.userData.userFloats.src = cms.VInputTag("ak8GenJetsPrunedLinks", ) ## Cleaning # We want to make sure that the jets are not the electrons or muons done previously import PhysicsTools.PatAlgos.cleaningLayer1.jetCleaner_cfi as jetCleaner_cfi cleanJets = jetCleaner_cfi.cleanPatJets.clone() cleanJets.src = "goodJets" cleanJets.checkOverlaps.muons.src = "goodMuons"
def addFatJet(process): from RecoJets.JetProducers.ak5PFJets_cfi import ak5PFJets process.ca8PFJetsCHS = ak5PFJets.clone( src='pfNoPileUp', jetPtMin=cms.double(10.0), doAreaFastjet=cms.bool(True), rParam=cms.double(0.8), jetAlgorithm=cms.string("CambridgeAachen"), ) jetSource = 'ca8PFJetsCHS' # corrections from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors process.patJetCorrFactorsCA8CHS = patJetCorrFactors.clone() process.patJetCorrFactorsCA8CHS.src = jetSource # will need to add L2L3 corrections in the cfg process.patJetCorrFactorsCA8CHS.levels = [ 'L1FastJet', 'L2Relative', 'L3Absolute' ] process.patJetCorrFactorsCA8CHS.payload = 'AK7PFchs' process.patJetCorrFactorsCA8CHS.useRho = True # pat jet from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets process.patJetsCA8CHS = patJets.clone() process.patJetsCA8CHS.jetSource = jetSource process.patJetsCA8CHS.addJetCharge = False process.patJetsCA8CHS.embedCaloTowers = False process.patJetsCA8CHS.embedPFCandidates = False process.patJetsCA8CHS.addAssociatedTracks = False process.patJetsCA8CHS.addBTagInfo = False process.patJetsCA8CHS.addDiscriminators = False process.patJetsCA8CHS.getJetMCFlavour = False process.patJetsCA8CHS.jetCorrFactorsSource = cms.VInputTag( cms.InputTag('patJetCorrFactorsCA8CHS')) process.patJetsCA8CHS.genPartonMatch = cms.InputTag( 'patJetPartonMatchCA8CHS') process.patJetsCA8CHS.genJetMatch = cms.InputTag('patJetGenJetMatchCA8CHS') from PhysicsTools.PatAlgos.selectionLayer1.jetSelector_cfi import selectedPatJets process.selectedPatJetsCA8CHS = selectedPatJets.clone() process.selectedPatJetsCA8CHS.src = 'patJetsCA8CHS' process.selectedPatJetsCA8CHS.cut = 'pt()>20' #process.jetMCSequenceCA8CHS = cms.Sequence( #process.patJetPartonMatchCA8CHS + #process.genParticlesForJetsNoNu + #process.ca8GenJetsNoNu + #process.patJetGenJetMatchCA8CHS #) process.PATJetSequenceCA8CHS = cms.Sequence( process.ca8PFJetsCHS + #process.jetMCSequenceCA8CHS + process.patJetCorrFactorsCA8CHS #process.patJetsCA8CHS + #process.selectedPatJetsCA8CHS ) process.PATJetPathCA8CHS = cms.Path(process.PATJetSequenceCA8CHS)
def customizePFPatLikeJetsROI(process, type="AK4PFCHS"): # set some default collection variables pfjets = "hltAK4PFJetsForBTag" PFDeepCSVTags = "hltDeepCombinedSecondaryVertexBPFPatROIJetTags" #original pfDeepCSVJetTags PFDeepFlavourTags = "hltPFDeepFlavourROIJetTags" #original pfDeepFlavourJetTagsSlimmedDeepFlavour payload = "AK4PFHLT" #original AK4PFchs hltVertices = "hltVerticesPFFilterForBTag" #original offlinePrimaryVertices rho = "hltFixedGridRhoFastjetAllForBTag" #original fixedGridRhoFastjetAll siPixelClusters = "hltSiPixelClusters" #original siPixelClusters ecalRecHit = "hltEcalRecHit" #original ecalRecHit hbhereco = "hltHbhereco" #original hbhereco hfreco = "hltHfreco" #original hfreco horeco = "hltHoreco" #original horeco rpcRecHits = "hltRpcRecHits" #original rpcRecHits tracks = "hltMergedTracksForBTag" #original generalTracks puppi = "hltPFPuppiROI" #original puppi puppijets = "hltAK4PFPuppiJetsROI" #original ak4PFJetsCHS payloadPuppi = "AK4PFPuppiHLT" #original AK4PFchs PFPuppiDeepFlavourTags = "hltPFPuppiDeepFlavourROIJetTags" #original pfDeepFlavourJetTagsSlimmedDeepFlavour PFPuppiDeepCSVTags = "hltDeepCombinedSecondaryVertexBPFPuppiPatROIJetTags" #original pfDeepCSVJetTags particleFlow = "hltParticleFlowForBTag" #original particleFlow beamSpot = "hltOnlineBeamSpot" #original offlineBeamSpot # clone and modify the HLT BTV sequence/producers to remove the jet pt and eta selections from "jetsForBtag" and replace with pfjets process.hltDeepBLifetimePFPatROITagInfos = process.hltDeepBLifetimeTagInfosPFROI.clone( jets=cms.InputTag(pfjets)) process.hltDeepSecondaryVertexPFPatROITagInfos = process.hltDeepSecondaryVertexTagInfosPFROI.clone( trackIPTagInfos=cms.InputTag("hltDeepBLifetimePFPatROITagInfos")) process.hltDeepCombinedSecondaryVertexBJetPatROITagInfos = process.hltDeepCombinedSecondaryVertexBJetTagsInfosROI.clone( svTagInfos=cms.InputTag("hltDeepSecondaryVertexPFPatROITagInfos")) process.hltDeepCombinedSecondaryVertexBPFPatROIJetTags = process.hltDeepCombinedSecondaryVertexBJetTagsPFROI.clone( src=cms.InputTag("hltDeepCombinedSecondaryVertexBJetPatROITagInfos")) process.HLTBtagDeepCSVSequencePFPatROI = cms.Sequence( process.hltVerticesPFForBTag + process.hltVerticesPFSelectorForBTag + process.hltVerticesPFFilterForBTag + process.hltDeepBLifetimePFPatROITagInfos + process.hltDeepInclusiveVertexFinderPFROI + process.hltDeepInclusiveSecondaryVerticesPFROI + process.hltDeepTrackVertexArbitratorPFROI + process.hltDeepInclusiveMergedVerticesPFROI + process.hltDeepSecondaryVertexPFPatROITagInfos + process.hltDeepCombinedSecondaryVertexBJetPatROITagInfos + process.hltDeepCombinedSecondaryVertexBPFPatROIJetTags) # # same for puppi jets # process.hltDeepBLifetimePFPuppiPatROITagInfos = process.hltDeepBLifetimeTagInfosPFROI.clone( jets=cms.InputTag(puppijets)) process.hltDeepSecondaryVertexPFPuppiPatROITagInfos = process.hltDeepSecondaryVertexTagInfosPFROI.clone( trackIPTagInfos=cms.InputTag("hltDeepBLifetimePFPuppiPatROITagInfos"), weights=cms.InputTag(puppi)) process.hltDeepCombinedSecondaryVertexBPuppiJetPatROITagInfos = process.hltDeepCombinedSecondaryVertexBJetTagsInfosROI.clone( svTagInfos=cms.InputTag("hltDeepSecondaryVertexPFPuppiPatROITagInfos")) process.hltDeepCombinedSecondaryVertexBPFPuppiPatROIJetTags = process.hltDeepCombinedSecondaryVertexBJetTagsPFROI.clone( src=cms.InputTag( "hltDeepCombinedSecondaryVertexBPuppiJetPatROITagInfos")) process.HLTBtagDeepCSVSequencePFPuppiPatROI = cms.Sequence( process.hltVerticesPFForBTag + process.hltVerticesPFSelectorForBTag + process.hltVerticesPFFilterForBTag + process.hltDeepBLifetimePFPuppiPatROITagInfos + process.hltDeepInclusiveVertexFinderPFROI + process.hltDeepInclusiveSecondaryVerticesPFROI + process.hltDeepTrackVertexArbitratorPFROI + process.hltDeepInclusiveMergedVerticesPFROI + process.hltDeepSecondaryVertexPFPuppiPatROITagInfos + process.hltDeepCombinedSecondaryVertexBPuppiJetPatROITagInfos + process.hltDeepCombinedSecondaryVertexBPFPuppiPatROIJetTags) # create patJets for ak4pfchs and all necessary missing inputs from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets process.hltPatJetsROI = patJets.clone( JetFlavourInfoSource=cms.InputTag("hltPatJetFlavourAssociationROI"), JetPartonMapSource=cms.InputTag( "hltPatJetFlavourAssociationLegacyROI"), addJetID=cms.bool(False), addTagInfos=cms.bool(True), discriminatorSources=cms.VInputTag( cms.InputTag(PFDeepCSVTags, "probb"), cms.InputTag(PFDeepCSVTags, "probc"), cms.InputTag(PFDeepCSVTags, "probudsg"), # cms.InputTag(PFDeepCSVTags,"probbb"), # hltDeepCSV: probb = probb +probbb cms.InputTag(PFDeepFlavourTags, "probb"), cms.InputTag(PFDeepFlavourTags, "probc"), cms.InputTag(PFDeepFlavourTags, "probg"), cms.InputTag(PFDeepFlavourTags, "problepb"), cms.InputTag(PFDeepFlavourTags, "probbb"), cms.InputTag(PFDeepFlavourTags, "probuds"), ), embedGenPartonMatch=cms.bool(False), genJetMatch=cms.InputTag("hltPatJetGenJetMatchROI"), genPartonMatch=cms.InputTag("hltPatJetPartonMatchROI"), jetChargeSource=cms.InputTag("hltPatJetChargeROI"), jetCorrFactorsSource=cms.VInputTag( cms.InputTag("hltPatJetCorrFactorsROI")), jetIDMap=cms.InputTag("hltAk4JetIDROI"), jetSource=cms.InputTag(pfjets), tagInfoSources=cms.VInputTag( cms.InputTag("hltDeepBLifetimePFPatROITagInfos"), cms.InputTag("hltDeepCombinedSecondaryVertexBJetPatROITagInfos"), cms.InputTag("hltDeepSecondaryVertexPFPatROITagInfos"), cms.InputTag("hltPFDeepFlavourROITagInfos"), ), trackAssociationSource=cms.InputTag( "hltAk4JetTracksAssociatorAtVertexPFROI"), ) process.hltPatJetsPuppiROI = patJets.clone( JetFlavourInfoSource=cms.InputTag( "hltPatJetFlavourAssociationPuppiROI"), JetPartonMapSource=cms.InputTag( "hltPatJetFlavourAssociationLegacyPuppiROI"), addJetID=cms.bool(False), addTagInfos=cms.bool(True), discriminatorSources=cms.VInputTag( cms.InputTag(PFPuppiDeepCSVTags, "probb"), cms.InputTag(PFPuppiDeepCSVTags, "probc"), cms.InputTag(PFPuppiDeepCSVTags, "probudsg"), # cms.InputTag(PFPuppiDeepCSVTags,"probbb"), # hltDeepCSV: probb = probb +probbb cms.InputTag(PFPuppiDeepFlavourTags, "probb"), cms.InputTag(PFPuppiDeepFlavourTags, "probc"), cms.InputTag(PFPuppiDeepFlavourTags, "probg"), cms.InputTag(PFPuppiDeepFlavourTags, "problepb"), cms.InputTag(PFPuppiDeepFlavourTags, "probbb"), cms.InputTag(PFPuppiDeepFlavourTags, "probuds"), ), embedGenPartonMatch=cms.bool(False), genJetMatch=cms.InputTag("hltPatJetGenJetMatchPuppiROI"), genPartonMatch=cms.InputTag("hltPatJetPartonMatchPuppiROI"), jetChargeSource=cms.InputTag("patJetPuppiChargeROI"), jetCorrFactorsSource=cms.VInputTag( cms.InputTag("hltPatJetCorrFactorsPuppiROI")), jetIDMap=cms.InputTag("hltAk4JetID"), jetSource=cms.InputTag(puppijets), tagInfoSources=cms.VInputTag( cms.InputTag("hltDeepBLifetimePFPuppiPatROITagInfos"), cms.InputTag( "hltDeepCombinedSecondaryVertexBPuppiJetPatROITagInfos"), cms.InputTag("hltDeepSecondaryVertexPFPuppiPatROITagInfos"), cms.InputTag("hltPFPuppiDeepFlavourROITagInfos"), ), trackAssociationSource=cms.InputTag( "hltAk4JetTracksAssociatorAtVertexPFPuppiROI"), ) # for patJets from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetFlavourAssociation, patJetPartons, patJetFlavourAssociationLegacy, patJetPartonAssociationLegacy, patJetPartonsLegacy process.hltPatJetFlavourAssociationROI = patJetFlavourAssociation.clone( bHadrons=cms.InputTag("hltPatJetPartons", "bHadrons"), cHadrons=cms.InputTag("hltPatJetPartons", "cHadrons"), jets=cms.InputTag(pfjets), leptons=cms.InputTag("hltPatJetPartons", "leptons"), partons=cms.InputTag("hltPatJetPartons", "physicsPartons"), ) process.hltPatJetFlavourAssociationPuppiROI = patJetFlavourAssociation.clone( bHadrons=cms.InputTag("hltPatJetPartons", "bHadrons"), cHadrons=cms.InputTag("hltPatJetPartons", "cHadrons"), jets=cms.InputTag(puppijets), leptons=cms.InputTag("hltPatJetPartons", "leptons"), partons=cms.InputTag("hltPatJetPartons", "physicsPartons"), weights=cms.InputTag(puppi)) process.hltPatJetPartonsROI = patJetPartons.clone() process.hltPatJetFlavourAssociationLegacyROI = patJetFlavourAssociationLegacy.clone( srcByReference=cms.InputTag("hltPatJetPartonAssociationLegacyROI")) process.hltPatJetFlavourAssociationLegacyPuppiROI = patJetFlavourAssociationLegacy.clone( srcByReference=cms.InputTag( "hltPatJetPartonAssociationLegacyPuppiROI")) process.hltPatJetPartonAssociationLegacyROI = patJetPartonAssociationLegacy.clone( jets=cms.InputTag(pfjets), partons=cms.InputTag("hltPatJetPartonsLegacyROI")) process.hltPatJetPartonAssociationLegacyPuppiROI = patJetPartonAssociationLegacy.clone( jets=cms.InputTag(puppijets), partons=cms.InputTag("hltPatJetPartonsLegacyROI")) process.hltPatJetPartonsLegacyROI = patJetPartonsLegacy.clone( src=cms.InputTag("genParticles"), ) from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch process.hltPatJetGenJetMatchROI = patJetGenJetMatch.clone( matched=cms.InputTag("hltSlimmedGenJets"), src=cms.InputTag(pfjets)) process.hltPatJetGenJetMatchPuppiROI = patJetGenJetMatch.clone( matched=cms.InputTag("hltSlimmedGenJets"), src=cms.InputTag(puppijets)) from PhysicsTools.PatAlgos.slimming.slimmedGenJets_cfi import slimmedGenJets process.hltSlimmedGenJets = slimmedGenJets.clone( packedGenParticles=cms.InputTag("hltPackedGenParticles"), src=cms.InputTag("ak4GenJetsNoNu")) from PhysicsTools.PatAlgos.slimming.packedGenParticles_cfi import packedGenParticles process.hltPackedGenParticles = packedGenParticles.clone( inputCollection=cms.InputTag("hltPrunedGenParticlesWithStatusOne"), inputOriginal=cms.InputTag("genParticles"), map=cms.InputTag("hltPrunedGenParticles"), ) from PhysicsTools.PatAlgos.slimming.genParticles_cff import prunedGenParticlesWithStatusOne from PhysicsTools.PatAlgos.slimming.prunedGenParticles_cfi import prunedGenParticles process.hltPrunedGenParticlesWithStatusOne = prunedGenParticlesWithStatusOne.clone( src=cms.InputTag("genParticles")) process.hltPrunedGenParticles = prunedGenParticles.clone( src=cms.InputTag("hltPrunedGenParticlesWithStatusOne")) from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetPartonMatch process.hltPatJetPartonMatchROI = patJetPartonMatch.clone( matched=cms.InputTag("hltPrunedGenParticles"), src=cms.InputTag(pfjets)) process.hltPatJetPartonMatchPuppiROI = patJetPartonMatch.clone( matched=cms.InputTag("hltPrunedGenParticles"), src=cms.InputTag(puppijets)) from PhysicsTools.PatAlgos.recoLayer0.jetTracksCharge_cff import patJetCharge process.hltPatJetChargeROI = patJetCharge.clone( src=cms.InputTag("hltAk4JetTracksAssociatorAtVertexPFROI"), ) process.patJetPuppiChargeROI = patJetCharge.clone( src=cms.InputTag("hltAk4JetTracksAssociatorAtVertexPFPuppiROI"), ) from RecoJets.JetAssociationProducers.ak4JTA_cff import ak4JetTracksAssociatorAtVertexPF process.hltAk4JetTracksAssociatorAtVertexPFROI = ak4JetTracksAssociatorAtVertexPF.clone( jets=cms.InputTag(pfjets), pvSrc=cms.InputTag(hltVertices), tracks=cms.InputTag(tracks), ) process.hltAk4JetTracksAssociatorAtVertexPFPuppiROI = ak4JetTracksAssociatorAtVertexPF.clone( jets=cms.InputTag(puppijets), pvSrc=cms.InputTag(hltVertices), tracks=cms.InputTag(tracks), ) from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors process.hltPatJetCorrFactorsROI = patJetCorrFactors.clone( payload=cms.string(payload), primaryVertices=cms.InputTag(hltVertices), rho=cms.InputTag(rho), src=cms.InputTag(pfjets), ) process.hltPatJetCorrFactorsPuppiROI = patJetCorrFactors.clone( payload=cms.string(payloadPuppi), primaryVertices=cms.InputTag(hltVertices), rho=cms.InputTag(rho), src=cms.InputTag(puppijets), ) from RecoJets.JetProducers.ak4JetID_cfi import ak4JetID process.hltAk4JetIDROI = ak4JetID.clone( ebRecHitsColl=cms.InputTag(ecalRecHit, "EcalRecHitsEB"), eeRecHitsColl=cms.InputTag(ecalRecHit, "EcalRecHitsEE"), hbheRecHitsColl=cms.InputTag(hbhereco), hfRecHitsColl=cms.InputTag(hfreco), hoRecHitsColl=cms.InputTag(horeco), rpcRecHits=cms.InputTag(rpcRecHits), src=cms.InputTag("hltAK4CaloJets"), ) #### TAGGERS # run DeepFlavour for HLT from RecoBTag.ONNXRuntime.pfDeepFlavourJetTags_cfi import pfDeepFlavourJetTags process.hltPFDeepFlavourROIJetTags = pfDeepFlavourJetTags.clone( src=cms.InputTag("hltPFDeepFlavourROITagInfos")) process.hltPFPuppiDeepFlavourROIJetTags = pfDeepFlavourJetTags.clone( src=cms.InputTag("hltPFPuppiDeepFlavourROITagInfos")) from RecoBTag.FeatureTools.pfDeepFlavourTagInfos_cfi import pfDeepFlavourTagInfos process.hltPFDeepFlavourROITagInfos = pfDeepFlavourTagInfos.clone( candidates=cms.InputTag(particleFlow), jets=cms.InputTag(pfjets), puppi_value_map=cms.InputTag(puppi), secondary_vertices=cms.InputTag( "hltDeepInclusiveSecondaryVerticesPFROI"), shallow_tag_infos=cms.InputTag( "hltDeepCombinedSecondaryVertexBJetPatROITagInfos"), vertex_associator=cms.InputTag("hltPrimaryVertexAssociationROI", "original"), vertices=cms.InputTag(hltVertices)) process.hltPFPuppiDeepFlavourROITagInfos = pfDeepFlavourTagInfos.clone( candidates=cms.InputTag(particleFlow), jets=cms.InputTag(puppijets), puppi_value_map=cms.InputTag(puppi), secondary_vertices=cms.InputTag( "hltDeepInclusiveSecondaryVerticesPFROI"), shallow_tag_infos=cms.InputTag( "hltDeepCombinedSecondaryVertexBPuppiJetPatROITagInfos"), vertex_associator=cms.InputTag("hltPrimaryVertexAssociationPuppiROI", "original"), vertices=cms.InputTag(hltVertices)) from RecoBTag.SecondaryVertex.candidateCombinedSecondaryVertexV2Computer_cfi import candidateCombinedSecondaryVertexV2Computer process.candidateCombinedSecondaryVertexV2Computer = candidateCombinedSecondaryVertexV2Computer.clone( ) from PhysicsTools.PatAlgos.slimming.primaryVertexAssociation_cfi import primaryVertexAssociation process.hltPrimaryVertexAssociationROI = primaryVertexAssociation.clone( jets=cms.InputTag(pfjets), particles=cms.InputTag(particleFlow), vertices=cms.InputTag(hltVertices), ) process.hltPrimaryVertexAssociationPuppiROI = primaryVertexAssociation.clone( jets=cms.InputTag(puppijets), particles=cms.InputTag(particleFlow), vertices=cms.InputTag(hltVertices), ) #from RecoParticleFlow.PFProducer.chargedHadronPFTrackIsolation_cfi import chargedHadronPFTrackIsolation #process.hltChargedHadronPFTrackIsolationROI = chargedHadronPFTrackIsolation.clone( # src = cms.InputTag(particleFlow) #) # create the final path process.MC_JetsMatchingPathROI = cms.Path( process.HLTAK4PFJetsSequenceForBTag * process.HLTBtagDeepCSVSequencePFPatROI * process.hltPrunedGenParticlesWithStatusOne * process.hltPrunedGenParticles * process.hltPackedGenParticles * process.hltPatJetPartonMatchROI * process.hltSlimmedGenJets * process.hltAk4JetIDROI * process.hltPatJetGenJetMatchROI * process.hltPatJetPartonsLegacyROI * process.hltPatJetPartonAssociationLegacyROI * process.hltPatJetFlavourAssociationLegacyROI * process.hltPatJetPartonsROI * process.hltPatJetFlavourAssociationROI * process.hltAk4JetTracksAssociatorAtVertexPFROI * process.hltPatJetChargeROI * process.hltPatJetCorrFactorsROI * process.hltPrimaryVertexAssociationROI # *process.hltChargedHadronPFTrackIsolationROI * process.hltPFDeepFlavourROITagInfos * process.hltPFDeepFlavourROIJetTags * process.hltPatJetsROI) process.MC_PuppiJetsMatchingPathROI = cms.Path( process.HLTAK4PFJetsSequenceForBTag * process.HLTAK4PFPuppiJetsSequenceROI * process.HLTBtagDeepCSVSequencePFPuppiPatROI * process.hltPrunedGenParticlesWithStatusOne * process.hltPrunedGenParticles * process.hltPackedGenParticles * process.hltPatJetPartonMatchPuppiROI * process.hltSlimmedGenJets * process.hltAk4JetIDROI * process.hltPatJetGenJetMatchPuppiROI * process.hltPatJetPartonsLegacyROI * process.hltPatJetPartonAssociationLegacyPuppiROI * process.hltPatJetFlavourAssociationLegacyPuppiROI * process.hltPatJetPartonsROI * process.hltPatJetFlavourAssociationPuppiROI * process.hltAk4JetTracksAssociatorAtVertexPFPuppiROI * process.patJetPuppiChargeROI * process.hltPatJetCorrFactorsPuppiROI * process.hltPrimaryVertexAssociationPuppiROI # *process.hltChargedHadronPFTrackIsolation * process.hltPFPuppiDeepFlavourROITagInfos * process.hltPFPuppiDeepFlavourROIJetTags * process.hltPatJetsPuppiROI) if process.schedule_(): process.schedule.extend([process.MC_JetsMatchingPathROI]) process.schedule.extend([process.MC_PuppiJetsMatchingPathROI]) return process
def 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
) from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets process.ak5CalopatJets = patJets.clone( jetSource=cms.InputTag("ak5CaloJets"), addGenPartonMatch=cms.bool(True), embedGenPartonMatch=cms.bool(True), embedGenJetMatch=cms.bool(True), addGenJetMatch=cms.bool(True), genPartonMatch=cms.InputTag("ak5CaloPartonMatch"), genJetMatch=cms.InputTag("ak5CaloGenMatchJets"), # jetIDMap = cms.InputTag("ak5CaloJetID"), jetIDMap=cms.InputTag("ak5JetID"), addJetCorrFactors=cms.bool(True), jetCorrFactorsSource=cms.VInputTag(cms.InputTag("ak5CaloJetCorrFactors")), getJetMCFlavour=cms.bool(True), JetPartonMapSource=cms.InputTag("ak5CaloJetFlavourAssociation"), addAssociatedTracks=cms.bool(True), trackAssociationSource=cms.InputTag("ak5JetTracksAssociatorAtVertex"), addJetCharge=cms.bool(True), jetChargeSource=cms.InputTag("ak5CaloJetCharge"), # btag information addBTagInfo=cms.bool(False), ## master switch addDiscriminators=cms.bool(False), ## addition btag discriminator # embedding of RECO items (do not use on AOD input!) embedCaloTowers=cms.bool(True)) process.ak5PFpatJets = patJets.clone( jetSource=cms.InputTag("ak5PFJets"),
secondaryVertexTagInfosCA8CHSprunedSubjets=secondaryVertexTagInfos.clone() secondaryVertexTagInfosCA8CHSprunedSubjets.trackIPTagInfos='impactParameterTagInfosCA8CHSprunedSubjets' combinedSecondaryVertexBJetTagsCA8CHSprunedSubjets=combinedSecondaryVertexBJetTags.clone() combinedSecondaryVertexBJetTagsCA8CHSprunedSubjets.tagInfos = cms.VInputTag(cms.InputTag("impactParameterTagInfosCA8CHSprunedSubjets"), cms.InputTag("secondaryVertexTagInfosCA8CHSprunedSubjets")) btaggingCA8CHSprunedSubjets=cms.Sequence(ca8CHSprunedSubjetsJetTracksAssociatorAtVertex+impactParameterTagInfosCA8CHSprunedSubjets+secondaryVertexTagInfosCA8CHSprunedSubjets+combinedSecondaryVertexBJetTagsCA8CHSprunedSubjets) ##jet probability jetProbabilityBJetTagsCA8CHSprunedSubjets=jetProbabilityBJetTags.clone() jetProbabilityBJetTagsCA8CHSprunedSubjets.tagInfos = cms.VInputTag(cms.InputTag("impactParameterTagInfosCA8CHSprunedSubjets")) jetBProbabilityBJetTagsCA8CHSprunedSubjets=jetBProbabilityBJetTags.clone() jetBProbabilityBJetTagsCA8CHSprunedSubjets.tagInfos = cms.VInputTag(cms.InputTag("impactParameterTagInfosCA8CHSprunedSubjets")) btaggingJPCA8CHSprunedSubjets=cms.Sequence(jetProbabilityBJetTagsCA8CHSprunedSubjets + jetBProbabilityBJetTagsCA8CHSprunedSubjets) patJetsCA8CHSprunedSubjetsOrig = patJets.clone() patJetsCA8CHSprunedSubjetsOrig.jetSource = cms.InputTag('ca8PFJetsCHSpruned','SubJets') patJetsCA8CHSprunedSubjetsOrig.addGenJetMatch = False patJetsCA8CHSprunedSubjetsOrig.addGenPartonMatch = False patJetsCA8CHSprunedSubjetsOrig.addJetCharge = False patJetsCA8CHSprunedSubjetsOrig.embedCaloTowers = False patJetsCA8CHSprunedSubjetsOrig.embedPFCandidates = False patJetsCA8CHSprunedSubjetsOrig.addAssociatedTracks = True patJetsCA8CHSprunedSubjetsOrig.addBTagInfo = True patJetsCA8CHSprunedSubjetsOrig.addDiscriminators = True patJetsCA8CHSprunedSubjetsOrig.addJetID = True patJetsCA8CHSprunedSubjetsOrig.tagInfoSources = cms.VInputTag(cms.InputTag("secondaryVertexTagInfosCA8CHSprunedSubjets"),cms.InputTag("impactParameterTagInfosCA8CHSprunedSubjets")) patJetsCA8CHSprunedSubjetsOrig.trackAssociationSource = cms.InputTag("ca8CHSprunedSubjetsJetTracksAssociatorAtVertex") patJetsCA8CHSprunedSubjetsOrig.discriminatorSources = cms.VInputTag(cms.InputTag("combinedSecondaryVertexBJetTagsCA8CHSprunedSubjets"),cms.InputTag("jetProbabilityBJetTagsCA8CHSprunedSubjets"),cms.InputTag("jetBProbabilityBJetTagsCA8CHSprunedSubjets")) patJetsCA8CHSprunedSubjetsOrig.getJetMCFlavour = False patJetsCA8CHSprunedSubjetsOrig.addJetCorrFactors = False
def JetSubstructure(process, isMC, coneSize=0.8, algo="AK", pileupMethod="chs", selection="pt > 175 && abs(eta) < 2.5", addPruning=True, addPrunedSubjets=True, addSoftDrop=True, addSoftDropSubjets=True, addTrimming=False, addTrimmedSubjets=False, addFiltering=False, addFilteredSubjets=False, addNsubjettiness=True, addEnergyCorrelation=True, addQJets=False, addQGLikelihood=True): print "############################" print "add substructure information" print "isMC = ", isMC print "coneSize = ", coneSize print "algo = ", algo print "pileupMethod = ", pileupMethod print "selection = ", selection print "addPruning = ", addPruning print "addPrunedSubjets = ", addPrunedSubjets print "addSoftDrop = ", addSoftDrop print "addSoftDropSubjets = ", addSoftDropSubjets print "addTrimming = ", addTrimming print "addTrimmedSubjets = ", addTrimmedSubjets print "addFiltering = ", addFiltering print "addFilteredSubjets = ", addFilteredSubjets print "addNsubjettiness = ", addNsubjettiness print "addEnergyCorrelation = ", addEnergyCorrelation print "addQJets = ", addQJets print "addQGLikelihood = ", addQGLikelihood print "############################" ## build jet algo name for jet clustering coneSizeStr = str(coneSize).replace("0", "").replace(".", "") jetAlgo = algo + coneSizeStr if algo == "AK": ALGO = "AntiKt" elif algo == "CA": ALGO = "CambridgeAachen" if isMC: ## run gen jet clustering from genParticles if not hasattr(process, "genParticlesForJetsNoNu"): setattr( process, 'genParticlesForJetsNoNu', cms.EDFilter( "CandPtrSelector", src=cms.InputTag("packedGenParticles"), cut=cms.string( "abs(pdgId) != 12 && abs(pdgId) != 14 && abs(pdgId) != 16 && abs(pdgId) != 1000022 && abs(pdgId) != 1000012 &&" + "abs(pdgId) != 1000014 && abs(pdgId) != 1000016 && abs(pdgId) != 2000012 && abs(pdgId) != 2000014 &&" + "abs(pdgId) != 2000016 && abs(pdgId) != 1000039 && abs(pdgId) != 5100039 && abs(pdgId) != 4000012 &&" + "abs(pdgId) != 4000014 && abs(pdgId) != 4000016 && abs(pdgId) != 9900012 && abs(pdgId) != 9900014 &&" + "abs(pdgId) != 9900016 && abs(pdgId) != 39 && abs(pdgId) != 9100012" ))) ## skip all the possible invisible particles if not hasattr(process, "genJets" + jetAlgo): setattr( process, "genJets" + jetAlgo, ak4GenJets.clone(src='genParticlesForJetsNoNu', rParam=coneSize, jetAlgorithm=ALGO, jetPtMin=cms.double(50.)) ) ## fix a lower reasonable threshold give the jet response ## filter only hadronically decaying W/Z and Higgs at generator level if not hasattr(process, "genBosons"): setattr( process, "genBosons", cms.EDFilter( "CandPtrSelector", src=cms.InputTag("prunedGenParticles"), cut=cms.string( "(abs(pdgId) == 23 || abs(pdgId) == 24 || abs(pdgId) == 25) &&" + "numberOfDaughters > 1 && abs(daughter(0).pdgId) <= 5 && abs(daughter(1).pdgId) <= 5" ))) ## b-tag discriminators to be considered bTagDiscriminators = [ #'pfCombinedInclusiveSecondaryVertexV2BJetTags', ## don't run b-tagging on the whole large cone jet 'pfBoostedDoubleSecondaryVertexAK8BJetTags' ## new tag for Boosted double b-tagging ] ## jet energy corrections already loaded in JECLevels if pileupMethod != "chs" and pileupMethod != "Puppi" and pileupMethod != "": sys.exit( "Invalid pileupMethod setup --> only recognized options are 'chs' and 'Puppi'" ) ## JEC JECLevel = copy.deepcopy(process.JECLevels.labels) payloadName = "" payloadNameSubJet = "" jetCollection = "" pfCand = "" ## in case of CHS select particles and re-cluster jets if pileupMethod == "chs": ## obtain chs candidates if not hasattr(process, "chs"): setattr( process, 'chs', cms.EDFilter('CandPtrSelector', src=cms.InputTag("packedPFCandidates"), cut=cms.string('fromPV'))) ## cluster basic jets given rParameter and algorithm if not hasattr(process, jetAlgo + 'PFJets' + pileupMethod.upper()): setattr( process, jetAlgo + 'PFJets' + pileupMethod.upper(), ak4PFJetsCHS.clone(src=cms.InputTag('chs'), doAreaFastjet=True, rParam=coneSize, jetAlgorithm=ALGO)) payloadName = jetAlgo + 'PF' + pileupMethod payloadNameSubjet = 'AK4PF' + pileupMethod jetCollection = jetAlgo + 'PFJets' + pileupMethod.upper() pfCand = "chs" ## for puppi jets elif pileupMethod == "Puppi": ### re-run optimal puppi weights if not hasattr(process, "puppi"): from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppiesFromMiniAOD makePuppiesFromMiniAOD(process, False) process.puppi.useExistingWeights = cms.bool(False) process.puppiNoLep.useExistingWeights = cms.bool(False) ## cluster puppi jets given rParameter and algorithm if not hasattr(process, jetAlgo + 'PFJets' + pileupMethod): setattr( process, jetAlgo + 'PFJets' + pileupMethod, ak4PFJetsPuppi.clone(src=cms.InputTag('puppi'), doAreaFastjet=True, rParam=coneSize, jetAlgorithm=ALGO)) payloadName = jetAlgo + 'PF' + pileupMethod payloadNameSubjet = 'AK4PF' + pileupMethod jetCollection = jetAlgo + 'PFJets' + pileupMethod pfCand = "puppi" ## standard PF jets elif pileupMethod == "": ## no pileup mitigation if not hasattr(process, jetAlgo + 'PFJets'): setattr( process, jetAlgo + 'PFJets', ak4PFJetsPuppi.clone(src=cms.InputTag('packedPFCandidates'), doAreaFastjet=True, rParam=coneSize, jetAlgorithm=ALGO)) payloadName = jetAlgo + 'PF' payloadNameSubjet = 'AK4PF' jetCollection = jetAlgo + 'PFJets' pfCand = "packedPFCandidates" ## apply selection and produce a restricted set of consituents only for jets passig the selection if not hasattr(process, jetCollection + "Reduced"): setattr( process, jetCollection + "Reduced", cms.EDFilter("MiniAODJetConstituentSelector", src=cms.InputTag(jetCollection), cut=cms.string("pt > 100 && abs(eta) < 2.5"))) ## build pat-jets from this skimmed collection: example if not hasattr(process, "patJets" + jetCollection): addJetCollection( process, labelName=jetCollection, jetSource=cms.InputTag(jetCollection + "Reduced"), algo=algo, rParam=coneSize, pfCandidates=cms.InputTag(pfCand), jetCorrections=(payloadName, JECLevel, 'None'), svSource=cms.InputTag('slimmedSecondaryVertices'), genJetCollection=cms.InputTag("genJets" + jetAlgo), pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'), btagDiscriminators=bTagDiscriminators, getJetMCFlavour=isMC, genParticles=cms.InputTag("prunedGenParticles"), ) ### special jec set for pruned/sof-drop mass correction --> to be taken from the EDAnalyzer if hasattr(process, "patJetCorrFactors" + jetCollection): if isMC: setattr( process, "patJetCorrFactors" + jetCollection + "v2", getattr( process, "patJetCorrFactors" + jetCollection).clone( levels=cms.vstring('L2Relative', 'L3Absolute'))) else: setattr( process, "patJetCorrFactors" + jetCollection + "v2", getattr(process, "patJetCorrFactors" + jetCollection).clone(levels=cms.vstring( 'L2Relative', 'L3Absolute', 'L2L3Residual'))) getattr(process, "patJets" + jetCollection).jetCorrFactorsSource = cms.VInputTag( cms.InputTag("patJetCorrFactors" + jetCollection), cms.InputTag("patJetCorrFactors" + jetCollection + "v2")) if hasattr(process, "selectedPatJets" + jetCollection): getattr(process, "selectedPatJets" + jetCollection).cut = cms.string(selection) ## match reco-jets with hadronically decaying genBosons (W,Z,H) if isMC: if not hasattr(process, jetCollection + 'GenBosonMatched'): setattr( process, jetCollection + 'GenBosonMatched', cms.EDProducer( "RecoJetCandDeltaRValueMapProducer", ## basic reco::jet ungroomed src=cms.InputTag(jetCollection + "Reduced"), ## mathched groomed pat jet matched=cms.InputTag('genBosons'), distMax=cms.double(coneSize), values=cms.vstring("pt", "eta", "phi", "mass"), valueLabels=cms.vstring("pt", "eta", "phi", "mass"))) getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + 'GenBosonMatched:pt' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + 'GenBosonMatched:eta' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + 'GenBosonMatched:phi' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + 'GenBosonMatched:mass' ] ## add QGLikelihood on fat jet if addQGLikelihood: if not hasattr(process, jetCollection + "QGL"): setattr( process, jetCollection + "QGL", QGTagger.clone(srcJets=cms.InputTag(jetCollection + "Reduced"), jetsLabel=cms.string('QGL_AK4PFchs'), srcVertexCollection=cms.InputTag( 'offlineSlimmedPrimaryVertices'))) getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + 'QGL:qgLikelihood' ] ## addNsubjettiness if addNsubjettiness: if not hasattr(process, 'Njettiness' + jetCollection): setattr( process, 'Njettiness' + jetCollection, Njettiness.clone(src=cms.InputTag(jetCollection + "Reduced"), cone=cms.double(coneSize))) getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ 'Njettiness' + jetCollection + ':tau1', 'Njettiness' + jetCollection + ':tau2', 'Njettiness' + jetCollection + ':tau3', 'Njettiness' + jetCollection + ':tau4' ] ## on gen jets if isMC: if not hasattr(process, "NjettinessGenJets" + jetAlgo): setattr( process, "NjettinessGenJets" + jetAlgo, Njettiness.clone(src=cms.InputTag("genJets" + jetAlgo), cone=cms.double(coneSize))) ## pattify gen jets --> temp if not hasattr(process, 'patGenJets' + jetAlgo): setattr( process, 'patGenJets' + jetAlgo, patJets.clone( jetSource=cms.InputTag("genJets" + jetAlgo), addJetCorrFactors=cms.bool(False), addBTagInfo=cms.bool(False), addDiscriminators=cms.bool(False), discriminatorSources=cms.VInputTag('None'), addAssociatedTracks=cms.bool(False), addJetCharge=cms.bool(False), addGenPartonMatch=cms.bool(False), embedGenPartonMatch=cms.bool(False), addGenJetMatch=cms.bool(False), embedGenJetMatch=cms.bool(False), getJetMCFlavour=cms.bool(False), addJetFlavourInfo=cms.bool(False))) getattr(process, 'patGenJets' + jetAlgo).userData.userFloats.src += [ "NjettinessGenJets" + jetAlgo + ':tau1' ] getattr(process, 'patGenJets' + jetAlgo).userData.userFloats.src += [ "NjettinessGenJets" + jetAlgo + ':tau2' ] getattr(process, 'patGenJets' + jetAlgo).userData.userFloats.src += [ "NjettinessGenJets" + jetAlgo + ':tau3' ] getattr(process, 'patGenJets' + jetAlgo).userData.userFloats.src += [ "NjettinessGenJets" + jetAlgo + ':tau4' ] if not hasattr(process, jetCollection + 'GenNjettinessMatched'): setattr( process, jetCollection + 'GenNjettinessMatched', cms.EDProducer( "RecoPATJetDeltaRValueMapProducer", ## basic reco::jet ungroomed src=cms.InputTag(jetCollection + "Reduced"), ## mathched groomed pat jet matched=cms.InputTag('patGenJets' + jetAlgo), distMax=cms.double(coneSize), values=cms.vstring( "userFloat('NjettinessGenJets" + jetAlgo + ":tau1')", "userFloat('NjettinessGenJets" + jetAlgo + ":tau2')", "userFloat('NjettinessGenJets" + jetAlgo + ":tau3')", "userFloat('NjettinessGenJets" + jetAlgo + ":tau4')"), valueLabels=cms.vstring("tau1", "tau2", "tau3", "tau4"))) getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + 'GenNjettinessMatched:tau1', jetCollection + 'GenNjettinessMatched:tau2', jetCollection + 'GenNjettinessMatched:tau3', jetCollection + 'GenNjettinessMatched:tau4' ] ## add ECF if addEnergyCorrelation: if not hasattr(process, 'ecf' + jetCollection): setattr( process, 'ecf' + jetCollection, ECF.clone(src=cms.InputTag(jetCollection + "Reduced"), Njets=cms.vuint32(1, 2, 3))) getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ 'ecf' + jetCollection + ':ecf1' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ 'ecf' + jetCollection + ':ecf2' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ 'ecf' + jetCollection + ':ecf3' ] ## add QJets if addQJets: if not hasattr(process, "qjets" + jetCollection): setattr( process, "qjets" + jetCollection, QJetsAdder.clone(src=cms.InputTag(jetCollection + "Reduced"), jeRad=cms.double(coneSize), jetAlgo=cms.string(algo))) setattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ "qjets" + jetCollection + ":QjetsVolatility" ] ### start with substructure: Pruning (run it on both reco and gen jets): Tags = [] Labels = [] JECLevelTemp = copy.deepcopy(JECLevel) if 'L1FastJet' in JECLevelTemp: JECLevelTemp.remove( 'L1FastJet') ## in any case groomers are removing already pileup if addPruning: runGroomedMethod(process, isMC=isMC, jetCollection=jetCollection, coneSize=coneSize, algo=algo, payloadName=payloadName, payloadNameSubjet=payloadNameSubjet, JECLevel=JECLevelTemp, pfCand=pfCand, btagDiscriminators=bTagDiscriminators, addSubJets=addPrunedSubjets, addQGLikelihood=addQGLikelihood, isPruning=True, isSoftDrop=False, isTrimming=False, isFiltering=False) if addPrunedSubjets: Tags += ['patJets' + jetCollection + 'PrunedPacked'] Labels += ['Pruned'] if addSoftDrop: runGroomedMethod(process, isMC=isMC, jetCollection=jetCollection, coneSize=coneSize, algo=algo, payloadName=payloadName, payloadNameSubjet=payloadNameSubjet, JECLevel=JECLevelTemp, pfCand=pfCand, btagDiscriminators=bTagDiscriminators, addSubJets=addSoftDropSubjets, addQGLikelihood=addQGLikelihood, isPruning=False, isSoftDrop=True, isTrimming=False, isFiltering=False) if addSoftDropSubjets: Tags += ['patJets' + jetCollection + 'SoftDropPacked'] Labels += ['SoftDrop'] if addTrimming: runGroomedMethod(process, isMC=isMC, jetCollection=jetCollection, coneSize=coneSize, algo=algo, payloadName=payloadName, payloadNameSubjet=payloadNameSubjet, JECLevel=JECLevelTemp, pfCand=pfCand, btagDiscriminators=bTagDiscriminators, addSubJets=addTrimmedSubjets, addQGLikelihood=addQGLikelihood, isPruning=False, isSoftDrop=False, isTrimming=True, isFiltering=False) if addTrimmedSubjets: Tags += ['patJets' + jetCollection + 'TrimmedPacked'] Labels += ['Trimmed'] if addFiltering: runGroomedMethod(process, isMC=isMC, jetCollection=jetCollection, coneSize=coneSize, algo=algo, payloadName=payloadName, payloadNameSubjet=payloadNameSubjet, JECLevel=JECLevelTemp, pfCand=pfCand, btagDiscriminators=bTagDiscriminators, addSubJets=addFilteredSubjets, addQGLikelihood=addQGLikelihood, isPruning=False, isSoftDrop=False, isTrimming=False, isFiltering=True) if addFilteredSubjets: Tags += ['patJets' + jetCollection + 'FilteredPacked'] Labels += ['Filtered'] ## finally fix the pat fat jet collection if not hasattr(process, "packedPatJets" + jetCollection): setattr( process, "packedPatJets" + jetCollection, cms.EDProducer("JetSubstructurePacker", jetSrc=cms.InputTag("selectedPatJets" + jetCollection), distMax=cms.double(coneSize), fixDaughters=cms.bool(False), algoTags=cms.VInputTag(), algoLabels=cms.vstring())) getattr(process, "packedPatJets" + jetCollection).algoTags = Tags getattr(process, "packedPatJets" + jetCollection).algoLabels = Labels return "packedPatJets" + jetCollection
def runGroomedMethod(process, isMC, jetCollection, coneSize, algo, payloadName, payloadNameSubjet, JECLevel, pfCand, btagDiscriminators, addSubJets=True, addQGLikelihood=True, isPruning=True, isSoftDrop=True, isTrimming=True, isFiltering=True): ### name for cone size and algo coneSizeStr = str(coneSize).replace("0", "").replace(".", "") jetAlgo = algo + coneSizeStr if algo == "AK": ALGO = "AntiKt" elif algo == "CA": ALGO = "CambridgeAachen" btagSubjets = ['pfCombinedInclusiveSecondaryVertexV2BJetTags'] ### form the right postfix if not isPruning and not isSoftDrop and not isTrimming and not isFiltering: sys.exit("runGroomedMethod: all bools are false --> please check") if isPruning and not isSoftDrop and not isTrimming and not isFiltering: postfix = "Pruned" elif not isPruning and isSoftDrop and not isTrimming and not isFiltering: postfix = "SoftDrop" elif not isPruning and not isSoftDrop and isTrimming and not isFiltering: postfix = "Trimmed" elif not isPruning and not isSoftDrop and not isTrimming and isFiltering: postfix = "Filtered" else: sys.exit( "wrong setup, only one groomer is allowed each time --> please check" ) ## build default reco groomed jets if not hasattr(process, jetCollection + postfix): if isPruning: setattr(process, jetCollection + postfix, ak8PFJetsCHSPruned.clone()) elif isSoftDrop: setattr(process, jetCollection + postfix, ak8PFJetsCHSSoftDrop.clone()) elif isTrimming: setattr(process, jetCollection + postfix, ak8PFJetsCHSTrimmed.clone()) elif isFiltering: setattr(process, jetCollection + postfix, ak8PFJetsCHSFiltered.clone()) getattr(process, jetCollection + postfix).src = cms.InputTag( jetCollection + "Reduced", 'constituents') getattr(process, jetCollection + postfix).rParam = coneSize getattr(process, jetCollection + postfix).jetAlgorithm = ALGO ## write compounds means that subjets are stored as reco::Jet while the groomed jet is stored as base::Jet getattr(process, jetCollection + postfix).writeCompound = cms.bool(True) getattr(process, jetCollection + postfix).doAreaFastjet = cms.bool(True) ## gen groomed jets if isMC: if not hasattr(process, "genJets" + jetAlgo + postfix): ## store AK8 gen::Jet setattr( process, "genJets" + jetAlgo + postfix, getattr(process, jetCollection + postfix).clone( src=cms.InputTag('genParticlesForJetsNoNu'), writeCompound=cms.bool(False), useExplicitGhosts=cms.bool(True), jetPtMin=cms.double(50.), jetType=cms.string('GenJet'), jetCollInstanceName=cms.string(""))) ## pruned pat jets with embeded gen-jet info if not hasattr(process, "patJets" + jetCollection + postfix): addJetCollection( process, labelName=jetCollection + postfix, jetSource=cms.InputTag(jetCollection + postfix), algo=algo, pfCandidates=cms.InputTag(pfCand), rParam=coneSize, jetCorrections=(payloadName, JECLevel, 'None'), svSource=cms.InputTag('slimmedSecondaryVertices'), genJetCollection=cms.InputTag("genJets" + jetAlgo + postfix), pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'), btagDiscriminators= btagDiscriminators, ## no b-tag info for pruned jets getJetMCFlavour= isMC, ## no flavor info genParticles=cms.InputTag("prunedGenParticles")) ## matched fat jet with groomed one adding info as user float if not hasattr(process, jetCollection + postfix + 'Matched'): setattr( process, jetCollection + postfix + 'Matched', cms.EDProducer( "RecoPATJetDeltaRValueMapProducer", ## basic reco::jet ungroomed src=cms.InputTag(jetCollection + "Reduced"), ## mathched groomed pat jet matched=cms.InputTag('patJets' + jetCollection + postfix), distMax=cms.double(coneSize), values=cms.vstring( "mass", "pt", "eta", "phi", "bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')", "bDiscriminator('pfBoostedDoubleSecondaryVertexAK8BJetTags')", "correctedP4(0).mass()", "correctedP4(0).pt()", "correctedP4(0).eta()", "correctedP4(0).phi()"), valueLabels=cms.vstring( "mass", "pt", "eta", "phi", "pfCombinedInclusiveSecondaryVertexV2BJetTags", "pfBoostedDoubleSecondaryVertexAK8BJetTags", "rawmass", "rawpt", "raweta", "rawphi"))) if isMC: getattr(process, jetCollection + postfix + 'Matched').valueLabels += [ "hadronFlavour", "partonFlavour", "genMass", "genPt", "genEta", "genPhi" ] getattr(process, jetCollection + postfix + 'Matched').values += [ "hadronFlavour", "partonFlavour", "genJet().mass", "genJet().pt", "genJet().eta", "genJet().phi" ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'Matched:mass' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'Matched:pt' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'Matched:pfCombinedInclusiveSecondaryVertexV2BJetTags' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'Matched:pfBoostedDoubleSecondaryVertexAK8BJetTags' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'Matched:eta' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'Matched:phi' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'Matched:rawmass' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'Matched:rawpt' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'Matched:raweta' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'Matched:rawphi' ] if isMC: getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'Matched:hadronFlavour' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'Matched:partonFlavour' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'Matched:genMass' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'Matched:genPt' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'Matched:genEta' ] getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'Matched:genPhi' ] ## add QGL --> some tricks are needed if addQGLikelihood: ## redo groomed jet with a special postfix (ForQGL) if not hasattr(process, jetCollection + postfix + "ForQGL"): setattr( process, jetCollection + postfix + "ForQGL", getattr(process, jetCollection + postfix).clone( writeCompound=cms.bool(False), jetCollInstanceName=cms.string(""))) ## run QGL evaluator if not hasattr(process, jetCollection + postfix + "QGL"): setattr( process, jetCollection + postfix + "QGL", QGTagger.clone(srcJets=cms.InputTag(jetCollection + postfix + "ForQGL"), jetsLabel=cms.string('QGL_AK4PFchs'), srcVertexCollection=cms.InputTag( 'offlineSlimmedPrimaryVertices'))) ## pattify jets on the fly if not hasattr(process, 'patJets' + jetCollection + postfix + "QGL"): setattr( process, 'patJets' + jetCollection + postfix + "QGL", patJets.clone(jetSource=cms.InputTag(jetCollection + postfix + "ForQGL"), addJetCorrFactors=cms.bool(False), addBTagInfo=cms.bool(False), addDiscriminators=cms.bool(False), discriminatorSources=cms.VInputTag('None'), addAssociatedTracks=cms.bool(False), addJetCharge=cms.bool(False), addGenPartonMatch=cms.bool(False), embedGenPartonMatch=cms.bool(False), addGenJetMatch=cms.bool(False), embedGenJetMatch=cms.bool(False), getJetMCFlavour=cms.bool(False), addJetFlavourInfo=cms.bool(False))) getattr(process, 'patJets' + jetCollection + postfix + "QGL").userData.userFloats.src += [ jetCollection + postfix + "QGL:qgLikelihood" ] ## match QGL value with the original jet if not hasattr(process, jetCollection + postfix + "QGLMatched"): setattr( process, jetCollection + postfix + 'QGLMatched', cms.EDProducer( "RecoPATJetDeltaRValueMapProducer", src=cms.InputTag(jetCollection + "Reduced"), matched=cms.InputTag('patJets' + jetCollection + postfix + "QGL"), distMax=cms.double(coneSize), values=cms.vstring("userFloat('" + jetCollection + postfix + "QGL:qgLikelihood')"), valueLabels=cms.vstring("qgLikelihood"))) getattr(process, 'patJets' + jetCollection).userData.userFloats.src += [ jetCollection + postfix + 'QGLMatched:qgLikelihood' ] ## add subjet information if addSubJets: ## gen groomed sub-jets --> star with default clustering if isMC and not hasattr(process, "genJets" + jetAlgo + postfix + "SubJets"): setattr( process, "genJets" + jetAlgo + postfix + "SubJets", getattr(process, "genJets" + jetAlgo + postfix).clone( writeCompound=cms.bool(True), jetCollInstanceName=cms.string('SubJets'))) if not hasattr(process, "patJets" + jetCollection + postfix + "SubJets"): addJetCollection( process, labelName=jetCollection + postfix + 'SubJets', jetSource=cms.InputTag(jetCollection + postfix, 'SubJets'), algo=algo, # needed for subjet b tagging rParam=coneSize, # needed for subjet b tagging pfCandidates=cms.InputTag(pfCand), jetCorrections=(payloadNameSubjet, JECLevel, 'None'), pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'), svSource=cms.InputTag('slimmedSecondaryVertices'), getJetMCFlavour=isMC, genParticles=cms.InputTag("prunedGenParticles"), btagDiscriminators=btagSubjets, genJetCollection=cms.InputTag( "genJets" + jetAlgo + postfix + "SubJets", "SubJets"), explicitJTA=True, # needed for subjet b tagging svClustering=True, # needed for subjet b tagging fatJets=cms.InputTag( jetCollection + "Reduced"), # needed for subjet flavor clustering groomedFatJets=cms.InputTag( jetCollection + postfix), # needed for subjet flavor clustering ) ## adding sub-jet QGL if addQGLikelihood: if not hasattr(process, jetCollection + postfix + "SubJetsQGL"): setattr( process, jetCollection + postfix + "SubJetsQGL", QGTagger.clone(srcJets=cms.InputTag( jetCollection + postfix, "SubJets"), jetsLabel=cms.string('QGL_AK4PFchs'), srcVertexCollection=cms.InputTag( 'offlineSlimmedPrimaryVertices'))) getattr(process, 'patJets' + jetCollection + postfix + "SubJets").userData.userFloats.src += [ jetCollection + postfix + 'SubJetsQGL:qgLikelihood' ] ## Establish references between PATified fat jets and subjets using the BoostedJetMerger if not hasattr(process, 'patJets' + jetCollection + postfix + 'Packed'): setattr( process, 'patJets' + jetCollection + postfix + 'Packed', cms.EDProducer( "BoostedJetMerger", jetSrc=cms.InputTag('selectedPatJets' + jetCollection + postfix), subjetSrc=cms.InputTag("selectedPatJets" + jetCollection + postfix + "SubJets")))
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
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
#pat genjet match patPFJetGenJetMatch = cms.EDFilter("GenJetMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR src = cms.InputTag("ak5PFJets"), # RECO jets (any View<Jet> is ok) matched = cms.InputTag("ak5GenJets"), # GEN jets (must be GenJetCollection) mcPdgId = cms.vint32(), # n/a mcStatus = cms.vint32(), # n/a checkCharge = cms.bool(False), # n/a maxDeltaR = cms.double(0.4), # Minimum deltaR for the match maxDPtRel = cms.double(3.0), # Minimum deltaPt/Pt for the match resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object resolveByMatchQuality = cms.bool(False) # False = just match input in order; True = pick lowest deltaR pair first ) from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets allLayer1PFJets = patJets.clone() allLayer1PFJets.jetSource = cms.InputTag('ak5PFJets') allLayer1PFJets.jetCorrFactorsSource = cms.VInputTag(cms.InputTag('patPFJetCorrFactors') ) allLayer1PFJets.addGenPartonMatch = cms.bool(False) allLayer1PFJets.genJetMatch = cms.InputTag("patPFJetGenJetMatch") allLayer1PFJets.getJetMCFlavour = cms.bool(False) allLayer1PFJets.addAssociatedTracks = cms.bool(False) allLayer1PFJets.addBTagInfo = cms.bool(False) allLayer1PFJets.addDiscriminators = cms.bool(False) allLayer1PFJets.addJetID = cms.bool(False) allLayer1PFJets.addJetCharge = cms.bool(False) allLayer1PFJets.embedGenPartonMatch = cms.bool(False) allLayer1PFJetsSequence = cms.Sequence(patPFJetCorrFactors*patPFJetGenJetMatch*allLayer1PFJets)
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
ak8GenJetsPrunedLinks = cms.EDProducer("RecoJetDeltaRValueMapProducer", src = cms.InputTag("ak8GenJets"), matched = cms.InputTag("ak8GenJetsPruned"), distMax = cms.double(0.8), value = cms.string('mass') ) from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets as patJets goodJets = patJets.clone( jetSource = "ak8GenJets", embedCaloTowers = cms.bool(False), embedPFCandidates = cms.bool(False), addJetCorrFactors = cms.bool(False), addBTagInfo = cms.bool(False), addDiscriminators = cms.bool(False), addAssociatedTracks = cms.bool(False), addJetCharge = cms.bool(False), addJetID = cms.bool(False), addGenPartonMatch = cms.bool(False), addGenJetMatch = cms.bool(False), getJetMCFlavour = cms.bool(False) ) goodJets.userData.userFloats.src = cms.VInputTag("ak8GenJetsPrunedLinks",) ## Cleaning # We want to make sure that the jets are not the electrons or muons done previously import PhysicsTools.PatAlgos.cleaningLayer1.jetCleaner_cfi as jetCleaner_cfi cleanJets = jetCleaner_cfi.cleanPatJets.clone() cleanJets.src = "goodJets"
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
selectedPatJets = patJets.clone(jetSource = inputGenJetCollection, embedCaloTowers = False, embedPFCandidates = False, addJetCorrFactors = True, jetCorrFactorsSource = cms.VInputTag(cms.InputTag("myPatJetCorrFactors") ), addBTagInfo = True, addDiscriminators = True, discriminatorSources = cms.VInputTag(cms.InputTag("combinedSecondaryVertexBJetTags"), cms.InputTag("combinedSecondaryVertexMVABJetTags"), cms.InputTag("jetBProbabilityBJetTags"), cms.InputTag("jetProbabilityBJetTags"), cms.InputTag("simpleSecondaryVertexHighEffBJetTags"), cms.InputTag("simpleSecondaryVertexHighPurBJetTags"), #cms.InputTag("softElectronByPtBJetTags"), #cms.InputTag("softElectronByIP3dBJetTags"), #cms.InputTag("softMuonBJetTags"), #cms.InputTag("softMuonByPtBJetTags"), #cms.InputTag("softMuonByIP3dBJetTags"), cms.InputTag("trackCountingHighEffBJetTags"), cms.InputTag("trackCountingHighPurBJetTags"), ), addTagInfos = False, addAssociatedTracks = False, addJetCharge = False, addJetID = False, addGenPartonMatch = False, embedGenPartonMatch = False, addGenJetMatch = False, embedGenJetMatch = False, addPartonJetMatch = False, getJetMCFlavour = False, addEfficiencies = False, addResolutions = False )