ATLAS Offline Software
Loading...
Searching...
No Matches
ReadOfcFromCrest.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: ReadOfcFromCrest.py
6# Sanya Solodkov <Sanya.Solodkov@cern.ch>, 2025-12-12
7#
8# Purpose: Read Opt.Filter weights for single channel (all phases)
9#
10
11
12import getopt,sys,os
13os.environ['TERM'] = 'linux'
14
15def usage():
16 print ("Usage: ",sys.argv[0]," [OPTION] ... ")
17 print ("Dumps the TileCal OFC values various schemas / folders / tags")
18 print ("")
19 print ("-h, --help shows this help")
20 print ("-f, --folder= specify status folder to use CIS, LAS, PHY ")
21 print ("-t, --tag= specify tag to use, f.i. UPD1 or UPD4 or full suffix like RUN2-HLT-UPD1-00")
22 print ("-r, --run= specify run number, by default uses latest iov")
23 print ("-l, --lumi= specify lumi block number, default is 0")
24 print ("-p, --ros= specify partition (ros number), default is 1")
25 print ("-d, --drawer= specify drawer number, default is 0")
26 print ("-m, --module= specify module to use, default is LBA01")
27 print ("-c, --chan= specify channel number, default is 0")
28 print ("-g, -a, --adc= specify gain (adc number), default is 0")
29 print ("-i, --field= specify field number, default is 0")
30 print ("-s, --schema= specify name of input JSON file or CREST_SERVER_PATH")
31
32letters = "hr:l:s:t:f:p:d:m:c:a:g:i:"
33keywords = ["help","run=","lumi=","schema=","tag=","folder=","ros=","drawer=","module=","chan=","channel=","adc=","gain=","field="]
34
35try:
36 opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
37except getopt.GetoptError as err:
38 print (str(err))
39 usage()
40 sys.exit(2)
41
42# defaults
43run = 2147483647
44lumi = 0
45schema = 'CREST'
46folderPath = "/TILE/ONL01/FILTER/OF2/PHY"
47tag = ""
48ros = 1
49drawer = 0
50channel = 0
51adc = 0
52field = 0
53
54for o, a in opts:
55 a = a.strip()
56 if o in ("-f","--folder"):
57 if a.startswith("/TILE"):
58 folderPath = a
59 elif a.startswith("OF"):
60 folderPath = "/TILE/ONL01/FILTER/%s" % a
61 else:
62 folderPath = "/TILE/ONL01/FILTER/OF2/%s" % a
63 elif o in ("-t","--tag"):
64 tag = a
65 elif o in ("-s","--schema"):
66 schema = a
67 elif o in ("-m","--module"):
68 partname = a[:3]
69 part_dict = {'AUX':0,'LBA':1,'LBC':2,'EBA':3,'EBC':4}
70 if partname in part_dict:
71 ros = part_dict[partname]
72 drawer = max(int(a[3:])-1,0)
73 elif o in ("-p","--ros"):
74 ros = int(a)
75 elif o in ("-d","--drawer"):
76 drawer = int(a)
77 elif o in ("-c","--chan","--channel"):
78 channel = int(a)
79 elif o in ("-a","--adc","-g","--gain"):
80 adc = int(a)
81 elif o in ("-i","--field"):
82 field = int(a)
83 elif o in ("-r","--run"):
84 run = int(a)
85 elif o in ("-l","--lumi"):
86 lumi = int(a)
87 elif o in ("-h","--help"):
88 usage()
89 sys.exit(2)
90 else:
91 raise RuntimeError("unhandled option")
92
93
94from TileCalibBlobPython import TileCalibCrest
95from TileCalibBlobObjs.Classes import TileCalibUtils
96
97from TileCalibBlobPython.TileCalibLogger import getLogger
98log = getLogger("ReadOfc")
99import logging
100log.setLevel(logging.DEBUG)
101
102
103if tag.upper().endswith('HEAD'):
104 tag=tag.upper()
105if len(tag)==0 or tag.endswith('HEAD'):
106 folderPath=folderPath.replace('OFL02','ONL01')
107 log.info("tag is %s, using %s folder", tag if tag else 'empty', folderPath)
108 if tag=='HEAD':
109 tag=''
110
111folderTag = tag
112if folderTag.upper().startswith("TILE") :
113 folderPath=""
114log.info("Initializing folder %s with tag %s", folderPath, folderTag)
115
116blobReader = TileCalibCrest.TileBlobReaderCrest(schema,folderPath, folderTag, run, lumi)
117#blobReader.log().setLevel(logging.DEBUG)
118
119#=== get drawer with status at given run
120log.info("Initializing ros %d, drawer %d for run %d, lumiblock %d", ros,drawer,run,lumi)
121log.info("... %s", blobReader.getComment((run,lumi)))
122ofc = blobReader.getDrawer(ros, drawer,(run,lumi))
123
124#=== get other OFC parameters
125nchann = ofc.getNChans()
126nfields = ofc.getNFields()
127nsamples = ofc.getNSamples()
128nphases = ofc.getNPhases()
129log.info( "" )
130log.info( "nchann = %d", nchann )
131log.info( "nfields = %d", nfields )
132log.info( "nphases = %d", nphases )
133log.info( "nsamples = %d", nsamples)
134log.info( "" )
135log.info( "OFC for %s channel %d adc %d field %d\n", TileCalibUtils.getDrawerString(ros,drawer),channel,adc,field)
136
137#=== get OFC field for given adc, sample and phase
138for iphase in range(abs(nphases)):
139 phase = ofc.getPhase(channel, adc, iphase)
140 msg = "phase %6.1f ns :" % phase
141 for smp in range(0, nsamples):
142 msg += " %f" % ofc.getOfc(field, channel, adc, phase, smp)
143 print (msg)
#define max(a, b)
Definition cfImp.cxx:41
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.