255def compare (o1, o2, thresh = 1e-6, ithresh = None):
257 if type(o1)
in inttypes
and type(o2)
in inttypes:
258 if o1 < 0: o1 = o1 + (1<<32)
259 if o2 < 0: o2 = o2 + (1<<32)
263 if isinstance(o1,list):
264 if len(o1) != len(o2):
266 for i
in range(len(o1)):
267 if not compare (o1[i], o2[i],
268 thresh=thresh, ithresh=ithresh):
return False
270 if type(o1).__name__
in [
'map<string,int>',
272 'map<string,string>']:
273 return ROOT.D3PDTest.MapDumper.equal (o1, o2)
274 if isinstance(o1, float):
275 if ithresh
and abs(o1) < ithresh
and abs(o2) < ithresh:
278 den = abs(o1)+abs(o2)
279 if den == 0:
return True
281 if callable(thresh): thresh = thresh(den)
283 print (
'fmismatch', o1, o2, x)
302 print (
'Different nentries for tree', t1.GetName(),
': ', n1, n2)
304 b1 = [b.GetName()
for b
in t1.GetListOfBranches()]
305 b2 = [b.GetName()
for b
in t2.GetListOfBranches()]
308 branchmap = renames.copy()
311 bb = branchmap.get (b)
312 if not bb
or bb
not in b2:
314 print (
'Branch', b,
'in first tree but not in second.')
315 if bb: del branchmap[b]
323 print (
'Branch', b,
'in second tree but not in first.')
330 bb = branchmap.get(b)
332 o1 = topy (getattr(t1, b))
333 o2 = topy (getattr(t2, bb))
337 if b.find(
'jet_')>=0
and b.endswith (
'_m'): ithresh = 0.1
338 if b ==
'mc_m': ithresh = 0.1
339 if b.find (
'_rawcl_etas') >= 0: thresh = 2e-4
340 if b.endswith (
'_convIP'): thresh = 3e-5
341 if b.endswith (
'_emscale_E'): thresh = 9e-5
342 if b.endswith (
'_emscale_eta'): thresh = 9e-5
343 if b.endswith (
'_emscale_m'): ithresh = 0.1
344 if b.endswith (
'_constscale_E'): thresh = 9e-5
345 if b.endswith (
'_constscale_eta'): thresh = 9e-5
346 if b ==
'mc_eta': thresh = mc_eta_thresh
347 if b.endswith (
'_seg_locX'): ithresh = 2e-12
348 if b.endswith (
'_seg_locY'): ithresh = 2e-12
349 if b ==
'MET_Goodness_DeltaEt_JetAlgs_Jet': ithresh = 2e-11
350 if b ==
'MET_Goodness_EEM_Jet': thresh = 2e-5
351 if b ==
'MET_Goodness_HECf_Jet': thresh = 3e-6
352 if b.find (
'_blayerPrediction') >= 0: thresh = 4e-4
353 if not compare (o1, o2, thresh = thresh, ithresh = ithresh):
354 print (
'Branch mismatch', b,
'entry', i,
':', ithresh)
371 k1 = [k.GetName()
for k
in f1.GetListOfKeys()]
372 k2 = [k.GetName()
for k
in f2.GetListOfKeys()]
376 print (
"Key list mismatch for", f1.GetName(), f2.GetName(),
":")
380 if k
not in k2:
continue
384 print (
'Type mismatch for ', k)
388 elif isinstance (o1, ROOT.TTree):
390 elif isinstance (o1, ROOT.TDirectory):
392 elif isinstance (o1, ROOT.TObjString):
393 diff_objstrings (k, o1, o2)