ATLAS Offline Software
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 
7 import getopt,sys,os
8 os.environ['TERM'] = 'linux'
9 
10 def 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 
22 letters = "hr:l:S:s:t:f:"
23 keywords = ["help","run=","lumi=","server=","schema=","tag=","folder="]
24 
25 try:
26  opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
27 except getopt.GetoptError as err:
28  print (str(err))
29  usage()
30  sys.exit(2)
31 
32 # defaults
33 run = 2147483647
34 lumi = 0
35 server = ''
36 schema = 'COOLOFL_TILE/OFLP200'
37 folderPath = "/TILE/OFL02/STATUS/ADC"
38 tag = "SDR-BS8T-10"
39 
40 for 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 
62 from TileCalibBlobPython import TileCalibTools
63 from TileCalibBlobObjs.Classes import TileCalibUtils
64 
65 from TileCalibBlobPython.TileCalibLogger import getLogger
66 log = getLogger("ReadTripsProbs")
67 import logging
68 logLevel=logging.DEBUG
69 log.setLevel(logLevel)
70 log1 = getLogger("TileCalibTools")
71 log1.setLevel(logLevel)
72 
73 
74 #=== set database
75 db = TileCalibTools.openDbConn(schema, server)
76 folderTag = TileCalibTools.getFolderTag(db, folderPath, tag)
77 log.info("Initializing folder %s with tag %s", folderPath, folderTag)
78 
79 blobReader = TileCalibTools.TileBlobReader(db, folderPath, folderTag)
80 
81 import cppyy
82 util = cppyy.gbl.TileCalibUtils()
83 tripsCalibDrawer = blobReader.getDrawer(util.trips_ros(), util.trips_drawer(), (run,lumi))
84 
85 if 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 
91 print ("")
92 print ("Module\tTrip (probability)")
93 print ("")
94 
95 for 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))):
98  modName = TileCalibUtils.getDrawerString(ros, mod)
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
105 db.closeDatabase()
TileCalibUtils::getMaxDrawer
static unsigned int getMaxDrawer(unsigned int ros)
Returns the maximal channel number for a given drawer.
Definition: TileCalibUtils.cxx:136
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
TileCalibUtils::getDrawerString
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.
Definition: TileCalibUtils.cxx:145
str
Definition: BTagTrackIpAccessor.cxx:11
readCCLHist.float
float
Definition: readCCLHist.py:83
ReadTripsProbsFromCool.usage
def usage()
Definition: ReadTripsProbsFromCool.py:10
python.CaloCondLogger.getLogger
def getLogger(name="CaloCond")
Definition: CaloCondLogger.py:16