7 from FWCore.ParameterSet.VarParsing
import VarParsing
10 ROOT.gSystem.Load(
"libFWCoreFWLite.so")
11 ROOT.AutoLibraryLoader.enable()
20 def warn (*args, **kwargs):
21 """print out warning with line number and rest of arguments"""
23 frame = inspect.stack()[1]
27 blankLines = kwargs.get(
'blankLines', 0)
29 print '\n' * blankLines
30 spaces = kwargs.get(
'spaces', 0)
34 print "%s (%s): " % (filename, lineNum),
39 print "%s (%s):" % (filename, lineNum)
50 """Python interface to FWLite Handle class"""
55 """Initialize python handle wrapper """
57 oldWarningLevel = ROOT.gErrorIgnoreLevel
58 ROOT.gErrorIgnoreLevel = ROOT.kError
62 self.
_exception = RuntimeError (
"getByLabel not called for '%s'", self)
63 ROOT.SetOwnership (self.
_wrapper,
False)
65 ROOT.gErrorIgnoreLevel = oldWarningLevel
70 if kwargs.get (
'noDelete'):
71 print "Not deleting wrapper"
72 del kwargs[
'noDelete']
74 self._wrapper.IsA().Destructor( self.
_wrapper )
80 raise RuntimeError,
"Unknown arguments %s" % kwargs
84 """Returns true if getByLabel call was successful and data is
90 """Returns product stored in handle."""
93 return self._wrapper.product()
97 return "%s" % (self.
_type)
103 """(Internal) Return the type info"""
108 """(Internal) Return address of edm wrapper"""
109 return ROOT.AddressOf (self.
_wrapper)
113 """(Internal) To be called by Events.getByLabel"""
114 if not getByLabelSuccess:
115 self.
_exception = RuntimeError (
"getByLabel (%s, %s) failed" \
116 % (self, labelString))
118 if not self._wrapper.isPresent():
119 self.
_exception = RuntimeError (
"getByLabel (%s, %s) not present this event" \
120 % (self, labelString))
135 """Python interface to FWLite LuminosityBlock"""
141 if isinstance (inputFiles, list):
144 elif isinstance (inputFiles, VarParsing):
155 if kwargs.has_key (
'maxEvents'):
157 del kwargs[
'maxEvents']
158 if kwargs.has_key (
'options'):
159 options = kwargs [
'options']
163 del kwargs[
'options']
169 raise RuntimeError,
"Unknown arguments %s" % kwargs
171 raise RuntimeError,
"No input files given"
176 raise RuntimeError,
"Never and information about Lumi"
180 """(Internal) Destructor"""
192 return self._lumi.luminosityBlockAuxiliary()
194 raise RuntimeError,
"Lumis.aux() called on object in invalid state"
199 return self._lumi.luminosityBlockAuxiliary()
201 raise RuntimeError,
"Lumis.luminosityBlockAuxiliary() called on object in invalid state"
205 """Calls FWLite's getByLabel. Called:
206 getByLabel (moduleLabel, handle)
207 getByLabel (moduleLabel, productInstanceLabel, handle),
208 getByLabel (moduleLabel, productInstanceLabel, processLabel, handle),
210 getByLabel ( (mL, pIL,pL), handle)
213 if length < 2
or length > 4:
215 raise RuntimeError,
"Incorrect number of arguments"
217 argsList = list (args)
218 handle = argsList.pop()
219 if len(argsList)==1
and \
220 ( isinstance (argsList[0], tuple)
or
221 isinstance (argsList[0], list) ) :
222 if len (argsList) > 3:
223 raise RuntimeError,
"getByLabel Error: label tuple has too " \
224 "many arguments '%s'" % argsList[0]
225 argsList =
list(argsList[0])
226 while len(argsList) < 3:
228 (moduleLabel, productInstanceLabel, processLabel) = argsList
229 labelString =
"'" +
"', '".
join(argsList) +
"'"
230 handle._setStatus ( self._lumi.getByLabel( handle._typeInfoGetter(),
232 productInstanceLabel,
234 handle._addressOf() ),
236 return handle.isValid()
244 """(Internal) Creates an FWLite Lumi"""
257 self.
_lumi = ROOT.fwlite.LuminosityBlock (self.
_tfile);
263 """(Internal) Iterator internals"""
265 if self._lumi.atEnd():
273 self._lumi.__preinc__()
286 """Python interface to FWLite LuminosityBlock"""
292 if isinstance (inputFiles, list):
295 elif isinstance (inputFiles, VarParsing):
306 if kwargs.has_key (
'maxEvents'):
308 del kwargs[
'maxEvents']
309 if kwargs.has_key (
'options'):
310 options = kwargs [
'options']
314 del kwargs[
'options']
320 raise RuntimeError,
"Unknown arguments %s" % kwargs
322 raise RuntimeError,
"No input files given"
327 raise RuntimeError,
"Never and information about Run"
331 """(Internal) Destructor"""
343 return self._run.runAuxiliary()
345 raise RuntimeError,
"Runs.aux() called on object in invalid state"
350 return self._run.runAuxiliary()
352 raise RuntimeError,
"Runs.runAuxiliary() called on object in invalid state"
356 """Calls FWLite's getByLabel. Called:
357 getByLabel (moduleLabel, handle)
358 getByLabel (moduleLabel, productInstanceLabel, handle),
359 getByLabel (moduleLabel, productInstanceLabel, processLabel, handle),
361 getByLabel ( (mL, pIL,pL), handle)
364 if length < 2
or length > 4:
366 raise RuntimeError,
"Incorrect number of arguments"
368 argsList = list (args)
369 handle = argsList.pop()
370 if len(argsList)==1
and \
371 ( isinstance (argsList[0], tuple)
or
372 isinstance (argsList[0], list) ) :
373 if len (argsList) > 3:
374 raise RuntimeError,
"getByLabel Error: label tuple has too " \
375 "many arguments '%s'" % argsList[0]
376 argsList =
list(argsList[0])
377 while len(argsList) < 3:
379 (moduleLabel, productInstanceLabel, processLabel) = argsList
380 labelString =
"'" +
"', '".
join(argsList) +
"'"
381 handle._setStatus ( self._run.getByLabel( handle._typeInfoGetter(),
383 productInstanceLabel,
385 handle._addressOf() ),
387 return handle.isValid()
397 """(Internal) Creates an FWLite Run"""
416 """(Internal) Iterator internals"""
418 if self._run.atEnd():
426 self._run.__preinc__()
438 """Python interface to FWLite ChainEvent class"""
441 """inputFiles => Either a single filename or a list of filenames
443 forceEvent => Use fwlite::Event IF there is only one file
444 maxEvents => Maximum number of events to process
453 if isinstance (inputFiles, list):
456 elif isinstance (inputFiles, VarParsing):
468 if kwargs.has_key (
'maxEvents'):
470 del kwargs[
'maxEvents']
471 if kwargs.has_key (
'forceEvent'):
473 del kwargs[
'forceEvent']
474 if kwargs.has_key (
'options'):
475 options = kwargs [
'options']
479 del kwargs[
'options']
485 raise RuntimeError,
"Unknown arguments %s" % kwargs
487 raise RuntimeError,
"No input files given"
490 def to (self, entryIndex):
491 """Jumps to event entryIndex"""
494 return self._event.to ( long(entryIndex) )
498 """Called to reset event loop to first event."""
503 """Returns number of events"""
506 return self._event.size()
510 """Returns eventAuxiliary object"""
512 raise RuntimeError,
"eventAuxiliary() called before "\
514 return self._event.eventAuxiliary()
518 """Returns event object"""
523 """Calls FWLite's getByLabel. Called:
524 getByLabel (moduleLabel, handle)
525 getByLabel (moduleLabel, productInstanceLabel, handle),
526 getByLabel (moduleLabel, productInstanceLabel, processLabel, handle),
528 getByLabel ( (mL, pIL,pL), handle)
533 if length < 2
or length > 4:
535 raise RuntimeError,
"Incorrect number of arguments"
537 argsList = list (args)
538 handle = argsList.pop()
539 if len(argsList)==1
and \
540 ( isinstance (argsList[0], tuple)
or
541 isinstance (argsList[0], list) ) :
542 if len (argsList) > 3:
543 raise RuntimeError,
"getByLabel Error: label tuple has too " \
544 "many arguments '%s'" % argsList[0]
545 argsList =
list(argsList[0])
546 while len(argsList) < 3:
548 (moduleLabel, productInstanceLabel, processLabel) = argsList
549 labelString =
"'" +
"', '".
join(argsList) +
"'"
550 handle._setStatus ( self._event.getByLabel( handle._typeInfoGetter(),
552 productInstanceLabel,
554 handle._addressOf() ),
556 return handle.isValid()
565 return self._event.fileIndex()
573 return self._event.secondaryFileIndex()
587 """(Internal) Parse options"""
591 """(Internal) Does actual work of toBegin() call"""
592 self._toBegin =
False
593 self._event.toBegin()
594 self._eventCounts = 0
598 """(Internal) Destructor"""
605 """(Internal) Creates an FWLite Event"""
608 if isinstance (self.
_filenames[0], ROOT.TFile):
610 self.
_mode =
'single'
615 self.
_mode =
'single'
617 filenamesSVec = ROOT.vector(
"string") ()
619 filenamesSVec.push_back (name)
621 secondarySVec = ROOT.vector(
"string") ()
623 secondarySVec.push_back (name)
624 self.
_event = ROOT.fwlite.MultiChainEvent (filenamesSVec,
628 self.
_event = ROOT.fwlite.ChainEvent (filenamesSVec)
634 """(Internal) Iterator internals"""
639 while not self._event.atEnd() :
649 self._event.__preinc__()
653 if __name__ ==
"__main__":
def _typeInfoGetter
Private member functions ##.
def _createFWLiteLumi
Private Member Functions ##.
def luminosityBlockAuxiliary
def _parseOptions
Private Member Functions ##.
_maxRuns
Parse optional arguments ##.
def _createFWLiteRun
Private Member Functions ##.
_maxLumis
Parse optional arguments ##.
static std::string join(char **cmd)
_maxEvents
Parse optional arguments ##.
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