ATLAS Offline Software
Loading...
Searching...
No Matches
convertTimingResiduals.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#__________________________________________________________________
13def pmt2channel_LB(pmtOrChannel):
14 """
15 This function converts channel to pmt or pmt to channel number.
16 Valid for Barrel only!
17 """
18
19 pmtOrChannel = int(pmtOrChannel)
20 channelOrPmt = pmtOrChannel;
21
22 # pmt==channel for pmt 0 - 23
23 # pmt 24 - 47: reverse in groups of 3
24 if pmtOrChannel>23:
25 mod = pmtOrChannel%3
26 if mod==0: channelOrPmt = pmtOrChannel+2
27 elif mod==2: channelOrPmt = pmtOrChannel-2
28 else : pass
29 return channelOrPmt
30
31
32#
33#__________________________________________________________________
34modToFrag = {'LBA' : '0x1',
35 'LBC' : '0x2',
36 'EBA' : '0x3',
37 'EBC' : '0x4'}
38
39inFile = sys.argv[1]
40
41tdlas = ""
42tclas = ""
43
44lines = open(inFile,"r").readlines()
45for line in lines:
46 field = line.split()
47 if not len(field): continue
48 module = field[0][:3]
49 modNum = int(field[0][3:]) - 1
50 drawerOffset = float(field[1])
51 chanOffsets = field[2:]
52 hexModule = modToFrag[module] + dec2hex(modNum)
53
54 #=== some sanity checks
55 sum=0.
56 for chan in xrange(6):
57 add = float(chanOffsets[chan])
58 sum += add
59 print "%s ---> Found %i channels, sum of first 6 is %f" % ( field[0] , len(chanOffsets) , sum )
60
61
62 #====================================================
63 #=== fill tdlas (channel is always 0)
64 #====================================================
65 tdlas = tdlas+ "Tdlas\t%s\t0\t%s\n" % (hexModule,drawerOffset)
66
67 #====================================================
68 #=== fill tclas
69 #====================================================
70 for chan in xrange(48):
71 offset = chanOffsets[chan]
72 tclas = tclas+"Tclas\t%s\t%i\t%s\t%s\n" % (hexModule,chan,offset,offset)
73
74tdlasFile = open("Tile.tdlas","w")
75tdlasFile.write(tdlas)
76tdlasFile.close()
77
78tclasFile = open("Tile.tclas","w")
79tclasFile.write(tclas)
80tclasFile.close()
81
82
83# print "---------------TDLAS--------------------------"
84# print tdlas
85# print "---------------TDLAS--------------------------"
86# print "---------------TCLAS--------------------------"
87# print tclas
88# print "---------------TCLAS--------------------------"
void xrange(TH1 *h, bool symmetric)