Skip to content

Commit

Permalink
Merge pull request cms-sw#126 from arizzi/overlapjetIndex
Browse files Browse the repository at this point in the history
Overlapjet index
  • Loading branch information
arizzi committed Jul 22, 2015
2 parents 5057d7c + 36f025e commit f6c77a9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
8 changes: 1 addition & 7 deletions PhysicsTools/Heppy/python/analyzers/objects/JetAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,10 @@ def process(self, event):
leps_with_overlaps = []
for i in range(jet.numberOfSourceCandidatePtrs()):
p1 = jet.sourceCandidatePtr(i) #Ptr<Candidate> p1
if not p1.isAvailable():
continue
for lep in leptons:
for j in range(lep.numberOfSourceCandidatePtrs()):
p2 = lep.sourceCandidatePtr(j)
if not p2.isAvailable():
continue
#for some reason, this does not work.
#has_overlaps = p1.refCore() == p2.refCore() and p1.key() == p2.key()
has_overlaps = p1.p4() == p2.p4() and p1.charge() == p2.charge()
has_overlaps = p1.key() == p2.key() and p1.refCore().id().productIndex() == p2.refCore().id().productIndex() and p1.refCore().id().processIndex() == p2.refCore().id().processIndex()
if has_overlaps:
leps_with_overlaps += [lep]
if len(leps_with_overlaps)>0:
Expand Down
2 changes: 2 additions & 0 deletions VHbbAnalysis/Heppy/python/VHbbAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ def process(self, event):
csvSortedJets=sorted(event.cleanJetsAll, key = lambda jet : jet.btag(getattr(self.cfg_ana,"btagDiscriminator",'pfCombinedInclusiveSecondaryVertexV2BJetTags')),reverse=True)
for j in event.cleanJetsAll:
j.btagIdx=csvSortedJets.index(j)
for j in event.discardedJets:
j.btagIdx=-1

# event.jee = list(self.handles['jee'].product())
#for j in list(jets)[0:3]:
Expand Down
3 changes: 2 additions & 1 deletion VHbbAnalysis/Heppy/python/vhbbobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
NTupleVariable("pixelLayers", lambda x : (x.track() if abs(x.pdgId())==13 else x.gsfTrack()).hitPattern().pixelLayersWithMeasurement(), int, help="Pixel Layers"),
# TTH-id related variables
NTupleVariable("mvaTTH", lambda lepton : lepton.mvaValue if hasattr(lepton,'mvaValue') else -1, help="Lepton MVA (ttH version)"),
NTupleVariable("jetOverlapIdx", lambda lepton : getattr(lepton, "jetOverlapIdx", -1), int, help="index of jet with overlapping PF constituents. If idx>=1000, then idx = idx-1000 and refers to discarded jets."),
NTupleVariable("jetPtRatio", lambda lepton : lepton.pt()/lepton.jet.pt() if hasattr(lepton,'jet') else -1, help="pt(lepton)/pt(nearest jet)"),
NTupleVariable("jetBTagCSV", lambda lepton : lepton.jet.btag('pfCombinedInclusiveSecondaryVertexV2BJetTags') if hasattr(lepton,'jet') and hasattr(lepton.jet, 'btag') else -99, help="btag of nearest jet"),
NTupleVariable("jetDR", lambda lepton : deltaR(lepton.eta(),lepton.phi(),lepton.jet.eta(),lepton.jet.phi()) if hasattr(lepton,'jet') else -1, help="deltaR(lepton, nearest jet)"),
Expand Down Expand Up @@ -70,7 +71,7 @@
##------------------------------------------

jetTypeVHbb = NTupleObjectType("jet", baseObjectTypes = [ jetType ], variables = [
NTupleVariable("idxFirstTauMatch", lambda x : x.tauIdxs[0] if len(x.tauIdxs) > 0 else -1, int,help='index of the first matching tau'),
NTupleVariable("idxFirstTauMatch", lambda x : x.tauIdxs[0] if len(getattr(x, "tauIdxs", [])) > 0 else -1, int,help='index of the first matching tau'),
NTupleVariable("hadronFlavour", lambda x : x.mcFlavour, int, mcOnly=True, help="match to heavy hadrons"),
NTupleVariable("btagBDT", lambda x : getattr(x,"btagBDT",-99), help="btag"),
NTupleVariable("btagProb", lambda x : x.btag('jetProbabilityBJetTags') , help="btag"),
Expand Down
2 changes: 2 additions & 0 deletions VHbbAnalysis/Heppy/test/vhbb.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@
"ajidxaddJetsdR08" : NTupleCollection("ajidxaddJetsdR08", objectInt, 8,help="additional jet indices with Higgs formed adding cen jets if dR<0.8 from hJetsCSV"),
"dRaddJetsdR08" : NTupleCollection("dRaddJetsdR08", objectFloat, 5,help="dR of add jet with Higgs formed adding cen jets if dR<0.8 from hJetsCSV"),
"cleanJetsAll" : NTupleCollection("Jet", jetTypeVHbb, 15, help="Cental+fwd jets after full selection and cleaning, sorted by b-tag"),
"discardedJets" : NTupleCollection("DiscardedJet", jetTypeVHbb, 15, help="jets that were discarded"),
"inclusiveTaus" : NTupleCollection("TauGood", tauTypeVHbb, 25, help="Taus after the preselection"),
"softActivityJets" : NTupleCollection("softActivityJets", fourVectorType, 5, help="jets made for soft activity"),
"softActivityVHJets" : NTupleCollection("softActivityVHJets", fourVectorType, 5, help="jets made for soft activity VH version"),
"goodVertices" : NTupleCollection("primaryVertices", primaryVertexType, 4, help="first four PVs"),

#dump of gen objects
"generatorSummary" : NTupleCollection("GenSummary", genParticleWithLinksType, 30, help="Generator summary, see description in Heppy GeneratorAnalyzer",mcOnly=True),
#"genJets" : NTupleCollection("GenJet", genParticleType, 15, help="Generated jets with hadron matching, sorted by pt descending",filter=lambda x: x.pt() > 20,mcOnly=True),
"gentopquarks" : NTupleCollection("GenTop", genParticleType, 4, help="Generated top quarks from hard scattering"),
"gennusFromTop" : NTupleCollection("GenNuFromTop", genParticleType, 4, help="Generated neutrino from t->W decay"),
"genbquarksFromH" : NTupleCollection("GenBQuarkFromH", genParticleType, 4, help="Generated bottom quarks from Higgs decays"),
Expand Down

0 comments on commit f6c77a9

Please sign in to comment.