-
Notifications
You must be signed in to change notification settings - Fork 0
/
runDlumi.py
executable file
·46 lines (40 loc) · 1.5 KB
/
runDlumi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python2
import sys
import subprocess as sp
import os
runD_firstRunNumber=256630
def createRunDjson(originalFileName):
with open(originalFileName) as forig:
jsonContent=forig.read()
# remove all newlines and spaces
jsonContent=jsonContent.replace("\n","")
jsonContent=jsonContent.replace(" ","")
jsonContent=jsonContent[1:-1] # remove {}
# build a list with one element for each run number
runNumberLines=[]
for rnl in jsonContent.split(',"'):
runNumberLines.append(rnl)
# first one still starts with a "
runNumberLines[0]=runNumberLines[0][1:]
# find selected lines
selLines=[]
for rnl in runNumberLines:
# print rnl
rn=int(rnl.split('"')[0])
if rn >= runD_firstRunNumber:
selLines.append('"'+rnl)
# write selection to a files
outFileName=originalFileName.split("/")[-1].split(".")[0]
outFileName+="_runD_only.txt"
fsel = open(outFileName,'w')
fsel.write('{\n')
fsel.write(",\n".join(selLines))
fsel.write('\n}\n')
fsel.close()
return outFileName
if __name__ == '__main__':
originalFileName=sys.argv[1]
selectedFile=createRunDjson(originalFileName)
normtagFile="/afs/cern.ch/user/l/lumipro/public/normtag_file/moriond16_normtag.json"
sp.call("brilcalc lumi -u /pb --normtag %s -i %s"%(normtagFile,selectedFile),shell=True)
os.remove(selectedFile)