ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArExample
LArConditionsCommon
python
LArRunFormat.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
3
# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4
5
from
CoolConvUtilities.AtlCoolLib
import
indirectOpen
6
from
functools
import
cache
7
8
9
class
LArRunInfo
:
10
"Wrapper class to hold LAr run configuration information"
11
def
__init__
(self,nSamples,gainType,latency,firstSample,format,runType):
12
self.
_nSamples
= nSamples
13
self.
_gainType
= gainType
14
self.
_latency
= latency
15
self.
_firstSample
= firstSample
16
self.
_format
= format
17
self.
_runType
= runType
18
19
def
nSamples
(self):
20
"Number of samples readout from FEB"
21
return
self.
_nSamples
22
23
def
gainType
(self):
24
"gainType: 0=auto,1=L,2=M,3=H,4=LM,5=LH,6=ML,7=MH,8=HL,9=HM,10=LMH,11=LHM,12=MLH,13=MHL,14=HLM,15=HML"
25
return
self.
_gainType
26
27
def
latency
(self):
28
"latency between l1 trigger and readout"
29
return
self.
_latency
30
31
def
firstSample
(self):
32
"firstsample"
33
return
self.
_firstSample
34
35
def
format
(self):
36
"format:0=Transparent, 1=Format 1, 2=Format 2"
37
return
self.
_format
38
39
def
runType
(self):
40
"runType: 0=RawData, 1=RawDataResult, 2=Result"
41
return
self.
_runType
42
43
def
stringFormat
(self):
44
if
(self.
_format
== 0) :
45
return
'transparent'
46
if
(self.
_format
== 1) :
47
return
'Format1'
48
if
(self.
_format
== 2) :
49
return
'Format2'
50
51
def
stringRunType
(self):
52
if
(self.
_runType
==0) :
53
return
'RawData'
54
if
(self.
_runType
==1) :
55
return
'RawDataResult'
56
if
(self.
_runType
==2) :
57
return
'Result'
58
59
@cache
60
def
getLArFormatForRun
(run,quiet=False,connstring="COOLONL_LAR/CONDBR2"):
61
from
AthenaCommon.Logging
import
logging
62
mlog_LRF = logging.getLogger(
'getLArRunFormatForRun'
)
63
64
mlog_LRF.info(
"Connecting to database %s"
, connstring)
65
66
runDB=indirectOpen(connstring)
67
if
(runDB
is
None
):
68
mlog_LRF.error(
"Cannot connect to database %s"
,connstring)
69
raise
RuntimeError(
"getLArFormatForRun ERROR: Cannot connect to database %s"
,connstring)
70
format=
None
71
nSamples=
None
72
gainType=
None
73
runType=
None
74
latency=
None
75
firstSample=
None
76
try
:
77
folder=runDB.getFolder(
'/LAR/Configuration/RunLog'
)
78
runiov=run << 32
79
obj=folder.findObject(runiov,0)
80
payload=obj.payload()
81
format=payload[
'format'
]
82
nSamples=ord(payload[
'nbOfSamples'
])
83
gainType=payload[
'gainType'
]
84
runType=payload[
'runType'
]
85
latency=ord(payload[
'l1aLatency'
])
86
firstSample=ord(payload[
'firstSample'
])
87
except
Exception:
88
mlog_LRF.warning(
"No information in /LAR/Configuration/RunLog for run %i"
, run)
89
#mlog_LRF.warning(e)
90
return
None
91
runDB.closeDatabase()
92
return
LArRunInfo
(nSamples,gainType,latency,firstSample,format,runType)
93
94
class
LArDTRunInfo
:
95
"Wrapper class to hold LAr DT run configuration information"
96
def
__init__
(self,streamTypes, streamLengths, streamTypesPEB, streamLengthsPEB, timing, adccalib, fw):
97
self.
_sTypes
= streamTypes
98
self.
_sLengths
= streamLengths
99
self.
_sTypesPEB
= streamTypesPEB
100
self.
_sLengthsPEB
= streamLengthsPEB
101
self.
_tim
= timing
102
self.
_adcc
= adccalib
103
self.
_fwversion
= fw
104
105
def
streamTypes
(self):
106
return
self.
_sTypes
107
108
def
streamLengths
(self):
109
return
self.
_sLengths
110
111
def
streamTypesPEB
(self):
112
return
self.
_sTypesPEB
113
114
def
streamLengthsPEB
(self):
115
return
self.
_sLengthsPEB
116
117
def
timing
(self):
118
return
self.
_tim
119
120
def
ADCCalib
(self):
121
return
self.
_adcc
122
123
def
FWversion
(self):
124
return
self.
_fwversion
125
126
def
parse_recipe
(recipe,mux,mlog):
127
# parse recipe string of the type at0_bcX-at1_bcY...
128
typesMap={0:
"ADC"
, 1:
"RawADC"
, 2:
"Energy"
, 3:
"SelectedEnergy"
,15:
"Invalid"
}
129
sTypes=[]
130
sLengths=[]
131
i1,i2=[1,0]
if
"swap"
in
recipe
else
[0,1]
132
for
s,m
in
[
"at0_bc"
,i1],[
"at1_bc"
,i2]:
133
pos=recipe.find(s)
134
if
pos >=0:
135
n=-1
136
try
:
137
n=int(recipe[pos+6:pos+8])
138
except
Exception:
139
try
:
140
n=int(recipe[pos+6:pos+7])
141
except
Exception:
142
mlog.warning(
"could not decode %s"
,recipe[pos+6:])
143
if
n>=0:
144
sLengths.append(n)
145
if
mux[m]
in
typesMap.keys():
146
sTypes.append(typesMap[mux[m]])
147
else
:
148
sTypes.append(15)
149
pass
150
pass
151
return
(sTypes,sLengths)
152
153
@cache
154
def
getLArDTInfoForRun
(run,quiet=False,connstring="COOLONL_LAR/CONDBR2"):
155
from
AthenaCommon.Logging
import
logging
156
mlog_LRF = logging.getLogger(
'getLArDTRunInfoForRun'
)
157
mlog_LRF.info(
"Connecting to database %s"
, connstring)
158
159
runDB=indirectOpen(connstring)
160
if
(runDB
is
None
):
161
mlog_LRF.error(
"Cannot connect to database %s"
,connstring)
162
raise
RuntimeError(
"getLArFormatForRun ERROR: Cannot connect to database %s"
,connstring)
163
164
timing=
"LAR"
165
adccalib=0
166
mux=[]
167
fw=0
168
try
:
169
folder=runDB.getFolder(
'/LAR/Configuration/RunLogDT'
)
170
runiov=run << 32
171
obj=folder.findObject(runiov,0)
172
payload=obj.payload()
173
timing=payload[
'timing_configuration'
]
174
recipe=payload[
'recipe_tdaq_A'
]
175
recipePEB=payload[
'recipe_tdaq_B'
]
176
mux.append(ord(payload[
'mux_setting_0_tdaq'
]))
177
mux.append(ord(payload[
'mux_setting_1_tdaq'
]))
178
adccalib=ord(payload[
'ADCCalibMode'
])
179
if
run > 493743:
# hardcoded, first run when this info was filled
180
fw=ord(payload[
'ttype_mask_A'
])
181
except
Exception:
182
mlog_LRF.warning(
"No information in /LAR/Configuration/RunLogDT for run %i"
, run)
183
mlog_LRF.warning(
"Using defaults: MUX0: ADC MUX1: ET_ID receipe: at0_bc5-at1_bc1_ts1-q"
)
184
recipe=
"at0_bc5-at1_bc1_ts1-q"
185
recipePEB=
''
186
mux.append(0)
187
mux.append(3)
188
189
runDB.closeDatabase()
190
print
(
"getLArDTInfoForRun: "
,recipe,
"/"
,recipePEB,
" : "
,mux)
191
sTypes, sLengths =
parse_recipe
(recipe,mux,mlog_LRF)
192
print
(sTypes, sLengths)
193
sTypesPEB, sLengthsPEB =
parse_recipe
(recipePEB,mux,mlog_LRF)
194
print
(sTypesPEB, sLengthsPEB)
195
return
LArDTRunInfo
(sTypes, sLengths, sTypesPEB, sLengthsPEB, timing, adccalib, fw)
196
197
# command line driver for convenience
198
if
__name__==
'__main__'
:
199
import
sys
200
if
len(sys.argv)!=2:
201
print
(
"Syntax"
,sys.argv[0],
'<run>'
)
202
sys.exit(-1)
203
run=int(sys.argv[1])
204
myformat=
getLArFormatForRun
(run, connstring=
"COOLONL_LAR/CONDBR2"
)
205
if
(myformat
is
not
None
):
206
print
(
" LAr run configuration: Nsamples:%d GainType:%d Latency:%d FirstSample:%d Format:%s runType:%s"
% (myformat.nSamples(),myformat.gainType(),myformat.latency(),myformat.firstSample(),myformat.stringFormat(),myformat.stringRunType()))
207
else
:
208
print
(
" LAr run information not available"
)
209
210
myformat1=
getLArDTInfoForRun
(run, connstring=
"COOLONL_LAR/CONDBR2"
)
211
if
(myformat1
is
not
None
):
212
print
(
" LAr DT run configuration: timing:%s adccalib:%d"
% (myformat1.timing(),myformat1.ADCCalib()))
213
for
i
in
range(0,len(myformat1.streamTypes())):
214
print
(
" stream: %s size: %d"
% (myformat1.streamTypes()[i], myformat1.streamLengths()[i]))
215
else
:
216
print
(
" LAr DT run information not available"
)
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
python.LArRunFormat.LArDTRunInfo
Definition
LArRunFormat.py:94
python.LArRunFormat.LArDTRunInfo.streamLengths
streamLengths(self)
Definition
LArRunFormat.py:108
python.LArRunFormat.LArDTRunInfo._sLengths
_sLengths
Definition
LArRunFormat.py:98
python.LArRunFormat.LArDTRunInfo.ADCCalib
ADCCalib(self)
Definition
LArRunFormat.py:120
python.LArRunFormat.LArDTRunInfo.streamTypes
streamTypes(self)
Definition
LArRunFormat.py:105
python.LArRunFormat.LArDTRunInfo.__init__
__init__(self, streamTypes, streamLengths, streamTypesPEB, streamLengthsPEB, timing, adccalib, fw)
Definition
LArRunFormat.py:96
python.LArRunFormat.LArDTRunInfo.streamTypesPEB
streamTypesPEB(self)
Definition
LArRunFormat.py:111
python.LArRunFormat.LArDTRunInfo._sLengthsPEB
_sLengthsPEB
Definition
LArRunFormat.py:100
python.LArRunFormat.LArDTRunInfo._adcc
_adcc
Definition
LArRunFormat.py:102
python.LArRunFormat.LArDTRunInfo._tim
_tim
Definition
LArRunFormat.py:101
python.LArRunFormat.LArDTRunInfo._sTypes
_sTypes
Definition
LArRunFormat.py:97
python.LArRunFormat.LArDTRunInfo.streamLengthsPEB
streamLengthsPEB(self)
Definition
LArRunFormat.py:114
python.LArRunFormat.LArDTRunInfo.timing
timing(self)
Definition
LArRunFormat.py:117
python.LArRunFormat.LArDTRunInfo._fwversion
_fwversion
Definition
LArRunFormat.py:103
python.LArRunFormat.LArDTRunInfo._sTypesPEB
_sTypesPEB
Definition
LArRunFormat.py:99
python.LArRunFormat.LArDTRunInfo.FWversion
FWversion(self)
Definition
LArRunFormat.py:123
python.LArRunFormat.LArRunInfo
Definition
LArRunFormat.py:9
python.LArRunFormat.LArRunInfo._firstSample
_firstSample
Definition
LArRunFormat.py:15
python.LArRunFormat.LArRunInfo._format
int _format
Definition
LArRunFormat.py:16
python.LArRunFormat.LArRunInfo._latency
_latency
Definition
LArRunFormat.py:14
python.LArRunFormat.LArRunInfo._nSamples
_nSamples
Definition
LArRunFormat.py:12
python.LArRunFormat.LArRunInfo.nSamples
nSamples(self)
Definition
LArRunFormat.py:19
python.LArRunFormat.LArRunInfo.latency
latency(self)
Definition
LArRunFormat.py:27
python.LArRunFormat.LArRunInfo.format
format(self)
Definition
LArRunFormat.py:35
python.LArRunFormat.LArRunInfo._runType
int _runType
Definition
LArRunFormat.py:17
python.LArRunFormat.LArRunInfo.stringFormat
stringFormat(self)
Definition
LArRunFormat.py:43
python.LArRunFormat.LArRunInfo.runType
runType(self)
Definition
LArRunFormat.py:39
python.LArRunFormat.LArRunInfo.firstSample
firstSample(self)
Definition
LArRunFormat.py:31
python.LArRunFormat.LArRunInfo.gainType
gainType(self)
Definition
LArRunFormat.py:23
python.LArRunFormat.LArRunInfo.stringRunType
stringRunType(self)
Definition
LArRunFormat.py:51
python.LArRunFormat.LArRunInfo._gainType
_gainType
Definition
LArRunFormat.py:13
python.LArRunFormat.LArRunInfo.__init__
__init__(self, nSamples, gainType, latency, firstSample, format, runType)
Definition
LArRunFormat.py:11
python.LArRunFormat.getLArFormatForRun
getLArFormatForRun(run, quiet=False, connstring="COOLONL_LAR/CONDBR2")
Definition
LArRunFormat.py:60
python.LArRunFormat.parse_recipe
parse_recipe(recipe, mux, mlog)
Definition
LArRunFormat.py:126
python.LArRunFormat.getLArDTInfoForRun
getLArDTInfoForRun(run, quiet=False, connstring="COOLONL_LAR/CONDBR2")
Definition
LArRunFormat.py:154
Generated on
for ATLAS Offline Software by
1.17.0