diff --git a/PhysicsTools/Heppy/python/analyzers/core/TriggerBitAnalyzer.py b/PhysicsTools/Heppy/python/analyzers/core/TriggerBitAnalyzer.py index f878f0fb618..33778f990ce 100644 --- a/PhysicsTools/Heppy/python/analyzers/core/TriggerBitAnalyzer.py +++ b/PhysicsTools/Heppy/python/analyzers/core/TriggerBitAnalyzer.py @@ -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" ], } ) ) diff --git a/PhysicsTools/Heppy/python/analyzers/objects/JetAnalyzer.py b/PhysicsTools/Heppy/python/analyzers/objects/JetAnalyzer.py index 9c93d3b6d0c..15548395eb5 100644 --- a/PhysicsTools/Heppy/python/analyzers/objects/JetAnalyzer.py +++ b/PhysicsTools/Heppy/python/analyzers/objects/JetAnalyzer.py @@ -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 = [] diff --git a/PhysicsTools/Heppy/python/analyzers/objects/METAnalyzer.py b/PhysicsTools/Heppy/python/analyzers/objects/METAnalyzer.py index 795e363649c..6a8282efde3 100644 --- a/PhysicsTools/Heppy/python/analyzers/objects/METAnalyzer.py +++ b/PhysicsTools/Heppy/python/analyzers/objects/METAnalyzer.py @@ -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))) @@ -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))) @@ -117,6 +117,7 @@ def process(self, event): setattr(METAnalyzer,"defaultConfig", cfg.Analyzer( class_object = METAnalyzer, + recalibrate = True, doTkMet = False, doMetNoMu = False, candidates='packedPFCandidates', diff --git a/PhysicsTools/Heppy/python/physicsobjects/Jet.py b/PhysicsTools/Heppy/python/physicsobjects/Jet.py index f80b2925ee5..bbde50d07ff 100644 --- a/PhysicsTools/Heppy/python/physicsobjects/Jet.py +++ b/PhysicsTools/Heppy/python/physicsobjects/Jet.py @@ -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(): diff --git a/PhysicsTools/Heppy/python/physicsobjects/Photon.py b/PhysicsTools/Heppy/python/physicsobjects/Photon.py index 371b25a0573..9ee22dc9fa8 100644 --- a/PhysicsTools/Heppy/python/physicsobjects/Photon.py +++ b/PhysicsTools/Heppy/python/physicsobjects/Photon.py @@ -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()