CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SimpleJetAnalyzer.py
Go to the documentation of this file.
1 from PhysicsTools.Heppy.analyzers.core.Analyzer import Analyzer
2 from PhysicsTools.Heppy.analyzers.core.AutoHandle import AutoHandle
3 from PhysicsTools.Heppy.physicsobjects.Jet import Jet, GenJet
4 from PhysicsTools.HeppyCore.utils.deltar import matchObjectCollection
5 
6 class SimpleJetAnalyzer(Analyzer):
7  '''Just a simple jet analyzer, to be used in tutorials.'''
8 
9  def declareHandles(self):
10  super(SimpleJetAnalyzer, self).declareHandles()
11  self.handles['jets'] = AutoHandle( 'slimmedJets',
12  'std::vector<pat::Jet>' )
13  self.mchandles['genjets'] = AutoHandle( 'slimmedGenJets',
14  'std::vector<reco::GenJet>')
15 
16  def process(self, event):
17  super(SimpleJetAnalyzer, self).readCollections(event.input)
18  # creating Jet python objects wrapping the EDM jets
19  # keeping only the first 2 leading jets
20  event.jets = map(Jet, self.handles['jets'].product())[:2]
21  event.jets = [ jet for jet in event.jets if jet.pt()>self.cfg_ana.ptmin]
22 
23  if self.cfg_comp.isMC:
24  event.genjets = map(GenJet, self.mchandles['genjets'].product())
25  matches = matchObjectCollection(event.jets, event.genjets, 0.2)
26  for jet in event.jets:
27  jet.gen = matches[jet]
28 
def matchObjectCollection
Definition: deltar.py:146