ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tools
PROCTools
python
xAODHistSize.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
4
import
sys
5
import
ROOT
6
import
argparse
7
import
subprocess
8
from
array
import
array
9
10
def
checkxAODSize
(xAODFiles, histfile, addgraphlabel=False):
11
12
# Set output HIST filename
13
histfilename = histfile
if
histfile
else
"hist.root"
14
15
# Loop over xAODFiles and extract Total size/event in kB with checkxAOD
16
sizes = []
17
for
filename
in
xAODFiles:
18
cmd = [
'checkxAOD'
, filename]
19
outlog = subprocess.Popen(cmd, stdout = subprocess.PIPE)
20
lines = str(outlog.communicate()).
split
(
"\\n"
)
21
# Set some variable to start values
22
iline = 0
23
for
line
in
lines:
24
# Parse CSV lines with domain sizes
25
if
line.startswith(
"CSV"
):
26
domainlist = lines[iline+1].
strip
().
split
(
","
)
27
domainsize = lines[iline+2].
strip
().
split
(
","
)
28
domaindict = dict(zip(domainlist, domainsize))
29
iline = iline + 1
30
sizes.append(float(domaindict[
'Total'
]))
31
32
# Open existing histogram file and add size/event infos
33
hfile = ROOT.TFile( histfilename,
'UPDATE'
,
'ROOT file with histograms'
)
34
hfile.cd()
35
hfile.mkdir(
"Sizes"
)
36
hfile.cd(
"Sizes"
)
37
38
# Histogram with "Total" checkxAOD sizes
39
hsize = ROOT.TH1F(
'hist PHYSLITE PHYS AOD event size'
,
'hist PHYSLITE PHYS AOD event size'
, len(sizes), -0.5, len(sizes)-0.5 )
40
for
i
in
range(0,len(sizes)):
41
hsize.Fill(i, sizes[i])
42
hsize.Write()
43
44
# The same "Total" checkxAOD size in a TGraph
45
xbins = [*range(len(sizes))]
46
x, y =
array
(
'd'
),
array
(
'd'
)
47
for
i
in
range(len(sizes)):
48
x.append(xbins[i])
49
y.append(sizes[i])
50
51
grsize = ROOT.TGraph(len(sizes),x,y)
52
grsize.SetTitle(
'graph PHYSLITE PHYS AOD file size'
)
53
grsize.SetName(
'graph PHYSLITE PHYS AOD file size'
)
54
55
# Add xaxis label names to TGraph
56
if
addgraphlabel:
57
xbinsLabel = [
'PHYSLITE %3.1f'
%sizes[0],
58
'PHYS %3.1f'
%sizes[1],
59
'AOD %3.1f'
%sizes[2] ]
60
61
graxis = grsize.GetXaxis()
62
for
ibin
in
range(0,len(sizes)):
63
tmpbin = graxis.FindBin(ibin)
64
graxis.SetBinLabel(tmpbin, xbinsLabel[ibin])
65
graxis.Draw(
"AP"
)
66
67
grsize.Write()
68
hfile.Close()
69
70
return
71
72
def
main
():
73
parser = argparse.ArgumentParser(
74
description=
"Extracts a few basic quantities from the xAOD file and dumps them into a hist ROOT file"
)
75
parser.add_argument(
"--xAODFiles"
, help=
"xAOD filenames (comma separated) for size/event check"
,
76
action=
"store"
, default=
None
)
77
parser.add_argument(
"--outputHISTFile"
, help=
"histogram output filename"
,
78
action=
"store"
, default=
None
)
79
parser.add_argument(
"--addgraphlabel"
, help=
"Add PHYSLITE PHYS AOD x-Axis graph label and size"
,
80
action=
"store_true"
, default=
False
)
81
82
args = parser.parse_args()
83
84
if
len(sys.argv) < 2:
85
parser.print_help()
86
sys.exit(1)
87
88
# Create input filelist
89
filelist = args.xAODFiles.split(
','
)
90
91
# Call checkxAOD
92
checkxAODSize
(filelist, args.outputHISTFile, args.addgraphlabel)
93
94
return
0
95
96
if
__name__ ==
"__main__"
:
97
98
main
()
SiliconTech::strip
@ strip
Definition
FPGATrackSimTypes.h:25
array
STL class.
split
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition
hcg.cxx:179
python.xAODHistSize.main
main()
Definition
xAODHistSize.py:72
python.xAODHistSize.checkxAODSize
checkxAODSize(xAODFiles, histfile, addgraphlabel=False)
Definition
xAODHistSize.py:10
Generated on
for ATLAS Offline Software by
1.17.0