CMS 3D CMS Logo

Analyzer.py
Go to the documentation of this file.
1 import os
2 import logging
3 
4 from PhysicsTools.HeppyCore.framework.analyzer import Analyzer as CoreAnalyzer
5 import six
6 
7 class Analyzer(CoreAnalyzer):
8  '''Base Analyzer class. Used in Looper.'''
9 
10  def declareHandles(self):
11  self.handles = {}
12  self.mchandles = {}
13 
14  def beginLoop(self, setup):
15  '''Automatically called by Looper, for all analyzers.'''
16  super(Analyzer, self).beginLoop(setup)
17  self.declareHandles()
18 
19 
20  def process(self, event ):
21  '''Automatically called by Looper, for all analyzers.
22  each analyzer in the sequence will be passed the same event instance.
23  each analyzer can access, modify, and store event information, of any type.'''
24  print self.cfg_ana.name
25  self.readCollections( event.input )
26 
27  def readCollections(self, iEvent ):
28  '''You must call this function at the beginning of the process
29  function of your child analyzer.'''
30  # if not self.beginLoopCalled:
31  # # necessary in case the user calls process to go straight to a given event, before looping
32  # self.beginLoop(setup)
33  for str,handle in six.iteritems(self.handles):
34  handle.Load( iEvent )
35  if self.cfg_comp.isMC:
36  for str,handle in six.iteritems(self.mchandles):
37  handle.Load( iEvent )
def process(self, event)
Definition: Analyzer.py:20
def declareHandles(self)
Definition: Analyzer.py:10
def beginLoop(self, setup)
Definition: Analyzer.py:14
def readCollections(self, iEvent)
Definition: Analyzer.py:27