ATLAS Offline Software
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 
8 import getopt,sys,os
9 os.environ['TERM'] = 'linux'
10 
11 def 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 
26 letters = "hr:l:S:s:t:p:d:c:a:g:"
27 keywords = ["help","run=","lumi=","server=","schema=","tag=","ros=","drawer=","channel=","adc=","gain="]
28 
29 try:
30  opts, extraparams = getopt.getopt(sys.argv[1:],letters,keywords)
31 except getopt.GetoptError as err:
32  print (str(err))
33  usage()
34  sys.exit(2)
35 
36 # defaults
37 run = 2147483647
38 lumi = 0
39 server = ''
40 schema = 'COOLONL_TILE/CONDBR2'
41 tag = "HLT-UPD1-01" # tag is needed only for COMP200, ignored in CONDBR2
42 ros = 1
43 drawer = 0
44 channel = 0
45 adc = 0
46 
47 for 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 
74 if '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 
79 from TileCalibBlobPython import TileCalibTools
80 from TileCalibBlobObjs.Classes import TileCalibUtils
81 
82 from TileCalibBlobPython.TileCalibLogger import getLogger
83 log = getLogger("readNoise")
84 import logging
85 log.setLevel(logging.DEBUG)
86 
87 
88 #=== set database
89 db = TileCalibTools.openDbConn(schema,server)
90 
91 folder1="/TILE/ONL01/NOISE/SAMPLE"
92 folder2="/TILE/ONL01/NOISE/OFNI"
93 if 'COMP200' in schema:
94  folder1="/TILE/OFL01/NOISE/SAMPLE"
95 log.info("Initializing ros %d, drawer %d for run %d, lumiblock %d", ros,drawer,run,lumi)
96 for 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 
112 log.info( "\n" )
113 print ( "%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
118 db.closeDatabase()
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ReadNoiseFromCool.usage
def usage()
Definition: ReadNoiseFromCool.py:11
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
python.CaloCondLogger.getLogger
def getLogger(name="CaloCond")
Definition: CaloCondLogger.py:16