ATLAS Offline Software
Loading...
Searching...
No Matches
python.xAODHistSize Namespace Reference

Functions

 checkxAODSize (xAODFiles, histfile, addgraphlabel=False)
 main ()

Function Documentation

◆ checkxAODSize()

python.xAODHistSize.checkxAODSize ( xAODFiles,
histfile,
addgraphlabel = False )

Definition at line 10 of file xAODHistSize.py.

10def 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
STL class.
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

◆ main()

python.xAODHistSize.main ( )

Definition at line 72 of file xAODHistSize.py.

72def 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
int main()
Definition hello.cxx:18