ATLAS Offline Software
LArConditionsContainer.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
2 
3 # File: LArRawConditions/python/LArConditionsContainer.py
4 # Author: RD Schaffer (R.D.Schaffer@cern.ch)
5 
6 #
7 # Generic class for all python interface classes to LArConditionsContainers.
8 #
9 # Main purpose is to add on python-style iterators over the containers
10 #
11 # Usage: to add on iterators, simply create a python object for the
12 # corresponding container, e.g.
13 # cont = LArConditionsContainer("LArRampComplete")
14 # then any LArRampComplete object will have iterators over
15 # conditions, corrections, COOL channels, and IOVs.
16 # i.e. for r in ramps.conditionsIter(gain): will loop over all
17 # conditions
18 #
19 
20 import cppyy
21 
22 def conditionsIter(self, gain) :
23  sequential = self.begin(gain)
24  end = self.end(gain)
25  while sequential != end :
26  yield sequential.__deref__(), sequential.channelId()
27  sequential.__preinc__()
28  raise StopIteration
29 
30 def correctionsIter(self, gain) :
31  sequential = self.correctionsBegin(gain)
32  end = self.correctionsEnd(gain)
33  while sequential != end :
34  yield sequential.__deref__()
35  sequential.__preinc__()
36  raise StopIteration
37 
38 def coolChannelIter(self) :
39  sequential = self.chan_begin()
40  end = self.chan_end()
41  while sequential != end :
42  yield sequential.__deref__()
43  sequential.__preinc__()
44  raise StopIteration
45 
46 def coolIOVIter(self) :
47  sequential = self.iov_begin()
48  end = self.iov_end()
49  while sequential != end :
50  yield sequential.__deref__()
51  sequential.__preinc__()
52  raise StopIteration
53 
55  def __init__(self, t) :
56 
57  # t is either the class name or the class itself
58  if type(t) is str :
59  self.typeName = t
60  t = cppyy.makeClass(t)
61  else :
62  self.typeName = t.type.__name__
63 
64  # Save type
65  self.type = t
66 
67  # Add on iterators for the different containers
68  self.type.conditionsIter = conditionsIter
69  self.type.correctionsIter = correctionsIter
70  self.type.coolChannelIter = coolChannelIter
71  self.type.coolIOVIter = coolIOVIter
72 
73 
74 
75 
76 
python.LArConditionsContainer.LArConditionsContainer.type
type
Definition: LArConditionsContainer.py:65
python.LArConditionsContainer.LArConditionsContainer.__init__
def __init__(self, t)
Definition: LArConditionsContainer.py:55
python.LArConditionsContainer.coolIOVIter
def coolIOVIter(self)
Definition: LArConditionsContainer.py:46
python.LArConditionsContainer.LArConditionsContainer
Definition: LArConditionsContainer.py:54
python.LArConditionsContainer.conditionsIter
def conditionsIter(self, gain)
Definition: LArConditionsContainer.py:22
python.LArConditionsContainer.LArConditionsContainer.typeName
typeName
Definition: LArConditionsContainer.py:59
pickleTool.object
object
Definition: pickleTool.py:30
python.LArConditionsContainer.coolChannelIter
def coolChannelIter(self)
Definition: LArConditionsContainer.py:38
python.LArConditionsContainer.correctionsIter
def correctionsIter(self, gain)
Definition: LArConditionsContainer.py:30