CMS 3D CMS Logo

das-selected-lumis.py
Go to the documentation of this file.
1 #!/bin/env python
2 import json , sys
3 input_range = []
4 output_files_list = []
5 lumi_ranges = sys.argv[1].split(':')
6 for lumi_range in lumi_ranges:
7  input_range.append(tuple(lumi_range.split(',')))
8 
9 jdata = sys.stdin.read()
10 try:
11  lumi_data = json.loads(jdata)
12 except:
13  print jdata
14  exit (1)
15 lumi_data = lumi_data['data']
16 
17 def match_in(sub_list,lumi_list):
18  sub_list = map(int,sub_list)
19  lumi_list = map(int,lumi_list)
20  for i in range(sub_list[0],sub_list[1]+1):
21  if i >= lumi_list[0] and i <= lumi_list[1]: return True
22  return False
23 
24 def check_lumi_ranges(given_lumi_list , sub_range):
25  for lumi_r in given_lumi_list:
26  if match_in(sub_range, lumi_r):
27  return True
28  return False
29 
30 def process_lumi(data):
31  for lumi_info in data:
32  lumi_rang = lumi_info['lumi'][0]['number']
33  lumi_file = lumi_info['file'][0]['name']
34  for sub_list in lumi_rang:
35  if check_lumi_ranges(input_range,tuple(sub_list)):
36  output_files_list.append(lumi_file)
37  break
38  for out_file_name in output_files_list:
39  print out_file_name
40 
41 #Get file names for desired lumi ranges
42 process_lumi(lumi_data)
43 
def check_lumi_ranges(given_lumi_list, sub_range)
double split
Definition: MVATrainer.cc:139
def match_in(sub_list, lumi_list)