ATLAS Offline Software
Loading...
Searching...
No Matches
TileCalibBlobPython_Ofl_Onl.py
Go to the documentation of this file.
1#!/bin/env python
2
3# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4#
5# TileCalibBlobPython_Ofl_Onl.py
6# Lukas Pribyl
7# This Python script needs sqlite file with default (empty) ONL01 and OFL02 folders
8# Script of this kind is generated by DQ Leader Web tool
9# What it does: offline problems are set, online problems are set and finally the ONL01 folder is synchronized with OFL02
10
11from TileCalibBlobPython import TileCalibTools
12from TileCalibBlobPython import TileBchTools
13from TileCalibBlobObjs.Classes import TileCalibUtils, TileBchDecoder, \
14 TileBchPrbs
15
16from TileCalibBlobPython.TileCalibLogger import getLogger
17log = getLogger("writeBch")
18import logging
19log.setLevel(logging.DEBUG)
20
21#===================================================================
22#====================== FILL DB BELOW ==============================
23#===================================================================
24db = TileCalibTools.openDb('SQLITE', 'CONDBR2', 'UPDATE')
25
26#=== ADC status folder
27folder = TileCalibTools.getTilePrefix(True,True) + "STATUS/ADC"
28
29#=== specify folder and tag
30folderTag = TileCalibUtils.getFullTag(folder, "RUN2-HLT-UPD1-00")
31
32#=== create bad channel manager
33mgr = TileBchTools.TileBchMgr()
34mgr.setLogLvl(logging.DEBUG)
35
36#=== always initialize with no bad channels
37log.info("Initializing with no bad channels at tag=%s and time=%s", folderTag, (0, 0))
38mgr.initialize(db, folder, folderTag, (0, 0))
39
40#=== Tuples of empty channels
41emptyChannelLongBarrel = (30, 31, 43)
42emptyChannelExtendedBarrel = (18, 19, 24, 25, 26, 27, 28, 29, 33, 34, 42, 43, 44, 45, 46, 47)
43#=== Add problems with mgr.addAdcProblem(ros, drawer, channel, adc, problem)
44
45# LBA
46# attention! mgr.addAdcProblem() is just an example
47mgr.addAdcProblem(1, 0, 23, 0, TileBchPrbs.BadCis)
48mgr.addAdcProblem(1, 1, 20, 0, TileBchPrbs.GeneralMaskAdc)
49
50# LBC
51
52# EBA
53
54# EBC
55
56#=== print bad channels
57log.info("bad channels after update")
58mgr.listBadAdcs()
59
60#=== commit changes
61mgr.commitToDb(db, folder, folderTag, TileBchDecoder.BitPat_ofl01, "lpribyl", "test offline", (151950, 0))
62
63#=== ONLINE FOLDER WITH SYNCHRONIZATION
64#=== ADC status folder
65folder = TileCalibTools.getTilePrefix(False) + "STATUS/ADC"
66
67#=== specify folder and tag
68folderTag = ""
69
70#=== create bad channel manager
71mgrOnl = TileBchTools.TileBchMgr()
72mgrOnl.setLogLvl(logging.DEBUG)
73
74#=== always initialize with no bad channels
75log.info("Initializing with no bad channels at tag=%s and time=%s", folderTag, (0, 0))
76mgrOnl.initialize(db, folder, folderTag, (0, 0))
77
78#=== Add problems with mgrOnl.addAdcProblem(ros, drawer, channel, adc, problem)
79
80# LBA
81# attention! mgrOnl.addAdcProblem() is just an example
82mgrOnl.addAdcProblem(1, 1, 33, 1, TileBchPrbs.IgnoredInDsp)
83mgrOnl.addAdcProblem(1, 1, 33, 0, TileBchPrbs.IgnoredInDsp)
84
85# LBC
86
87# EBA
88
89# EBC
90
91#--- synchronization with offline folder
92for ros in range(1, 5):
93 for mod in range(0, 64):
94 for chn in range(0, 48):
95 statlo = mgr.getAdcStatus(ros, mod, chn, 0)
96 stathi = mgr.getAdcStatus(ros, mod, chn, 1)
97
98 #--- add IgnoreInHlt if either of the ADCs has isBad
99 #--- add OnlineGeneralMaskAdc if the ADCs has isBad
100 if statlo.isBad() and stathi.isBad():
101 mgrOnl.addAdcProblem(ros, mod, chn, 0, TileBchPrbs.IgnoredInHlt)
102 mgrOnl.addAdcProblem(ros, mod, chn, 0, TileBchPrbs.OnlineGeneralMaskAdc)
103 mgrOnl.addAdcProblem(ros, mod, chn, 1, TileBchPrbs.IgnoredInHlt)
104 mgrOnl.addAdcProblem(ros, mod, chn, 1, TileBchPrbs.OnlineGeneralMaskAdc)
105 elif statlo.isBad():
106 mgrOnl.addAdcProblem(ros, mod, chn, 0, TileBchPrbs.IgnoredInHlt)
107 mgrOnl.addAdcProblem(ros, mod, chn, 0, TileBchPrbs.OnlineGeneralMaskAdc)
108 mgrOnl.addAdcProblem(ros, mod, chn, 1, TileBchPrbs.IgnoredInHlt)
109 mgrOnl.delAdcProblem(ros, mod, chn, 1, TileBchPrbs.OnlineGeneralMaskAdc)
110 elif stathi.isBad():
111 mgrOnl.addAdcProblem(ros, mod, chn, 0, TileBchPrbs.IgnoredInHlt)
112 mgrOnl.delAdcProblem(ros, mod, chn, 0, TileBchPrbs.OnlineGeneralMaskAdc)
113 mgrOnl.addAdcProblem(ros, mod, chn, 1, TileBchPrbs.IgnoredInHlt)
114 mgrOnl.addAdcProblem(ros, mod, chn, 1, TileBchPrbs.OnlineGeneralMaskAdc)
115 else:
116 #--- delete IgnoreInHlt and OnlineGeneralMaskAdc if both ADCs are not Bad
117 mgrOnl.delAdcProblem(ros, mod, chn, 0, TileBchPrbs.IgnoredInHlt)
118 mgrOnl.delAdcProblem(ros, mod, chn, 0, TileBchPrbs.OnlineGeneralMaskAdc)
119 mgrOnl.delAdcProblem(ros, mod, chn, 1, TileBchPrbs.IgnoredInHlt)
120 mgrOnl.delAdcProblem(ros, mod, chn, 1, TileBchPrbs.OnlineGeneralMaskAdc)
121
122 #--- add OnlineWrongBCID if either of the ADCs has isWrongBCID
123 if statlo.isWrongBCID() or stathi.isWrongBCID():
124 mgrOnl.addAdcProblem(ros, mod, chn, 0, TileBchPrbs.OnlineWrongBCID)
125 mgrOnl.addAdcProblem(ros, mod, chn, 1, TileBchPrbs.OnlineWrongBCID)
126 else:
127 #--- delete OnlineWrongBCID if the both ADCs has not isWrongBCID
128 mgrOnl.delAdcProblem(ros, mod, chn, 0, TileBchPrbs.OnlineWrongBCID)
129 mgrOnl.delAdcProblem(ros, mod, chn, 1, TileBchPrbs.OnlineWrongBCID)
130
131 #--- add OnlineBadTiming if either of the ADCs has isBadTiming
132 if statlo.isBadTiming() or stathi.isBadTiming():
133 mgrOnl.addAdcProblem(ros, mod, chn, 0, TileBchPrbs.OnlineBadTiming)
134 mgrOnl.addAdcProblem(ros, mod, chn, 1, TileBchPrbs.OnlineBadTiming)
135 else:
136 #--- delete OnlineBadTiming if the both ADCs has not isBadTiming
137 mgrOnl.delAdcProblem(ros, mod, chn, 0, TileBchPrbs.OnlineBadTiming)
138 mgrOnl.delAdcProblem(ros, mod, chn, 1, TileBchPrbs.OnlineBadTiming)
139
140 #--- add OnlineTimingDmuBcOffsetPos if either of the ADCs has isTimingDmuBcOffsetPos
141 if statlo.isTimingDmuBcOffsetPos() or stathi.isTimingDmuBcOffsetPos():
142 mgrOnl.addAdcProblem(ros, mod, chn, 0, TileBchPrbs.OnlineTimingDmuBcOffsetPos)
143 mgrOnl.addAdcProblem(ros, mod, chn, 1, TileBchPrbs.OnlineTimingDmuBcOffsetPos)
144 else:
145 #--- delete OnlineTimingDmuBcOffsetPos if the both ADCs has not isTimingDmuBcOffsetPos
146 mgrOnl.delAdcProblem(ros, mod, chn, 0, TileBchPrbs.OnlineTimingDmuBcOffsetPos)
147 mgrOnl.delAdcProblem(ros, mod, chn, 1, TileBchPrbs.OnlineTimingDmuBcOffsetPos)
148
149 #--- add OnlineTimingDmuBcOffsetNeg if either of the ADCs has isTimingDmuBcOffsetNeg
150 if statlo.isTimingDmuBcOffsetNeg() or stathi.isTimingDmuBcOffsetNeg():
151 mgrOnl.addAdcProblem(ros, mod, chn, 0, TileBchPrbs.OnlineTimingDmuBcOffsetNeg)
152 mgrOnl.addAdcProblem(ros, mod, chn, 1, TileBchPrbs.OnlineTimingDmuBcOffsetNeg)
153 else:
154 #--- delete OnlineTimingDmuBcOffsetNeg if the both ADCs has not isTimingDmuBcOffsetNeg
155 mgrOnl.delAdcProblem(ros, mod, chn, 0, TileBchPrbs.OnlineTimingDmuBcOffsetNeg)
156 mgrOnl.delAdcProblem(ros, mod, chn, 1, TileBchPrbs.OnlineTimingDmuBcOffsetNeg)
157
158log.info("============================")
159log.info("ONL01 and OFL02 synchronized")
160log.info("============================")
161
162
163#=== print bad channels
164log.info("bad channels after update")
165mgrOnl.listBadAdcs()
166
167#=== commit changes
168mgrOnl.commitToDb(db, folder, folderTag, TileBchDecoder.BitPat_onl01, "lpribyl", "test online", (151950,0))
169
170#=== close DB
171db.closeDatabase()
static std::string getFullTag(const std::string &folder, const std::string &tag)
Returns the full tag string, composed of camelized folder name and tag part.