ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileCalib
TileCalibBlobPython
scripts
ReadLUTFromCrest.py
Go to the documentation of this file.
1
#!/bin/env python
2
3
# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4
#
5
# File: ReadLUTFromCrest.py
6
# Sanya Solodkov <Sanya.Solodkov@cern.ch>, 2025-12-12
7
#
8
# Purpose: Read Look-up tables for non-linear CIS and Laser corrections
9
#
10
11
import
getopt,sys,os
12
os.environ[
'TERM'
] =
'linux'
13
14
def
usage
():
15
print
(
"Usage: "
,sys.argv[0],
" [OPTION] ... "
)
16
print
(
"Dumps the TileCal CIS/NLN from various schemas / folders / tags"
)
17
print
(
""
)
18
print
(
"-h, --help shows this help"
)
19
print
(
"-f, --folder= specify status folder to use f.i. /TILE/OFL02/CALIB/CIS/NLN "
)
20
print
(
"-t, --tag= specify tag to use, f.i. UPD1 or UPD4 or full suffix like RUN2-HLT-UPD1-00"
)
21
print
(
"-r, --run= specify run number, by default uses latest iov"
)
22
print
(
"-l, --lumi= specify lumi block number, default is 0"
)
23
print
(
"-p, --ros= specify partition (ros number), default is 1"
)
24
print
(
"-d, --drawer= specify drawer number, default is 0"
)
25
print
(
"-m, --module= specify module to use, default is LBA01"
)
26
print
(
"-c, --chan= specify channel number, default is 0"
)
27
print
(
"-g, -a, --adc= specify gain (adc number), default is 0"
)
28
print
(
"-s, --schema= specify name of input JSON file or CREST_SERVER_PATH"
)
29
30
letters =
"hr:l:s:t:f:p:d:m:c:a:g:"
31
keywords = [
"help"
,
"run="
,
"lumi="
,
"schema="
,
"tag="
,
"folder="
,
"ros="
,
"drawer="
,
"module="
,
"chan="
,
"channel="
,
"adc="
,
"gain="
]
32
33
try
:
34
opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
35
except
getopt.GetoptError
as
err:
36
print
(str(err))
37
usage
()
38
sys.exit(2)
39
40
# defaults
41
run = 2147483647
42
lumi = 0
43
schema =
'CREST'
44
folderPath =
"/TILE/OFL02/CALIB/CIS/NLN"
45
tag =
"UPD4"
46
ros = 1
47
drawer = 0
48
channel = 0
49
adc = 0
50
51
for
o, a
in
opts:
52
a = a.strip()
53
if
o
in
(
"-f"
,
"--folder"
):
54
folderPath = a
55
elif
o
in
(
"-t"
,
"--tag"
):
56
tag = a
57
elif
o
in
(
"-s"
,
"--schema"
):
58
schema = a
59
elif
o
in
(
"-m"
,
"--module"
):
60
partname = a[:3]
61
part_dict = {
'AUX'
:0,
'LBA'
:1,
'LBC'
:2,
'EBA'
:3,
'EBC'
:4}
62
if
partname
in
part_dict:
63
ros = part_dict[partname]
64
drawer =
max
(int(a[3:])-1,0)
65
elif
o
in
(
"-p"
,
"--ros"
):
66
ros = int(a)
67
elif
o
in
(
"-d"
,
"--drawer"
):
68
drawer = int(a)
69
elif
o
in
(
"-c"
,
"--chan"
,
"--channel"
):
70
channel = int(a)
71
elif
o
in
(
"-a"
,
"--adc"
,
"-g"
,
"--gain"
):
72
adc = int(a)
73
elif
o
in
(
"-r"
,
"--run"
):
74
run = int(a)
75
elif
o
in
(
"-l"
,
"--lumi"
):
76
lumi = int(a)
77
elif
o
in
(
"-h"
,
"--help"
):
78
usage
()
79
sys.exit(2)
80
else
:
81
raise
RuntimeError(
"unhandled option"
)
82
83
84
from
TileCalibBlobPython
import
TileCalibCrest
85
from
TileCalibBlobObjs.Classes
import
TileCalibUtils
86
87
from
TileCalibBlobPython.TileCalibLogger
import
getLogger
88
log = getLogger(
"ReadLUT"
)
89
import
logging
90
log.setLevel(logging.DEBUG)
91
92
93
if
tag.upper().endswith(
'HEAD'
):
94
tag=tag.upper()
95
if
len(tag)==0
or
tag.endswith(
'HEAD'
):
96
folderPath=folderPath.replace(
'OFL02'
,
'ONL01'
)
97
log.info(
"tag is %s, using %s folder"
, tag
if
tag
else
'empty'
, folderPath)
98
if
tag==
'HEAD'
:
99
tag=
''
100
101
folderTag = tag
102
tag = tag.upper()
103
tag1 = tag.split(
'_'
)[1][:4]
if
'_'
in
tag
else
tag[:4]
104
if
tag1 ==
"TILE"
or
tag1 ==
"CALO"
or
tag.startswith(
"TILE"
)
or
tag.startswith(
"CALO"
):
105
folderPath=
""
106
if
not
os.path.isfile(schema):
107
log.info(
"Initializing folder %s with tag %s"
, folderPath, folderTag)
108
109
blobReader = TileCalibCrest.TileBlobReaderCrest(schema,folderPath, folderTag, run, lumi)
110
#blobReader.log().setLevel(logging.DEBUG)
111
112
#=== get drawer with status at given run
113
log.info(
"Initializing ros %d, drawer %d for run %d, lumiblock %d"
, ros,drawer,run,lumi)
114
log.info(
"... %s"
, blobReader.getComment((run,lumi)))
115
flt = blobReader.getDrawer(ros, drawer,(run,lumi))
116
maxidx = flt.getObjSizeUint32()
117
log.info(
"Maxidx = %d"
, maxidx )
118
log.info(
"\n"
)
119
120
#=== get float for a given ADC
121
modName =
TileCalibUtils.getDrawerString
(ros,drawer)
122
print
(
"%s ch %i gn %i :"
% ( modName, channel, adc ) )
123
for
idx
in
range(0,maxidx):
124
print
(
" %2d %f"
% (idx, flt.getData(channel, adc, idx) ) )
125
max
#define max(a, b)
Definition
cfImp.cxx:41
TileCalibUtils::getDrawerString
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.
Definition
TileCalibUtils.cxx:145
ReadLUTFromCrest.usage
usage()
Definition
ReadLUTFromCrest.py:14
Generated on
for ATLAS Offline Software by
1.17.0