CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
python.Lumis Class Reference

## Lumis

More...

Public Member Functions

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

Private Member Functions

def _createFWLiteLumi
 Private Member Functions ##. More...
 
def _next
 

Private Attributes

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

Detailed Description

## Lumis

Python interface to FWLite LuminosityBlock

Definition at line 141 of file __init__.py.

Constructor & Destructor Documentation

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

Definition at line 143 of file __init__.py.

144  def __init__ (self, inputFiles = '', **kwargs):
145  self._lumi = None
146  self._lumiCounts = 0
147  self._tfile = None
148  self._maxLumis = 0
149  if isinstance (inputFiles, list):
150  # it's a list
151  self._filenames = inputFiles[:]
152  elif isinstance (inputFiles, VarParsing):
153  # it's a VarParsing object
154  options = inputFiles
155  self._maxLumis = options.maxEvents
156  self._filenames = options.inputFiles
157  else:
158  # it's probably a single string
159  self._filenames = [inputFiles]
160  ##############################
161  ## Parse optional arguments ##
162  ##############################
163  if 'maxEvents' in kwargs:
164  self._maxLumis = kwargs['maxEvents']
165  del kwargs['maxEvents']
166  if 'options' in kwargs:
167  options = kwargs ['options']
168  self._maxLumis = options.maxEvents
169  self._filenames = options.inputFiles
170  self._secondaryFilenames = options.secondaryInputFiles
171  del kwargs['options']
172  # Since we deleted the options as we used them, that means
173  # that kwargs should be empty. If it's not, that means that
174  # somebody passed in an argument that we're not using and we
175  # should complain.
176  if len (kwargs):
177  raise RuntimeError("Unknown arguments %s" % kwargs)
178  if not self._filenames:
179  raise RuntimeError("No input files given")
180  if not self._createFWLiteLumi():
181  # this shouldn't happen as you are getting nothing the
182  # very first time out, but let's at least check to
183  # avoid problems.
184  raise RuntimeError("Never and information about Lumi")
185 
def _createFWLiteLumi
Private Member Functions ##.
Definition: __init__.py:257
_maxLumis
Parse optional arguments ##.
Definition: __init__.py:147
def __init__
Definition: __init__.py:143
def python.Lumis.__del__ (   self)
(Internal) Destructor

Definition at line 186 of file __init__.py.

References python.Lumis._lumi.

187  def __del__ (self):
188  """(Internal) Destructor"""
189  # print "Goodbye cruel world, I'm leaving you today."
190  del self._lumi
191  # print "Goodbye, goodbye, goodbye."
192 

Member Function Documentation

def python.Lumis.__iter__ (   self)

Definition at line 193 of file __init__.py.

References python.Lumis._next().

194  def __iter__ (self):
195  return self._next()
196 
def __iter__
Definition: __init__.py:193
def python.Lumis._createFWLiteLumi (   self)
private

Private Member Functions ##.

(Internal) Creates an FWLite Lumi

Definition at line 257 of file __init__.py.

References python.Lumis._filenames, and python.Lumis._lumi.

Referenced by python.Lumis._next().

258  def _createFWLiteLumi (self):
259  """(Internal) Creates an FWLite Lumi"""
260  # are there any files left?
261  if not self._filenames:
262  return False
263  if self._lumi:
264  del self._lumi
265  self._lumi = None
266  self._veryFirstTime = False
267  self._currFilename = self._filenames.pop(0)
268  #print "Opening file", self._currFilename
269  if self._tfile:
270  del self._tfile
271  self._tfile = ROOT.TFile.Open (self._currFilename)
272  self._lumi = ROOT.fwlite.LuminosityBlock (self._tfile);
273  self._lumi.toBegin()
274  return True
275 
def _createFWLiteLumi
Private Member Functions ##.
Definition: __init__.py:257
def python.Lumis._next (   self)
private
(Internal) Iterator internals

Definition at line 276 of file __init__.py.

References python.Lumis._createFWLiteLumi(), python.Lumis._lumiCounts, and python.Lumis._maxLumis.

Referenced by python.Lumis.__iter__(), python.Runs.__iter__(), and python.Events.__iter__().

