test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
eventsfwlite.py
Go to the documentation of this file.
1 from DataFormats.FWLite import Events as FWLiteEvents
2 
3 from ROOT import gROOT, gSystem, AutoLibraryLoader
4 
5 print "Loading FW Lite"
6 gSystem.Load("libFWCoreFWLite");
7 gROOT.ProcessLine('FWLiteEnabler::enable();')
8 
9 gSystem.Load("libFWCoreFWLite");
10 gSystem.Load("libDataFormatsPatCandidates");
11 
12 from ROOT import gInterpreter
13 gInterpreter.ProcessLine("using namespace reco;")
14 gInterpreter.ProcessLine("using edm::refhelper::FindUsingAdvance;")
15 
16 class Events(object):
17  def __init__(self, files, tree_name, options=None):
18  if options is not None :
19  if not hasattr(options,"inputFiles"):
20  options.inputFiles=files
21  if not hasattr(options,"maxEvents"):
22  options.maxEvents = 0
23  if not hasattr(options,"secondaryInputFiles"):
24  options.secondaryInputFiles = []
25  self.events = FWLiteEvents(options=options)
26  else :
27  self.events = FWLiteEvents(files)
28 
29  def __len__(self):
30  return self.events.size()
31 
32  def __getattr__(self, key):
33  return getattr(self.events, key)
34 
35  def __getitem__(self, iEv):
36  self.events.to(iEv)
37  return self
38