ATLAS Offline Software
Loading...
Searching...
No Matches
maskDeadModules.py
Go to the documentation of this file.
1#!/bin/env python
2
3# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4#
5# File: maskDeadModules.py
6# Purpose: Mask a dead module over a range. A new IOV gets created in the process.
7#
8# The script takes conditions from reference tag in tileSqlite.db, and
9# masks all channels in a (dead) module. The module to be masked is
10# provided by the first 2 arguments: ros (=1-4), mod (0-63). Next
11# four arguments are run,lum for IOV's "since", and run,lum for IOV's
12# "until", defining the IOV for the masked module. Last argument is
13# the comment to be added.
14#
15# 2013-09-11 Guilherme Lima - Adapted code received from Tibor
16
17from TileCalibBlobPython import TileCalibTools
18from TileCalibBlobPython import TileBchTools
19from TileCalibBlobObjs.Classes import TileBchPrbs, TileBchDecoder, \
20 TileCalibUtils
21
22from TileCalibBlobPython.TileCalibLogger import getLogger
23import logging
24log = getLogger("writeBch")
25log.setLevel(logging.DEBUG)
26
27#=== ADC status folder
28folder = "/TILE/OFL02/STATUS/ADC"
29tag = "clean"
30instance="OFLP200"
31
32#.. Parsing arguments
33
34import sys
35ros=int(sys.argv[1])
36mod=int(sys.argv[2])
37run=int(sys.argv[3])
38lum=int(sys.argv[4])
39since=(run,lum)
40run1=int(sys.argv[5])
41lum1=int(sys.argv[6])
42until=(run1,lum1)
43comment=sys.argv[7]
44
45#.. very basic input validation
46if ros<1 or ros>4:
47 raise Exception("Invalid ros=%i" % ros)
48if mod<0 or mod>63:
49 raise Exception("Invalid module=%i" % mod)
50if run1<run:
51 raise Exception("Invalid validity range: %i < %i" % (run1,run))
52log.info("ros=%i mod=%i since=%s until=%s comment=%s", ros,mod,since,until,comment)
53
54#===================================================================
55#====================== FILL DB BELOW ==============================
56#===================================================================
57db = TileCalibTools.openDb('SQLITE', 'OFLP200', 'UPDATE')
58
59#=== specify folder and tag
60folderTag = TileCalibUtils.getFullTag(folder, tag )
61
62#=== create bad channel manager
63mgr = TileBchTools.TileBchMgr()
64mgr.setLogLvl(logging.DEBUG)
65
66#=== initialize bch mgr with conditions from DB
67log.info("Initializing with conditions from tag=%s and time=%s", folderTag, since)
68mgr.initialize(db, folder, folderTag, since)
69
70#=== Tuples of empty channels
71emptyChannelLongBarrel = (30, 31, 43)
72emptyChannelExtendedBarrel = (18, 19, 24, 25, 26, 27, 28, 29, 33, 34, 42, 43, 44, 45, 46, 47)
73#=== Add problems with mgr.addAdcProblem(ros, drawer, channel, adc, problem)
74
75log.info("bad channels before update")
76mgr.listBadAdcs()
77
78
79
80#.. loop over channels to be updated
81#for adc in range(0,2):
82# for mod in range(38, 42) + range(54, 58):
83# #.. apply updates
84# mgr.delAdcProblem(3, mod, 4, adc, TileBchPrbs.GeneralMaskChannel)
85# mgr.delAdcProblem(4, mod, 4, adc, TileBchPrbs.GeneralMaskChannel)
86
87for ichan in range(0,48):
88 if (ros<3 and ichan not in emptyChannelLongBarrel) or (ros>2 and ichan not in emptyChannelExtendedBarrel):
89 log.info("Masking channel %i off", ichan)
90 mgr.addAdcProblem( ros, mod, ichan, 0, TileBchPrbs.NoHV)
91 mgr.addAdcProblem( ros, mod, ichan, 1, TileBchPrbs.NoHV)
92
93#=== print bad channels
94log.info("bad channels after update")
95mgr.listBadAdcs()
96
97#=== commit changes
98mgr.commitToDb(db, folder, folderTag, TileBchDecoder.BitPat_ofl01, "Guilherme", comment, since, until)
99
100#=== close DB
101db.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.