Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:26

0001 from __future__ import print_function
0002 import os 
0003 import logging 
0004 
0005 from PhysicsTools.HeppyCore.framework.analyzer import Analyzer as CoreAnalyzer
0006 
0007 class Analyzer(CoreAnalyzer):
0008     '''Base Analyzer class. Used in Looper.'''
0009     
0010     def declareHandles(self):
0011         self.handles = {}
0012         self.mchandles = {}
0013 
0014     def beginLoop(self, setup):
0015         '''Automatically called by Looper, for all analyzers.'''
0016         super(Analyzer, self).beginLoop(setup)
0017         self.declareHandles()
0018         
0019 
0020     def process(self, event ):
0021         '''Automatically called by Looper, for all analyzers.
0022         each analyzer in the sequence will be passed the same event instance.
0023         each analyzer can access, modify, and store event information, of any type.'''
0024         print(self.cfg_ana.name)
0025         self.readCollections( event.input )
0026 
0027     def readCollections(self, iEvent ):
0028         '''You must call this function at the beginning of the process
0029         function of your child analyzer.'''
0030         # if not self.beginLoopCalled:
0031         #    # necessary in case the user calls process to go straight to a given event, before looping
0032         #    self.beginLoop(setup)
0033         for str,handle in self.handles.items():
0034             handle.Load( iEvent )
0035         if self.cfg_comp.isMC:
0036             for str,handle in self.mchandles.items():
0037                 handle.Load( iEvent )