ATLAS Offline Software
Loading...
Searching...
No Matches
convertBadChannels.py
Go to the documentation of this file.
1#!/usr/bin/env python
2import sys
3
4
5#
6#__________________________________________________________________
7def dec2hex(n):
8 return ("0%X" % n)[-2:]
9
10
11#
12#__________________________________________________________________
13modToFrag = {'LBA' : '0x1',
14 'LBC' : '0x2',
15 'EBA' : '0x3',
16 'EBC' : '0x4'}
17
18inFile = sys.argv[1]
19
20buf = ""
21
22lines = open(inFile,"r").readlines()
23for line in lines:
24 field = line.split(":")
25 if not len(field): continue
26 module = field[0][:3]
27 modNum = int(field[0][3:]) - 1
28 chan = int(field[1])
29 type = field[2].strip()
30
31 hexModule = modToFrag[module] + dec2hex(modNum)
32
33 lhstat = ""
34 if type=="L": lhstat = "1\t0"
35 elif type=="H": lhstat = "0\t1"
36 elif type=="B": lhstat = "1\t1"
37 else:
38 raise("unkown type \"%s\""%type)
39
40 buf = buf + "Bch\t%s\t%s\t%s\n" % (hexModule,chan,lhstat)
41
42print buf
43
44bchFile = open("Tile2007.bch","w")
45bchFile.write(buf)
46bchFile.close()