277  def _next (self):
278  """(Internal) Iterator internals"""
279  while True:
280  if self._lumi.atEnd():
281  if not self._createFWLiteLumi():
282  # there are no more files here, so we are done
283  break
284  yield self
285  self._lumiCounts += 1
286  if self._maxLumis > 0 and self._lumiCounts >= self._maxLumis:
287  break
288  self._lumi.__preinc__()
289 
290 
def _createFWLiteLumi
Private Member Functions ##.
Definition: __init__.py:257
_maxLumis
Parse optional arguments ##.
Definition: __init__.py:147
def python.Lumis.aux (   self)

Definition at line 197 of file __init__.py.

198  def aux (self):
199  try:
200  return self._lumi.luminosityBlockAuxiliary()
201  except:
202  raise RuntimeError("Lumis.aux() called on object in invalid state")
203 
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 211 of file __init__.py.

References submitPVResolutionJobs.count, if(), join(), and submitPVValidationJobs.split().

212  def getByLabel (self, *args):
213  """Calls FWLite's getByLabel. Called:
214  getByLabel (moduleLabel, handle)
215  getByLabel (moduleLabel, productInstanceLabel, handle),
216  getByLabel (moduleLabel, productInstanceLabel, processLabel, handle),
217  or
218  getByLabel ( (mL, pIL,pL), handle)
219  """
220  length = len (args)
221  if length < 2 or length > 4:
222  # not called correctly
223  raise RuntimeError("Incorrect number of arguments")
224  # handle is always the last argument
225  argsList = list (args)
226  handle = argsList.pop()
227  if len(argsList)==1 :
228  if( isinstance (argsList[0], tuple) or
229  isinstance (argsList[0], list) ) :
230  if len (argsList[0]) > 3:
231  raise RuntimeError("getByLabel Error: label tuple has too " \
232  "many arguments '%s'" % argsList[0])
233  argsList = list(argsList[0])
234  if( isinstance(argsList[0], str) and ":" in argsList[0] ):
235  if argsList[0].count(":") > 3:
236  raise RuntimeError("getByLabel Error: label tuple has too " \
237  "many arguments '%s'" % argsList[0].split(":"))
238  argsList = argsList[0].split(":")
239  while len(argsList) < 3:
240  argsList.append ('')
241  (moduleLabel, productInstanceLabel, processLabel) = argsList
242  labelString = "'" + "', '".join(argsList) + "'"
243  if not handle._wrapper :
244  handle._resetWrapper()
245  handle._setStatus ( self._lumi.getByLabel( handle._typeInfoGetter(),
246  moduleLabel,
247  productInstanceLabel,
248  processLabel,
249  handle._addressOf() ),
250  labelString )
251  return handle.isValid()
252 
def getByLabel
Definition: __init__.py:211
if(conf_.getParameter< bool >("UseStripCablingDB"))
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def python.Lumis.luminosityBlockAuxiliary (   self)

Definition at line 204 of file __init__.py.

205  def luminosityBlockAuxiliary (self):
206  try:
207  return self._lumi.luminosityBlockAuxiliary()
208  except:
209  raise RuntimeError("Lumis.luminosityBlockAuxiliary() called on object in invalid state")
210 
def luminosityBlockAuxiliary
Definition: __init__.py:204

Member Data Documentation

python.Lumis._currFilename
private

Definition at line 266 of file __init__.py.

python.Lumis._filenames
private

Definition at line 150 of file __init__.py.

Referenced by python.Events._createFWLiteEvent(), python.Lumis._createFWLiteLumi(), and python.Runs._createFWLiteRun().

python.Lumis._lumi
private

Definition at line 144 of file __init__.py.

Referenced by python.Lumis.__del__(), and python.Lumis._createFWLiteLumi().

python.Lumis._lumiCounts
private

Definition at line 145 of file __init__.py.

Referenced by python.Lumis._next().

python.Lumis._maxLumis
private

Parse optional arguments ##.

Definition at line 147 of file __init__.py.

Referenced by python.Lumis._next().

python.Lumis._secondaryFilenames
private

Definition at line 169 of file __init__.py.

python.Lumis._tfile
private

Definition at line 146 of file __init__.py.

python.Lumis._veryFirstTime
private

Definition at line 265 of file __init__.py.

Referenced by python.Events._createFWLiteEvent(), python.Events._next(), python.Events.eventAuxiliary(), python.Events.getByLabel(), python.Events.size(), and python.Events.to().