298def diff_trees (t1, t2):
299 n1 = t1.GetEntries()
300 n2 = t2.GetEntries()
301 if n1 != n2:
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()]
306 b1.sort()
307 b2.sort()
308 branchmap = renames.copy()
309 for b in b1:
310 if b not in b2:
311 bb = branchmap.get (b)
312 if not bb or bb not in b2:
313 if not ignore_p(b):
314 print ('Branch', b, 'in first tree but not in second.')
315 if bb: del branchmap[b]
316 else:
317 b2.remove (bb)
318 else:
319 b2.remove (b)
320 branchmap[b] = b
321 for b in b2:
322 if not ignore_p(b):
323 print ('Branch', b, 'in second tree but not in first.')
324
325 for i in range (n1):
326 t1.GetEntry(i)
327 t2.GetEntry(i)
328 for b in b1:
329 if ignore_p(b): continue
330 bb = branchmap.get(b)
331 if not bb: continue
332 o1 = topy (getattr(t1, b))
333 o2 = topy (getattr(t2, bb))
334
335 ithresh = None
336 thresh = 1e-6
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)
355 print (o1)
356 print (o2)
357
358 return
359
360