CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

python::Lumis Class Reference

################# ## ## ########### ## ## ## ## Lumis ## ## ## ## ########### ## ## ################# ## More...

List of all members.

Public Member Functions

def __del__
def __init__
def __iter__
def aux
def getByLabel
def luminosityBlockAuxiliary

Private Member Functions

def _createFWLiteLumi
 Private Member Functions ##.
def _next

Private Attributes

 _currFilename
 _filenames
 _lumi
 _lumiCounts
 _maxLumis
 Parse optional arguments ##.
 _secondaryFilenames
 _tfile
 _veryFirstTime

Detailed Description

################# ## ## ########### ## ## ## ## Lumis ## ## ## ## ########### ## ## ################# ##

Python interface to FWLite LuminosityBlock

Definition at line 132 of file __init__.py.


Constructor & Destructor Documentation

def python::Lumis::__init__ (   self,
  inputFiles = '',
  kwargs 
)

Definition at line 134 of file __init__.py.

00135                                                   :
00136         self._lumi = None
00137         self._lumiCounts = 0
00138         self._tfile = None
00139         self._maxLumis = 0
00140         if isinstance (inputFiles, list):
00141             # it's a list
00142             self._filenames = inputFiles[:]
00143         elif isinstance (inputFiles, VarParsing):
00144             # it's a VarParsing object
00145             options = inputFiles
00146             self._maxLumis           = options.maxEvents
00147             self._filenames           = options.inputFiles
00148         else:
00149             # it's probably a single string
00150             self._filenames = [inputFiles]
00151         ##############################
00152         ## Parse optional arguments ##
00153         ##############################
00154         if kwargs.has_key ('maxEvents'):
00155             self._maxLumis = kwargs['maxEvents']
00156             del kwargs['maxEvents']
00157         if kwargs.has_key ('options'):
00158             options = kwargs ['options']
00159             self._maxLumis           = options.maxEvents
00160             self._filenames           = options.inputFiles
00161             self._secondaryFilenames  = options.secondaryInputFiles
00162             del kwargs['options']
00163         # Since we deleted the options as we used them, that means
00164         # that kwargs should be empty.  If it's not, that means that
00165         # somebody passed in an argument that we're not using and we
00166         # should complain.
00167         if len (kwargs):
00168             raise RuntimeError, "Unknown arguments %s" % kwargs
00169         if not self._filenames:
00170             raise RuntimeError, "No input files given"
00171         if not self._createFWLiteLumi():
00172             # this shouldn't happen as you are getting nothing the
00173             # very first time out, but let's at least check to
00174             # avoid problems.
00175             raise RuntimeError, "Never and information about Lumi"
00176 

def python::Lumis::__del__ (   self)
(Internal) Destructor

Definition at line 177 of file __init__.py.

00178                       :
00179         """(Internal) Destructor"""
00180         # print "Goodbye cruel world, I'm leaving you today."
00181         del self._lumi
00182         # print "Goodbye, goodbye, goodbye."
00183 


Member Function Documentation

def python::Lumis::__iter__ (   self)

Definition at line 184 of file __init__.py.

00185                        :
00186         return self._next()
00187 

def python::Lumis::_createFWLiteLumi (   self) [private]

Private Member Functions ##.

(Internal) Creates an FWLite Lumi

Definition at line 241 of file __init__.py.

00242                                 :
00243         """(Internal) Creates an FWLite Lumi"""
00244         # are there any files left?
00245         if not self._filenames:
00246             return False
00247         if self._lumi:
00248             del self._lumi
00249             self._lumi = None
00250         self._veryFirstTime = False
00251         self._currFilename = self._filenames.pop(0)
00252         #print "Opening file", self._currFilename
00253         if self._tfile:
00254             del self._tfile
00255         self._tfile = ROOT.TFile.Open (self._currFilename)
00256         self._lumi = ROOT.fwlite.LuminosityBlock (self._tfile);
00257         self._lumi.toBegin()
00258         return True
00259 

def python::Lumis::_next (   self) [private]
(Internal) Iterator internals

Definition at line 260 of file __init__.py.

00261                     :
00262         """(Internal) Iterator internals"""
00263         while True:
00264             if self._lumi.atEnd():
00265                 if not self._createFWLiteLumi():
00266                     # there are no more files here, so we are done
00267                     break
00268             yield self
00269             self._lumiCounts += 1
00270             if self._maxLumis > 0 and self._lumiCounts >= self._maxLumis:
00271                 break
00272             self._lumi.__preinc__()
00273             
00274                     
        
def python::Lumis::aux (   self)

Definition at line 188 of file __init__.py.

00189                   :
00190         try:
00191             return self._lumi.luminosityBlockAuxiliary()
00192         except:
00193             raise RuntimeError, "Lumis.aux() called on object in invalid state"
00194 

def python::Lumis::getByLabel (   self,
  args 
)
Calls FWLite's getByLabel.  Called:
getByLabel (moduleLabel, handle)
getByLabel (moduleLabel, productInstanceLabel, handle),
getByLabel (moduleLabel, productInstanceLabel, processLabel, handle),
or
getByLabel ( (mL, pIL,pL), handle)

Definition at line 202 of file __init__.py.

00203                                 :
00204         """Calls FWLite's getByLabel.  Called:
00205         getByLabel (moduleLabel, handle)
00206         getByLabel (moduleLabel, productInstanceLabel, handle),
00207         getByLabel (moduleLabel, productInstanceLabel, processLabel, handle),
00208         or
00209         getByLabel ( (mL, pIL,pL), handle)
00210         """
00211         length = len (args)
00212         if length < 2 or length > 4:
00213             # not called correctly
00214             raise RuntimeError, "Incorrect number of arguments"
00215         # handle is always the last argument
00216         argsList = list (args)
00217         handle = argsList.pop()
00218         if len(argsList)==1 and \
00219                ( isinstance (argsList[0], tuple) or
00220                  isinstance (argsList[0], list) ) :
00221             if len (argsList) > 3:
00222                 raise RuntimeError, "getByLabel Error: label tuple has too " \
00223                       "many arguments '%s'" % argsList[0]
00224             argsList = list(argsList[0])
00225         while len(argsList) < 3:
00226             argsList.append ('')
00227         (moduleLabel, productInstanceLabel, processLabel) = argsList
00228         labelString = "'" + "', '".join(argsList) + "'"
00229         handle._setStatus ( self._lumi.getByLabel( handle._typeInfoGetter(),
00230                                                    moduleLabel,
00231                                                    productInstanceLabel,
00232                                                    processLabel,
00233                                                    handle._addressOf() ),
00234                             labelString )
00235         return handle.isValid()
00236 

def python::Lumis::luminosityBlockAuxiliary (   self)

Definition at line 195 of file __init__.py.

00196                                        :
00197         try:
00198             return self._lumi.luminosityBlockAuxiliary()
00199         except:
00200             raise RuntimeError, "Lumis.luminosityBlockAuxiliary() called on object in invalid state"
00201         


Member Data Documentation

Definition at line 241 of file __init__.py.

Definition at line 134 of file __init__.py.

Definition at line 134 of file __init__.py.

Definition at line 134 of file __init__.py.

Parse optional arguments ##.

Definition at line 134 of file __init__.py.

Definition at line 137 of file __init__.py.

Definition at line 134 of file __init__.py.

Definition at line 241 of file __init__.py.