10 from __future__
import print_function
14 if 'DISPLAY' in os.environ:
15 del os.environ[
'DISPLAY']
20 from fnmatch
import fnmatch
21 from PyUtils.Helpers
import ROOT6Setup
201 'MET_Goodness_N_Jets',
202 'MET_Goodness_DeltaTrackTopo',
203 'MET_Goodness_isBad_Jet',
204 'MET_Goodness_isGood_Jet',
205 'MET_Goodness_isUgly_Jet',
206 'MET_Goodness_tileGap3F_Jet',
207 'MET_Goodness_MET_CorrTopo_etx',
208 'MET_Goodness_MET_CorrTopo_ety',
209 'MET_Goodness_MET_CorrTopo_sumet',
210 'MET_Goodness_MET_Topo_etx',
211 'MET_Goodness_MET_Topo_ety',
212 'MET_Goodness_MET_Topo_sumet',
221 'trk_blayerPrediction_locX',
232 ver = os.environ.get (
'CMTPATH')
234 for vlist
in _ignore_branches:
237 if ver
and ver.find (v) >= 0:
249 if type(o).__name__.startswith (
'vector<'):
251 if ll
and type(ll[0]).__name__.startswith (
'vector<'):
252 ll = [
list(l)
for l
in ll]
257 inttypes = [types.IntType, types.LongType]
258 def compare (o1, o2, thresh = 1e-6, ithresh = None):
260 if type(o1)
in inttypes
and type(o2)
in inttypes:
261 if o1 < 0: o1 = o1 + (1<<32)
262 if o2 < 0: o2 = o2 + (1<<32)
266 if isinstance(o1,list):
267 if len(o1) != len(o2):
269 for i
in range(len(o1)):
270 if not compare (o1[i], o2[i],
271 thresh=thresh, ithresh=ithresh):
return False
273 if type(o1).__name__
in [
'map<string,int>',
275 'map<string,string>']:
276 return ROOT.D3PDTest.MapDumper.equal (o1, o2)
277 if isinstance(o1, float):
278 if ithresh
and abs(o1) < ithresh
and abs(o2) < ithresh:
281 den = abs(o1)+abs(o2)
282 if den == 0:
return True
284 if callable(thresh): thresh =
thresh(den)
286 print (
'fmismatch', o1, o2, x)
293 if x > 36:
return 1e-2
294 if x > 34:
return 2e-3
295 if x > 32:
return 2e-4
296 if x > 30:
return 1e-4
297 if x > 28:
return 1e-5
305 print (
'Different nentries for tree', t1.GetName(),
': ', n1, n2)
307 b1 = [b.GetName()
for b
in t1.GetListOfBranches()]
308 b2 = [b.GetName()
for b
in t2.GetListOfBranches()]
311 branchmap = renames.copy()
314 bb = branchmap.get (b)
315 if not bb
or bb
not in b2:
317 print (
'Branch', b,
'in first tree but not in second.')
318 if bb: del branchmap[b]
326 print (
'Branch', b,
'in second tree but not in first.')
333 bb = branchmap.get(b)
335 o1 = topy (getattr(t1, b))
336 o2 = topy (getattr(t2, bb))
340 if b.find(
'jet_')>=0
and b.endswith (
'_m'): ithresh = 0.1
341 if b ==
'mc_m': ithresh = 0.1
342 if b.find (
'_rawcl_etas') >= 0: thresh = 2e-4
343 if b.endswith (
'_convIP'): thresh = 3e-5
344 if b.endswith (
'_emscale_E'): thresh = 9e-5
345 if b.endswith (
'_emscale_eta'): thresh = 9e-5
346 if b.endswith (
'_emscale_m'): ithresh = 0.1
347 if b.endswith (
'_constscale_E'): thresh = 9e-5
348 if b.endswith (
'_constscale_eta'): thresh = 9e-5
349 if b ==
'mc_eta': thresh = mc_eta_thresh
350 if b.endswith (
'_seg_locX'): ithresh = 2e-12
351 if b.endswith (
'_seg_locY'): ithresh = 2e-12
352 if b ==
'MET_Goodness_DeltaEt_JetAlgs_Jet': ithresh = 2e-11
353 if b ==
'MET_Goodness_EEM_Jet': thresh = 2e-5
354 if b ==
'MET_Goodness_HECf_Jet': thresh = 3e-6
355 if b.find (
'_blayerPrediction') >= 0: thresh = 4e-4
356 if not compare (o1, o2, thresh = thresh, ithresh = ithresh):
357 print (
'Branch mismatch', b,
'entry', i,
':', ithresh)
367 print (
'Objstring', k,
'mismatch:')
374 k1 = [k.GetName()
for k
in f1.GetListOfKeys()]
375 k2 = [k.GetName()
for k
in f2.GetListOfKeys()]
379 print (
"Key list mismatch for", f1.GetName(), f2.GetName(),
":")
383 if k
not in k2:
continue
387 print (
'Type mismatch for ', k)
391 elif isinstance (o1, ROOT.TTree):
393 elif isinstance (o1, ROOT.TDirectory):
395 elif isinstance (o1, ROOT.TObjString):
396 diff_objstrings (k, o1, o2)
402 if __name__ ==
'__main__':
404 f1 = ROOT.TFile (sys.argv[1])
405 f2 = ROOT.TFile (sys.argv[2])