ATLAS Offline Software
Loading...
Searching...
No Matches
ReadNoiseFromCrest.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: ReadNoiseFromCrest.py
6# Sanya Solodkov <Sanya.Solodkov@cern.ch>, 2025-12-12
7#
8# Purpose: Read sample noise and non-iterative Opt.Filter noise values for single channel
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 noise from SAMPLE and OFNI folders")
17 print ("")
18 print ("-h, --help shows this help")
19 print ("-t, --tag= specify tag to use, f.i. RUN2-HLT-UPD1-01 or COM-01")
20 print ("-r, --run= specify run number, by default uses latest iov")
21 print ("-l, --lumi= specify lumi block number, default is 0")
22 print ("-p, --ros= specify partition (ros number), default is 1")
23 print ("-d, --drawer= specify drawer number, default is 0")
24 print ("-m, --module= specify module to use, default is LBA01")
25 print ("-c, --chan= specify channel number, default is 0")
26 print ("-g, -a, --adc= specify gain (adc number), default is 0")
27 print ("-s, --schema= specify name of input JSON file or CREST_SERVER_PATH")
28
29letters = "hr:l:s:t:p:d:m:c:a:g:"
30keywords = ["help","run=","lumi=","schema=","tag=","ros=","drawer=","module","chan=","channel=","adc=","gain="]
31
32try:
33 opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
34except getopt.GetoptError as err:
35 print (str(err))
36 usage()
37 sys.exit(2)
38
39# defaults
40run = 2147483647
41lumi = 0
42schema = 'CREST'
43tag = 'HEAD'
44ros = 1
45drawer = 0
46channel = 0
47adc = 0
48
49for o, a in opts:
50 a = a.strip()
51 if o in ("-t","--tag"):
52 tag = a
53 elif o in ("-s","--schema"):
54 schema = a
55 elif o in ("-r","--run"):
56 run = int(a)
57 elif o in ("-l","--lumi"):
58 lumi = int(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 ("-h","--help"):
74 usage()
75 sys.exit(2)
76 else:
77 raise RuntimeError("unhandled option")
78
79
80
81from TileCalibBlobPython import TileCalibCrest
82from TileCalibBlobObjs.Classes import TileCalibUtils
83
84from TileCalibBlobPython.TileCalibLogger import getLogger
85log = getLogger("readNoise")
86import logging
87log.setLevel(logging.DEBUG)
88
89
90folder1="/TILE/ONL01/NOISE/SAMPLE"
91folder2="/TILE/ONL01/NOISE/OFNI"
92log.info("Initializing ros %d, drawer %d for run %d, lumiblock %d", ros,drawer,run,lumi)
93for folderPath in [folder1, folder2]:
94
95 log.info("Initializing folder %s with tag %s", folderPath, tag)
96 blobReader = TileCalibCrest.TileBlobReaderCrest(schema, folderPath, tag, run, lumi)
97 log.info("... %s", blobReader.getComment((run,lumi)))
98 blob = blobReader.getDrawer(ros, drawer,(run,lumi))
99
100 if folderPath.find("SAMPLE")!=-1:
101 ped = blob.getData(channel, adc, 0)
102 hfn = blob.getData(channel, adc, 1)
103 lfn = blob.getData(channel, adc, 2)
104 else:
105 rms = blob.getData(channel, adc, 0)
106 plp = blob.getData(channel, adc, 1)
107
108log.info( "\n" )
109print ( "%s ch %i gn %i : PED = %f HFN = %f LFN = %f OF_RMS = %f PILEUP = %f" %
110 ( TileCalibUtils.getDrawerString(ros,drawer), channel, adc,
111 ped, hfn, lfn, rms, plp) )
#define max(a, b)
Definition cfImp.cxx:41
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.