CMS 3D CMS Logo

diclist.py
Go to the documentation of this file.
1 # Copyright (C) 2014 Colin Bernet
2 # https://github.com/cbernet/heppy/blob/master/LICENSE
3 
4 class diclist( list ):
5  '''list with an internal dictionary for indexing,
6  allowing to keep dictionary elements ordered.
7  keys can be everything except an integer.
8  '''
9 
10  def __init__(self):
11  super( diclist, self).__init__()
12  # internal dictionary, will contain key -> index in list
13  self.dico = {}
14 
15  def add( self, key, value ):
16  if isinstance(key, (int, long)):
17  raise ValueError("key cannot be an integer")
18  if key in self.dico:
19  raise ValueError("key '{key}' already exists".format(key=key) )
20  self.dico[key] = len(self)
21  self.append(value)
22 
23  def __getitem__(self, index):
24  '''index can be a dictionary key, or an integer specifying
25  the rank of the value to be accessed
26  '''
27  try:
28  # if index is an integer (the rank), use the list.
29  return super(diclist, self).__getitem__(index)
30  except (TypeError, ValueError):
31  # else it's the dictionary key.
32  # use the internal dictionary to get the index,
33  # and return the corresponding value from the list
34  return super(diclist, self).__getitem__( self.dico[index] )
35 
36  def __setitem__(self, index, value):
37  '''These functions are quite risky...'''
38  try:
39  return super(diclist, self).__setitem__(index, value)
40  except TypeError as ValueError:
41  return super(diclist, self).__setitem__( self.dico[index], value )
42 
43 
44 
def __setitem__(self, index, value)
Definition: diclist.py:36
def __getitem__(self, index)
Definition: diclist.py:23
def __init__(self)
Definition: diclist.py:10
def add(self, key, value)
Definition: diclist.py:15
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