28def cli(skip_tps, number_of_data_producers, check_for_logfile_errors, run_duration, trigger_rate, run_dir):
30 dirfiles = [ join(run_dir, f)
for f
in os.listdir(run_dir)
if os.path.isfile(f) ]
31 log_files = [ f
for f
in dirfiles
if "log_" in f]
32 data_files = [ f
for f
in dirfiles
if ".hdf5" in f]
37 run_trigger_counts = {}
40 if "log_trigger" in f:
41 for line
in open(f).readlines():
42 match_tds = re.search(
r"Sent (\d+) TDs\.", line)
44 current_td_match = match_tds.group(1)
45 match_run = re.search(
r"End of run (\d+)", line)
47 current_run_match = match_run.group(1)
49 if current_td_match != 0
and current_run_match != 0:
50 run_trigger_counts[current_run_match] = current_td_match
55 print(run_trigger_counts)
56 expected_event_count = run_duration * trigger_rate
57 expected_event_count_tolerance = 2
59 wib1_frag_hsi_trig_params = {
"fragment_type_description":
"WIB",
60 "hdf5_detector_group":
"TPC",
"hdf5_region_prefix":
"APA",
61 "expected_fragment_count": number_of_data_producers,
62 "min_size_bytes": 37200,
"max_size_bytes": 37200}
63 wib1_frag_multi_trig_params = {
"fragment_type_description":
"WIB",
64 "hdf5_detector_group":
"TPC",
"hdf5_region_prefix":
"APA",
65 "expected_fragment_count": number_of_data_producers,
66 "min_size_bytes": 80,
"max_size_bytes": 37200}
67 rawtp_frag_params = {
"fragment_type_description":
"Raw TP",
68 "hdf5_detector_group":
"TPC",
"hdf5_region_prefix":
"TP_APA",
69 "expected_fragment_count": number_of_data_producers,
70 "min_size_bytes": 80,
"max_size_bytes": 80}
71 triggertp_frag_params = {
"fragment_type_description":
"Trigger TP",
72 "hdf5_detector_group":
"Trigger",
"hdf5_region_prefix":
"Region",
73 "expected_fragment_count": number_of_data_producers,
74 "min_size_bytes": 80,
"max_size_bytes": 80}
77 if check_for_logfile_errors:
79 log_file_checks.logs_are_error_free(log_files)
82 local_expected_event_count = expected_event_count
83 local_event_count_tolerance = expected_event_count_tolerance
84 fragment_check_list = []
86 local_expected_event_count+=(270 * number_of_data_producers * run_duration / 100)
87 local_event_count_tolerance+=(10 * number_of_data_producers * run_duration / 100)
88 fragment_check_list.append(wib1_frag_multi_trig_params)
89 fragment_check_list.append(rawtp_frag_params)
90 fragment_check_list.append(triggertp_frag_params)
91 if len(fragment_check_list) == 0:
92 fragment_check_list.append(wib1_frag_hsi_trig_params)
94 for idx
in range(len(data_files)):
95 data_file = data_file_checks.DataFile(data_files[idx])
96 data_file_checks.sanity_check(data_file)
97 data_file_checks.check_file_attributes(data_file)
98 data_file_checks.check_event_count(data_file, local_expected_event_count, local_event_count_tolerance)
99 for jdx
in range(len(fragment_check_list)):
100 data_file_checks.check_fragment_count(data_file, fragment_check_list[jdx])
101 data_file_checks.check_fragment_sizes(data_file, fragment_check_list[jdx])