test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
6 class Analyzer(CoreAnalyzer):
7  '''Base Analyzer class. Used in Looper.'''
8 
9  def declareHandles(self):
10  self.handles = {}
11  self.mchandles = {}
12 
13  def beginLoop(self, setup):
14  '''Automatically called by Looper, for all analyzers.'''
15  super(Analyzer, self).beginLoop(setup)
16  self.declareHandles()
17 
18 
19  def process(self, event ):
20  '''Automatically called by Looper, for all analyzers.
21  each analyzer in the sequence will be passed the same event instance.
22  each analyzer can access, modify, and store event information, of any type.'''
23  print self.cfg_ana.name
24  self.readCollections( event.input )
25 
26  def readCollections(self, iEvent ):
27  '''You must call this function at the beginning of the process
28  function of your child analyzer.'''
29  # if not self.beginLoopCalled:
30  # # necessary in case the user calls process to go straight to a given event, before looping
31  # self.beginLoop(setup)
32  for str,handle in self.handles.iteritems():
33  handle.Load( iEvent )
34  if self.cfg_comp.isMC:
35  for str,handle in self.mchandles.iteritems():
36  handle.Load( iEvent )