ATLAS Offline Software
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 
11 from TileCalibBlobPython import TileCalibTools
12 from TileCalibBlobPython import TileBchTools
13 from TileCalibBlobObjs.Classes import TileCalibUtils, TileBchDecoder, \
14  TileBchPrbs
15 
16 from TileCalibBlobPython.TileCalibLogger import getLogger
17 log = getLogger("writeBch")
18 import logging
19 log.setLevel(logging.DEBUG)
20 
21 #===================================================================
22 #====================== FILL DB BELOW ==============================
23 #===================================================================
24 db = TileCalibTools.openDb('SQLITE', 'CONDBR2', 'UPDATE')
25 
26 #=== ADC status folder
27 folder = TileCalibTools.getTilePrefix(True,True) + "STATUS/ADC"
28 
29 #=== specify folder and tag
30 folderTag = TileCalibUtils.getFullTag(folder, "RUN2-HLT-UPD1-00")
31 
32 #=== create bad channel manager
33 mgr = TileBchTools.TileBchMgr()
34 mgr.setLogLvl(logging.DEBUG)
35 
36 #=== always initialize with no bad channels
37 log.info("Initializing with no bad channels at tag=%s and time=%s", folderTag, (0, 0))
38 mgr.initialize(db, folder, folderTag, (0, 0))
39 
40 #=== Tuples of empty channels
41 emptyChannelLongBarrel = (30, 31, 43)
42 emptyChannelExtendedBarrel = (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
47 mgr.addAdcProblem(1, 0, 23, 0, TileBchPrbs.BadCis)
48 mgr.addAdcProblem(1, 1, 20, 0, TileBchPrbs.GeneralMaskAdc)
49 
50 # LBC
51 
52 # EBA
53 
54 # EBC
55 
56 #=== print bad channels
57 log.info("bad channels after update")
58 mgr.listBadAdcs()
59 
60 #=== commit changes
61 mgr.commitToDb(db, folder, folderTag, TileBchDecoder.BitPat_ofl01, "lpribyl", "test offline", (151950, 0))
62 
63 #=== ONLINE FOLDER WITH SYNCHRONIZATION
64 #=== ADC status folder
65 folder = TileCalibTools.getTilePrefix(False) + "STATUS/ADC"
66 
67 #=== specify folder and tag
68 folderTag = ""
69 
70 #=== create bad channel manager
71 mgrOnl = TileBchTools.TileBchMgr()
72 mgrOnl.setLogLvl(logging.DEBUG)
73 
74 #=== always initialize with no bad channels
75 log.info("Initializing with no bad channels at tag=%s and time=%s", folderTag, (0, 0))
76 mgrOnl.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
82 mgrOnl.addAdcProblem(1, 1, 33, 1, TileBchPrbs.IgnoredInDsp)
83 mgrOnl.addAdcProblem(1, 1, 33, 0, TileBchPrbs.IgnoredInDsp)
84 
85 # LBC
86 
87 # EBA
88 
89 # EBC
90 
91 #--- synchronization with offline folder
92 for 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 
158 log.info("============================")
159 log.info("ONL01 and OFL02 synchronized")
160 log.info("============================")
161 
162 
163 #=== print bad channels
164 log.info("bad channels after update")
165 mgrOnl.listBadAdcs()
166 
167 #=== commit changes
168 mgrOnl.commitToDb(db, folder, folderTag, TileBchDecoder.BitPat_onl01, "lpribyl", "test online", (151950,0))
169 
170 #=== close DB
171 db.closeDatabase()
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.CaloCondLogger.getLogger
def getLogger(name="CaloCond")
Definition: CaloCondLogger.py:16
TileCalibUtils::getFullTag
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.
Definition: TileCalibUtils.cxx:33