108 print(
"Neither tuple is Reference Root file reference?")
111 dsks = list(ds.keys())
112 dpks = list(dp.keys())
120 print(
"\n" +
"=" * 80)
121 print(
"Comparison of Paths : Reference vs Test ROOT files")
124 "Number of paths in Reference file : %i (objects, histos) = ( %i, %i )"
125 % (len(dsks), os, hs)
128 "Number of paths in Test file : %i (objects, histos) = ( %i, %i )"
129 % (len(dpks), op, hp)
131 matching = sset.intersection(pset)
134 if ds[n].__class__.__name__
in histos:
136 print(
"\nMatching paths : %i" % (len(matching)))
139 uniqueReferenceHistos = 0
141 if ds[n].__class__.__name__
in histos:
142 uniqueReferenceHistos += 1
144 "Paths unique to Reference file : %i ( %i Histos )"
145 % (len(uSer), uniqueReferenceHistos)
149 print(
"\t%s : \t%s" % (ds[n], n))
153 if dp[n].__class__.__name__
in histos:
154 uniqueTestHistos += 1
156 "Paths unique to Test file : %i ( %i Histos )" % (len(uPar), uniqueTestHistos)
160 print(
"\t%s : \t%s" % (dp[n], n))
161 print(
"Matching Histos to test : %i" % (matchingHistos))
162 print(
"=" * 80 +
"\n")
164 ((os, hs), (op, hp)),
165 (uSer, uniqueReferenceHistos),
166 (uPar, uniqueTestHistos),
217 ((referenceObjects, referenceHistos), (parallObjects, parallHistos)),
218 (uniqueSerPaths, uniqueSerHistos),
219 (uniqueParPaths, uniqueParHistos),
231 print(
"Neither tuple is Reference Root file reference?")
240 omit = [re.compile(regex)
for regex
in gRegexBlackList]
244 if not any(regex.search(k)
is not None for regex
in omit):
245 if ds[k].__class__.__name__
in histos:
250 if not any(regex.search(k)
is not None for regex
in omit):
251 if dp[k].__class__.__name__
in histos:
266 identityDiffBins = {}
272 zeroIntegralMatch = 0
280 if sh.GetEntries() != ph.GetEntries():
281 diffEntries.append(h)
287 for i
in range(sh.GetNbinsX()):
288 sBinError += sh.GetBinError(i)
289 for i
in range(ph.GetNbinsX()):
290 pBinError += ph.GetBinError(i)
293 doKS = (bool(sint)
and bool(pint))
and (sBinError > 0
and pBinError > 0)
294 if checkBin2BinIdentity
and doKS:
300 diffIdentity.append(h)
301 identityDiffBins[h] = diffBins
302 if (bool(sint)
and bool(pint))
and (sBinError > 0
and pBinError > 0):
304 kTest = sh.KolmogorovTest(ph)
305 kTestResults[h] = kTest
315 if all((sint, pint))
and (sint == pint):
318 zeroIntegralMatch += 1
320 diffIntegrals.append(h)
324 print(
"not found? ", h)
327 print(
"\n\n" +
"-" * 80)
328 print(
"Summary of histos with different Entries")
332 for e
in diffEntries:
334 "\t\t\t%s:\t%i != %i"
335 % (e, int(ds[e].GetEntries()), int(dp[e].GetEntries()))
340 print(
"\n\n" +
"-" * 60)
341 print(
"Summary of histos which failed Kolmogorov Test")
346 result = kTestResults[e]
348 "%s\t\t%s :\tK-Test Result :\t %5.16f" % (ds[e].ClassName(), e, result)
353 print(
"\n\n" +
"-" * 60)
354 print(
"Summary of histos which failed Integral Check")
358 for e
in diffIntegrals:
359 diff = dp[e].Integral() - ds[e].Integral()
360 pc = (diff * 100) / ds[e].Integral()
362 "%s\t\t%s:\t Diff = %5.6f\tPercent Diff to Reference : %5.6f "
363 % (ds[e].ClassName(), e, diff, pc)
365 print(
"-" * 60 +
"\n")
366 print(
"=" * 80 +
"\n")
369 if checkBin2BinIdentity:
371 print(
"\n\n" +
"-" * 80)
372 print(
"Summary of histos with at least one bin with different Entries")
376 for e
in diffIdentity:
378 "%s\t\t%s: %i different bins"
379 % (ds[e].ClassName(), e, identityDiffBins[e])
383 print(
"\n" +
"=" * 80)
384 print(
"Comparison : Reference/Test ROOT Histo files")
385 print(
"\n\t\tReference\tTest")
387 "\tObjects : %i\t%i\t\t( p-s = %i )"
388 % (referenceObjects, parallObjects, parallObjects - referenceObjects)
391 "\tHistos : %i\t%i\t\t( p-s = %i )"
392 % (referenceHistos, parallHistos, parallHistos - referenceHistos)
394 print(
"\t __________")
397 % (referenceHistos + referenceObjects, parallHistos + parallObjects)
400 "Objects/Histos unique to Reference File : %i / %i"
401 % (len(uniqueSerPaths) - uniqueSerHistos, uniqueSerHistos)
404 "Objects/Histos unique to Test File : %i / %i"
405 % (len(uniqueParPaths) - uniqueParHistos, uniqueParHistos)
407 print(
"\nMatching Histograms valid for Comparison : %i" % (mh))
408 print(
"\nOmissions' patterns : ")
409 for entry
in gRegexBlackList:
410 print(
"\t%s" % (entry))
412 "\nHistograms for Comparison (after Omissions) : %i"
413 % (mh - len(gRegexBlackList))
415 print(
"\n\tHISTOGRAM TESTS : ")
416 print(
"\t\tKOLMOGOROV TEST : %i" % (kTested))
417 print(
"\t\tINTEGRAL TEST : %i" % (otherTest))
418 print(
"\t\tENTRIES TEST : %i" % (xEntries))
419 if checkBin2BinIdentity:
420 print(
"\t\tBIN2BIN TEST : %i" % (passedIdentity))
422 print(
"\t\tTested : %i" % (cEntries))
424 print(
"\n\tDISCREPANCIES : ")
425 print(
"\t\tK-Test : %i" % (failedKol))
426 print(
"\t\tIntegrals : %i" % (xIntegrals))
427 print(
"\t\tEntries : %i" % (xEntries))
428 retval = failedKol + xIntegrals + xEntries + failedIdentity
430 print(
"\nThe two sets of histograms were not identical")
431 print(
"\n" +
"=" * 80)