ATLAS Offline Software
Loading...
Searching...
No Matches
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
20import cppyy
21
22def 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
30def 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
38def 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
46def 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