12os.environ[
'TERM'] =
'linux'
15 print (
"Usage: ",sys.argv[0],
" [OPTION] ... ")
16 print (
"Dump Lumi values from online or offline CALO DB or from sqlite file")
18 print (
"-h, --help shows this help")
19 print (
"-s, --schema= specify schema to use, ONL or OFL for RUN1 or ONL2 or OFL2 for RUN2 or MC")
20 print (
"-S, --server= specify server - ORACLE or FRONTIER, default is FRONTIER")
21 print (
"-d, --dbname= specify the database name e.g. CONDBR2")
22 print (
"-f, --folder= specify folder to use e.g. /CALO/Ofl/Noise/PileUpNoiseLumi")
23 print (
"-t, --tag= specify tag to use, f.i. UPD1 or UPD4 or tag suffix like RUN2-UPD4-04")
24 print (
"-c, --channel= specify COOL channel, by default COOL channels 0 and 1 are used")
25 print (
"-r, --run= specify run number, by default uses latest iov")
26 print (
"-l, --lumi= specify lumi block number, default is 0")
27 print (
"-b, --begin= specify run number of first iov in multi-iov mode, by default uses very first iov")
28 print (
"-e, --end= specify run number of last iov in multi-iov mode, by default uses latest iov")
30letters =
"hS:s:d:t:f:c:r:l:b:e:"
31keywords = [
"help",
"server=",
"schema=",
"dbname=",
"tag=",
"folder=",
"channel=",
"run=",
"lumi=",
"begin=",
"end="]
34 opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
35except getopt.GetoptError
as err:
55 if o
in (
"-s",
"--schema"):
57 elif o
in (
"-S",
"--server"):
59 elif o
in (
"-d",
"--dbname"):
61 elif o
in (
"-f",
"--folder"):
63 elif o
in (
"-t",
"--tag"):
65 elif o
in (
"-c",
"--channel"):
67 elif o
in (
"-r",
"--run"):
69 elif o
in (
"-l",
"--lumi"):
71 elif o
in (
"-b",
"--begin"):
74 elif o
in (
"-e",
"--end"):
77 elif o
in (
"-h",
"--help"):
84from CaloCondBlobAlgs
import CaloCondTools, CaloCondLogger
85from TileCalibBlobPython
import TileCalibTools
88log = CaloCondLogger.getLogger(
"ReadLumi")
90log.setLevel(logging.DEBUG)
95 schema=
'COOLONL_CALO/COMP200'
96 if tag==
'UPD1' or tag==
'UPD4':
99 schema=
'COOLONL_CALO/CONDBR2'
100 if tag==
'UPD1' or tag==
'UPD4':
103 schema=
'COOLOFL_CALO/COMP200'
109 schema=
'COOLOFL_CALO/CONDBR2'
111 schema=
'COOLONL_CALO/OFLP200'
113 tag=
'OFLCOND-RUN12-SDR-07'
114elif schema==
'OFLMC' or schema==
'MC':
115 schema=
'COOLOFL_CALO/OFLP200'
117 tag=
'OFLCOND-MC23-SDR-RUN3-02'
122if os.path.isfile(schema):
123 schema =
'sqlite://;schema='+schema+
';dbname='+dbName
125 log.info(
"File %s was not found, assuming it's full schema string" , schema)
128db = CaloCondTools.openDbConn(schema, server)
130if len(folderPath)==0:
132 folderPath =
'/CALO/Noise/PileUpNoiseLumi'
134 folderPath =
'/CALO/Ofl/Noise/PileUpNoiseLumi'
136folderTag = TileCalibTools.getFolderTag(schema
if 'COMP200' in schema
or 'OFLP200' in schema
else db, folderPath, tag )
138log.info(
"Initializing folder %s with tag %s", folderPath, folderTag)
140folder = db.getFolder(folderPath)
146 blobReader = CaloCondTools.CaloBlobReader(db,folderPath, folderTag)
147 dbobjs = blobReader.getDBobjsWithinRange(0)
149 raise Exception(
"No DB objects retrieved when building IOV list!")
150 while dbobjs.goToNext():
151 obj = dbobjs.currentRef()
152 since = CaloCondTools.runLumiFromIov(obj.since())
153 until = CaloCondTools.runLumiFromIov(obj.until())
154 iovList.append((since, until))
156 log.warning(
"Warning: can not read IOVs from input DB file" )
162 if begin != be
or end != en:
165 for i,iovs
in enumerate(iovList):
168 if (run<begin
and run>be)
or (run==begin
and lumi==0) :
171 if run>=end
and run<en:
176 log.info(
"Changing begin run from %d to %d (start of IOV)", begin,be)
180 log.info(
"Changing end run from %d to %d (start of next IOV)", end,en)
182 log.info(
"Changing end run from %d to %d (start of last IOV)", end,en)
184 iovList=iovList[ib:ie]
185 log.info(
"%d IOVs in total", len(iovList) )
187 iovList.append(((run,lumi),(CaloCondTools.MAXRUN, CaloCondTools.MAXLBK)))
198 pref =
"(%i,%i) " % (iovs[0][0],iovs[0][1])
200 since = CaloCondTools.iovFromRunLumi(iovs[0][0],iovs[0][1])
202 for chan
in channels:
204 obj = folder.findObject( since, chan, folderTag )
206 values += [[obj.payload()[0],obj.payload()[1]]]
211 values += [obj.payload()[0]]
214 log.warning(
"Warning: can not read data from input DB" )
215 if not iov
and obj
is not None:
216 (sinceRun,sinceLum) = CaloCondTools.runLumiFromIov(obj.since())
217 (untilRun,untilLum) = CaloCondTools.runLumiFromIov(obj.until())
218 suff =
" iov since [%d,%d] until (%d,%d)" % (sinceRun,sinceLum,untilRun,untilLum)
220 print(pref1,values[0],suff)
222 print(pref1,values,suff)
void print(char *figname, TCanvas *c1)