13 if 'DISPLAY' in os.environ:
14 del os.environ[
'DISPLAY']
19 from fnmatch
import fnmatch
198 'MET_Goodness_N_Jets',
199 'MET_Goodness_DeltaTrackTopo',
200 'MET_Goodness_isBad_Jet',
201 'MET_Goodness_isGood_Jet',
202 'MET_Goodness_isUgly_Jet',
203 'MET_Goodness_tileGap3F_Jet',
204 'MET_Goodness_MET_CorrTopo_etx',
205 'MET_Goodness_MET_CorrTopo_ety',
206 'MET_Goodness_MET_CorrTopo_sumet',
207 'MET_Goodness_MET_Topo_etx',
208 'MET_Goodness_MET_Topo_ety',
209 'MET_Goodness_MET_Topo_sumet',
218 'trk_blayerPrediction_locX',
229 ver = os.environ.get (
'CMTPATH')
231 for vlist
in _ignore_branches:
234 if ver
and ver.find (v) >= 0:
246 if type(o).__name__.startswith (
'vector<'):
248 if ll
and type(ll[0]).__name__.startswith (
'vector<'):
249 ll = [
list(l)
for l
in ll]
254 inttypes = [types.IntType, types.LongType]
255 def 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)
290 if x > 36:
return 1e-2
291 if x > 34:
return 2e-3
292 if x > 32:
return 2e-4
293 if x > 30:
return 1e-4
294 if x > 28:
return 1e-5
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)
364 print (
'Objstring', k,
'mismatch:')
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)
399 if __name__ ==
'__main__':
401 f1 = ROOT.TFile (sys.argv[1])
402 f2 = ROOT.TFile (sys.argv[2])