Skip to content

Commit

Permalink
Add AK4 and AK8 candidates without overlap.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenhay committed Apr 23, 2020
1 parent 0f582f4 commit bd39660
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 46 deletions.
4 changes: 4 additions & 0 deletions BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
<use name="DataFormats/Common"/>
<use name="DataFormats/StdDictionaries"/>
<use name="DataFormats/Candidate"/>
<use name="DataFormats/PatCandidates"/>
<use name="CommonTools/Utils"/>
<use name="CommonTools/UtilAlgos"/>
<use name="CommonTools/CandAlgos"/>
<use name="DataFormats/NanoAOD"/>
<use name="boost"/>
<export>
Expand Down
3 changes: 2 additions & 1 deletion plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
<use name="DataFormats/VertexReco"/>
<use name="DataFormats/NanoAOD"/>
<use name="CommonTools/Utils"/>
<use name="CommonTools/UtilAlgos"/>
<use name="CommonTools/CandAlgos"/>
<use name="RecoBTag/FeatureTools"/>
<use name="RecoJets/JetAlgorithms"/>
<use name="PhysicsTools/Pancakes"/>
<use name="TrackingTools/Records"/>
<use name="roottmva"/>
<use name="fastjet"/>
Expand Down
101 changes: 56 additions & 45 deletions python/addPFCands_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,34 @@ def addPFCands(process, runOnMC=False, onlyAK4=False, onlyAK8=False):
process.customizedPFCandsTask = cms.Task( )
process.schedule.associate(process.customizedPFCandsTask)

process.customAK8ConstituentsTable = cms.EDProducer("JetConstituentTableProducer",
src = cms.InputTag("finalJetsAK8"),
cut = cms.string("pt()>170"),
name = cms.string("FatJetPFCands"))

process.customAK8ConstituentsExtTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
src = cms.InputTag("customAK8ConstituentsTable"),
cut = cms.string(""), #we should not filter after pruning
name = cms.string("FatJetPFCands"),
doc = cms.string("interesting particles from AK8 jets"),
singleton = cms.bool(False), # the number of entries is variable
extension = cms.bool(True), # this is the extension table for the AK8 constituents
variables = cms.PSet(CandVars,
process.finalJetsAK8Constituents = cms.EDProducer("PatJetConstituentPtrSelector",
src = cms.InputTag("finalJetsAK8"),
cut = cms.string("pt > 170.0")
)
process.finalJetsAK4Constituents = cms.EDProducer("PatJetConstituentPtrSelector",
src = cms.InputTag("finalJets"),
cut = cms.string("pt > 30.0")
)
if onlyAK4:
candList = cms.VInputTag(cms.InputTag("finalJetsAK4Constituents", "constituents"))
process.customizedPFCandsTask.add(process.finalJetsAK4Constituents)
elif onlyAK8:
candList = cms.VInputTag(cms.InputTag("finalJetsAK8Constituents", "constituents"))
process.customizedPFCandsTask.add(process.finalJetsAK8Constituents)
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)
process.customConstituentsExtTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
src = cms.InputTag("finalJetsConstituents"),
cut = cms.string(""), #we should not filter after pruning
name = cms.string("JetPFCands"),
doc = cms.string("interesting particles from AK4 and AK8 jets"),
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,
puppiWeight = Var("puppiWeight()", float, doc="Puppi weight",precision=10),
puppiWeightNoLep = Var("puppiWeightNoLep()", float, doc="Puppi weight removing leptons",precision=10),
vtxChi2 = Var("?hasTrackDetails()?vertexChi2():-1", float, doc="vertex chi2",precision=10),
Expand All @@ -31,16 +46,9 @@ def addPFCands(process, runOnMC=False, onlyAK4=False, onlyAK8=False):
trkQuality = Var("?hasTrackDetails()?pseudoTrack().qualityMask():0", int, doc="track quality mask"),
)
)

process.customAK4ConstituentsTable = process.customAK8ConstituentsTable.clone( src = 'finalJets', cut = 'pt()>20', name = 'JetPFCands' )
process.customAK4ConstituentsExtTable = process.customAK8ConstituentsExtTable.clone( src = 'customAK4ConstituentsTable', name = 'JetPFCands', doc = 'interesting particles from AK4 jets' )

if not onlyAK4:
process.customizedPFCandsTask.add(process.customAK8ConstituentsTable)
process.customizedPFCandsTask.add(process.customAK8ConstituentsExtTable)
if not onlyAK8:
process.customizedPFCandsTask.add(process.customAK4ConstituentsTable)
process.customizedPFCandsTask.add(process.customAK4ConstituentsExtTable)

process.customizedPFCandsTask.add(process.finalJetsConstituents)
process.customizedPFCandsTask.add(process.customConstituentsExtTable)

if runOnMC:

Expand All @@ -49,32 +57,35 @@ def addPFCands(process, runOnMC=False, onlyAK4=False, onlyAK8=False):
cut = cms.string("pt > 100.0")
)

process.genJetsAK8ParticleTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
src = cms.InputTag("genJetsAK8Constituents", "constituents"),
cut = cms.string(""), #we should not filter after pruning
name= cms.string("GenJetAK8Cands"),
doc = cms.string("interesting gen particles from AK8 jets"),
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
)
)


process.genJetsAK4Constituents = process.genJetsAK8Constituents.clone(
src = cms.InputTag("slimmedGenJets"),
cut = cms.string("pt > 20.0")
)
process.genJetsAK4ParticleTable = process.genJetsAK8ParticleTable.clone(
src = cms.InputTag("genJetsAK4Constituents", "constituents"),
name= cms.string("GenJetCands"),
doc = cms.string("interesting gen particles from AK4 jets"),
)

if not onlyAK8:
if onlyAK4:
genCandList = cms.VInputTag(cms.InputTag("genJetsAK4Constituents", "constituents"))
process.customizedPFCandsTask.add(process.genJetsAK4Constituents)
process.customizedPFCandsTask.add(process.genJetsAK4ParticleTable)
if not onlyAK4:
elif onlyAK8:
genCandList = cms.VInputTag(cms.InputTag("genJetsAK8Constituents", "constituents"))
process.customizedPFCandsTask.add(process.genJetsAK8Constituents)
process.customizedPFCandsTask.add(process.genJetsAK8ParticleTable)

else:
genCandList = cms.VInputTag(cms.InputTag("genJetsAK4Constituents", "constituents"), cms.InputTag("genJetsAK8Constituents", "constituents"))
process.customizedPFCandsTask.add(process.genJetsAK4Constituents)
process.customizedPFCandsTask.add(process.genJetsAK8Constituents)
process.genJetsConstituents = cms.EDProducer("PackedGenParticlePtrMerger",
src = genCandList
)
process.genJetsParticleTable = cms.EDProducer("SimpleCandidateFlatTableProducer",
src = cms.InputTag("genJetsConstituents"),
cut = cms.string(""), #we should not filter after pruning
name= cms.string("GenJetCands"),
doc = cms.string("interesting gen particles from AK4 and AK8 jets"),
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
)
)
process.customizedPFCandsTask.add(process.genJetsConstituents)
process.customizedPFCandsTask.add(process.genJetsParticleTable)

return process

0 comments on commit bd39660

Please sign in to comment.