-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdas_selected_lumis.py
41 lines (36 loc) · 1.08 KB
/
das_selected_lumis.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
#!/bin/env python
import json , sys
input_range = []
output_files_list = []
lumi_ranges = sys.argv[1].split(';')
for lumi_range in lumi_ranges:
input_range.append(tuple(lumi_range.split(',')))
jdata = sys.stdin.read()
try:
lumi_data = json.loads(jdata)
except:
print jdata
exit (1)
lumi_data = lumi_data['data']
def match_in(sub_list,lumi_list):
sub_list = map(int,sub_list)
lumi_list = map(int,lumi_list)
for i in range(sub_list[0],sub_list[1]+1):
if i >= lumi_list[0] and i <= lumi_list[1]: return True
return False
def check_lumi_ranges(given_lumi_list , sub_range):
for lumi_r in given_lumi_list:
if match_in(sub_range, lumi_r):
return True
return False
def process_lumi(data):
for lumi_info in data:
lumi_rang = lumi_info['lumi'][0]['number']
lumi_file = limi_info['file'][0]['name']
for sub_list in lumi_rang:
if check_lumi_ranges(input_range,tuple(sub_list)):
output_files_list.append(lumi_file)
for out_file_name in output_files_list:
print out_file_name
#Get file names for desired lumi ranges
process_lumi(lumi_data)