Belle II Software  release-08-01-10
printBeamSpotSteerings.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
16 
17 
18 from glob import glob
19 import re
20 
21 # Produce json file for airflow-based mumu-skims (exp12)
22 
23 
24 def storeSteering(name, tag):
25 
26  baseDir = '/group/belle2/dataprod/dp_managers/ddossett/airflow/output_data'
27 
28  def getRun(x): return int(re.findall('[0-9]*$', x)[0])
29 
30  res = None
31  if not isinstance(tag, list):
32  tag = str(tag)
33  res = glob(baseDir+'/'+tag+'/mumu_2trk/e12/*')
34  else:
35  res = []
36  for t in tag:
37  t = str(t)
38  res += glob(baseDir+'/'+t+'/mumu_2trk/e12/*')
39 
40  res = sorted(res, key=getRun)
41 
42  fOut = open(name, 'w')
43 
44  fOut.write('{"hlt_mumu": [')
45 
46  for i, r in enumerate(res):
47  n = getRun(r)
48  fOut.write('["' + r + '", [12, '+str(n)+']]')
49  if i != len(res) - 1:
50  fOut.write(', ')
51 
52  fOut.write(']}')
53  fOut.close()
54 
55 
56 # Produce json file for bucket12 or exp7,exp8 or exp10
57 def storeSteering2(name, tag):
58  baseDir = '/group/belle2/dataprod/Data/OfficialReco/proc11/e00'+tag+'/4S/r*/skim/hlt_mumu_2trk/mdst'
59  if tag == 'bucket12':
60  baseDir = '/group/belle2/dataprod/Data/release-04-02-04/DB00001113/' +\
61  'bucket12/e0012/4S_offres/GoodRuns/r*/skim/hlt_mumu_2trk/mdst'
62  elif tag == '08off':
63  baseDir = '/group/belle2/dataprod/Data/OfficialReco/proc11/e0008/4S_offres/r*/skim/hlt_mumu_2trk/mdst'
64  tag = '08'
65  elif tag == '08scan':
66  baseDir = '/group/belle2/dataprod/Data/OfficialReco/proc11/e0008/4S_scan/r*/skim/hlt_mumu_2trk/mdst'
67  tag = '08'
68 
69  res = glob(baseDir)
70 
71  def getRun(r): return int(re.findall('/r[0-9]*/', r)[0][2:-1])
72 
73  res = sorted(res, key=getRun)
74 
75  fOut = open(name, 'w')
76 
77  fOut.write('{"hlt_mumu": [')
78 
79  for i, r in enumerate(res):
80  n = getRun(r)
81  exp = 12 if tag == 'bucket12' else int(tag)
82  fOut.write('["' + r + '", ['+str(exp)+', '+str(n)+']]')
83  if i != len(res) - 1:
84  fOut.write(', ')
85 
86  fOut.write(']}')
87  fOut.close()
88 
89 
90 # Produce all the json steerings to the steering directory
91 
92 storeSteering2('steerings/input_data_exp8off.json', '08off')
93 storeSteering2('steerings/input_data_exp8scan.json', '08scan')
94 
95 storeSteering2('steerings/input_data_exp7.json', '07')
96 storeSteering2('steerings/input_data_exp8.json', '08')
97 storeSteering2('steerings/input_data_exp10.json', '10')
98 
99 storeSteering('steerings/input_data_bucket9.json', 71)
100 storeSteering('steerings/input_data_bucket10.json', 91)
101 storeSteering('steerings/input_data_bucket11.json', [110, 112])
102 storeSteering2('steerings/input_data_bucket12.json', 'bucket12')
103 storeSteering('steerings/input_data_bucket13.json', 139)
104 storeSteering('steerings/input_data_bucket14.json', 166)
105 storeSteering('steerings/input_data_bucket15.json', 192)
static ExpRun getRun(std::map< ExpRun, std::pair< double, double >> runs, double t)
Get exp number + run number from time.
Definition: Splitter.cc:262