Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge in Heppy branch after PR #208 (jet pt sorting) #215

Merged
merged 4 commits into from
Jan 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def process(self, event):
"trkPOG_manystripclus53X" : [ "Flag_trkPOG_manystripclus53X" ],
"trkPOG_toomanystripclus53X" : [ "Flag_trkPOG_toomanystripclus53X" ],
"trkPOG_logErrorTooManyClusters" : [ "Flag_trkPOG_logErrorTooManyClusters" ],
"METFilters" : [ "Flag_METFilters" ],
}
)
)
7 changes: 5 additions & 2 deletions PhysicsTools/Heppy/python/analyzers/objects/JetAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ def process(self, event):
self.matchJets(event, allJets)
if getattr(self.cfg_ana, 'smearJets', False):
self.smearJets(event, allJets)

## Apply jet selection

##Sort Jets by pT
allJets.sort(key = lambda j : j.pt(), reverse = True)

## Apply jet selection
event.jets = []
event.jetsFailId = []
event.jetsAllNoID = []
Expand Down
9 changes: 5 additions & 4 deletions PhysicsTools/Heppy/python/analyzers/objects/METAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ def makeMETNoMu(self, event):
mupy += mu.py()

#subtract muon momentum and construct met
if hasattr(event, 'deltaMetFromJetSmearing'):
if self.cfg_ana.recalibrate and hasattr(event, 'deltaMetFromJetSmearing'):
import ROOT
px,py = event.metNoMu.px()+event.deltaMetFromJetSmearing[0]-mupx, event.metNoMu.py()+event.deltaMetFromJetSmearing[1]-mupy
event.metNoMu.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
px,py = event.metNoMuNoPU.px()+event.deltaMetFromJetSmearing[0]-mupx, event.metNoMuNoPU.py()+event.deltaMetFromJetSmearing[1]-mupy
event.metNoMuNoPU.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, hypot(px,py)))
if hasattr(event, 'deltaMetFromJEC') and event.deltaMetFromJEC[0] != 0 and event.deltaMetFromJEC[1] != 0:
if self.cfg_ana.recalibrate and hasattr(event, 'deltaMetFromJEC') and event.deltaMetFromJEC[0] != 0 and event.deltaMetFromJEC[1] != 0:
import ROOT
px,py = event.metNoMu.px()+event.deltaMetFromJEC[0]-mupx, event.metNoMu.py()+event.deltaMetFromJEC[1]-mupy
event.met.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
Expand All @@ -85,13 +85,13 @@ def makeMETNoMu(self, event):
def makeMETs(self, event):
event.met = self.handles['met'].product()[0]
event.metNoPU = self.handles['nopumet'].product()[0]
if hasattr(event, 'deltaMetFromJetSmearing'):
if self.cfg_ana.recalibrate and hasattr(event, 'deltaMetFromJetSmearing'):
import ROOT
px,py = event.met.px()+event.deltaMetFromJetSmearing[0], event.met.py()+event.deltaMetFromJetSmearing[1]
event.met.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
px,py = event.metNoPU.px()+event.deltaMetFromJetSmearing[0], event.metNoPU.py()+event.deltaMetFromJetSmearing[1]
event.metNoPU.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
if hasattr(event, 'deltaMetFromJEC') and event.deltaMetFromJEC[0] != 0 and event.deltaMetFromJEC[1] != 0:
if self.cfg_ana.recalibrate and hasattr(event, 'deltaMetFromJEC') and event.deltaMetFromJEC[0] != 0 and event.deltaMetFromJEC[1] != 0:
import ROOT
px,py = event.met.px()+event.deltaMetFromJEC[0], event.met.py()+event.deltaMetFromJEC[1]
event.met.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
Expand All @@ -117,6 +117,7 @@ def process(self, event):

setattr(METAnalyzer,"defaultConfig", cfg.Analyzer(
class_object = METAnalyzer,
recalibrate = True,
doTkMet = False,
doMetNoMu = False,
candidates='packedPFCandidates',
Expand Down
11 changes: 6 additions & 5 deletions PhysicsTools/Heppy/python/physicsobjects/Jet.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ def jetID(self,name=""):
if not self.isPFJet():
raise RuntimeError, "jetID implemented only for PF Jets"
eta = abs(self.eta());
chf = self.chargedHadronEnergyFraction();
nhf = self.neutralHadronEnergyFraction();
phf = self.neutralEmEnergyFraction();
muf = self.muonEnergyFraction();
elf = self.chargedEmEnergyFraction();
energy = (self.p4()*self.rawFactor()).energy();
chf = self.chargedHadronEnergy()/energy;
nhf = self.neutralHadronEnergy()/energy;
phf = self.neutralEmEnergy()/energy;
muf = self.muonEnergy()/energy;
elf = self.chargedEmEnergy()/energy;
chm = self.chargedHadronMultiplicity();
npr = self.chargedMultiplicity() + self.neutralMultiplicity();
#if npr != self.nConstituents():
Expand Down
8 changes: 4 additions & 4 deletions PhysicsTools/Heppy/python/physicsobjects/Photon.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ class Photon(PhysicsObject ):
'''
def hOVERe(self):
# return self.physObj.full5x5_hadTowOverEm()
hadTowDepth1O = self.physObj.hadTowDepth1OverEm() * (self.physObj.superCluster().energy()/self.physObj.full5x5_e5x5() if self.physObj.full5x5_e5x5() else 1)
hadTowDepth2O = self.physObj.hadTowDepth2OverEm() * (self.physObj.superCluster().energy()/self.physObj.full5x5_e5x5() if self.physObj.full5x5_e5x5() else 1)
hadTowDepth1O = self.physObj.hadTowDepth1OverEm() * (self.physObj.superCluster().energy()/self.physObj.e5x5() if self.physObj.e5x5() else 1)
hadTowDepth2O = self.physObj.hadTowDepth2OverEm() * (self.physObj.superCluster().energy()/self.physObj.e5x5() if self.physObj.e5x5() else 1)
return hadTowDepth1O + hadTowDepth2O

def r9(self):
return self.physObj.full5x5_r9()
return self.physObj.r9()

def sigmaIetaIeta(self):
return self.physObj.full5x5_sigmaIetaIeta()
return self.physObj.sigmaIetaIeta()

def chargedHadronIso(self):
return self.physObj.chargedHadronIso()
Expand Down