ATLAS Offline Software
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 
17 from TileCalibBlobPython import TileCalibTools
18 from TileCalibBlobPython import TileBchTools
19 from TileCalibBlobObjs.Classes import TileBchPrbs, TileBchDecoder, \
20  TileCalibUtils
21 
22 from TileCalibBlobPython.TileCalibLogger import getLogger
23 import logging
24 log = getLogger("writeBch")
25 log.setLevel(logging.DEBUG)
26 
27 #=== ADC status folder
28 folder = "/TILE/OFL02/STATUS/ADC"
29 tag = "clean"
30 instance="OFLP200"
31 
32 #.. Parsing arguments
33 
34 import sys
35 ros=int(sys.argv[1])
36 mod=int(sys.argv[2])
37 run=int(sys.argv[3])
38 lum=int(sys.argv[4])
39 since=(run,lum)
40 run1=int(sys.argv[5])
41 lum1=int(sys.argv[6])
42 until=(run1,lum1)
43 comment=sys.argv[7]
44 
45 #.. very basic input validation
46 if ros<1 or ros>4:
47  raise Exception("Invalid ros=%i" % ros)
48 if mod<0 or mod>63:
49  raise Exception("Invalid module=%i" % mod)
50 if run1<run:
51  raise Exception("Invalid validity range: %i < %i" % (run1,run))
52 log.info("ros=%i mod=%i since=%s until=%s comment=%s", ros,mod,since,until,comment)
53 
54 #===================================================================
55 #====================== FILL DB BELOW ==============================
56 #===================================================================
57 db = TileCalibTools.openDb('SQLITE', 'OFLP200', 'UPDATE')
58 
59 #=== specify folder and tag
60 folderTag = TileCalibUtils.getFullTag(folder, tag )
61 
62 #=== create bad channel manager
63 mgr = TileBchTools.TileBchMgr()
64 mgr.setLogLvl(logging.DEBUG)
65 
66 #=== initialize bch mgr with conditions from DB
67 log.info("Initializing with conditions from tag=%s and time=%s", folderTag, since)
68 mgr.initialize(db, folder, folderTag, since)
69 
70 #=== Tuples of empty channels
71 emptyChannelLongBarrel = (30, 31, 43)
72 emptyChannelExtendedBarrel = (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 
75 log.info("bad channels before update")
76 mgr.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 
87 for 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
94 log.info("bad channels after update")
95 mgr.listBadAdcs()
96 
97 #=== commit changes
98 mgr.commitToDb(db, folder, folderTag, TileBchDecoder.BitPat_ofl01, "Guilherme", comment, since, until)
99 
100 #=== close DB
101 db.closeDatabase()
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
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