ATLAS Offline Software
Loading...
Searching...
No Matches
ReadLUTFromCrest.py
Go to the documentation of this file.
1#!/bin/env python
2
3# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4#
5# File: ReadLUTFromCrest.py
6# Sanya Solodkov <Sanya.Solodkov@cern.ch>, 2025-12-12
7#
8# Purpose: Read Look-up tables for non-linear CIS and Laser corrections
9#
10
11import getopt,sys,os
12os.environ['TERM'] = 'linux'
13
14def usage():
15 print ("Usage: ",sys.argv[0]," [OPTION] ... ")
16 print ("Dumps the TileCal CIS/NLN from various schemas / folders / tags")
17 print ("")
18 print ("-h, --help shows this help")
19 print ("-f, --folder= specify status folder to use f.i. /TILE/OFL02/CALIB/CIS/NLN ")
20 print ("-t, --tag= specify tag to use, f.i. UPD1 or UPD4 or full suffix like RUN2-HLT-UPD1-00")
21 print ("-r, --run= specify run number, by default uses latest iov")
22 print ("-l, --lumi= specify lumi block number, default is 0")
23 print ("-p, --ros= specify partition (ros number), default is 1")
24 print ("-d, --drawer= specify drawer number, default is 0")
25 print ("-m, --module= specify module to use, default is LBA01")
26 print ("-c, --chan= specify channel number, default is 0")
27 print ("-g, -a, --adc= specify gain (adc number), default is 0")
28 print ("-s, --schema= specify name of input JSON file or CREST_SERVER_PATH")
29
30letters = "hr:l:s:t:f:p:d:m:c:a:g:"
31keywords = ["help","run=","lumi=","schema=","tag=","folder=","ros=","drawer=","module=","chan=","channel=","adc=","gain="]
32
33try:
34 opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
35except getopt.GetoptError as err:
36 print (str(err))
37 usage()
38 sys.exit(2)
39
40# defaults
41run = 2147483647
42lumi = 0
43schema = 'CREST'
44folderPath = "/TILE/OFL02/CALIB/CIS/NLN"
45tag = "UPD4"
46ros = 1
47drawer = 0
48channel = 0
49adc = 0
50
51for o, a in opts:
52 a = a.strip()
53 if o in ("-f","--folder"):
54 folderPath = a
55 elif o in ("-t","--tag"):
56 tag = a
57 elif o in ("-s","--schema"):
58 schema = a
59 elif o in ("-m","--module"):
60 partname = a[:3]
61 part_dict = {'AUX':0,'LBA':1,'LBC':2,'EBA':3,'EBC':4}
62 if partname in part_dict:
63 ros = part_dict[partname]
64 drawer = max(int(a[3:])-1,0)
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","--chan","--channel"):
70 channel = int(a)
71 elif o in ("-a","--adc","-g","--gain"):
72 adc = int(a)
73 elif o in ("-r","--run"):
74 run = int(a)
75 elif o in ("-l","--lumi"):
76 lumi = int(a)
77 elif o in ("-h","--help"):
78 usage()
79 sys.exit(2)
80 else:
81 raise RuntimeError("unhandled option")
82
83
84from TileCalibBlobPython import TileCalibCrest
85from TileCalibBlobObjs.Classes import TileCalibUtils
86
87from TileCalibBlobPython.TileCalibLogger import getLogger
88log = getLogger("ReadLUT")
89import logging
90log.setLevel(logging.DEBUG)
91
92
93if tag.upper().endswith('HEAD'):
94 tag=tag.upper()
95if len(tag)==0 or tag.endswith('HEAD'):
96 folderPath=folderPath.replace('OFL02','ONL01')
97 log.info("tag is %s, using %s folder", tag if tag else 'empty', folderPath)
98 if tag=='HEAD':
99 tag=''
100
101folderTag = tag
102if folderTag.upper().startswith("TILE") :
103 folderPath=""
104log.info("Initializing folder %s with tag %s", folderPath, folderTag)
105
106blobReader = TileCalibCrest.TileBlobReaderCrest(schema,folderPath, folderTag, run, lumi)
107#blobReader.log().setLevel(logging.DEBUG)
108
109#=== get drawer with status at given run
110log.info("Initializing ros %d, drawer %d for run %d, lumiblock %d", ros,drawer,run,lumi)
111log.info("... %s", blobReader.getComment((run,lumi)))
112flt = blobReader.getDrawer(ros, drawer,(run,lumi))
113maxidx = flt.getObjSizeUint32()
114log.info( "Maxidx = %d", maxidx )
115log.info( "\n" )
116
117#=== get float for a given ADC
119print ( "%s ch %i gn %i :" % ( modName, channel, adc ) )
120for idx in range(0,maxidx):
121 print ( " %2d %f" % (idx, flt.getData(channel, adc, idx) ) )
122
#define max(a, b)
Definition cfImp.cxx:41
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.