3 from __future__
import print_function
8 from FWCore.ParameterSet.VarParsing
import VarParsing
11 ROOT.gSystem.Load(
"libFWCoreFWLite")
12 ROOT.FWLiteEnabler.enable()
21 def warn (*args, **kwargs):
22 """print out warning with line number and rest of arguments""" 24 frame = inspect.stack()[1]
28 blankLines = kwargs.get(
'blankLines', 0)
30 print(
'\n' * blankLines)
31 spaces = kwargs.get(
'spaces', 0)
33 print(
' ' * spaces, end=
' ')
35 print(
"%s (%s): " % (filename, lineNum), end=
' ')
40 print(
"%s (%s):" % (filename, lineNum))
51 """Python interface to FWLite Handle class""" 56 """Initialize python handle wrapper """ 58 oldWarningLevel = ROOT.gErrorIgnoreLevel
59 ROOT.gErrorIgnoreLevel = ROOT.kError
61 if kwargs.get (
'noDelete'):
62 print(
"Not deleting wrapper")
63 del kwargs[
'noDelete']
68 self.
_exception = RuntimeError (
"getByLabel not called for '%s'", self)
70 ROOT.gErrorIgnoreLevel = oldWarningLevel
76 raise RuntimeError(
"Unknown arguments %s" % kwargs)
79 """Returns true if getByLabel call was successful and data is 85 """Returns product stored in handle.""" 88 return self._wrapper.product()
92 return "%s" % (self.
_type)
98 """(Internal) reset the edm wrapper""" 101 ROOT.SetOwnership (self.
_wrapper,
False)
107 ROOT.TClass.GetClass(
"edm::Wrapper<"+self.
_type+
">").Destructor( self.
_wrapper )
110 """(Internal) Return the type info""" 115 """(Internal) Return address of edm wrapper""" 116 return ROOT.AddressOf (self.
_wrapper)
120 """(Internal) To be called by Events.getByLabel""" 121 if not getByLabelSuccess:
122 self.
_exception = RuntimeError (
"getByLabel (%s, %s) failed" \
123 % (self, labelString))
125 if not self._wrapper.isPresent():
126 self.
_exception = RuntimeError (
"getByLabel (%s, %s) not present this event" \
127 % (self, labelString))
142 """Python interface to FWLite LuminosityBlock""" 148 if isinstance (inputFiles, list):
151 elif isinstance (inputFiles, VarParsing):
162 if 'maxEvents' in kwargs:
164 del kwargs[
'maxEvents']
165 if 'options' in kwargs:
166 options = kwargs [
'options']
170 del kwargs[
'options']
176 raise RuntimeError(
"Unknown arguments %s" % kwargs)
178 raise RuntimeError(
"No input files given")
183 raise RuntimeError(
"Never and information about Lumi")
187 """(Internal) Destructor""" 199 return self._lumi.luminosityBlockAuxiliary()
201 raise RuntimeError(
"Lumis.aux() called on object in invalid state")
206 return self._lumi.luminosityBlockAuxiliary()
208 raise RuntimeError(
"Lumis.luminosityBlockAuxiliary() called on object in invalid state")
212 """Calls FWLite's getByLabel. Called: 213 getByLabel (moduleLabel, handle) 214 getByLabel (moduleLabel, productInstanceLabel, handle), 215 getByLabel (moduleLabel, productInstanceLabel, processLabel, handle), 217 getByLabel ( (mL, pIL,pL), handle) 220 if length < 2
or length > 4:
222 raise RuntimeError(
"Incorrect number of arguments")
224 argsList = list (args)
225 handle = argsList.pop()
226 if len(argsList)==1 :
227 if( isinstance (argsList[0], tuple)
or 228 isinstance (argsList[0], list) ) :
229 if len (argsList[0]) > 3:
230 raise RuntimeError(
"getByLabel Error: label tuple has too " \
231 "many arguments '%s'" % argsList[0])
232 argsList =
list(argsList[0])
233 if( isinstance(argsList[0], str)
and ":" in argsList[0] ):
234 if argsList[0].
count(
":") > 3:
235 raise RuntimeError(
"getByLabel Error: label tuple has too " \
236 "many arguments '%s'" % argsList[0].
split(
":"))
237 argsList = argsList[0].
split(
":")
238 while len(argsList) < 3:
240 (moduleLabel, productInstanceLabel, processLabel) = argsList
241 labelString =
"'" +
"', '".
join(argsList) +
"'" 242 if not handle._wrapper :
243 handle._resetWrapper()
244 handle._setStatus ( self._lumi.getByLabel( handle._typeInfoGetter(),
246 productInstanceLabel,
248 handle._addressOf() ),
250 return handle.isValid()
258 """(Internal) Creates an FWLite Lumi""" 271 self.
_lumi = ROOT.fwlite.LuminosityBlock (self.
_tfile);
277 """(Internal) Iterator internals""" 279 if self._lumi.atEnd():
287 self._lumi.__preinc__()
300 """Python interface to FWLite LuminosityBlock""" 306 if isinstance (inputFiles, list):
309 elif isinstance (inputFiles, VarParsing):
320 if 'maxEvents' in kwargs:
322 del kwargs[
'maxEvents']
323 if 'options' in kwargs:
324 options = kwargs [
'options']
328 del kwargs[
'options']
334 raise RuntimeError(
"Unknown arguments %s" % kwargs)
336 raise RuntimeError(
"No input files given")
341 raise RuntimeError(
"Never and information about Run")
345 """(Internal) Destructor""" 357 return self._run.runAuxiliary()
359 raise RuntimeError(
"Runs.aux() called on object in invalid state")
364 return self._run.runAuxiliary()
366 raise RuntimeError(
"Runs.runAuxiliary() called on object in invalid state")
370 """Calls FWLite's getByLabel. Called: 371 getByLabel (moduleLabel, handle) 372 getByLabel (moduleLabel, productInstanceLabel, handle), 373 getByLabel (moduleLabel, productInstanceLabel, processLabel, handle), 375 getByLabel ( (mL, pIL,pL), handle) 378 if length < 2
or length > 4:
380 raise RuntimeError(
"Incorrect number of arguments")
382 argsList = list (args)
383 handle = argsList.pop()
384 if len(argsList)==1 :
385 if( isinstance (argsList[0], tuple)
or 386 isinstance (argsList[0], list) ) :
387 if len (argsList[0]) > 3:
388 raise RuntimeError(
"getByLabel Error: label tuple has too " \
389 "many arguments '%s'" % argsList[0])
390 argsList =
list(argsList[0])
391 if( isinstance(argsList[0], str)
and ":" in argsList[0] ):
392 if argsList[0].
count(
":") > 3:
393 raise RuntimeError(
"getByLabel Error: label tuple has too " \
394 "many arguments '%s'" % argsList[0].
split(
":"))
395 argsList = argsList[0].
split(
":")
396 while len(argsList) < 3:
398 (moduleLabel, productInstanceLabel, processLabel) = argsList
399 labelString =
"'" +
"', '".
join(argsList) +
"'" 400 if not handle._wrapper :
401 handle._resetWrapper()
402 handle._setStatus ( self._run.getByLabel( handle._typeInfoGetter(),
404 productInstanceLabel,
406 handle._addressOf() ),
408 return handle.isValid()
418 """(Internal) Creates an FWLite Run""" 437 """(Internal) Iterator internals""" 439 if self._run.atEnd():
447 self._run.__preinc__()
459 """Python interface to FWLite ChainEvent class""" 462 """inputFiles => Either a single filename or a list of filenames 464 forceEvent => Use fwlite::Event IF there is only one file 465 maxEvents => Maximum number of events to process 474 if isinstance (inputFiles, list):
477 elif isinstance (inputFiles, VarParsing):
489 if 'maxEvents' in kwargs:
491 del kwargs[
'maxEvents']
492 if 'forceEvent' in kwargs:
494 del kwargs[
'forceEvent']
495 if 'options' in kwargs:
496 options = kwargs [
'options']
500 del kwargs[
'options']
506 raise RuntimeError(
"Unknown arguments %s" % kwargs)
508 raise RuntimeError(
"No input files given")
511 def to (self, entryIndex):
512 """Jumps to event entryIndex""" 515 return self._event.to ( long(entryIndex) )
519 """Called to reset event loop to first event.""" 524 """Returns number of events""" 527 return self._event.size()
531 """Returns eventAuxiliary object""" 533 raise RuntimeError(
"eventAuxiliary() called before "\
535 return self._event.eventAuxiliary()
539 """Returns event object""" 544 """Calls FWLite's getByLabel. Called: 545 getByLabel (moduleLabel, handle) 546 getByLabel (moduleLabel, productInstanceLabel, handle), 547 getByLabel (moduleLabel, productInstanceLabel, processLabel, handle), 549 getByLabel ( (mL, pIL,pL), handle) 554 if length < 2
or length > 4:
556 raise RuntimeError(
"Incorrect number of arguments")
558 argsList = list (args)
559 handle = argsList.pop()
560 if len(argsList)==1 :
561 if( isinstance (argsList[0], tuple)
or 562 isinstance (argsList[0], list) ) :
563 if len (argsList[0]) > 3:
564 raise RuntimeError(
"getByLabel Error: label tuple has too " \
565 "many arguments '%s'" % argsList[0])
566 argsList =
list(argsList[0])
567 if( isinstance(argsList[0], str)
and ":" in argsList[0] ):
568 if argsList[0].
count(
":") > 3:
569 raise RuntimeError(
"getByLabel Error: label tuple has too " \
570 "many arguments '%s'" % argsList[0].
split(
":"))
571 argsList = argsList[0].
split(
":")
572 while len(argsList) < 3:
574 (moduleLabel, productInstanceLabel, processLabel) = argsList
575 labelString =
"'" +
"', '".
join(argsList) +
"'" 576 if not handle._wrapper :
577 handle._resetWrapper()
578 handle._setStatus ( self._event.getByLabel( handle._typeInfoGetter(),
580 productInstanceLabel,
582 handle._addressOf() ),
584 return handle.isValid()
593 return self._event.fileIndex()
601 return self._event.secondaryFileIndex()
615 """(Internal) Parse options""" 619 """(Internal) Does actual work of toBegin() call""" 620 self._toBegin =
False 621 self._event.toBegin()
622 self._eventCounts = 0
626 """(Internal) Destructor""" 633 """(Internal) Creates an FWLite Event""" 636 if isinstance (self.
_filenames[0], ROOT.TFile):
638 self.
_mode =
'single' 643 self.
_mode =
'single' 645 filenamesSVec = ROOT.vector(
"string") ()
647 filenamesSVec.push_back (name)
649 secondarySVec = ROOT.vector(
"string") ()
651 secondarySVec.push_back (name)
652 self.
_event = ROOT.fwlite.MultiChainEvent (filenamesSVec,
656 self.
_event = ROOT.fwlite.ChainEvent (filenamesSVec)
662 """(Internal) Iterator internals""" 667 while not self._event.atEnd() :
677 self._event.__preinc__()
681 if __name__ ==
"__main__":
def _resetWrapper(self)
Private member functions ##.
def setQuietWarn(quiet=True)
def getByLabel(self, args)
def __init__(self, typeString, kwargs)
S & print(S &os, JobReport::InputFile const &f)
def _createFWLiteEvent(self)
def secondaryFileIndex(self)
def __init__(self, inputFiles='', kwargs)
def _createFWLiteRun(self)
Private Member Functions ##.
_maxRuns
Parse optional arguments ##.
def _setStatus(self, getByLabelSuccess, labelString)
def __init__(self, inputFiles='', kwargs)
def getByLabel(self, args)
def getByLabel(self, args)
_maxLumis
Parse optional arguments ##.
static std::string join(char **cmd)
def _createFWLiteLumi(self)
Private Member Functions ##.
def __init__(self, inputFiles='', kwargs)
def _typeInfoGetter(self)
def _parseOptions(self, options)
Private Member Functions ##.
_maxEvents
Parse optional arguments ##.
def luminosityBlockAuxiliary(self)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run