Attachment 'sortConstantsMar2018.py'
Download 1 def sortConstantsMar2018():
2 #define mapping:
3 #modules, that were also used in feb tb will not be used again, thus their value is set to -1000
4 layerToModule = [{1:22,2:26,3:23,4:24,5:25,6:5,7:14,8:15,9:32,10:40},{1:-1000,2:-1000,3:30,4:36,5:37},{1:18,2:28,3:31,4:38,5:39},{1:-1000,2:27,3:29,4:33,5:34}]
5
6 #define input and output files
7 workfile=["dbstyle_gain_2018Mar_batch1_2.txt","dbstyle_gain_2018Mar_batch3.txt","dbstyle_gain_2018Mar_batch4.txt","dbstyle_gain_2018Mar_batch6.txt","db_mip_Mar2018_batch1_2.txt","db_mip_Mar2018_batch3.txt","db_mip_Mar2018_batch4.txt","db_mip_Mar2018_batch6.txt","DB_Pedestal_Mar2018_batch1_2.txt","DB_Pedestal_Mar2018_batch3.txt","DB_Pedestal_Mar2018_batch4.txt","DB_Pedestal_Mar2018_batch6.txt"]
8 outfile=["gainSorted_1_2.txt","gainSorted_3.txt","gainSorted_4.txt","gainSorted_6.txt","mipSorted_1_2.txt","mipSorted_3.txt","mipSorted_4.txt","mipSorted_6.txt","pedestalSorted_1_2.txt","pedestalSorted_3.txt","pedestalSorted_4.txt","pedestalSorted_6.txt"]
9
10
11 for n in range (0,3):
12 for nn in range (0,4):
13 f = open(workfile[n*4+nn], 'r')
14 out = open(outfile[n*4+nn], 'w')
15
16 #search for legend and print it to output file
17 for line in f:
18 if line.startswith('#Layer') or line.startswith('#Module'):
19 out.write(line)
20
21 else:
22 read = line.split()
23 #substitute layer number with module number
24 read[0]=layerToModule[nn][int(read[0])]
25
26 #write values to output file
27 str1 = ' '.join(str(item) for item in read)
28 out.write(str(str1))
29 out.write("\n")
30
31 sortConstantsMar2018()
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.