-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDQM_loop.py
48 lines (42 loc) · 1.64 KB
/
DQM_loop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import argparse
import os, re
from glob import glob
import numpy as np
import time
def parsing():
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--input_file_template", type=str, default="../data/VME/RecoData/RecoWithTracks/v3/RawDataSaver0CMSVMETiming_RunXXX_0_Raw.root")
parser.add_argument("-C", "--config", type=str, default='config/FNAL_TB_1904/VME_v1.txt', help="Config file")
parser.add_argument("-S", "--save_loc", type=str, default='../results/online_dqm/', help="Saving location")
parser.add_argument("-g", "--group", type=int, default=5, help="Number of runs to be grouped")
args = parser.parse_args()
return args
def getDirsRunN(s):
out = re.search('[0-9]+_DQM', s)
if hasattr(out, 'group'):
return int(out.group(0)[:-4])
else:
return np.nan
def getFileRunN(s):
out = re.search('Run[0-9]+', s)
if hasattr(out, 'group'):
return int(out.group(0)[3:])
else:
return np.nan
args = parsing()
if args.save_loc[-1] != '/':
args.save_loc += '/'
while(True):
dir_list = glob(args.save_loc + '*')
last_run_processed = int(np.nanmax(map(getDirsRunN, dir_list)))
file_list = glob(args.input_file_template.replace('XXX', '*'))
newest_run = int(np.nanmax(map(getFileRunN, file_list)))
if newest_run - last_run_processed > args.group+1:
cmd = 'python DQM_SiPM.py -C ' + args.config
cmd += ' -S ' + args.save_loc
cmd += ' -i ' + args.input_file_template
cmd += ' -N {} {}'.format(last_run_processed + 1, newest_run - 1)
os.system(cmd)
else:
print time.time(), 'Nothing to be done'
time.sleep(5)