Skip to content

Commit

Permalink
Merge pull request cms-sw#114 from arizzi/VHISRJET
Browse files Browse the repository at this point in the history
adding code to find ISR jet in VH events
  • Loading branch information
arizzi committed Jul 17, 2015
2 parents 97aff8d + b49e71f commit d02436f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
21 changes: 16 additions & 5 deletions VHbbAnalysis/Heppy/python/VHbbAnalyzer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from PhysicsTools.Heppy.analyzers.core.Analyzer import Analyzer
from PhysicsTools.Heppy.analyzers.core.AutoHandle import AutoHandle
from PhysicsTools.HeppyCore.utils.deltar import deltaR
from PhysicsTools.HeppyCore.utils.deltar import deltaR,deltaPhi
from copy import deepcopy
from math import *
import itertools
Expand Down Expand Up @@ -72,10 +72,13 @@ def doSoftActivityVH(self,event) :
j1=event.hJetsCSV[0]
j2=event.hJetsCSV[1]
#print "VH"
event.softActivityVHJets=self.softActivity(event,j1,j2,event.hJetsCSV+event.selectedElectrons+event.selectedMuons)
excludedJets=event.hJetsCSV+event.selectedElectrons+event.selectedMuons
if event.isrJetVH >= 0 :
excludedJets+=[event.cleanJetsAll[event.isrJetVH]]
event.softActivityVHJets=self.softActivity(event,j1,j2,excludedJets,-1000)


def softActivity(self,event,j1,j2,excludedJets) :
def softActivity(self,event,j1,j2,excludedJets,dR0=0.4) :
if not hasattr(event,"pfCands") :
event.pfCands = list(self.handles['pfCands'].product())

Expand All @@ -88,15 +91,21 @@ def softActivity(self,event,j1,j2,excludedJets) :
#get the pointed objects
used = [x.get() for x in used]
remainingPF = [x for x in event.pfCands if x.charge() != 0 and abs(x.eta()) < 2.5 and x.pt() > 0.3 and x.fromPV() >=2 and x not in used]
dR0=0.4
dRbb = deltaR(j1.eta(),j1.phi(),j2.eta(),j2.phi())
map(lambda x:inputs.push_back(x.p4()), remainingPF)
softActivity=ROOT.heppy.FastSoftActivity(inputs,-1,0.4,j1.p4(),j2.p4(),dRbb+2*dR0)
jets=softActivity.getGrouping(1)
softActivityJets = [ ROOT.reco.Particle.LorentzVector(p4) for p4 in jets ]
softActivityJets.sort(key=lambda x:x.pt(), reverse=True)
return softActivityJets

def searchISRforVH(self,event):
p4VH=event.HCSV+event.V
if p4VH.pt() > 30 :
phi=pi+p4VH.phi()
matchedJets=[(x,deltaPhi(phi,x.phi())) for x in event.cleanJetsAll if deltaPhi(phi,x.phi()) < 0.4 and x.puJetId() > 0 and x.jetID('POG_PFID_Loose') and x not in event.hJetsCSV ]
if len(matchedJets) > 0 :
event.isrJetVH=event.cleanJetsAll.index(sorted(matchedJets, key=lambda x:x[1])[0][0])

def makeJets(self,event,b):
inputs=ROOT.std.vector(ROOT.heppy.ReclusterJets.LorentzVector)()
event.pfCands = list(self.handles['pfCands'].product())
Expand Down Expand Up @@ -318,6 +327,7 @@ def initOutputs (self,event) :
event.ajidx3cj = []
event.aLeptons = []
event.vLeptons = []
event.isrJetVH=-1
event.H = ROOT.reco.Particle.LorentzVector(0.,0.,0.,0.)
event.HCSV = ROOT.reco.Particle.LorentzVector(0.,0.,0.,0.)
event.H3cj = ROOT.reco.Particle.LorentzVector(0.,0.,0.,0.)
Expand Down Expand Up @@ -357,6 +367,7 @@ def process(self, event):
map(lambda x :x.qgl(),event.jetsForHiggs[:4])
self.doHiggsHighCSV(event)
self.doHiggsHighPt(event)
self.searchISRforVH(event)
self.doHiggs3cj(event)
self.fillTauIndices(event)
if getattr(self.cfg_ana,"doVBF", True) :
Expand Down
1 change: 1 addition & 0 deletions VHbbAnalysis/Heppy/test/vhbb.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
NTupleVariable("metNoPU_pt", lambda ev : ev.metNoPU.pt(), help="PFnoPU E_{T}^{miss}"),
NTupleVariable("tkMet_pt", lambda ev : ev.tkMet.pt(), help="E_{T}^{miss} from tracks"),
NTupleVariable("tkMetPVchs_pt", lambda ev : ev.tkMetPVchs.pt(), help="E_{T}^{miss} from tracks"),
NTupleVariable("isrJetVH", lambda ev : ev.isrJetVH, help="Index of ISR jet in VH"),
],
globalObjects = {
"met" : NTupleObject("met", metType, help="PF E_{T}^{miss}, after default type 1 corrections"),
Expand Down

0 comments on commit d02436f

Please sign in to comment.