7 from FWCore.ParameterSet.VarParsing
import VarParsing
10 ROOT.gSystem.Load(
"libFWCoreFWLite")
11 ROOT.FWLiteEnabler.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
60 if kwargs.get (
'noDelete'):
61 print "Not deleting wrapper"
62 del kwargs[
'noDelete']
67 self.
_exception = RuntimeError (
"getByLabel not called for '%s'", self)
69 ROOT.gErrorIgnoreLevel = oldWarningLevel
75 raise RuntimeError,
"Unknown arguments %s" % kwargs
78 """Returns true if getByLabel call was successful and data is
84 """Returns product stored in handle."""
87 return self._wrapper.product()
91 return "%s" % (self.
_type)
97 """(Internal) reset the edm wrapper"""
100 ROOT.SetOwnership (self.
_wrapper,
False)
106 ROOT.TClass.GetClass(
"edm::Wrapper<"+self.
_type+
">").Destructor( self.
_wrapper )
109 """(Internal) Return the type info"""
114 """(Internal) Return address of edm wrapper"""
115 return ROOT.AddressOf (self.
_wrapper)
119 """(Internal) To be called by Events.getByLabel"""
120 if not getByLabelSuccess:
121 self.
_exception = RuntimeError (
"getByLabel (%s, %s) failed" \
122 % (self, labelString))
124 if not self._wrapper.isPresent():
125 self.
_exception = RuntimeError (
"getByLabel (%s, %s) not present this event" \
126 % (self, labelString))
141 """Python interface to FWLite LuminosityBlock"""
147 if isinstance (inputFiles, list):
150 elif isinstance (inputFiles, VarParsing):
161 if kwargs.has_key (
'maxEvents'):
163 del kwargs[
'maxEvents']
164 if kwargs.has_key (
'options'):
165 options = kwargs [
'options']
169 del kwargs[
'options']
175 raise RuntimeError,
"Unknown arguments %s" % kwargs
177 raise RuntimeError,
"No input files given"
182 raise RuntimeError,
"Never and information about Lumi"
186 """(Internal) Destructor"""
198 return self._lumi.luminosityBlockAuxiliary()
200 raise RuntimeError,
"Lumis.aux() called on object in invalid state"
205 return self._lumi.luminosityBlockAuxiliary()
207 raise RuntimeError,
"Lumis.luminosityBlockAuxiliary() called on object in invalid state"
211 """Calls FWLite's getByLabel. Called:
212 getByLabel (moduleLabel, handle)
213 getByLabel (moduleLabel, productInstanceLabel, handle),
214 getByLabel (moduleLabel, productInstanceLabel, processLabel, handle),
216 getByLabel ( (mL, pIL,pL), handle)
219 if length < 2
or length > 4:
221 raise RuntimeError,
"Incorrect number of arguments"
223 argsList = list (args)
224 handle = argsList.pop()
225 if len(argsList)==1 :
226 if( isinstance (argsList[0], tuple)
or
227 isinstance (argsList[0], list) ) :
228 if len (argsList[0]) > 3:
229 raise RuntimeError,
"getByLabel Error: label tuple has too " \
230 "many arguments '%s'" % argsList[0]
231 argsList =
list(argsList[0])
232 if( type(argsList[0])
is str
and ":" in argsList[0] ):
233 if argsList[0].
count(
":") > 3:
234 raise RuntimeError,
"getByLabel Error: label tuple has too " \
235 "many arguments '%s'" % argsList[0].
split(
":")
236 argsList = argsList[0].
split(
":")
237 while len(argsList) < 3:
239 (moduleLabel, productInstanceLabel, processLabel) = argsList
240 labelString =
"'" +
"', '".
join(argsList) +
"'"
241 if not handle._wrapper :
242 handle._resetWrapper()
243 handle._setStatus ( self._lumi.getByLabel( handle._typeInfoGetter(),
245 productInstanceLabel,
247 handle._addressOf() ),
249 return handle.isValid()
257 """(Internal) Creates an FWLite Lumi"""
270 self.
_lumi = ROOT.fwlite.LuminosityBlock (self.
_tfile);
276 """(Internal) Iterator internals"""
278 if self._lumi.atEnd():
286 self._lumi.__preinc__()
299 """Python interface to FWLite LuminosityBlock"""
305 if isinstance (inputFiles, list):
308 elif isinstance (inputFiles, VarParsing):
319 if kwargs.has_key (
'maxEvents'):
321 del kwargs[
'maxEvents']
322 if kwargs.has_key (
'options'):
323 options = kwargs [
'options']
327 del kwargs[
'options']
333 raise RuntimeError,
"Unknown arguments %s" % kwargs
335 raise RuntimeError,
"No input files given"
340 raise RuntimeError,
"Never and information about Run"
344 """(Internal) Destructor"""
356 return self._run.runAuxiliary()
358 raise RuntimeError,
"Runs.aux() called on object in invalid state"
363 return self._run.runAuxiliary()
365 raise RuntimeError,
"Runs.runAuxiliary() called on object in invalid state"
369 """Calls FWLite's getByLabel. Called:
370 getByLabel (moduleLabel, handle)
371 getByLabel (moduleLabel, productInstanceLabel, handle),
372 getByLabel (moduleLabel, productInstanceLabel, processLabel, handle),
374 getByLabel ( (mL, pIL,pL), handle)
377 if length < 2
or length > 4:
379 raise RuntimeError,
"Incorrect number of arguments"
381 argsList = list (args)
382 handle = argsList.pop()
383 if len(argsList)==1 :
384 if( isinstance (argsList[0], tuple)
or
385 isinstance (argsList[0], list) ) :
386 if len (argsList[0]) > 3:
387 raise RuntimeError,
"getByLabel Error: label tuple has too " \
388 "many arguments '%s'" % argsList[0]
389 argsList =
list(argsList[0])
390 if( type(argsList[0])
is str
and ":" in argsList[0] ):
391 if argsList[0].
count(
":") > 3:
392 raise RuntimeError,
"getByLabel Error: label tuple has too " \
393 "many arguments '%s'" % argsList[0].
split(
":")
394 argsList = argsList[0].
split(
":")
395 while len(argsList) < 3:
397 (moduleLabel, productInstanceLabel, processLabel) = argsList
398 labelString =
"'" +
"', '".
join(argsList) +
"'"
399 if not handle._wrapper :
400 handle._resetWrapper()
401 handle._setStatus ( self._run.getByLabel( handle._typeInfoGetter(),
403 productInstanceLabel,
405 handle._addressOf() ),
407 return handle.isValid()
417 """(Internal) Creates an FWLite Run"""
436 """(Internal) Iterator internals"""
438 if self._run.atEnd():
446 self._run.__preinc__()
458 """Python interface to FWLite ChainEvent class"""
461 """inputFiles => Either a single filename or a list of filenames
463 forceEvent => Use fwlite::Event IF there is only one file
464 maxEvents => Maximum number of events to process
473 if isinstance (inputFiles, list):
476 elif isinstance (inputFiles, VarParsing):
488 if kwargs.has_key (
'maxEvents'):
490 del kwargs[
'maxEvents']
491 if kwargs.has_key (
'forceEvent'):
493 del kwargs[
'forceEvent']
494 if kwargs.has_key (
'options'):
495 options = kwargs [
'options']
499 del kwargs[
'options']
505 raise RuntimeError,
"Unknown arguments %s" % kwargs
507 raise RuntimeError,
"No input files given"
510 def to (self, entryIndex):
511 """Jumps to event entryIndex"""
514 return self._event.to ( long(entryIndex) )
518 """Called to reset event loop to first event."""
523 """Returns number of events"""
526 return self._event.size()
530 """Returns eventAuxiliary object"""
532 raise RuntimeError,
"eventAuxiliary() called before "\
534 return self._event.eventAuxiliary()
538 """Returns event object"""
543 """Calls FWLite's getByLabel. Called:
544 getByLabel (moduleLabel, handle)
545 getByLabel (moduleLabel, productInstanceLabel, handle),
546 getByLabel (moduleLabel, productInstanceLabel, processLabel, handle),
548 getByLabel ( (mL, pIL,pL), handle)
553 if length < 2
or length > 4:
555 raise RuntimeError,
"Incorrect number of arguments"
557 argsList = list (args)
558 handle = argsList.pop()
559 if len(argsList)==1 :
560 if( isinstance (argsList[0], tuple)
or
561 isinstance (argsList[0], list) ) :
562 if len (argsList[0]) > 3:
563 raise RuntimeError,
"getByLabel Error: label tuple has too " \
564 "many arguments '%s'" % argsList[0]
565 argsList =
list(argsList[0])
566 if( type(argsList[0])
is str
and ":" in argsList[0] ):
567 if argsList[0].
count(
":") > 3:
568 raise RuntimeError,
"getByLabel Error: label tuple has too " \
569 "many arguments '%s'" % argsList[0].
split(
":")
570 argsList = argsList[0].
split(
":")
571 while len(argsList) < 3:
573 (moduleLabel, productInstanceLabel, processLabel) = argsList
574 labelString =
"'" +
"', '".
join(argsList) +
"'"
575 if not handle._wrapper :
576 handle._resetWrapper()
577 handle._setStatus ( self._event.getByLabel( handle._typeInfoGetter(),
579 productInstanceLabel,
581 handle._addressOf() ),
583 return handle.isValid()
592 return self._event.fileIndex()
600 return self._event.secondaryFileIndex()
614 """(Internal) Parse options"""
618 """(Internal) Does actual work of toBegin() call"""
619 self._toBegin =
False
620 self._event.toBegin()
621 self._eventCounts = 0
625 """(Internal) Destructor"""
632 """(Internal) Creates an FWLite Event"""
635 if isinstance (self.
_filenames[0], ROOT.TFile):
637 self.
_mode =
'single'
642 self.
_mode =
'single'
644 filenamesSVec = ROOT.vector(
"string") ()
646 filenamesSVec.push_back (name)
648 secondarySVec = ROOT.vector(
"string") ()
650 secondarySVec.push_back (name)
651 self.
_event = ROOT.fwlite.MultiChainEvent (filenamesSVec,
655 self.
_event = ROOT.fwlite.ChainEvent (filenamesSVec)
661 """(Internal) Iterator internals"""
666 while not self._event.atEnd() :
676 self._event.__preinc__()
680 if __name__ ==
"__main__":
def _resetWrapper
Private member functions ##.
def _createFWLiteLumi
Private Member Functions ##.
def luminosityBlockAuxiliary
def _parseOptions
Private Member Functions ##.
_maxRuns
Parse optional arguments ##.
if(c.getParameter< edm::InputTag >("puppiValueMap").label().size()!=0)
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