ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileCalib
TileCalibBlobPython
share
ReadFloatFromCool.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
# ReadFloatFromCool.py
6
# Lukas Pribyl <lukas.pribyl@cern.ch>, 2008-11-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 constants from various schemas / folders / tags"
)
14
print
(
""
)
15
print
(
"-h, --help shows this help"
)
16
print
(
"-f, --folder= specify status folder to use f.i. /TILE/OFL02/CALIB/CIS/LIN "
)
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
(
"-n, --nval= specify number of values to output, default is all"
)
25
print
(
"-s, --schema= specify schema to use, like 'COOLOFL_TILE/CONDBR2' or 'sqlite://;schema=tileSqlite.db;dbname=CONDBR2'"
)
26
print
(
"-S, --server= specify server - ORACLE or FRONTIER, default is FRONTIER"
)
27
28
letters =
"hr:l:S:s:t:f:p:d:c:a:g:n:"
29
keywords = [
"help"
,
"run="
,
"lumi="
,
"server="
,
"schema="
,
"tag="
,
"folder="
,
"ros="
,
"drawer="
,
"channel="
,
"adc="
,
"gain="
,
"nval="
]
30
31
try
:
32
opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
33
except
getopt.GetoptError
as
err:
34
print
(str(err))
35
usage
()
36
sys.exit(2)
37
38
# defaults
39
run = 2147483647
40
lumi = 0
41
server =
''
42
schema =
'COOLOFL_TILE/CONDBR2'
43
folderPath =
"/TILE/OFL02/CALIB/CIS/LIN"
44
tag =
"UPD4"
45
ros = 1
46
drawer = 0
47
channel = 0
48
adc = 0
49
nval = 0
50
# note: for MUID there are 40 values stored at every channel 0
51
52
for
o, a
in
opts:
53
a = a.strip()
54
if
o
in
(
"-f"
,
"--folder"
):
55
folderPath = a
56
elif
o
in
(
"-t"
,
"--tag"
):
57
tag = a
58
elif
o
in
(
"-S"
,
"--server"
):
59
server = a
60
elif
o
in
(
"-s"
,
"--schema"
):
61
schema = a
62
elif
o
in
(
"-p"
,
"--ros"
):
63
ros = int(a)
64
elif
o
in
(
"-d"
,
"--drawer"
):
65
drawer = int(a)
66
elif
o
in
(
"-c"
,
"--channel"
):
67
channel = int(a)
68
elif
o
in
(
"-a"
,
"--adc"
,
"-g"
,
"--gain"
):
69
adc = int(a)
70
elif
o
in
(
"-n"
,
"--nval"
):
71
nval = int(a)
72
elif
o
in
(
"-r"
,
"--run"
):
73
run = int(a)
74
elif
o
in
(
"-l"
,
"--lumi"
):
75
lumi = int(a)
76
elif
o
in
(
"-h"
,
"--help"
):
77
usage
()
78
sys.exit(2)
79
else
:
80
raise
RuntimeError(
"unhandled option"
)
81
82
83
if
schema==
'COOLONL_TILE/COMP200'
:
84
if
'/TILE/ONL01'
not
in
folderPath
and
'/TILE/OFL01'
not
in
folderPath:
85
print
(
"Folder %s doesn't exist in schema %s "
% (folderPath,schema) )
86
sys.exit(2)
87
88
if
schema==
'COOLONL_TILE/CONDBR2'
:
89
if
'/TILE/ONL01'
not
in
folderPath:
90
print
(
"Folder %s doesn't exist in schema %s "
% (folderPath,schema) )
91
sys.exit(2)
92
93
if
schema==
'COOLOFL_TILE/COMP200'
or
schema==
'COOLOFL_TILE/CONDBR2'
:
94
if
'/TILE/OFL02'
not
in
folderPath:
95
print
(
"Folder %s doesn't exist in schema %s "
% (folderPath,schema) )
96
sys.exit(2)
97
98
99
from
TileCalibBlobPython
import
TileCalibTools
100
from
TileCalibBlobObjs.Classes
import
TileCalibUtils
101
102
from
TileCalibBlobPython.TileCalibLogger
import
getLogger
103
log = getLogger(
"ReadFloat"
)
104
import
logging
105
log.setLevel(logging.DEBUG)
106
107
108
#=== set database
109
db = TileCalibTools.openDbConn(schema,server)
110
folderTag = TileCalibTools.getFolderTag(db, folderPath, tag)
111
log.info(
"Initializing folder %s with tag %s"
, folderPath, folderTag)
112
113
#=== initialize blob reader
114
blobReader = TileCalibTools.TileBlobReader(db,folderPath, folderTag)
115
#blobReader.log().setLevel(logging.DEBUG)
116
117
#=== get drawer with status at given run
118
log.info(
"Initializing ros %d, drawer %d for run %d, lumiblock %d"
, ros,drawer,run,lumi)
119
log.info(
"... %s"
, blobReader.getComment((run,lumi)))
120
log.info(
"\n"
)
121
122
#=== get float for a given ADC
123
flt = blobReader.getDrawer(ros, drawer,(run,lumi))
124
modName =
TileCalibUtils.getDrawerString
(ros,drawer)
125
msg =
"%s ch %i gn %i :"
% ( modName, channel, adc )
126
if
nval<1:
127
nval = flt.getObjSizeUint32()
128
for
val
in
range(0,nval):
129
msg +=
" %f"
% flt.getData(channel, adc, val)
130
print
(msg)
131
132
#=== close DB
133
db.closeDatabase()
TileCalibUtils::getDrawerString
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.
Definition
TileCalibUtils.cxx:145
ReadFloatFromCool.usage
usage()
Definition
ReadFloatFromCool.py:11
Generated on
for ATLAS Offline Software by
1.17.0