4 from __future__
import print_function
9 from array
import array
14 histfilename = histfile
if histfile
else "hist.root"
18 for filename
in xAODFiles:
19 cmd = [
'checkxAOD', filename]
20 outlog = subprocess.Popen(cmd, stdout = subprocess.PIPE)
21 lines =
str(outlog.communicate()).
split(
"\\n")
26 if line.startswith(
"CSV"):
27 domainlist = lines[iline+1].strip().
split(
",")
28 domainsize = lines[iline+2].strip().
split(
",")
29 domaindict = dict(zip(domainlist, domainsize))
31 sizes.append(
float(domaindict[
'Total']))
34 hfile = ROOT.TFile( histfilename,
'UPDATE',
'ROOT file with histograms' )
40 hsize = ROOT.TH1F(
'hist PHYSLITE PHYS AOD event size',
'hist PHYSLITE PHYS AOD event size', len(sizes), -0.5, len(sizes)-0.5 )
41 for i
in range(0,len(sizes)):
42 hsize.Fill(i, sizes[i])
46 xbins = [*
range(len(sizes))]
48 for i
in range(len(sizes)):
52 grsize = ROOT.TGraph(len(sizes),x,y)
53 grsize.SetTitle(
'graph PHYSLITE PHYS AOD file size')
54 grsize.SetName(
'graph PHYSLITE PHYS AOD file size')
58 xbinsLabel = [
'PHYSLITE %3.1f'%sizes[0],
59 'PHYS %3.1f'%sizes[1],
60 'AOD %3.1f'%sizes[2] ]
62 graxis = grsize.GetXaxis()
63 for ibin
in range(0,len(sizes)):
64 tmpbin = graxis.FindBin(ibin)
65 graxis.SetBinLabel(tmpbin, xbinsLabel[ibin])
74 parser = argparse.ArgumentParser(
75 description=
"Extracts a few basic quantities from the xAOD file and dumps them into a hist ROOT file")
76 parser.add_argument(
"--xAODFiles", help=
"xAOD filenames (comma separated) for size/event check",
77 action=
"store", default=
None)
78 parser.add_argument(
"--outputHISTFile", help=
"histogram output filename",
79 action=
"store", default=
None)
80 parser.add_argument(
"--addgraphlabel", help=
"Add PHYSLITE PHYS AOD x-Axis graph label and size",
81 action=
"store_true", default=
False)
83 args = parser.parse_args()
90 filelist = args.xAODFiles.split(
',')
93 checkxAODSize(filelist, args.outputHISTFile, args.addgraphlabel)
97 if __name__ ==
"__main__":