ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetValidation
InDetPhysValMonitoring
scripts
histdef_bookkeep
get_hdefs.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
3
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4
5
'''
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
11
'''
12
import
re
13
import
argparse
14
15
from
hist_bookkeep_utils
import
get_hbuff
16
17
parser = argparse.ArgumentParser(
18
description=
'Get histogram xml blocks for list of id-s'
)
19
20
parser.add_argument(
'--id'
,
21
dest=
'in_histid'
,
22
type=open,
23
required=
True
,
24
help=
'list of histogram id-s, one per line'
)
25
26
parser.add_argument(
'--xml'
,
27
dest=
'in_xmldef'
,
28
type=open,
29
required=
True
,
30
help=
'xml file with histogram definitions'
)
31
32
parser.add_argument(
'--c'
,
33
dest=
'comment'
,
34
required=
False
,
35
default=
''
,
36
help=
'comment to put above each of the histograms'
)
37
38
args = parser.parse_args()
39
40
42
in_histid_name=args.in_histid.name
43
in_xmldef_name=args.in_xmldef.name
44
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"
47
48
print
(
''
)
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)
53
print
(
''
)
54
55
out_xmldef=open(out_xmldef_name,
'w'
)
56
out_missingdef=open(out_missingdef_name,
'w'
)
57
58
59
for
line
in
args.in_histid:
60
id=re.sub(
'\n'
,
''
,line)
61
buff=get_hbuff(id,in_xmldef_name)
62
if
not
buff:
63
out_missingdef.write(id+
'\n'
)
64
else
:
65
for
bline
in
buff:
66
out_xmldef.write(bline)
67
68
69
71
out_xmldef.close()
72
out_missingdef.close()
73
74
print
(
''
)
75
print
(
'all done'
)
76
print
(
''
)
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
Generated on
for ATLAS Offline Software by
1.17.0