19 result[(run,evt)]=[
float(s)
for s
in l[2:]]
31 print(
"ERROR, headers don't match")
37 if len(res2) < len(res1):
45 for runEvt
in runEvts:
46 values1 = res1[runEvt]
47 values2 = res2[runEvt]
48 for i, name
in enumerate(h1[2:]):
50 if values1[i] != values2[i]:
52 if ignoredColumns
and name
in ignoredColumns:
54 suffix =
' (ignored)' if ignored
else ''
55 print (
"Diff: Run {} Evt {} {} {} -> {}{}".
format(runEvt[0],runEvt[1],name,values1[i],values2[i],suffix))
61 print(
"Summary of differences:")
65 for (name,count)
in diffCounter.items():
68 print (
"{}: {} events (out of {})".
format(name,count,nEvt))
69 if not ignoredColumns
or name
not in ignoredColumns:
76 print(
"No changes for:",noChanges)
82 print(
"Got only %i files. Can't compare")
90 datestamp=f.split(
'/')[9]
91 print(
"Fond file for %s" % datestamp)
93 if datestamp
in summary:
94 print(
"ERROR, duplicate date-stamp %s" % datestamp)
101 print(
"ERROR, headers of file %s doesn't match!" % f)
104 summary[datestamp]=res
105 runevtset |=
set(res.keys())
110 nValues=len(header)-2
113 for runevt
in runevtset:
115 for i
in range(nValues):
118 for day,data
in summary.items():
119 for runevt,v
in data.items():
120 for i
in range(nValues):
121 perEvt[runevt][i].
add(v[i])
124 row_format =
"{:>12}" * len(header)
126 print (row_format.format(*header))
127 for runevt,v
in perEvt.items():
128 updates=[runevt[0],runevt[1]]
129 updates+=[len(x)-1
for x
in v]
130 print (row_format.format(*updates))
133 if __name__ ==
"__main__":
134 parser = argparse.ArgumentParser(
135 description=
"A script to compare 2 xAODDigest files")
136 parser.add_argument(
"digestFile", nargs=2, type=str,
137 help=
"digest filename", action=
"store")
138 parser.add_argument(
"--ignoreMuons", help=
"Ignore muons",
139 action=
"store_true", default=
False)
140 parser.add_argument(
"--ignoreMET", help=
"Ignore MET",
141 action=
"store_true", default=
False)
143 args = parser.parse_args()
147 ignored += [
'nMuons',
'muon1pt',
'muon1eta',
'muon1phi']
149 ignored += [
'nmet',
'metx',
'mety',
'sumet']
151 retval =
compare2Files(args.digestFile[0], args.digestFile[1], ignoredColumns=ignored)