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