ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileCalib
TileCalibBlobPython
scripts
ReadLumiFromCrest.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: ReadLumiFromCrest.py
6
# Sanya Solodkov <Sanya.Solodkov@cern.ch>, 2025-12-12
7
#
8
# Purpose: Read lumi values from CALO*PileUpNoiseLumi* tags
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
(
"Dump Lumi values from online or offline CALO DB or from sqlite file"
)
17
print
(
""
)
18
print
(
"-h, --help shows this help"
)
19
print
(
"-s, --schema= specify name of input JSON file or CREST_SERVER_PATH"
)
20
print
(
"-f, --folder= specify folder to use e.g. /CALO/Ofl/Noise/PileUpNoiseLumi"
)
21
print
(
"-t, --tag= specify tag to use, f.i. UPD1 or UPD4 or tag suffix like RUN2-UPD4-04"
)
22
print
(
"-c, --channel= specify COOL channel, by default COOL channels 0 and 1 are used"
)
23
print
(
"-r, --run= specify run number, by default uses latest iov"
)
24
print
(
"-l, --lumi= specify lumi block number, default is 0"
)
25
print
(
"-b, --begin= specify run number of first iov in multi-iov mode, by default uses very first iov"
)
26
print
(
"-e, --end= specify run number of last iov in multi-iov mode, by default uses latest iov"
)
27
28
letters =
"hs:t:f:c:r:l:b:e:"
29
keywords = [
"help"
,
"schema="
,
"tag="
,
"folder="
,
"channel="
,
"run="
,
"lumi="
,
"begin="
,
"end="
]
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
schema =
'CREST'
42
#folderPath = '/CALO/Noise/PileUpNoiseLumi'
43
folderPath =
'/CALO/Ofl/Noise/PileUpNoiseLumi'
44
dbName =
'CONDBR2'
45
tag =
'UPD4'
46
begin = 0
47
end = 2147483647
48
iov =
False
49
channels = [0,1]
50
51
for
o, a
in
opts:
52
a = a.strip()
53
if
o
in
(
"-s"
,
"--schema"
):
54
schema = a
55
elif
o
in
(
"-f"
,
"--folder"
):
56
folderPath = a
57
elif
o
in
(
"-t"
,
"--tag"
):
58
tag = a
59
elif
o
in
(
"-c"
,
"--channel"
):
60
channels = [int(a)]
61
elif
o
in
(
"-r"
,
"--run"
):
62
run = int(a)
63
elif
o
in
(
"-l"
,
"--lumi"
):
64
lumi = int(a)
65
elif
o
in
(
"-b"
,
"--begin"
):
66
begin = int(a)
67
iov =
True
68
elif
o
in
(
"-e"
,
"--end"
):
69
end = int(a)
70
iov =
True
71
elif
o
in
(
"-h"
,
"--help"
):
72
usage
()
73
sys.exit(2)
74
else
:
75
usage
()
76
sys.exit(2)
77
78
from
TileCalibBlobPython
import
TileCalibCrest
79
from
TileCalibBlobPython.TileCalibLogger
import
getLogger
80
81
#=== get a logger
82
log = getLogger(
"ReadLumi"
)
83
import
logging
84
log.setLevel(logging.DEBUG)
85
86
#=== Initialize blob reader
87
folderTag = tag
88
tag = tag.upper()
89
tag1 = tag.split(
'_'
)[1][:4]
if
'_'
in
tag
else
tag[:4]
90
if
tag1 ==
"CALO"
or
tag.startswith(
"CALO"
):
91
folderPath=
""
92
if
not
os.path.isfile(schema):
93
log.info(
"Initializing folder %s with tag %s"
, folderPath, folderTag)
94
blobReader = TileCalibCrest.TileBlobReaderCrest(schema, folderPath, folderTag, run, lumi, channels[0], channels[-1],
True
)
95
96
#=== Filling the iovList
97
iovList = []
98
if
iov:
99
iovList = blobReader.getIovs((begin,0),(end,0))
100
be=iovList[0][0]
101
en=iovList[-1][0]
102
103
if
begin != be
or
end != en:
104
log.info(
""
)
105
if
be != begin:
106
log.info(
"Changing begin run from %d to %d (start of IOV)"
, begin,be)
107
begin=be
108
if
en != end:
109
if
en>end:
110
log.info(
"Changing end run from %d to %d (start of next IOV)"
, end,en)
111
else
:
112
log.info(
"Changing end run from %d to %d (start of last IOV)"
, end,en)
113
end=en
114
log.info(
"%d IOVs in total"
, len(iovList) )
115
else
:
116
iovList.append((run,lumi))
117
118
log.info(
"\n"
)
119
120
#=== loop over all iovs
121
obj =
None
122
pref =
""
123
pref1 =
""
124
suff =
""
125
for
iovs
in
iovList:
126
if
iov:
127
pref =
"(%i,%i) "
% (iovs[0],iovs[1])
128
pref1 = pref
129
values = []
130
try
:
131
obj = blobReader.getPayload(iovs,
False
)
132
for
chan
in
channels:
133
values += [obj[str(chan)]]
134
pref1 = pref+
"lumi"
135
except
Exception:
136
obj =
None
137
log.warning(
"Warning: can not read data from input DB"
)
138
if
not
iov
and
obj
is
not
None
:
139
io = blobReader.getIov()
140
(sinceRun,sinceLum) = (io[0][0],io[0][1])
141
(untilRun,untilLum) = (io[1][0],io[1][1])
142
suff =
" iov since [%d,%d] until (%d,%d)"
% (sinceRun,sinceLum,untilRun,untilLum)
143
if
len(values)==1:
144
print
(pref1,values[0],suff)
145
else
:
146
print
(pref1,values,suff)
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
ReadLumiFromCrest.usage
usage()
Definition
ReadLumiFromCrest.py:14
Generated on
for ATLAS Offline Software by
1.17.0