ATLAS Offline Software
Loading...
Searching...
No Matches
ReadNoiseFromCool.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# ReadNoiseFromCool.py
6# Lukas Pribyl <lukas.pribyl@cern.ch>, 2008-08-05
7
8import getopt,sys,os
9os.environ['TERM'] = 'linux'
10
11def usage():
12 print ("Usage: ",sys.argv[0]," [OPTION] ... ")
13 print ("Dumps the TileCal noise from SAMPLE and OFNI folders")
14 print ("")
15 print ("-h, --help shows this help")
16 print ("-t, --tag= specify tag to use, f.i. RUN2-HLT-UPD1-01 or COM-01")
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 ("-p, --ros= specify partition (ros number), default is 1")
20 print ("-d, --drawer= specify drawer number, default is 0")
21 print ("-c, --channel= specify channel number, default is 0")
22 print ("-g, -a, --adc= specify gain (adc number), default is 0")
23 print ("-s, --schema= specify schema to use, like 'COOLONL_TILE/CONDBR2' or 'sqlite://;schema=tileSqlite.db;dbname=CONDBR2'")
24 print ("-S, --server= specify server - ORACLE or FRONTIER, default is FRONTIER")
25
26letters = "hr:l:S:s:t:p:d:c:a:g:"
27keywords = ["help","run=","lumi=","server=","schema=","tag=","ros=","drawer=","channel=","adc=","gain="]
28
29try:
30 opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
31except getopt.GetoptError as err:
32 print (str(err))
33 usage()
34 sys.exit(2)
35
36# defaults
37run = 2147483647
38lumi = 0
39server = ''
40schema = 'COOLONL_TILE/CONDBR2'
41tag = "HLT-UPD1-01" # tag is needed only for COMP200, ignored in CONDBR2
42ros = 1
43drawer = 0
44channel = 0
45adc = 0
46
47for o, a in opts:
48 a = a.strip()
49 if o in ("-t","--tag"):
50 tag = a
51 elif o in ("-S","--server"):
52 server = 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 ("-p","--ros"):
60 ros = int(a)
61 elif o in ("-d","--drawer"):
62 drawer = int(a)
63 elif o in ("-c","--channel"):
64 channel = int(a)
65 elif o in ("-a","--adc","-g","--gain"):
66 adc = int(a)
67 elif o in ("-h","--help"):
68 usage()
69 sys.exit(2)
70 else:
71 raise RuntimeError("unhandled option")
72
73
74if 'COOLONL_TILE' not in schema and 'sqlite' not in schema:
75 print ("This script works on the 'COOLONL_TILE/COMP200' or 'COOLONL_TILE/CONDBR2' schema" )
76 sys.exit(2)
77
78
79from TileCalibBlobPython import TileCalibTools
80from TileCalibBlobObjs.Classes import TileCalibUtils
81
82from TileCalibBlobPython.TileCalibLogger import getLogger
83log = getLogger("readNoise")
84import logging
85log.setLevel(logging.DEBUG)
86
87
88#=== set database
89db = TileCalibTools.openDbConn(schema,server)
90
91folder1="/TILE/ONL01/NOISE/SAMPLE"
92folder2="/TILE/ONL01/NOISE/OFNI"
93if 'COMP200' in schema:
94 folder1="/TILE/OFL01/NOISE/SAMPLE"
95log.info("Initializing ros %d, drawer %d for run %d, lumiblock %d", ros,drawer,run,lumi)
96for folderPath in [folder1, folder2]:
97
98 folderTag = TileCalibTools.getFolderTag(db, folderPath, tag)
99 log.info("Initializing folder %s with tag %s", folderPath, folderTag)
100 blobReader = TileCalibTools.TileBlobReader(db,folderPath, folderTag)
101 log.info("... %s", blobReader.getComment((run,lumi)))
102 blob = blobReader.getDrawer(ros, drawer,(run,lumi))
103
104 if folderPath.find("SAMPLE")!=-1:
105 ped = blob.getData(channel, adc, 0)
106 hfn = blob.getData(channel, adc, 1)
107 lfn = blob.getData(channel, adc, 2)
108 else:
109 rms = blob.getData(channel, adc, 0)
110 plp = blob.getData(channel, adc, 1)
111
112log.info( "\n" )
113print ( "%s ch %i gn %i : PED = %f HFN = %f LFN = %f OF_RMS = %f PILEUP = %f" %
114 ( TileCalibUtils.getDrawerString(ros,drawer), channel, adc,
115 ped, hfn, lfn, rms, plp) )
116
117#=== close DB
118db.closeDatabase()
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.