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