CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
python.Lumis Class Reference

## Lumis

More...

Public Member Functions

def __del__ (self)
 
def __init__ (self, inputFiles='', kwargs)
 
def __iter__ (self)
 
def aux (self)
 
def getByLabel (self, args)
 
def luminosityBlockAuxiliary (self)
 

Private Member Functions

def _createFWLiteLumi (self)
 Private Member Functions ##. More...
 
def _next (self)
 

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 139 of file __init__.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 141 of file __init__.py.

141  def __init__ (self, inputFiles = '', **kwargs):
142  self._lumi = None
143  self._lumiCounts = 0
144  self._tfile = None
145  self._maxLumis = 0
146  if isinstance (inputFiles, list):
147  # it's a list
148  self._filenames = inputFiles[:]
149  elif isinstance (inputFiles, VarParsing):
150  # it's a VarParsing object
151  options = inputFiles
152  self._maxLumis = options.maxEvents
153  self._filenames = options.inputFiles
154  else:
155  # it's probably a single string
156  self._filenames = [inputFiles]
157 
160  if 'maxEvents' in kwargs:
161  self._maxLumis = kwargs['maxEvents']
162  del kwargs['maxEvents']
163  if 'options' in kwargs:
164  options = kwargs ['options']
165  self._maxLumis = options.maxEvents
166  self._filenames = options.inputFiles
167  self._secondaryFilenames = options.secondaryInputFiles
168  del kwargs['options']
169  # Since we deleted the options as we used them, that means
170  # that kwargs should be empty. If it's not, that means that
171  # somebody passed in an argument that we're not using and we
172  # should complain.
173  if len (kwargs):
174  raise RuntimeError("Unknown arguments %s" % kwargs)
175  if not self._filenames:
176  raise RuntimeError("No input files given")
177  if not self._createFWLiteLumi():
178  # this shouldn't happen as you are getting nothing the
179  # very first time out, but let's at least check to
180  # avoid problems.
181  raise RuntimeError("Never and information about Lumi")
182 
183 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

◆ __del__()

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

Definition at line 184 of file __init__.py.

References python.Lumis._lumi.

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

Member Function Documentation

◆ __iter__()

def python.Lumis.__iter__ (   self)

Definition at line 191 of file __init__.py.

References python.Lumis._next().

191  def __iter__ (self):
192  return self._next()
193 
194 

◆ _createFWLiteLumi()

def python.Lumis._createFWLiteLumi (   self)
private

Private Member Functions ##.

(Internal) Creates an FWLite Lumi

Definition at line 255 of file __init__.py.

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

Referenced by python.Lumis._next().

255  def _createFWLiteLumi (self):
256  """(Internal) Creates an FWLite Lumi"""
257  # are there any files left?
258  if not self._filenames:
259  return False
260  if self._lumi:
261  del self._lumi
262  self._lumi = None
263  self._veryFirstTime = False
264  self._currFilename = self._filenames.pop(0)
265  #print "Opening file", self._currFilename
266  if self._tfile:
267  del self._tfile
268  self._tfile = ROOT.TFile.Open (self._currFilename)
269  self._lumi = ROOT.fwlite.LuminosityBlock (self._tfile);
270  self._lumi.toBegin()
271  return True
272 
273 

◆ _next()

def python.Lumis._next (   self)
private
(Internal) Iterator internals

Definition at line 274 of file __init__.py.

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

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

274  def _next (self):
275  """(Internal) Iterator internals"""
276  while True:
277  if self._lumi.atEnd():
278  if not self._createFWLiteLumi():
279  # there are no more files here, so we are done
280  break
281  yield self
282  self._lumiCounts += 1
283  if self._maxLumis > 0 and self._lumiCounts >= self._maxLumis:
284  break
285  self._lumi.__preinc__()
286 
287 
288 

◆ aux()

def python.Lumis.aux (   self)

Definition at line 195 of file __init__.py.

References python.Lumis._lumi, and python.Lumis.luminosityBlockAuxiliary().

195  def aux (self):
196  try:
197  return self._lumi.luminosityBlockAuxiliary()
198  except:
199  raise RuntimeError("Lumis.aux() called on object in invalid state")
200 
201 

◆ getByLabel()

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 209 of file __init__.py.

References python.Lumis._lumi, submitPVResolutionJobs.count, caHitNtupletGeneratorKernels.if(), join(), and submitPVValidationJobs.split().

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

◆ luminosityBlockAuxiliary()

def python.Lumis.luminosityBlockAuxiliary (   self)

Definition at line 202 of file __init__.py.

References python.Lumis._lumi.

Referenced by python.Lumis.aux().

202  def luminosityBlockAuxiliary (self):
203  try:
204  return self._lumi.luminosityBlockAuxiliary()
205  except:
206  raise RuntimeError("Lumis.luminosityBlockAuxiliary() called on object in invalid state")
207 
208 

Member Data Documentation

◆ _currFilename

python.Lumis._currFilename
private

Definition at line 264 of file __init__.py.

◆ _filenames

python.Lumis._filenames
private

◆ _lumi

python.Lumis._lumi
private

◆ _lumiCounts

python.Lumis._lumiCounts
private

Definition at line 143 of file __init__.py.

Referenced by python.Lumis._next().

◆ _maxLumis

python.Lumis._maxLumis
private

Parse optional arguments ##.

Definition at line 145 of file __init__.py.

Referenced by python.Lumis._next().

◆ _secondaryFilenames

python.Lumis._secondaryFilenames
private

Definition at line 167 of file __init__.py.

◆ _tfile

python.Lumis._tfile
private

Definition at line 144 of file __init__.py.

◆ _veryFirstTime

python.Lumis._veryFirstTime
private