ATLAS Offline Software
Loading...
Searching...
No Matches
ReadOfcFromCool.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# ReadOfcFromCool.py
6# Lukas Pribyl <lukas.pribyl@cern.ch>, 2008-07-25
7
8import getopt,sys,os
9os.environ['TERM'] = 'linux'
10
11def usage():
12 print ("Usage: ",sys.argv[0]," [OPTION] ... ")
13 print ("Dumps the TileCal OFC values various schemas / folders / tags")
14 print ("")
15 print ("-h, --help shows this help")
16 print ("-f, --folder= specify status folder to use CIS, LAS, PHY ")
17 print ("-r, --run= specify run number, by default uses latest iov")
18 print ("-l, --lumi= specify lumi block number, default is 0")
19 print ("-p, --ros= specify partition (ros number), default is 1")
20 print ("-d, --drawer= specify drawer number, default is 0")
21 print ("-c, --channel= specify channel number, default is 0")
22 print ("-g, -a, --adc= specify gain (adc number), default is 0")
23 print ("-i, --field= specify field number, default is 0")
24 print ("-s, --schema= specify schema to use, like 'COOLONL_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:i:"
28keywords = ["help","run=","lumi=","server=","schema=","tag=","folder=","ros=","drawer=","channel=","adc=","gain=","field="]
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 = 'COOLONL_TILE/CONDBR2'
42folderPath = "/TILE/ONL01/FILTER/OF2/PHY"
43tag = ""
44ros = 1
45drawer = 0
46channel = 0
47adc = 0
48field = 0
49
50for o, a in opts:
51 a = a.strip()
52 if o in ("-f","--folder"):
53 if a.startswith("/TILE"):
54 folderPath = a
55 elif a.startswith("OF"):
56 folderPath = "/TILE/ONL01/FILTER/%s" % a
57 else:
58 folderPath = "/TILE/ONL01/FILTER/OF2/%s" % a
59 elif o in ("-t","--tag"):
60 tag = a
61 elif o in ("-S","--server"):
62 server = a
63 elif o in ("-s","--schema"):
64 schema = a
65 elif o in ("-p","--ros"):
66 ros = int(a)
67 elif o in ("-d","--drawer"):
68 drawer = int(a)
69 elif o in ("-c","--channel"):
70 channel = int(a)
71 elif o in ("-a","--adc","-g","--gain"):
72 adc = int(a)
73 elif o in ("-i","--field"):
74 field = int(a)
75 elif o in ("-r","--run"):
76 run = int(a)
77 elif o in ("-l","--lumi"):
78 lumi = int(a)
79 elif o in ("-h","--help"):
80 usage()
81 sys.exit(2)
82 else:
83 raise RuntimeError("unhandled option")
84
85
86from TileCalibBlobPython import TileCalibTools
87from TileCalibBlobObjs.Classes import TileCalibUtils
88
89from TileCalibBlobPython.TileCalibLogger import getLogger
90log = getLogger("ReadOfc")
91import logging
92log.setLevel(logging.DEBUG)
93
94
95#=== set database
96db = TileCalibTools.openDbConn(schema,server)
97folderTag = TileCalibTools.getFolderTag(schema if 'COMP200' in schema or 'OFLP200' in schema else db, folderPath, tag)
98
99#=== required OF2 folder
100if len(tag)>0:
101 log.info("Initializing folder %s with tag %s", folderPath, folderTag)
102else:
103 log.info("Initializing folder %s", folderPath)
104blobReader = TileCalibTools.TileBlobReader(db,folderPath, folderTag)
105#blobReader.log().setLevel(logging.DEBUG)
106
107#=== get drawer with status at given run
108log.info("Initializing ros %d, drawer %d for run %d, lumiblock %d", ros,drawer,run,lumi)
109log.info("... %s", blobReader.getComment((run,lumi)))
110ofc = blobReader.getDrawer(ros, drawer,(run,lumi))
111
112#=== get other OFC parameters
113nchann = ofc.getNChans()
114nfields = ofc.getNFields()
115nsamples = ofc.getNSamples()
116nphases = ofc.getNPhases()
117log.info( "" )
118log.info( "nchann = %d", nchann )
119log.info( "nfields = %d", nfields )
120log.info( "nphases = %d", nphases )
121log.info( "nsamples = %d", nsamples)
122log.info( "" )
123log.info( "OFC for %s channel %d adc %d field %d\n", TileCalibUtils.getDrawerString(ros,drawer),channel,adc,field)
124
125#=== get OFC field for given adc, sample and phase
126for iphase in range(abs(nphases)):
127 phase = ofc.getPhase(channel, adc, iphase)
128 msg = "phase %6.1f ns :" % phase
129 for smp in range(0, nsamples):
130 msg += " %f" % ofc.getOfc(field, channel, adc, phase, smp)
131 print (msg)
132
133#=== close DB
134db.closeDatabase()
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.