From 22b8fc0cbf9dc2c8ce94896917f83860eee6af42 Mon Sep 17 00:00:00 2001 From: DryRun Date: Tue, 2 Mar 2021 21:14:24 -0600 Subject: [PATCH 1/3] Reconfigure interface for saving PF cands to add more jet collections --- python/addBTV.py | 5 +- python/addPFCands_cff.py | 155 +++++++++++++++++++++++++-------------- python/pfnano_cff.py | 36 ++++----- 3 files changed, 120 insertions(+), 76 deletions(-) diff --git a/python/addBTV.py b/python/addBTV.py index 1fd6678..8321ec9 100644 --- a/python/addBTV.py +++ b/python/addBTV.py @@ -216,10 +216,7 @@ def get_DeepCSV_vars(): ) return DeepCSVVars -def add_BTV(process, runOnMC=False, onlyAK4=False, onlyAK8=False, keepInputs=True): - addAK4 = not onlyAK8 - addAK8 = not onlyAK4 - +def add_BTV(process, runOnMC=False, addAK4=True, addAK8=True, addAK15=False, keepInputs=True): if addAK4: process = update_jets_AK4(process) if addAK8: diff --git a/python/addPFCands_cff.py b/python/addPFCands_cff.py index 1f1a90c..de3364e 100644 --- a/python/addPFCands_cff.py +++ b/python/addPFCands_cff.py @@ -1,41 +1,55 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.NanoAOD.common_cff import * -def addPFCands(process, runOnMC=False, allPF = False, onlyAK4=False, onlyAK8=False): +def addPFCands(process, runOnMC=False, saveAll=False, saveAK4=False, saveAK8=False, saveAK15=False): + if saveAll and (saveAK4 or saveAK8 or saveAK15): + raise ValueError("In call to addPFCands(), argument saveAll is incompatible with other save options (saveAll={}, saveAK4={} ,saveAK8={}, saveAK15={}".format(saveAll, saveAK4, saveAK8, saveAK15)) + + if not (saveAll or saveAK4 or saveAK8 or saveAK15): + raise ValueError("In call to addPFCands(), specify at least one save option.") + process.customizedPFCandsTask = cms.Task( ) process.schedule.associate(process.customizedPFCandsTask) - process.finalJetsAK8Constituents = cms.EDProducer("PatJetConstituentPtrSelector", - src = cms.InputTag("finalJetsAK8"), - cut = cms.string("") - ) - process.finalJetsAK4Constituents = cms.EDProducer("PatJetConstituentPtrSelector", - src = cms.InputTag("finalJets"), - cut = cms.string("") - ) - if allPF: + if saveAll: candInput = cms.InputTag("packedPFCandidates") - elif onlyAK4: - candList = cms.VInputTag(cms.InputTag("finalJetsAK4Constituents", "constituents")) - process.customizedPFCandsTask.add(process.finalJetsAK4Constituents) - process.finalJetsConstituents = cms.EDProducer("PackedCandidatePtrMerger", src = candList, skipNulls = cms.bool(True), warnOnSkip = cms.bool(True)) - candInput = cms.InputTag("finalJetsConstituents") - elif onlyAK8: - candList = cms.VInputTag(cms.InputTag("finalJetsAK8Constituents", "constituents")) - process.customizedPFCandsTask.add(process.finalJetsAK8Constituents) - process.finalJetsConstituents = cms.EDProducer("PackedCandidatePtrMerger", src = candList, skipNulls = cms.bool(True), warnOnSkip = cms.bool(True)) - candInput = cms.InputTag("finalJetsConstituents") else: - candList = cms.VInputTag(cms.InputTag("finalJetsAK4Constituents", "constituents"), cms.InputTag("finalJetsAK8Constituents", "constituents")) - process.customizedPFCandsTask.add(process.finalJetsAK4Constituents) - process.customizedPFCandsTask.add(process.finalJetsAK8Constituents) - process.finalJetsConstituents = cms.EDProducer("PackedCandidatePtrMerger", src = candList, skipNulls = cms.bool(True), warnOnSkip = cms.bool(True)) + candList = cms.VInputTag() + if saveAK4: + process.finalJetsAK4Constituents = cms.EDProducer("PatJetConstituentPtrSelector", + src = cms.InputTag("finalJets"), + cut = cms.string("") + ) + candList.append(cms.InputTag("finalJetsAK4Constituents", "constituents")) + process.customizedPFCandsTask.add(process.finalJetsAK4Constituents) + + if saveAK8: + process.finalJetsAK8Constituents = cms.EDProducer("PatJetConstituentPtrSelector", + src = cms.InputTag("finalJetsAK8"), + cut = cms.string("") + ) + candList.append(cms.InputTag("finalJetsAK8Constituents", "constituents")) + process.customizedPFCandsTask.add(process.finalJetsAK8Constituents) + ''' + if saveAK15: + process.finalJetsAK15Constituents = cms.EDProducer("PatJetConstituentPtrSelector", + src = cms.InputTag("finalJetsAK15"), + cut = cms.string("") + ) + candList.append(cms.InputTag("finalJetsAK15Constituents", "constituents")) + process.customizedPFCandsTask.add(process.finalJetsAK15Constituents) + ''' + process.finalJetsConstituents = cms.EDProducer("PackedCandidatePtrMerger", + src = candList, + skipNulls = cms.bool(True), + warnOnSkip = cms.bool(True)) candInput = cms.InputTag("finalJetsConstituents") + process.customConstituentsExtTable = cms.EDProducer("SimpleCandidateFlatTableProducer", src = candInput, cut = cms.string(""), #we should not filter after pruning name = cms.string("PFCands"), - doc = cms.string("interesting particles from AK4 and AK8 jets"), + doc = cms.string("interesting particles from various jet collections"), singleton = cms.bool(False), # the number of entries is variable extension = cms.bool(False), # this is the extension table for the AK8 constituents variables = cms.PSet(CandVars, @@ -52,15 +66,7 @@ def addPFCands(process, runOnMC=False, allPF = False, onlyAK4=False, onlyAK8=Fal trkQuality = Var("?hasTrackDetails()?pseudoTrack().qualityMask():0", int, doc="track quality mask"), ) ) - process.customAK8ConstituentsTable = cms.EDProducer("PatJetConstituentTableProducer", - candidates = candInput, - jets = cms.InputTag("finalJetsAK8"), - jet_radius = cms.double(0.8), - name = cms.string("FatJetPFCands"), - idx_name = cms.string("pFCandsIdx"), - nameSV = cms.string("FatJetSVs"), - idx_nameSV = cms.string("sVIdx"), - ) + process.customAK4ConstituentsTable = cms.EDProducer("PatJetConstituentTableProducer", #candidates = cms.InputTag("packedPFCandidates"), candidates = candInput, @@ -71,47 +77,75 @@ def addPFCands(process, runOnMC=False, allPF = False, onlyAK4=False, onlyAK8=Fal nameSV = cms.string("JetSVs"), idx_nameSV = cms.string("sVIdx"), ) - if not allPF: + process.customAK8ConstituentsTable = cms.EDProducer("PatJetConstituentTableProducer", + candidates = candInput, + jets = cms.InputTag("finalJetsAK8"), + jet_radius = cms.double(0.8), + name = cms.string("FatJetPFCands"), + idx_name = cms.string("pFCandsIdx"), + nameSV = cms.string("FatJetSVs"), + idx_nameSV = cms.string("sVIdx"), + ) + ''' + process.customAK15ConstituentsTable = cms.EDProducer("PatJetConstituentTableProducer", + candidates = candInput, + jets = cms.InputTag("finalJetsAK15"), + jet_radius = cms.double(1.5), + name = cms.string("JetPFCandsAK15"), + nameSV = cms.string("JetSVsAK15")) + ''' + + if not saveAll: process.customizedPFCandsTask.add(process.finalJetsConstituents) + process.customizedPFCandsTask.add(process.customConstituentsExtTable) - process.customizedPFCandsTask.add(process.customAK8ConstituentsTable) process.customizedPFCandsTask.add(process.customAK4ConstituentsTable) + process.customizedPFCandsTask.add(process.customAK8ConstituentsTable) + #process.customizedPFCandsTask.add(process.customAK15ConstituentsTable) if runOnMC: - process.genJetsAK8Constituents = cms.EDProducer("GenJetPackedConstituentPtrSelector", src = cms.InputTag("slimmedGenJetsAK8"), cut = cms.string("pt > 100.") ) - process.genJetsAK4Constituents = process.genJetsAK8Constituents.clone( src = cms.InputTag("slimmedGenJets"), cut = cms.string("pt > 20") ) - if allPF: + ''' + process.genJetsAK15Constituents = process.genJetsAK8Constituents.clone( + src = cms.InputTag("AK15GenJetsNoNu"), # "slimmedGenJetsAK15" + cut = cms.string("pt > 100") + ) + ''' + + if saveAll: genCandInput = cms.InputTag("packedGenParticles") - elif onlyAK4: - genCandList = cms.VInputTag(cms.InputTag("genJetsAK4Constituents", "constituents")) - genCandInput = cms.InputTag("genJetsConstituents") - process.genJetsConstituents = cms.EDProducer("PackedGenParticlePtrMerger", src = genCandList, skipNulls = cms.bool(True), warnOnSkip = cms.bool(True)) - elif onlyAK8: - genCandList = cms.VInputTag(cms.InputTag("genJetsAK8Constituents", "constituents")) - genCandInput = cms.InputTag("genJetsConstituents") - process.genJetsConstituents = cms.EDProducer("PackedGenParticlePtrMerger", src = genCandList, skipNulls = cms.bool(True), warnOnSkip = cms.bool(True)) else: - genCandList = cms.VInputTag(cms.InputTag("genJetsAK4Constituents", "constituents"), cms.InputTag("genJetsAK8Constituents", "constituents")) genCandInput = cms.InputTag("genJetsConstituents") - process.genJetsConstituents = cms.EDProducer("PackedGenParticlePtrMerger", src = genCandList, skipNulls = cms.bool(True), warnOnSkip = cms.bool(True)) + genCandList = cms.VInputTag() + if saveAK4: + genCandList.append(cms.InputTag("genJetsAK4Constituents", "constituents")) + if saveAK8: + genCandList.append(cms.InputTag("genJetsAK8Constituents", "constituents")) + ''' + if saveAK15: + genCandList.append(cms.InputTag("genJetsAK15Constituents", "constituents")) + ''' + process.genJetsConstituents = cms.EDProducer("PackedGenParticlePtrMerger", + src = genCandList, + skipNulls = cms.bool(True), + warnOnSkip = cms.bool(True)) + process.genJetsParticleTable = cms.EDProducer("SimpleCandidateFlatTableProducer", src = genCandInput, cut = cms.string(""), #we should not filter after pruning name= cms.string("GenCands"), - doc = cms.string("interesting gen particles from AK4 and AK8 jets"), + doc = cms.string("interesting gen particles from various jet collections"), singleton = cms.bool(False), # the number of entries is variable extension = cms.bool(False), # this is the main table for the AK8 constituents - variables = cms.PSet(CandVars - ) + variables = cms.PSet(CandVars) ) process.genAK8ConstituentsTable = cms.EDProducer("GenJetConstituentTableProducer", candidates = genCandInput, @@ -129,12 +163,25 @@ def addPFCands(process, runOnMC=False, allPF = False, onlyAK4=False, onlyAK8=Fal idx_name = cms.string("pFCandsIdx"), idx_nameSV = cms.string("sVIdx"), readBtag = cms.bool(False)) + ''' + process.genAK15ConstituentsTable = cms.EDProducer("GenJetConstituentTableProducer", + candidates = cms.InputTag("genJetsConstituents"), + jets = cms.InputTag("genJetsAK15Constituents"), # Note: The name has "Constituents" in it, but these are the jets + name = cms.string("GenJetCandsAK15"), + nameSV = cms.string("GenJetSVsAK15"), + idx_name = cms.string("pFCandsIdx"), + idx_nameSV = cms.string("sVIdx"), + readBtag = cms.bool(False)) + ''' process.customizedPFCandsTask.add(process.genJetsAK4Constituents) #Note: For gen need to add jets to the process to keep pt cuts. process.customizedPFCandsTask.add(process.genJetsAK8Constituents) - if not allPF: + #process.customizedPFCandsTask.add(process.genJetsAK15Constituents) + if not saveAll: process.customizedPFCandsTask.add(process.genJetsConstituents) + process.customizedPFCandsTask.add(process.genJetsParticleTable) process.customizedPFCandsTask.add(process.genAK8ConstituentsTable) process.customizedPFCandsTask.add(process.genAK4ConstituentsTable) - + #process.customizedPFCandsTask.add(process.genAK15ConstituentsTable) + return process diff --git a/python/pfnano_cff.py b/python/pfnano_cff.py index 96178ed..8e87404 100644 --- a/python/pfnano_cff.py +++ b/python/pfnano_cff.py @@ -5,61 +5,61 @@ def PFnano_customizeMC(process): - addPFCands(process, True) - add_BTV(process, True) + addPFCands(process, runOnMC=True, saveAK4=True, saveAK8=True) + add_BTV(process, runOnMC=True) process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_allPF(process): - addPFCands(process, True, True) - add_BTV(process, True) + addPFCands(process, runOnMC=True, saveAll=True) + add_BTV(process, runOnMC=True) process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_AK4JetsOnly(process): - addPFCands(process, True, False, True) - add_BTV(process, True, True) + addPFCands(process, runOnMC=True, saveAK4=True) + add_BTV(process, runOnMC=True, addAK4=True, addAK8=False) process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_AK8JetsOnly(process): - addPFCands(process, True, False, False, True) - add_BTV(process, True, False, True) + addPFCands(process, runOnMC=True, saveAK8=True) + add_BTV(process, runOnMC=True, addAK4=False, addAK8=True) process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeMC_noInputs(process): - add_BTV(process, True, keepInputs=False) + add_BTV(process, runOnMC=True, keepInputs=False) process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process #### DATA customization def PFnano_customizeData(process): - addPFCands(process, False) - add_BTV(process, False) + addPFCands(process, runOnMC=False, saveAK4=True, saveAK8=True) + add_BTV(process, runOnMC=False) process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_allPF(process): - addPFCands(process, False, True) - add_BTV(process, False) + addPFCands(process, runOnMC=False, saveAll=True) + add_BTV(process, runOnMC=False) process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_AK4JetsOnly(process): - addPFCands(process, False, False, True) - add_BTV(process, False, True) + addPFCands(process, runOnMC=False, saveAK4=True) + add_BTV(process, runOnMC=False, addAK4=True, addAK8=False) process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_AK8JetsOnly(process): - addPFCands(process, False, False, False, True) - add_BTV(process, False, False, True) + addPFCands(process, runOnMC=False, saveAK4=True) + add_BTV(process, runOnMC=False, addAK4=False, addAK8=True) process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process def PFnano_customizeData_noInputs(process): - add_BTV(process, False, keepInputs=False) + add_BTV(process, runOnMC=False, keepInputs=False) process.NANOAODSIMoutput.fakeNameForCrab = cms.untracked.bool(True) # needed for crab publication return process From 12bb2b1a89ccf005cd7f18b12ae6b684a1501e6a Mon Sep 17 00:00:00 2001 From: David Yu Date: Fri, 12 Mar 2021 08:12:55 -0600 Subject: [PATCH 2/3] Remove AK15 template code --- python/addPFCands_cff.py | 48 ++++------------------------------------ 1 file changed, 4 insertions(+), 44 deletions(-) diff --git a/python/addPFCands_cff.py b/python/addPFCands_cff.py index de3364e..b48b5b2 100644 --- a/python/addPFCands_cff.py +++ b/python/addPFCands_cff.py @@ -1,11 +1,11 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.NanoAOD.common_cff import * -def addPFCands(process, runOnMC=False, saveAll=False, saveAK4=False, saveAK8=False, saveAK15=False): - if saveAll and (saveAK4 or saveAK8 or saveAK15): - raise ValueError("In call to addPFCands(), argument saveAll is incompatible with other save options (saveAll={}, saveAK4={} ,saveAK8={}, saveAK15={}".format(saveAll, saveAK4, saveAK8, saveAK15)) +def addPFCands(process, runOnMC=False, saveAll=False, saveAK4=False, saveAK8=False): + if saveAll and (saveAK4 or saveAK8): + raise ValueError("In call to addPFCands(), argument saveAll is incompatible with other save options (saveAll={}, saveAK4={} ,saveAK8={}".format(saveAll, saveAK4, saveAK8)) - if not (saveAll or saveAK4 or saveAK8 or saveAK15): + if not (saveAll or saveAK4 or saveAK8): raise ValueError("In call to addPFCands(), specify at least one save option.") process.customizedPFCandsTask = cms.Task( ) @@ -30,15 +30,6 @@ def addPFCands(process, runOnMC=False, saveAll=False, saveAK4=False, saveAK8=Fal ) candList.append(cms.InputTag("finalJetsAK8Constituents", "constituents")) process.customizedPFCandsTask.add(process.finalJetsAK8Constituents) - ''' - if saveAK15: - process.finalJetsAK15Constituents = cms.EDProducer("PatJetConstituentPtrSelector", - src = cms.InputTag("finalJetsAK15"), - cut = cms.string("") - ) - candList.append(cms.InputTag("finalJetsAK15Constituents", "constituents")) - process.customizedPFCandsTask.add(process.finalJetsAK15Constituents) - ''' process.finalJetsConstituents = cms.EDProducer("PackedCandidatePtrMerger", src = candList, skipNulls = cms.bool(True), @@ -86,14 +77,6 @@ def addPFCands(process, runOnMC=False, saveAll=False, saveAK4=False, saveAK8=Fal nameSV = cms.string("FatJetSVs"), idx_nameSV = cms.string("sVIdx"), ) - ''' - process.customAK15ConstituentsTable = cms.EDProducer("PatJetConstituentTableProducer", - candidates = candInput, - jets = cms.InputTag("finalJetsAK15"), - jet_radius = cms.double(1.5), - name = cms.string("JetPFCandsAK15"), - nameSV = cms.string("JetSVsAK15")) - ''' if not saveAll: process.customizedPFCandsTask.add(process.finalJetsConstituents) @@ -101,7 +84,6 @@ def addPFCands(process, runOnMC=False, saveAll=False, saveAK4=False, saveAK8=Fal process.customizedPFCandsTask.add(process.customConstituentsExtTable) process.customizedPFCandsTask.add(process.customAK4ConstituentsTable) process.customizedPFCandsTask.add(process.customAK8ConstituentsTable) - #process.customizedPFCandsTask.add(process.customAK15ConstituentsTable) if runOnMC: process.genJetsAK8Constituents = cms.EDProducer("GenJetPackedConstituentPtrSelector", @@ -113,12 +95,6 @@ def addPFCands(process, runOnMC=False, saveAll=False, saveAK4=False, saveAK8=Fal src = cms.InputTag("slimmedGenJets"), cut = cms.string("pt > 20") ) - ''' - process.genJetsAK15Constituents = process.genJetsAK8Constituents.clone( - src = cms.InputTag("AK15GenJetsNoNu"), # "slimmedGenJetsAK15" - cut = cms.string("pt > 100") - ) - ''' if saveAll: genCandInput = cms.InputTag("packedGenParticles") @@ -129,10 +105,6 @@ def addPFCands(process, runOnMC=False, saveAll=False, saveAK4=False, saveAK8=Fal genCandList.append(cms.InputTag("genJetsAK4Constituents", "constituents")) if saveAK8: genCandList.append(cms.InputTag("genJetsAK8Constituents", "constituents")) - ''' - if saveAK15: - genCandList.append(cms.InputTag("genJetsAK15Constituents", "constituents")) - ''' process.genJetsConstituents = cms.EDProducer("PackedGenParticlePtrMerger", src = genCandList, skipNulls = cms.bool(True), @@ -163,25 +135,13 @@ def addPFCands(process, runOnMC=False, saveAll=False, saveAK4=False, saveAK8=Fal idx_name = cms.string("pFCandsIdx"), idx_nameSV = cms.string("sVIdx"), readBtag = cms.bool(False)) - ''' - process.genAK15ConstituentsTable = cms.EDProducer("GenJetConstituentTableProducer", - candidates = cms.InputTag("genJetsConstituents"), - jets = cms.InputTag("genJetsAK15Constituents"), # Note: The name has "Constituents" in it, but these are the jets - name = cms.string("GenJetCandsAK15"), - nameSV = cms.string("GenJetSVsAK15"), - idx_name = cms.string("pFCandsIdx"), - idx_nameSV = cms.string("sVIdx"), - readBtag = cms.bool(False)) - ''' process.customizedPFCandsTask.add(process.genJetsAK4Constituents) #Note: For gen need to add jets to the process to keep pt cuts. process.customizedPFCandsTask.add(process.genJetsAK8Constituents) - #process.customizedPFCandsTask.add(process.genJetsAK15Constituents) if not saveAll: process.customizedPFCandsTask.add(process.genJetsConstituents) process.customizedPFCandsTask.add(process.genJetsParticleTable) process.customizedPFCandsTask.add(process.genAK8ConstituentsTable) process.customizedPFCandsTask.add(process.genAK4ConstituentsTable) - #process.customizedPFCandsTask.add(process.genAK15ConstituentsTable) return process From 9629b6714672523207225a85239536b02b7b925e Mon Sep 17 00:00:00 2001 From: David Date: Wed, 7 Jul 2021 22:34:27 -0500 Subject: [PATCH 3/3] Add AK15 --- python/addPFCands_cff.py | 166 +++++++++++++++++++++++++-------------- 1 file changed, 109 insertions(+), 57 deletions(-) diff --git a/python/addPFCands_cff.py b/python/addPFCands_cff.py index b48b5b2..67989a5 100644 --- a/python/addPFCands_cff.py +++ b/python/addPFCands_cff.py @@ -1,14 +1,14 @@ import FWCore.ParameterSet.Config as cms from PhysicsTools.NanoAOD.common_cff import * -def addPFCands(process, runOnMC=False, saveAll=False, saveAK4=False, saveAK8=False): - if saveAll and (saveAK4 or saveAK8): - raise ValueError("In call to addPFCands(), argument saveAll is incompatible with other save options (saveAll={}, saveAK4={} ,saveAK8={}".format(saveAll, saveAK4, saveAK8)) +def addPFCands(process, runOnMC=False, saveAll=False, saveAK4=False, saveAK8=False, saveAK15=False): + if saveAll and (saveAK4 or saveAK8 or saveAK15): + raise ValueError("In call to addPFCands(), argument saveAll is incompatible with other save options (saveAll={}, saveAK4={} ,saveAK8={}, saveAK15={}".format(saveAll, saveAK4, saveAK8, saveAK15)) - if not (saveAll or saveAK4 or saveAK8): + if not (saveAll or saveAK4 or saveAK8 or saveAK15): raise ValueError("In call to addPFCands(), specify at least one save option.") - process.customizedPFCandsTask = cms.Task( ) + process.customizedPFCandsTask = cms.Task() process.schedule.associate(process.customizedPFCandsTask) if saveAll: @@ -30,12 +30,21 @@ def addPFCands(process, runOnMC=False, saveAll=False, saveAK4=False, saveAK8=Fal ) candList.append(cms.InputTag("finalJetsAK8Constituents", "constituents")) process.customizedPFCandsTask.add(process.finalJetsAK8Constituents) + + if saveAK15: + process.finalJetsAK15Constituents = cms.EDProducer("PatJetConstituentPtrSelector", + src = cms.InputTag("finalJetsAK15"), + cut = cms.string("") + ) + candList.append(cms.InputTag("finalJetsAK15Constituents", "constituents")) + process.customizedPFCandsTask.add(process.finalJetsAK15Constituents) process.finalJetsConstituents = cms.EDProducer("PackedCandidatePtrMerger", src = candList, skipNulls = cms.bool(True), warnOnSkip = cms.bool(True)) candInput = cms.InputTag("finalJetsConstituents") + # Make constituent table producers process.customConstituentsExtTable = cms.EDProducer("SimpleCandidateFlatTableProducer", src = candInput, cut = cms.string(""), #we should not filter after pruning @@ -58,43 +67,63 @@ def addPFCands(process, runOnMC=False, saveAll=False, saveAK4=False, saveAK8=Fal ) ) - process.customAK4ConstituentsTable = cms.EDProducer("PatJetConstituentTableProducer", - #candidates = cms.InputTag("packedPFCandidates"), - candidates = candInput, - jets = cms.InputTag("finalJets"), - jet_radius = cms.double(0.4), - name = cms.string("JetPFCands"), - idx_name = cms.string("pFCandsIdx"), - nameSV = cms.string("JetSVs"), - idx_nameSV = cms.string("sVIdx"), - ) - process.customAK8ConstituentsTable = cms.EDProducer("PatJetConstituentTableProducer", - candidates = candInput, - jets = cms.InputTag("finalJetsAK8"), - jet_radius = cms.double(0.8), - name = cms.string("FatJetPFCands"), - idx_name = cms.string("pFCandsIdx"), - nameSV = cms.string("FatJetSVs"), - idx_nameSV = cms.string("sVIdx"), - ) + if saveAK4 or saveAll: + process.customAK4ConstituentsTable = cms.EDProducer("PatJetConstituentTableProducer", + #candidates = cms.InputTag("packedPFCandidates"), + candidates = candInput, + jets = cms.InputTag("finalJets"), + jet_radius = cms.double(0.4), + name = cms.string("JetPFCands"), + idx_name = cms.string("pFCandsIdx"), + nameSV = cms.string("JetSVs"), + idx_nameSV = cms.string("sVIdx"), + ) + if saveAK8 or saveAll: + process.customAK8ConstituentsTable = cms.EDProducer("PatJetConstituentTableProducer", + candidates = candInput, + jets = cms.InputTag("finalJetsAK8"), + jet_radius = cms.double(0.8), + name = cms.string("FatJetPFCands"), + idx_name = cms.string("pFCandsIdx"), + nameSV = cms.string("FatJetSVs"), + idx_nameSV = cms.string("sVIdx"), + ) + + if saveAK15 or saveAll: + process.customAK15ConstituentsTable = cms.EDProducer("PatJetConstituentTableProducer", + candidates = candInput, + jets = cms.InputTag("finalJetsAK15"), + jet_radius = cms.double(1.5), + name = cms.string("JetPFCandsAK15"), + nameSV = cms.string("JetSVsAK15")) + # Add constituents tables to customizedPFCandsTask if not saveAll: process.customizedPFCandsTask.add(process.finalJetsConstituents) - process.customizedPFCandsTask.add(process.customConstituentsExtTable) - process.customizedPFCandsTask.add(process.customAK4ConstituentsTable) - process.customizedPFCandsTask.add(process.customAK8ConstituentsTable) - - if runOnMC: - process.genJetsAK8Constituents = cms.EDProducer("GenJetPackedConstituentPtrSelector", - src = cms.InputTag("slimmedGenJetsAK8"), - cut = cms.string("pt > 100.") - ) + if saveAK4 or saveAll: + process.customizedPFCandsTask.add(process.customAK4ConstituentsTable) + if saveAK8 or saveAll: + process.customizedPFCandsTask.add(process.customAK8ConstituentsTable) + if saveAK15 or saveAll: + process.customizedPFCandsTask.add(process.customAK15ConstituentsTable) - process.genJetsAK4Constituents = process.genJetsAK8Constituents.clone( - src = cms.InputTag("slimmedGenJets"), - cut = cms.string("pt > 20") - ) + if runOnMC: + if saveAK4 or saveAll: + process.genJetsAK4Constituents = cms.EDProducer("GenJetPackedConstituentPtrSelector", + src = cms.InputTag("slimmedGenJets"), + cut = cms.string("pt > 20") + ) + if saveAK8 or saveAll: + process.genJetsAK8Constituents = cms.EDProducer("GenJetPackedConstituentPtrSelector", + src = cms.InputTag("slimmedGenJetsAK8"), + cut = cms.string("pt > 100.") + ) + if saveAK15 or saveAll: + process.genJetsAK15Constituents = cms.EDProducer("GenJetPackedConstituentPtrSelector", + src = cms.InputTag("AK15GenJetsNoNu"), # "slimmedGenJetsAK15" + cut = cms.string("pt > 100") + ) if saveAll: genCandInput = cms.InputTag("packedGenParticles") @@ -105,6 +134,9 @@ def addPFCands(process, runOnMC=False, saveAll=False, saveAK4=False, saveAK8=Fal genCandList.append(cms.InputTag("genJetsAK4Constituents", "constituents")) if saveAK8: genCandList.append(cms.InputTag("genJetsAK8Constituents", "constituents")) + if saveAK15: + genCandList.append(cms.InputTag("genJetsAK15Constituents", "constituents")) + process.genJetsConstituents = cms.EDProducer("PackedGenParticlePtrMerger", src = genCandList, skipNulls = cms.bool(True), @@ -119,29 +151,49 @@ def addPFCands(process, runOnMC=False, saveAll=False, saveAK4=False, saveAK8=Fal extension = cms.bool(False), # this is the main table for the AK8 constituents variables = cms.PSet(CandVars) ) - process.genAK8ConstituentsTable = cms.EDProducer("GenJetConstituentTableProducer", - candidates = genCandInput, - jets = cms.InputTag("genJetsAK8Constituents"), # Note: The name has "Constituents" in it, but these are the jets - name = cms.string("GenFatJetCands"), - nameSV = cms.string("GenFatJetSVs"), - idx_name = cms.string("pFCandsIdx"), - idx_nameSV = cms.string("sVIdx"), - readBtag = cms.bool(False)) - process.genAK4ConstituentsTable = cms.EDProducer("GenJetConstituentTableProducer", - candidates = genCandInput, - jets = cms.InputTag("genJetsAK4Constituents"), # Note: The name has "Constituents" in it, but these are the jets - name = cms.string("GenJetCands"), - nameSV = cms.string("GenJetSVs"), - idx_name = cms.string("pFCandsIdx"), - idx_nameSV = cms.string("sVIdx"), - readBtag = cms.bool(False)) - process.customizedPFCandsTask.add(process.genJetsAK4Constituents) #Note: For gen need to add jets to the process to keep pt cuts. - process.customizedPFCandsTask.add(process.genJetsAK8Constituents) + if saveAK8 or saveAll: + process.genAK8ConstituentsTable = cms.EDProducer("GenJetConstituentTableProducer", + candidates = genCandInput, + jets = cms.InputTag("genJetsAK8Constituents"), # Note: The name has "Constituents" in it, but these are the jets + name = cms.string("GenFatJetCands"), + nameSV = cms.string("GenFatJetSVs"), + idx_name = cms.string("pFCandsIdx"), + idx_nameSV = cms.string("sVIdx"), + readBtag = cms.bool(False)) + if saveAK4 or saveAll: + process.genAK4ConstituentsTable = cms.EDProducer("GenJetConstituentTableProducer", + candidates = genCandInput, + jets = cms.InputTag("genJetsAK4Constituents"), # Note: The name has "Constituents" in it, but these are the jets + name = cms.string("GenJetCands"), + nameSV = cms.string("GenJetSVs"), + idx_name = cms.string("pFCandsIdx"), + idx_nameSV = cms.string("sVIdx"), + readBtag = cms.bool(False)) + if saveAK15 or saveAll: + process.genAK15ConstituentsTable = cms.EDProducer("GenJetConstituentTableProducer", + candidates = cms.InputTag("genJetsConstituents"), + jets = cms.InputTag("genJetsAK15Constituents"), # Note: The name has "Constituents" in it, but these are the jets + name = cms.string("GenJetCandsAK15"), + nameSV = cms.string("GenJetSVsAK15"), + idx_name = cms.string("pFCandsIdx"), + idx_nameSV = cms.string("sVIdx"), + readBtag = cms.bool(False)) + + if saveAK4 or saveAll: + process.customizedPFCandsTask.add(process.genJetsAK4Constituents) #Note: For gen need to add jets to the process to keep pt cuts. + if saveAK8 or saveAll: + process.customizedPFCandsTask.add(process.genJetsAK8Constituents) + if saveAK15 or saveAll: + process.customizedPFCandsTask.add(process.genJetsAK15Constituents) if not saveAll: process.customizedPFCandsTask.add(process.genJetsConstituents) process.customizedPFCandsTask.add(process.genJetsParticleTable) - process.customizedPFCandsTask.add(process.genAK8ConstituentsTable) - process.customizedPFCandsTask.add(process.genAK4ConstituentsTable) + if saveAK8 or saveAll: + process.customizedPFCandsTask.add(process.genAK8ConstituentsTable) + if saveAK4 or saveAll: + process.customizedPFCandsTask.add(process.genAK4ConstituentsTable) + if saveAK15 or saveAll: + process.customizedPFCandsTask.add(process.genAK15ConstituentsTable) return process