checkFeASICSettings.py
1 
from sys import argv 

2  
3 
script, filename = argv 
4  
5 
txt = open(filename)

6  
7 
#print "Here's your file %r:" % filename

8 
#print txt.read()

9  
10 
for line in txt: 
11 
if line.find('FeAsicSpi') != 1: 
12 
num = line[22:]

13 
num = int(num[:3]) 
14 

15 
for x in range(0, 4): 
16  
17 
#skip end of ASIC spots

18 
if num == 8 and ( x == 1 or x == 3): 
19 
continue

20 
if num == 16 and ( x == 0 or x == 2): 
21 
continue

22 
if num == 25 and ( x == 1 or x == 3): 
23 
continue

24 
if num == 33 and ( x == 0 or x == 2): 
25 
continue

26  
27 
asicStr = 'Err'

28 
chan = 1

29 
if num >= 0 and num < 8 : 
30 
if( x < 2 ): 
31 
asicStr = 'ASIC 7'

32 
if( x >= 2 ): 
33 
asicStr = 'ASIC 3'

34 
chan = 15  2*num + x % 2  1 
35 
if num >= 8 and num < 17 : 
36 
if( x < 2 ): 
37 
asicStr = 'ASIC 6'

38 
if( x >= 2 ): 
39 
asicStr = 'ASIC 2'

40 
chan = 15  2*(num  8) + x % 2 
41 
if num >= 17 and num < 25 : 
42 
if( x < 2 ): 
43 
asicStr = 'ASIC 5'

44 
if( x >= 2 ): 
45 
asicStr = 'ASIC 1'

46 
chan = 15  2*(num  17) + x % 2  1 
47 
if num >= 25 and num < 34 : 
48 
if( x < 2 ): 
49 
asicStr = 'ASIC 4'

50 
if( x >= 2 ): 
51 
asicStr = 'ASIC 0'

52 
chan = 15  2*(num  26) + x % 2 2 
53  
54 
base = 28 + 2*x 
55 
spiStr = line[base:base+2]

56 
#spiStr = line[30:32]

57 
#spiStr = line[32:34]

58 
#spiStr = line[34:36]

59 
spi = int(spiStr, 16) 
60 
gain = (spi & 0x30) >> 4 
61 
gainStr = 'Err'

62 
if gain == 0: 
63 
gainStr = '4.7mV/fC'

64 
if gain == 2: 
65 
gainStr = '7.8mV/fC'

66 
if gain == 1: 
67 
gainStr = '14mV/fC'

68 
if gain == 3: 
69 
gainStr = '25mV/fC'

70 
shape = (spi & 0x0C) >> 2 
71 
shapeStr = 'Err'

72 
if shape == 2: 
73 
shapeStr ='0.5us'

74 
if shape == 0: 
75 
shapeStr ='1us'

76 
if shape == 3: 
77 
shapeStr = '2us'

78 
if shape == 1: 
79 
shapeStr ='3us'

80 
#print line

81 
print "%s, Channel %d, %s, %s" %(asicStr, chan, gainStr, shapeStr) 