ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileCalib
TileCalibBlobPython
share
ReadLUTFromCool.py
Go to the documentation of this file.
1
#!/bin/env python
2
3
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4
#
5
# ReadLUTFromCool.py
6
# Lukas Pribyl <lukas.pribyl@cern.ch>, 2010-03-18
7
8
import
getopt,sys,os
9
os.environ[
'TERM'
] =
'linux'
10
11
def
usage
():
12
print
(
"Usage: "
,sys.argv[0],
" [OPTION] ... "
)
13
print
(
"Dumps the TileCal CIS/NLN from various schemas / folders / tags"
)
14
print
(
""
)
15
print
(
"-h, --help shows this help"
)
16
print
(
"-f, --folder= specify status folder to use ONL01 or OFL02 "
)
17
print
(
"-t, --tag= specify tag to use, f.i. UPD1 or UPD4 or full suffix like RUN2-HLT-UPD1-00"
)
18
print
(
"-r, --run= specify run number, by default uses latest iov"
)
19
print
(
"-l, --lumi= specify lumi block number, default is 0"
)
20
print
(
"-p, --ros= specify partition (ros number), default is 1"
)
21
print
(
"-d, --drawer= specify drawer number, default is 0"
)
22
print
(
"-c, --channel= specify channel number, default is 0"
)
23
print
(
"-g, -a, --adc= specify gain (adc number), default is 0"
)
24
print
(
"-s, --schema= specify schema to use, like 'COOLOFL_TILE/CONDBR2' or 'sqlite://;schema=tileSqlite.db;dbname=CONDBR2'"
)
25
print
(
"-S, --server= specify server - ORACLE or FRONTIER, default is FRONTIER"
)
26
27
letters =
"hr:l:S:s:t:f:p:d:c:a:g:"
28
keywords = [
"help"
,
"run="
,
"lumi="
,
"server="
,
"schema="
,
"tag="
,
"folder="
,
"ros="
,
"drawer="
,
"channel="
,
"adc="
,
"gain="
]
29
30
try
:
31
opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
32
except
getopt.GetoptError
as
err:
33
print
(str(err))
34
usage
()
35
sys.exit(2)
36
37
# defaults
38
run = 2147483647
39
lumi = 0
40
server =
''
41
schema =
'COOLOFL_TILE/CONDBR2'
42
folderPath =
"/TILE/OFL02/CALIB/CIS/NLN"
43
tag =
"UPD4"
44
ros = 1
45
drawer = 0
46
channel = 0
47
adc = 0
48
49
for
o, a
in
opts:
50
a = a.strip()
51
if
o
in
(
"-f"
,
"--folder"
):
52
folderPath =
"/TILE/%s/CALIB/CIS/NLN"
% a
53
elif
o
in
(
"-t"
,
"--tag"
):
54
tag = a
55
elif
o
in
(
"-S"
,
"--server"
):
56
server = a
57
elif
o
in
(
"-s"
,
"--schema"
):
58
schema = a
59
elif
o
in
(
"-p"
,
"--ros"
):
60
ros = int(a)
61
elif
o
in
(
"-d"
,
"--drawer"
):
62
drawer = int(a)
63
elif
o
in
(
"-c"
,
"--channel"
):
64
channel = int(a)
65
elif
o
in
(
"-a"
,
"--adc"
,
"-g"
,
"--gain"
):
66
adc = int(a)
67
elif
o
in
(
"-r"
,
"--run"
):
68
run = int(a)
69
elif
o
in
(
"-l"
,
"--lumi"
):
70
lumi = int(a)
71
elif
o
in
(
"-h"
,
"--help"
):
72
usage
()
73
sys.exit(2)
74
else
:
75
raise
RuntimeError(
"unhandled option"
)
76
77
78
if
schema==
'COOLONL_TILE/COMP200'
:
79
if
'/TILE/ONL01'
not
in
folderPath
and
'/TILE/OFL01'
not
in
folderPath:
80
print
(
"Folder %s doesn't exist in schema %s "
% (folderPath,schema) )
81
sys.exit(2)
82
83
if
schema==
'COOLONL_TILE/CONDBR2'
:
84
if
'/TILE/ONL01'
not
in
folderPath:
85
print
(
"Folder %s doesn't exist in schema %s "
% (folderPath,schema) )
86
sys.exit(2)
87
88
if
schema==
'COOLOFL_TILE/COMP200'
or
schema==
'COOLOFL_TILE/CONDBR2'
:
89
if
'/TILE/OFL02'
not
in
folderPath:
90
print
(
"Folder %s doesn't exist in schema %s "
% (folderPath,schema) )
91
sys.exit(2)
92
93
94
from
TileCalibBlobPython
import
TileCalibTools
95
from
TileCalibBlobObjs.Classes
import
TileCalibUtils
96
97
from
TileCalibBlobPython.TileCalibLogger
import
getLogger
98
log = getLogger(
"ReadLUT"
)
99
import
logging
100
log.setLevel(logging.DEBUG)
101
102
103
#=== set database
104
db = TileCalibTools.openDbConn(schema,server)
105
folderTag = TileCalibTools.getFolderTag(db, folderPath, tag)
106
log.info(
"Initializing folder %s with tag %s"
, folderPath, folderTag)
107
108
#=== initialize blob reader
109
blobReader = TileCalibTools.TileBlobReader(db,folderPath, folderTag)
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
126
#=== close DB
127
db.closeDatabase()
TileCalibUtils::getDrawerString
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.
Definition
TileCalibUtils.cxx:145
ReadLUTFromCool.usage
usage()
Definition
ReadLUTFromCool.py:11
Generated on
for ATLAS Offline Software by
1.17.0