ATLAS Offline Software
Loading...
Searching...
No Matches
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
8import getopt,sys,os
9os.environ['TERM'] = 'linux'
10
11def 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
28letters = "hr:l:S:s:t:f:p:d:c:a:g:n:"
29keywords = ["help","run=","lumi=","server=","schema=","tag=","folder=","ros=","drawer=","channel=","adc=","gain=","nval="]
30
31try:
32 opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
33except getopt.GetoptError as err:
34 print (str(err))
35 usage()
36 sys.exit(2)
37
38# defaults
39run = 2147483647
40lumi = 0
41server = ''
42schema = 'COOLOFL_TILE/CONDBR2'
43folderPath = "/TILE/OFL02/CALIB/CIS/LIN"
44tag = "UPD4"
45ros = 1
46drawer = 0
47channel = 0
48adc = 0
49nval = 0
50# note: for MUID there are 40 values stored at every channel 0
51
52for 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
83if 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
88if 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
93if 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
99from TileCalibBlobPython import TileCalibTools
100from TileCalibBlobObjs.Classes import TileCalibUtils
101
102from TileCalibBlobPython.TileCalibLogger import getLogger
103log = getLogger("ReadFloat")
104import logging
105log.setLevel(logging.DEBUG)
106
107
108#=== set database
109db = TileCalibTools.openDbConn(schema,server)
110folderTag = TileCalibTools.getFolderTag(db, folderPath, tag)
111log.info("Initializing folder %s with tag %s", folderPath, folderTag)
112
113#=== initialize blob reader
114blobReader = TileCalibTools.TileBlobReader(db,folderPath, folderTag)
115#blobReader.log().setLevel(logging.DEBUG)
116
117#=== get drawer with status at given run
118log.info("Initializing ros %d, drawer %d for run %d, lumiblock %d", ros,drawer,run,lumi)
119log.info("... %s", blobReader.getComment((run,lumi)))
120log.info( "\n" )
121
122#=== get float for a given ADC
123flt = blobReader.getDrawer(ros, drawer,(run,lumi))
125msg = "%s ch %i gn %i :" % ( modName, channel, adc )
126if nval<1:
127 nval = flt.getObjSizeUint32()
128for val in range(0,nval):
129 msg += " %f" % flt.getData(channel, adc, val)
130print (msg)
131
132#=== close DB
133db.closeDatabase()
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.