ATLAS Offline Software
Loading...
Searching...
No Matches
ReadTripsProbsFromCool.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# ./ReadTripsProbsFromCool.py --schema='COOLOFL_TILE/OFLP200' --folder='OFL02' --tag='UPD4'
6
7import getopt,sys,os
8os.environ['TERM'] = 'linux'
9
10def usage():
11 print ("Usage: ",sys.argv[0]," [OPTION] ... ")
12 print ("Dumps the TileCal drawer trips probabilities from various schemas / folders")
13 print ("")
14 print ("-h, --help shows this help")
15 print ("-f, --folder= specify status folder, by default OFL02 ")
16 print ("-t, --tag= specify tag to use, f.i. UPD1 or UPD4")
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 ("-s, --schema= specify schema to use, like 'COOLOFL_TILE/OFLP200' or 'sqlite://;schema=tileSqlite.db;dbname=OFLP200'")
20 print ("-S, --server= specify server - ORACLE or FRONTIER, default is FRONTIER")
21
22letters = "hr:l:S:s:t:f:"
23keywords = ["help","run=","lumi=","server=","schema=","tag=","folder="]
24
25try:
26 opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
27except getopt.GetoptError as err:
28 print (str(err))
29 usage()
30 sys.exit(2)
31
32# defaults
33run = 2147483647
34lumi = 0
35server = ''
36schema = 'COOLOFL_TILE/OFLP200'
37folderPath = "/TILE/OFL02/STATUS/ADC"
38tag = "SDR-BS8T-10"
39
40for o, a in opts:
41 a = a.strip()
42 if o in ("-f","--folder"):
43 folderPath = "/TILE/%s/STATUS/ADC" % a
44 elif o in ("-t","--tag"):
45 tag = a
46 elif o in ("-S","--server"):
47 server = a
48 elif o in ("-s","--schema"):
49 schema = a
50 elif o in ("-r","--run"):
51 run = int(a)
52 elif o in ("-l","--lumi"):
53 lumi = int(a)
54 elif o in ("-h","--help"):
55 usage()
56 sys.exit(2)
57 else:
58 raise RuntimeError("unhandled option")
59
60
61
62from TileCalibBlobPython import TileCalibTools
63from TileCalibBlobObjs.Classes import TileCalibUtils
64
65from TileCalibBlobPython.TileCalibLogger import getLogger
66log = getLogger("ReadTripsProbs")
67import logging
68logLevel=logging.DEBUG
69log.setLevel(logLevel)
70log1 = getLogger("TileCalibTools")
71log1.setLevel(logLevel)
72
73
74#=== set database
75db = TileCalibTools.openDbConn(schema, server)
76folderTag = TileCalibTools.getFolderTag(db, folderPath, tag)
77log.info("Initializing folder %s with tag %s", folderPath, folderTag)
78
79blobReader = TileCalibTools.TileBlobReader(db, folderPath, folderTag)
80
81import cppyy
82util = cppyy.gbl.TileCalibUtils()
83tripsCalibDrawer = blobReader.getDrawer(util.trips_ros(), util.trips_drawer(), (run,lumi))
84
85if tripsCalibDrawer.getNChans() != util.max_ros() \
86 or tripsCalibDrawer.getObjSizeUint32() != (util.max_drawer() + 1):
87 log.info("There no drawer trips probabilities in tag %s", folderTag)
88 sys.exit(2)
89
90
91print ("")
92print ("Module\tTrip (probability)")
93print ("")
94
95for ros in range(1, util.max_ros()):
96 denominator = tripsCalibDrawer.getData(ros, 0, util.max_drawer())
97 for mod in range(0, min(64, TileCalibUtils.getMaxDrawer(ros))):
99 trip = tripsCalibDrawer.getData(ros, 0, mod)
100 #log.info("%s\t%s" % (modName, str(float(trip)/ denominator)))
101 print ("%s\t%s" % (modName, str(float(trip)/ denominator)))
102
103
104#=== close DB
105db.closeDatabase()
#define min(a, b)
Definition cfImp.cxx:40
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.
static unsigned int getMaxDrawer(unsigned int ros)
Returns the maximal channel number for a given drawer.