Belle II Software  release-06-02-00
createLookUpTable_data.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 import os
13 import sys
14 from tools import addLine, getBelleUrl_data, getMaxRunNo_data, readConfigFile_data
15 
16 # print debug messages ?
17 debug = False
18 debugCounter = 0
19 
20 if len(sys.argv) == 1:
21  sys.exit('Need one argument: path of config file with job parameters !')
22 
23 # read jobs parameters from config file
24 runsPerJob, expNoList, skimTypeList, dataTypeList, belleLevelList =\
25  readConfigFile_data()
26 
27 # create output directory for tables if it doesn't exist
28 if not os.path.exists('tables'):
29  os.makedirs('tables')
30 
31 # open table and write in it
32 # table name contains threshold for events number of each job
33 tableName = 'tables/lookUpTable_data_' + str(runsPerJob) + '.txt'
34 f = open(tableName, 'w')
35 
36 # write one line for each job will submit
37 # grouping the smallest set of runs that has more than Nthreshold events
38 for expNo in expNoList:
39 
40  absMaxRunNo = getMaxRunNo_data(expNo)
41  if absMaxRunNo is None:
42  sys.exit('ExpNo ' + str(expNo) + ' not found. Does it exist ?')
43 
44  if debug:
45  print('For expNo ' + str(expNo) + ' max runNo is ' + str(absMaxRunNo))
46 
47  for skimType in skimTypeList:
48  for dataType in dataTypeList:
49  for belleLevel in belleLevelList:
50 
51  minRunNo = 1
52  while minRunNo < absMaxRunNo: # stop searching for runs after maxRunNo
53 
54  maxRunNo = minRunNo + (runsPerJob - 1)
55 
56  thisUrl = getBelleUrl_data(expNo, minRunNo, maxRunNo,
57  skimType, dataType, belleLevel)
58 
59  if debug:
60  print('Checking up url: ' + thisUrl)
61 
62  addLine(f, [expNo, skimType, dataType,
63  belleLevel, minRunNo, maxRunNo])
64 
65  minRunNo = maxRunNo + 1
66 f.close()