CMS 3D CMS Logo

eventsfwlite.py
Go to the documentation of this file.
1 from __future__ import print_function
2 from DataFormats.FWLite import Events as FWLiteEvents
3 
4 from ROOT import gROOT, gSystem, AutoLibraryLoader
5 
6 print("Loading FW Lite")
7 gSystem.Load("libFWCoreFWLite");
8 gROOT.ProcessLine('FWLiteEnabler::enable();')
9 
10 gSystem.Load("libFWCoreFWLite");
11 gSystem.Load("libDataFormatsPatCandidates");
12 
13 from ROOT import gInterpreter
14 gInterpreter.ProcessLine("using namespace reco;")
15 gInterpreter.ProcessLine("using edm::refhelper::FindUsingAdvance;")
16 
17 class Events(object):
18  def __init__(self, files, tree_name, options=None):
19  if options is not None :
20  if not hasattr(options,"inputFiles"):
21  options.inputFiles=files
22  if not hasattr(options,"maxEvents"):
23  options.maxEvents = 0
24  if not hasattr(options,"secondaryInputFiles"):
25  options.secondaryInputFiles = []
26  self.events = FWLiteEvents(options=options)
27  else :
28  self.events = FWLiteEvents(files)
29 
30  def __len__(self):
31  return self.events.size()
32 
33  def __getattr__(self, key):
34  return getattr(self.events, key)
35 
36  def __getitem__(self, iEv):
37  self.events.to(iEv)
38  return self
39 
def __getitem__(self, iEv)
Definition: eventsfwlite.py:36
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def __init__(self, files, tree_name, options=None)
Definition: eventsfwlite.py:18
def __getattr__(self, key)
Definition: eventsfwlite.py:33