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