CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

python::Runs Class Reference

################ ## ## ########## ## ## ## ## Runs ## ## ## ## ########## ## ## ################ ## More...

List of all members.

Public Member Functions

def __del__
def __init__
def __iter__
def aux
def getByLabel
def runAuxiliary

Private Member Functions

def _createFWLiteRun
 Private Member Functions ##.
def _next

Private Attributes

 _currFilename
 _filenames
 _maxRuns
 Parse optional arguments ##.
 _run
 _runCounts
 _secondaryFilenames
 _tfile
 _veryFirstTime

Detailed Description

################ ## ## ########## ## ## ## ## Runs ## ## ## ## ########## ## ## ################ ##

Python interface to FWLite LuminosityBlock

Definition at line 283 of file __init__.py.


Constructor & Destructor Documentation

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

Definition at line 285 of file __init__.py.

00286                                                   :
00287         self._run = None
00288         self._runCounts = 0
00289         self._tfile = None
00290         self._maxRuns = 0
00291         if isinstance (inputFiles, list):
00292             # it's a list
00293             self._filenames = inputFiles[:]
00294         elif isinstance (inputFiles, VarParsing):
00295             # it's a VarParsing object
00296             options = inputFiles
00297             self._maxRuns           = options.maxEvents
00298             self._filenames           = options.inputFiles
00299         else:
00300             # it's probably a single string
00301             self._filenames = [inputFiles]
00302         ##############################
00303         ## Parse optional arguments ##
00304         ##############################
00305         if kwargs.has_key ('maxEvents'):
00306             self._maxRuns = kwargs['maxEvents']
00307             del kwargs['maxEvents']
00308         if kwargs.has_key ('options'):
00309             options = kwargs ['options']
00310             self._maxRuns           = options.maxEvents
00311             self._filenames           = options.inputFiles
00312             self._secondaryFilenames  = options.secondaryInputFiles
00313             del kwargs['options']
00314         # Since we deleted the options as we used them, that means
00315         # that kwargs should be empty.  If it's not, that means that
00316         # somebody passed in an argument that we're not using and we
00317         # should complain.
00318         if len (kwargs):
00319             raise RuntimeError, "Unknown arguments %s" % kwargs
00320         if not self._filenames:
00321             raise RuntimeError, "No input files given"
00322         if not self._createFWLiteRun():
00323             # this shouldn't happen as you are getting nothing the
00324             # very first time out, but let's at least check to
00325             # avoid problems.
00326             raise RuntimeError, "Never and information about Run"
00327 

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

Definition at line 328 of file __init__.py.

00329                       :
00330         """(Internal) Destructor"""
00331         # print "Goodbye cruel world, I'm leaving you today."
00332         del self._run
00333         # print "Goodbye, goodbye, goodbye."
00334 


Member Function Documentation

def python::Runs::__iter__ (   self)

Definition at line 335 of file __init__.py.

00336                        :
00337         return self._next()
00338 

def python::Runs::_createFWLiteRun (   self) [private]

Private Member Functions ##.

(Internal) Creates an FWLite Run

Definition at line 394 of file __init__.py.

00395                                :
00396         """(Internal) Creates an FWLite Run"""
00397         # are there any files left?
00398         if not self._filenames:
00399             return False
00400         if self._run:
00401             del self._run
00402             self._run = None
00403         self._veryFirstTime = False
00404         self._currFilename = self._filenames.pop(0)
00405         #print "Opening file", self._currFilename
00406         if self._tfile:
00407             del self._tfile
00408         self._tfile = ROOT.TFile.Open (self._currFilename)
00409         self._run = ROOT.fwlite.Run (self._tfile);
00410         self._run.toBegin()
00411         return True
00412 

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

Definition at line 413 of file __init__.py.

00414                     :
00415         """(Internal) Iterator internals"""
00416         while True:
00417             if self._run.atEnd():
00418                 if not self._createFWLiteRun():
00419                     # there are no more files here, so we are done
00420                     break
00421             yield self
00422             self._runCounts += 1
00423             if self._maxRuns > 0 and self._runCounts >= self._maxRuns:
00424                 break
00425             self._run.__preinc__()
00426             

def python::Runs::aux (   self)

Definition at line 339 of file __init__.py.

00340                   :
00341         try:
00342             return self._run.runAuxiliary()
00343         except:
00344             raise RuntimeError, "Runs.aux() called on object in invalid state"
00345 

def python::Runs::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 353 of file __init__.py.

00354                                 :
00355         """Calls FWLite's getByLabel.  Called:
00356         getByLabel (moduleLabel, handle)
00357         getByLabel (moduleLabel, productInstanceLabel, handle),
00358         getByLabel (moduleLabel, productInstanceLabel, processLabel, handle),
00359         or
00360         getByLabel ( (mL, pIL,pL), handle)
00361         """
00362         length = len (args)
00363         if length < 2 or length > 4:
00364             # not called correctly
00365             raise RuntimeError, "Incorrect number of arguments"
00366         # handle is always the last argument
00367         argsList = list (args)
00368         handle = argsList.pop()
00369         if len(argsList)==1 and \
00370                ( isinstance (argsList[0], tuple) or
00371                  isinstance (argsList[0], list) ) :
00372             if len (argsList) > 3:
00373                 raise RuntimeError, "getByLabel Error: label tuple has too " \
00374                       "many arguments '%s'" % argsList[0]
00375             argsList = list(argsList[0])
00376         while len(argsList) < 3:
00377             argsList.append ('')
00378         (moduleLabel, productInstanceLabel, processLabel) = argsList
00379         labelString = "'" + "', '".join(argsList) + "'"
00380         handle._setStatus ( self._run.getByLabel( handle._typeInfoGetter(),
00381                                                    moduleLabel,
00382                                                    productInstanceLabel,
00383                                                    processLabel,
00384                                                    handle._addressOf() ),
00385                             labelString )
00386         return handle.isValid()
00387 
00388                     
00389        

def python::Runs::runAuxiliary (   self)

Definition at line 346 of file __init__.py.

00347                            :
00348         try:
00349             return self._run.runAuxiliary()
00350         except:
00351             raise RuntimeError, "Runs.runAuxiliary() called on object in invalid state"
00352         


Member Data Documentation

Definition at line 394 of file __init__.py.

Definition at line 285 of file __init__.py.

Parse optional arguments ##.

Definition at line 285 of file __init__.py.

python::Runs::_run [private]

Definition at line 285 of file __init__.py.

Definition at line 285 of file __init__.py.

Definition at line 288 of file __init__.py.

Definition at line 285 of file __init__.py.

Definition at line 394 of file __init__.py.