389 logging.basicConfig(stream=sys.stdout,
390 format=
'%(levelname)-8s %(message)s',
391 level=logging.DEBUG
if args.verbose
else logging.INFO)
401 logging.error(
'Failed to open input file %s', args.inputFile)
403 logging.debug(
'Opened input file %s', args.inputFile)
405 if args.referenceFile:
408 logging.error(
'Failed to open input file %s', args.referenceFile)
410 logging.debug(
'Opened input file %s', args.referenceFile)
417 if len(in_hists) == 0:
418 logging.error(
'No count histograms could be loaded.')
420 logging.info(
'Loaded count histograms: %s',
sorted(in_hists))
423 if len(in_total_hists) == 0:
424 logging.error(
'No total-events histogram could be loaded')
426 items =
list(in_total_hists.items())
428 logging.info(
'Loaded total-events histogram %s, number of events: %d',
429 items[0][0], in_total)
432 ref_total_hists =
None
434 if args.referenceFile:
436 logging.info(
'Loaded reference count histograms: %s',
sorted(ref_hists))
437 missing_refs = [k
for k
in in_hists
if k
not in ref_hists]
438 if len(missing_refs) > 0:
439 logging.error(
'Count histogram(s) %s missing in the reference', missing_refs)
442 if len(ref_total_hists) == 0:
443 logging.error(
'No total-events reference histogram could be loaded')
446 logging.info(
'Loaded total-events reference histogram %s, number of events: %d',
447 list(ref_total_hists.keys())[0], ref_total)
455 'hist_name':
list(in_total_hists.keys())[0],
456 'count':
int(in_total),
457 'ref_count':
int(ref_total)
if ref_total
else 'n/a'
461 for hist_name, hist
in in_hists.items():
463 if text_name
in json_dict:
465 'Name "%s" assigned to more than one histogram, ', text_name,
466 'results would be overwritten. Use --countHists and ',
467 '--histDict options to avoid duplicates. Exiting.')
469 rowLabel =
'Express' if 'Express' in text_name
else 'Output'
473 ref_hist = ref_hists[hist_name]
474 ref_counts =
get_2D_counts(ref_hist)
if text_name
in [
'HLTStep',
'HLTDecision']
else get_counts(ref_hist, rowLabel)
477 json_dict[text_name] = {
478 'hist_name': hist_name,
487 if args.referenceFile:
488 logging.info(
'Comparing counts to reference')
489 retcode =
compare_ref(json_dict, args.fracTolerance, args.intTolerance)
491 if args.printOnly
and not args.diffOnly:
492 logging.info(
'Printing counts instead of dumping to files because of --printOnly option')
495 if not args.printOnly:
499 logging.info(
'Writing results to %s', args.json)
500 with open(args.json,
'w')
as outfile:
501 json.dump(json_dict, outfile, sort_keys=
True)
504 logging.info(
'Writing results extract to %s', args.yaml)
506 with open(args.yaml,
'w')
as outfile:
507 yaml.dump(light_dict, outfile, sort_keys=
True)