ATLAS Offline Software
Loading...
Searching...
No Matches
LArCondDataDumper.py
Go to the documentation of this file.
1# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2
3#----------------------------------------------------------------
4# class LArCondDataDumper
5#
6# Used for printing out the contents of LArConditionsContainers
7#
8#----------------------------------------------------------------
9# python for LArConditionsContainer
10from LArRawConditions.LArConditionsContainer import LArConditionsContainer
11# pyKernel access
12from PyKernel import PyKernel
13
15 def __init__(self, larCablingSvc, outputLevel) :
16 self.larCablingSvc = larCablingSvc
17 self.outputLevel = outputLevel
18
19 # workaround, not needed in 12.2.0 and later.
21 # delete iterator types to prevent spurious typedeffing
22 import libPyROOT
23
24 try :
25 del libPyROOT.const_iterator
26 except AttributeError:
27 pass
28
29 try:
30 del libPyROOT.iterator
31 except AttributeError:
32 pass
33
34
35
36 #--------------------------------------------------------------
37 # print LAr*P data objects
38 #--------------------------------------------------------------
39 def printLarCondObject(self, obj):
40 t = str(type(obj))
41
42 if -1!=t.find("LArRampP"):
43 obj_str = ""
44 for obj_i in obj.m_vRamp:
45 obj_str = obj_str+str(obj_i)+' '
46 print("ramp = ", obj_str)
47
48
49 elif -1!=t.find("LArShapeP"):
50 obj_str = ""
51 for obj_i in obj.m_vShape :
52 obj_str = obj_str+str(obj_i)+' '
53 print("LArShape = ", obj_str)
54 obj_str = ""
55 for obj_i in obj.m_vShapeDer :
56 obj_str = obj_str+str(obj_i)+' '
57 print("LArShapeDer = ", obj_str)
58
59 elif -1!=t.find("LArPedestalP"):
60 obj_str = ""
61 for obj_i in obj.m_vPedestal:
62 obj_str = obj_str+str(obj_i)+' '
63 print("Pedestal = ", obj_str)
64
65 obj_str = ""
66 for obj_i in obj.m_vPedestalRMS:
67 obj_str = obj_str+str(obj_i)+' '
68 print("PedestalRMS = ", obj_str)
69
70 elif -1!=t.find("LArAutoCorrP"):
71 obj_str = ""
72 for obj_i in obj.m_vAutoCorr:
73 obj_str = obj_str+str(obj_i)+' '
74 print("AutoCorr = ", obj_str)
75
76 elif -1!=t.find("LArDAC2uAP"):
77 obj_str = ""
78 print("DAC2uA = ", obj.m_DAC2uA)
79
80 elif -1!=t.find("LArfSamplP"):
81 obj_str = ""
82 print("fSampl = ", obj.m_fSampl)
83
84 elif -1!=t.find("LAruA2MeVP"):
85 print("uA2MeV = ", obj.m_uA2MeV)
86
87 elif -1!=t.find("LArNoiseP") :
88 print("Noise = ", obj.m_Noise)
89
90 elif -1!=t.find("LArMinBiasP") :
91 print("MinBias = ", obj.m_MinBiasRMS)
92
93 elif -1!=t.find("LArMphysOverMcalP") :
94 print("MphysOverMcal = ", obj.m_MphysOverMcal)
95
96 elif -1!=t.find("LArOFCP") :
97 delay=0
98 for obj_i in obj.m_vOFC_a:
99 print(" delay=",delay)
100
101 obj_str = ""
102 for obj_j in obj_i:
103 obj_str = obj_str + str(obj_j) + ' '
104 print(" OFC_a = ", obj_str)
105
106 obj_str = ""
107 for obj_j in obj.m_vOFC_b[delay]:
108 obj_str = obj_str + str(obj_j) + ' '
109 print(" OFC_b = ", obj_str)
110 delay +=1
111
112
113 elif -1!=t.find("LArCaliWaveVec") :
114 for wave in obj:
115 print(" DAC_0 = ", wave.getDAC(), " Dt=", wave.getDt())
116
117 obj_str = ""
118 i = 0
119 for obj_i in wave.getWave():
120 obj_str = obj_str + str(i) + ' ' + str(obj_i) + ' '
121 i += 1
122 print(" Wave = ", obj_str)
123
124
125 #
126 #--------------------------------------------------------------
127 # print out data for a list of containers
128 #--------------------------------------------------------------
129 def printAllLArCondData(self, ListofType, ListofKey):
130
131 import sys
132 import traceback
133
134 if len(ListofType) != len(ListofKey) :
135 print(" ERROR: Type and Key not the same length")
136 return
137
138 first = True
139
140 for i in range(len(ListofType)):
141 key = ListofKey[i]
142 typ = ListofType[i]
143
144 # Add on extra iterators for the python class
145 try:
146 _ = LArConditionsContainer(typ.__name__)
147 except Exception:
148 print("Cannot get ",typ.__name__," Container")
149
150 try :
152
153 container = PyKernel.retrieveDet(typ,key)
154 if first:
155 # First time through get the cabling server and id helper
156 #self.larCablingSvc = container.larCablingSvc()
157 self.onlineID = container.onlineHelper()
158 first = False
159
160 # for CaliWave, T=LArCaliWaveVec
161 caliWave = -1!=key.find("CaliWave")
162
163 # Loop Over Gains
164 for gain in range(container.minGain(), container.minGain()+container.nGains()):
165 print(" Accessing ",key," gain = ", gain)
166 # Give Conditions
167 n=0
168 FeedThroughs = {}
169 for obj,id in container.conditionsIter(gain):
170 ft = self.onlineID.feedthrough_name(id)
171 FeedThroughs[ft]=1
172 if ( (not caliWave) and (not obj.isEmpty()) ) or (caliWave and len(obj)!=0):
173 n=n+1
174 if self.outputLevel <= 2:
175 str_id1 = self.onlineID.print_to_string(id)
176 print(str_id1)
177 if self.larCablingSvc.isOnlineConnected(id) :
178 off_id = self.larCablingSvc.cnvToIdentifier(id)
179 str_id2 = self.onlineID.print_to_string(off_id)
180 print(str_id2)
181 else:
182 print(" disconnected channel" )
183 self.printLarCondObject(obj)
184 #self.getDataMembers(obj, type(obj))
185
186 print(n, " ",key," accessed" )
187 keys = FeedThroughs.keys()
188 keys.sort()
189 print(" Feedthroughs ",keys )
190
191 except Exception:
192 print(" accessing ",key," failed ")
193 typ, value, traceBack = sys.exc_info()
194 #_logger.error("resetDefinedJobs : %s %s" % (typ,value))
195 traceback.print_exc()
196
197
198
199 # Loop over data members and print them out.
200 # We assume here that they are simple types or vectors of simple types
201 # Get object type
202 def getDataMembers(self, obj, objName, tab = " "):
203 import operator
204 if operator.isNumberType(obj):
205 #print "Attribute name = ", objName, ", value = ", obj
206 print(tab, objName, " = ", obj)
207 else:
208 objType = type(obj)
209 # If Object is a method, replace obj with the result of the method
210 if objType.__name__ == 'MethodProxy':
211 try:
212 obj = obj()
213 objType = type(obj)
214 # Exception is thrown for functions that take arguments. We
215 # ignore them for the moment. It may be that there are two
216 # methods, one providing access to individual values, and
217 # another giving a whole vector of values.
218 except Exception:
219 pass
220 if operator.isNumberType(obj):
221 print("obj type = ",objType.__name__)
222 #print "Attribute name = ", objName, ", value = ", obj
223 print(tab, objName, " = ", obj)
224 return
225 print("obj type =",objType.__name__)
226 # Is this a vector?
227 isVector = False
228 if objType.__name__.find('vector') == 0:
229 isVector = True
230 elif hasattr(obj,'begin') and hasattr(obj,'end') and hasattr(obj,'size'):
231 isVector = True
232 # If a vector, loop over elements and print each one out
233 if isVector:
234 i = 0
235 newTab = tab + " "
236 for o in obj:
237 self.getDataMembers(o, objName + '_' + str(i), newTab)
238 i += 1
239 # Assume a complex type, loop over attributes and print them out
240 else:
241 attrNames = dir(obj)
242 #print ("found attributes:",attrNames)
243 newTab = tab + " "
244 for attrName in attrNames:
245 # Select attributes that begin with m_ or get
246 if attrName.find("m_") == 0 or attrName.find("get") == 0:
247 try:
248 attr = getattr(obj, attrName)
249 except Exception:
250 print("Could not get attr", attrName)
251 self.getDataMembers(attr, attrName, newTab)
void print(char *figname, TCanvas *c1)
getDataMembers(self, obj, objName, tab=" ")
__init__(self, larCablingSvc, outputLevel)
printAllLArCondData(self, ListofType, ListofKey)