ATLAS Offline Software
convertTimingResiduals.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import sys
3 
4 
5 #
6 #__________________________________________________________________
7 def dec2hex(n):
8  return ("0%X" % n)[-2:]
9 
10 
11 #
12 #__________________________________________________________________
13 def 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 #__________________________________________________________________
34 modToFrag = {'LBA' : '0x1',
35  'LBC' : '0x2',
36  'EBA' : '0x3',
37  'EBC' : '0x4'}
38 
39 inFile = sys.argv[1]
40 
41 tdlas = ""
42 tclas = ""
43 
44 lines = open(inFile,"r").readlines()
45 for 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 
74 tdlasFile = open("Tile.tdlas","w")
75 tdlasFile.write(tdlas)
76 tdlasFile.close()
77 
78 tclasFile = open("Tile.tclas","w")
79 tclasFile.write(tclas)
80 tclasFile.close()
81 
82 
83 # print "---------------TDLAS--------------------------"
84 # print tdlas
85 # print "---------------TDLAS--------------------------"
86 # print "---------------TCLAS--------------------------"
87 # print tclas
88 # print "---------------TCLAS--------------------------"
xrange
void xrange(TH1 *h, bool symmetric)
Definition: computils.cxx:515
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
convertTimingResiduals.dec2hex
def dec2hex(n)
Definition: convertTimingResiduals.py:7
convertTimingResiduals.pmt2channel_LB
def pmt2channel_LB(pmtOrChannel)
Definition: convertTimingResiduals.py:13
Trk::open
@ open
Definition: BinningType.h:40
readCCLHist.float
float
Definition: readCCLHist.py:83