ATLAS Offline Software
Public Member Functions | Static Private Attributes | List of all members
python.EI_Lib.IOV Class Reference
Inheritance diagram for python.EI_Lib.IOV:
Collaboration diagram for python.EI_Lib.IOV:

Public Member Functions

def __init__ (self)
 
def cmpBN (self, a, b)
 
def isInInterval (self, point, interval)
 
def add (self, key, value, interval)
 
def dump (self)
 
def get (self, key, point)
 

Static Private Attributes

dictionary _iovs = {}
 
dictionary _cached = {}
 

Detailed Description

Definition at line 10 of file EI_Lib.py.

Constructor & Destructor Documentation

◆ __init__()

def python.EI_Lib.IOV.__init__ (   self)

Definition at line 15 of file EI_Lib.py.

15  def __init__(self):
16  pass
17 

Member Function Documentation

◆ add()

def python.EI_Lib.IOV.add (   self,
  key,
  value,
  interval 
)

Definition at line 55 of file EI_Lib.py.

55  def add(self, key, value, interval):
56  if key not in self._iovs:
57  self._iovs[key] = []
58 
59  try:
60  if len(interval) != 4:
61  raise TypeError("interval must contain 4 elements")
62  except Exception:
63  raise TypeError("interval must be a tuple or list")
64 
65  try:
66  # convert interval into ints to prevent lexicographic comparison
67  interval2 = []
68  for number in interval:
69  interval2.append(int(number))
70  except Exception:
71  raise TypeError("interval ranges must be a integers or longs")
72 
73  self._iovs[key].append((interval2, value))
74 

◆ cmpBN()

def python.EI_Lib.IOV.cmpBN (   self,
  a,
  b 
)

Definition at line 18 of file EI_Lib.py.

18  def cmpBN(self, a, b):
19 
20  # compare a and b and return -1,0,1 if a is <,=,> than b
21  # a (and b) are represented as a pair of numbers
22  # (most significant part, least significant part)
23 
24  try:
25  (r, e) = a
26  (r1, e1) = b
27  except Exception:
28  raise TypeError("element must be a tuple with two components")
29 
30  c = cmp(r, r1) # compare most significant part
31  if c == 0:
32  c = cmp(e, e1) # if equal, compare least significant part
33 
34  return c
35 

◆ dump()

def python.EI_Lib.IOV.dump (   self)

Definition at line 75 of file EI_Lib.py.

75  def dump(self):
76  for k in self._iovs:
77  print(k)
78  for e in self._iovs[k]:
79  print(" ", e)
80 

◆ get()

def python.EI_Lib.IOV.get (   self,
  key,
  point 
)

Definition at line 81 of file EI_Lib.py.

81  def get(self, key, point):
82  if key not in self._iovs:
83  return None
84  if key in self._cached:
85  i, v = self._cached[key]
86  if self.isInInterval(point, i):
87  return v
88  ivalues = self._iovs[key]
89  for i, v in ivalues:
90  if self.isInInterval(point, i):
91  self._cached[key] = (i, v)
92  return v
93  return None

◆ isInInterval()

def python.EI_Lib.IOV.isInInterval (   self,
  point,
  interval 
)

Definition at line 36 of file EI_Lib.py.

36  def isInInterval(self, point, interval):
37 
38  try:
39  if len(interval) != 4:
40  raise TypeError("interval must contain 4 elements")
41  except Exception:
42  raise TypeError("interval must be a tuple or list")
43 
44  # broke down the two parts of the interval
45 
46  i1 = interval[:2]
47  i2 = interval[2:]
48 
49  # look if point belongs to [i1,i2[
50  if self.cmpBN(point, i1) >= 0 and self.cmpBN(point, i2) < 0:
51  return True
52  else:
53  return False
54 

Member Data Documentation

◆ _cached

dictionary python.EI_Lib.IOV._cached = {}
staticprivate

Definition at line 13 of file EI_Lib.py.

◆ _iovs

dictionary python.EI_Lib.IOV._iovs = {}
staticprivate

Definition at line 12 of file EI_Lib.py.


The documentation for this class was generated from the following file:
python.EI_Lib.cmp
def cmp(x, y)
Definition: EI_Lib.py:6
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
run_Egamma1_LArStrip_Fex.dump
dump
Definition: run_Egamma1_LArStrip_Fex.py:88
add
bool add(const std::string &hname, TKey *tobj)
Definition: fastadd.cxx:55
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70