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