6 make ordered list of .xml histogram definitions for
7 * input histogram title list (one per line)
8 * and an input .xml file (containing unordered superset
9 of input histo definitions)
10 use-case: introducing some order in ~ 1k histograms InDetPVM produces
15 from hist_bookkeep_utils
import get_hbuff
17 parser = argparse.ArgumentParser(
18 description=
'Get histogram xml blocks for list of id-s')
20 parser.add_argument(
'--id',
24 help=
'list of histogram id-s, one per line')
26 parser.add_argument(
'--xml',
30 help=
'xml file with histogram definitions')
32 parser.add_argument(
'--c',
36 help=
'comment to put above each of the histograms')
38 args = parser.parse_args()
42 in_histid_name=args.in_histid.name
43 in_xmldef_name=args.in_xmldef.name
45 out_xmldef_name=in_xmldef_name.split(
".")[0]+
"_"+in_histid_name.split(
".")[0]+
".xml"
46 out_missingdef_name=in_xmldef_name.split(
".")[0]+
"_"+in_histid_name.split(
".")[0]+
"_missing.txt"
49 print(
' reading input histogram ids in: ', in_histid_name)
50 print(
' reading histogram xml definitions in: ', in_xmldef_name)
51 print(
' writing histogram definitions to: ', out_xmldef_name)
52 print(
' writing histos missing definitions to: ', out_missingdef_name)
55 out_xmldef=
open(out_xmldef_name,
'w')
56 out_missingdef=
open(out_missingdef_name,
'w')
59 for line
in args.in_histid:
60 id=re.sub(
'\n',
'',line)
63 out_missingdef.write(id+
'\n')
66 out_xmldef.write(bline)
72 out_missingdef.close()