Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:31

0001 from __future__ import print_function
0002 from DataFormats.FWLite import Events as FWLiteEvents
0003 
0004 from ROOT import gROOT, gSystem, AutoLibraryLoader
0005 
0006 print("Loading FW Lite")
0007 gSystem.Load("libFWCoreFWLite");
0008 gROOT.ProcessLine('FWLiteEnabler::enable();')
0009 
0010 gSystem.Load("libFWCoreFWLite");
0011 gSystem.Load("libDataFormatsPatCandidates");
0012 
0013 from ROOT import gInterpreter
0014 gInterpreter.ProcessLine("using namespace reco;")
0015 gInterpreter.ProcessLine("using edm::refhelper::FindUsingAdvance;")
0016 
0017 class Events(object):
0018     def __init__(self, files, tree_name,  options=None):
0019         if options is not None :
0020             if not hasattr(options,"inputFiles"):
0021                 options.inputFiles=files
0022             if not hasattr(options,"maxEvents"):
0023                 options.maxEvents = 0   
0024             if not hasattr(options,"secondaryInputFiles"):
0025                 options.secondaryInputFiles = []
0026             self.events = FWLiteEvents(options=options)
0027         else :
0028             self.events = FWLiteEvents(files)
0029 
0030     def __len__(self):
0031         return self.events.size()
0032 
0033     def __getattr__(self, key):
0034         return getattr(self.events, key)
0035 
0036     def __getitem__(self, iEv):
0037         self.events.to(iEv)
0038         return self
0039