diff --git a/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/Treereader.py b/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/Treereader.py index bfb0edc8fadbf0a11ccf95166c8903a81b6ad863..6a50e7e6f9a10307f3de1b8c7160f36f97c5330e 100644 --- a/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/Treereader.py +++ b/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/Treereader.py @@ -1,10 +1,15 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration class Treereader (object): - leaftypes = (int, float, long, complex, buffer) + leaftypes = (int, float, complex) + import builtins + if 'long' in builtins.__dict__: + leaftypes = leaftypes + (builtins.__dict__['long'],) + if 'buffer' in builtins.__dict__: + leaftypes = leaftypes + (builtins.__dict__['buffer'],) def __init__ (*self): - raise Exception, "Use treereader() rather than creating Treereader directly." + raise Exception ("Use treereader() rather than creating Treereader directly.") def real_init (self, tree, parent = None, subpattern = None): self.parent = parent diff --git a/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/__init__.py b/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/__init__.py index c54d388aa3e202927ae72b2b3f7950d5b47a148e..689fed30153ac0ed632c018ce1307d19313ba3c3 100644 --- a/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/__init__.py +++ b/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration # $Id$ # @@ -16,7 +16,7 @@ # D3PDMakerTest.FillerAlg # -import D3PDMakerTestConf +from . import D3PDMakerTestConf for k, v in D3PDMakerTestConf.__dict__.items(): if k.startswith ('D3PDTest__'): globals()[k[10:]] = v diff --git a/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/changerun.py b/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/changerun.py index 5fe281465dac4b608d8cca25311f291b0902979c..660938a25d840895e3cd29f7507fdf046f6ddf6a 100644 --- a/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/changerun.py +++ b/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/changerun.py @@ -1,15 +1,17 @@ #!/usr/bin/env python -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + +from __future__ import print_function import sys if len(sys.argv) < 4: - print """Change the run number in a pool file. + print ("""Change the run number in a pool file. Probably only works correctly for simple, single-run MC files. Usage: changerun.py NEWRUN INFILE OUTFILE -""" +""") newrun = int (sys.argv[1]) infile = sys.argv[2] diff --git a/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/difftuple.py b/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/difftuple.py index a51e7bc1aa9368b0833726d9777411f95d1e3e6c..691baabd213d0f95f423471d895dc411373d251d 100644 --- a/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/difftuple.py +++ b/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/difftuple.py @@ -1,7 +1,5 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -# -# $Id$ # # File: D3PDMakerTest/python/difftuple.py # Author: snyder@bnl.gov @@ -9,6 +7,8 @@ # Purpose: Diff two root tuple files. # +from __future__ import print_function + # Always run in batch mode. import os if os.environ.has_key('DISPLAY'): @@ -284,7 +284,7 @@ def compare (o1, o2, thresh = 1e-6, ithresh = None): x = abs(num / den) if callable(thresh): thresh = thresh(den) if x > thresh: - print 'fmismatch', o1, o2, x + print ('fmismatch', o1, o2, x) return False return True return o1 == o2 @@ -303,7 +303,7 @@ def diff_trees (t1, t2): n1 = t1.GetEntries() n2 = t2.GetEntries() if n1 != n2: - print 'Different nentries for tree', t1.GetName(), ': ', n1, n2 + print ('Different nentries for tree', t1.GetName(), ': ', n1, n2) n1 = min(n1, n2) b1 = [b.GetName() for b in t1.GetListOfBranches()] b2 = [b.GetName() for b in t2.GetListOfBranches()] @@ -315,7 +315,7 @@ def diff_trees (t1, t2): bb = branchmap.get (b) if not bb or bb not in b2: if not ignore_p(b): - print 'Branch', b, 'in first tree but not in second.' + print ('Branch', b, 'in first tree but not in second.') if bb: del branchmap[b] else: b2.remove (bb) @@ -324,7 +324,7 @@ def diff_trees (t1, t2): branchmap[b] = b for b in b2: if not ignore_p(b): - print 'Branch', b, 'in second tree but not in first.' + print ('Branch', b, 'in second tree but not in first.') for i in range (n1): t1.GetEntry(i) @@ -355,9 +355,9 @@ def diff_trees (t1, t2): if b == 'MET_Goodness_HECf_Jet': thresh = 3e-6 if b.find ('_blayerPrediction') >= 0: thresh = 4e-4 if not compare (o1, o2, thresh = thresh, ithresh = ithresh): - print 'Branch mismatch', b, 'entry', i, ':', ithresh - print o1 - print o2 + print ('Branch mismatch', b, 'entry', i, ':', ithresh) + print (o1) + print (o2) return @@ -365,9 +365,9 @@ def diff_trees (t1, t2): def diff_objstrings (k, s1, s2): # nb. != not working correctly for TObjString in 5.26.00c_python2.6 if not (s1 == s2): - print 'Objstring', k, 'mismatch:' - print repr(s1) - print repr(s2) + print ('Objstring', k, 'mismatch:') + print (repr(s1)) + print (repr(s2)) return @@ -377,16 +377,16 @@ def diff_dirs (f1, f2): k1.sort() k2.sort() if k1 != k2: - print "Key list mismatch for", f1.GetName(), f2.GetName(), ":" - print k1 - print k2 + print ("Key list mismatch for", f1.GetName(), f2.GetName(), ":") + print (k1) + print (k2) for k in k1: if k not in k2: continue o1 = f1.Get(k) o2 = f2.Get(k) if type(o1) != type(o2): - print 'Type mismatch for ', k - print o1, o2 + print ('Type mismatch for ', k) + print (o1, o2) if k == 'Schema': pass elif isinstance (o1, ROOT.TTree): @@ -396,7 +396,7 @@ def diff_dirs (f1, f2): elif isinstance (o1, ROOT.TObjString): diff_objstrings (k, o1, o2) else: - print k, type(o1) + print (k, type(o1)) return diff --git a/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/difftuple_text.py b/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/difftuple_text.py index e7f49d61115fa9af3905766be849ed61a711a5f7..c2cdd602a016f31bb73cc184e31903924ed4a8f8 100644 --- a/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/difftuple_text.py +++ b/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/difftuple_text.py @@ -1,7 +1,5 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -# -# $Id$ # # File: D3PDMakerTest/python/difftuple_text.py # Author: snyder@bnl.gov @@ -9,6 +7,8 @@ # Purpose: Diff a root tuple file against a text dump. # +from __future__ import print_function + import operator import os @@ -1255,7 +1255,7 @@ class Dumpreader (object): if l.find ('wrong interface id') >= 0: continue ll = l.split() if len(ll) != 2: - print 'Unknown line', l + print ('Unknown line', l) break (typ, key) = ll if typ == 'Tree': @@ -1265,7 +1265,7 @@ class Dumpreader (object): elif typ == 'TH1': self.keys[key] = Hist (self.reader) else: - print 'Unknown type', typ + print ('Unknown type', typ) break @@ -1278,9 +1278,9 @@ def dictkey_diff (d1, d2, msg, filter = None): if filter: keys = [k for k in keys if not filter(k)] if keys: keys.sort() - print msg + print (msg) for k in keys: - print ' ', k + print (' ', k) return @@ -1295,8 +1295,8 @@ def apply_renames (d1, d2, renames): def diff_string (k, s1, s2): if s1.val != s2.val: - print 'String', k, 'has value', s1.val, \ - 'in new file but value', s2.val, 'in reference file' + print ('String', k, 'has value', s1.val, + 'in new file but value', s2.val, 'in reference file') return @@ -1334,7 +1334,7 @@ def compare (o1, o2, thresh = 1e-6, ithresh = None, eltcmp = None): if den == 0: continue x = xabs(num / den) if x > thresh: - print 'fnmismatch', x1, x2, x, thresh + print ('fnmismatch', x1, x2, x, thresh) return False return True @@ -1361,7 +1361,7 @@ def compare (o1, o2, thresh = 1e-6, ithresh = None, eltcmp = None): x = abs(num / den) if callable(thresh): thresh = thresh(den) if x > thresh: - print 'fmismatch', o1, o2, x, thresh + print ('fmismatch', o1, o2, x, thresh) return False return True return o1 == o2 @@ -1541,8 +1541,8 @@ def diff_branch (k, kb, v1, v2): ev1 = list(set(ev1).intersection(set(ev2))) ev1.sort() else: - print head, 'Different set of events; new file: ', \ - ev1, 'reference file', ev2 + print (head, 'Different set of events; new file: ', + ev1, 'reference file', ev2) return ithresh = None @@ -1675,13 +1675,13 @@ def diff_branch (k, kb, v1, v2): b2 = float(b2) if type(b1) != type(b2): - print head, 'Type differs; new file: ', type(b1).__name__, \ - 'reference file:', type(b2).__name__ + print (head, 'Type differs; new file: ', type(b1).__name__, + 'reference file:', type(b2).__name__) elif not compare (b1, b2, thresh = thresh, ithresh = ithresh, eltcmp = eltcmp): - print head, 'Branch mismatch' - print ' new file:', b1 - print ' ref file:', b2 + print (head, 'Branch mismatch') + print (' new file:', b1) + print (' ref file:', b2) return @@ -1701,13 +1701,13 @@ def diff_tree (k, t1, t2): def diff_hist (k, h1, h2): if not compare (h1.bins, h2.bins): - print 'Hist', k, 'has bins', h1.bins - print 'in new file but bins', h2.bins - print 'in reference file' + print ('Hist', k, 'has bins', h1.bins) + print ('in new file but bins', h2.bins) + print ('in reference file') if not compare (h1.errs, h2.errs): - print 'Hist', k, 'has errs', h1.errs - print 'in new file but errs', h2.errs - print 'in reference file' + print ('Hist', k, 'has errs', h1.errs) + print ('in new file but errs', h2.errs) + print ('in reference file') return @@ -1722,9 +1722,9 @@ def diff_files (d1, d2): v1 = d1.keys[k] v2 = d2.keys[k] if type(v1) != type(v2): - print 'Key', k, 'has type', type(v1).__name__, \ - 'in new file, but type', type(v2).__name__, \ - 'in reference file' + print ('Key', k, 'has type', type(v1).__name__, + 'in new file, but type', type(v2).__name__, + 'in reference file') elif type(v1) == String: diff_string (k, v1, v2) elif type(v1) == Tree: @@ -1732,7 +1732,7 @@ def diff_files (d1, d2): elif type(v1) == Hist: diff_hist (k, v1, v2) else: - print 'Unknown type for diff:', type(v1).__name__ + print ('Unknown type for diff:', type(v1).__name__) return diff --git a/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/dumptuple1.py b/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/dumptuple1.py index 085ebab48e81c9d3a6697629506ce6e1026cbe6d..402e61dde0c67703e4a42b3b8c5794d5bb9e0f77 100644 --- a/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/dumptuple1.py +++ b/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/dumptuple1.py @@ -1,7 +1,5 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -# -# $Id$ # # File: D3PDMakerTest/python/dumptuple1.py # Author: snyder@bnl.gov @@ -9,10 +7,12 @@ # Purpose: Test D3PD making. # +from __future__ import print_function + # Always run in batch mode. import os -if os.environ.has_key('DISPLAY'): +if 'DISPLAY' in os.environ: del os.environ['DISPLAY'] @@ -33,6 +33,8 @@ getattr(cppyy.gbl, 'map<string,string>') from RootUtils import PyROOTFixes PyROOTFixes.enable_tree_speedups() +from PyUtils.fprint import fprintln + def safeord(x): if type(x) == type(''): return ord(x) @@ -43,106 +45,108 @@ def safeord(x): def dump_obj1 (tr, coll = True, dodef = False): for i in range (tr.n): assert tr.i[i] == tr.mult_i[i] - print ' %1d %3d %3d %3d %3d %3d %3d %5.1f %5.1f %1d %3d %5.1f %3d %5.1f %3d %5.1f %3d %5.1f' % \ - (i, - safeord(tr.c[i]), - safeord(tr.uc[i]), - tr.s[i], - tr.us[i], - tr.i[i], - tr.ui[i], - tr.f[i], - tr.d[i], - tr.b[i], - tr.o2a_i[i], - tr.o2a_f[i], - tr.o2c_i[i], - tr.o2c_f[i], - tr.o2c_o2d_i[i], - tr.o2c_o2d_f[i], - tr.o2c_o2e_i[i], - tr.o2c_o2e_i[i], - ) + print (' %1d %3d %3d %3d %3d %3d %3d %5.1f %5.1f %1d %3d %5.1f %3d %5.1f %3d %5.1f %3d %5.1f' % + (i, + safeord(tr.c[i]), + safeord(tr.uc[i]), + tr.s[i], + tr.us[i], + tr.i[i], + tr.ui[i], + tr.f[i], + tr.d[i], + tr.b[i], + tr.o2a_i[i], + tr.o2a_f[i], + tr.o2c_i[i], + tr.o2c_f[i], + tr.o2c_o2d_i[i], + tr.o2c_o2d_f[i], + tr.o2c_o2e_i[i], + tr.o2c_o2e_i[i], + )) if dodef: - print ' %3d %3d' % (ord(tr.c1[i]), ord(tr.c2[i])), - print ' %3d %3d' % (ord(tr.uc1[i]), ord(tr.uc2[i])), - print ' %3d %3d' % (tr.s1[i], tr.s2[i]), - print ' %3d %3d' % (tr.us1[i], tr.us2[i]), - print ' %3d %3d' % (tr.i1[i], tr.i2[i]), - print ' %3d %3d' % (tr.ui1[i], tr.ui2[i]), - print ' %5.1f %5.1f' % (tr.f1[i], tr.f2[i]), - print ' %5.1f %5.1f' % (tr.d1[i], tr.d2[i]), - print ' %3d %3d' % (tr.b1[i], tr.b2[i]) + print (' %3d %3d' % (ord(tr.c1[i]), ord(tr.c2[i])), end='') + print (' %3d %3d' % (ord(tr.uc1[i]), ord(tr.uc2[i])), end='') + print (' %3d %3d' % (tr.s1[i], tr.s2[i]), end='') + print (' %3d %3d' % (tr.us1[i], tr.us2[i]), end='') + print (' %3d %3d' % (tr.i1[i], tr.i2[i]), end='') + print (' %3d %3d' % (tr.ui1[i], tr.ui2[i]), end='') + print (' %5.1f %5.1f' % (tr.f1[i], tr.f2[i]), end='') + print (' %5.1f %5.1f' % (tr.d1[i], tr.d2[i]), end='') + print (' %3d %3d' % (tr.b1[i], tr.b2[i])) if coll: for j in range (tr.o2b_n[i]): assert tr.o2b_mult_i[i][j] == tr.o2b_i[i][j] - print ' o2b%1d %3d %5.1f' % (j, - tr.o2b_i[i][j], - tr.o2b_f[i][j]) + print (' o2b%1d %3d %5.1f' % (j, + tr.o2b_i[i][j], + tr.o2b_f[i][j])) return def dump_obj1_2 (tr): for i in range (tr.n): - print ' %1d %3d %5.1f %3d %5.1f %3d %5.1f' % \ - (i, - tr.o2a_i[i], - tr.o2a_f[i], - tr.o2b_i[i], - tr.o2b_f[i], - tr.o2c_i[i], - tr.o2c_f[i], - ) + print (' %1d %3d %5.1f %3d %5.1f %3d %5.1f' % + (i, + tr.o2a_i[i], + tr.o2a_f[i], + tr.o2b_i[i], + tr.o2b_f[i], + tr.o2c_i[i], + tr.o2c_f[i], + )) return def dump_obj3 (tr): for i in range (tr.n): - print ' ', i, tr.pt[i], tr.eta[i], tr.phi[i], tr.m[i], tuple(tr.index[i]), tr.a1_index[i] - print ' ', tr.hlv_pt[i], tr.hlv_eta[i], tr.hlv_phi[i], tr.hlv_m[i] + fprintln (sys.stdout, ' ', i, tr.pt[i], tr.eta[i], tr.phi[i], tr.m[i], tuple(tr.index[i]), tr.a1_index[i]) + fprintln (sys.stdout, ' ', tr.hlv_pt[i], tr.hlv_eta[i], tr.hlv_phi[i], tr.hlv_m[i]) + return def dump_obj4 (tr): for i in range (tr.n): - print ' ', i, tr.obj4[i] + print (' ', i, tr.obj4[i]) def dump_obj5 (tr): for i in range (tr.n): - print ' ', i, tr.obj5[i], tr.anInt[i], tr.aFloat[i], tr.s[i], \ - '%7.1f %6.3f %6.3f' % (tr.aFourvec[i].Pt(), - tr.aFourvec[i].Eta(), - tr.aFourvec[i].Phi()), \ - tr.dummy[i] + print (' ', i, tr.obj5[i], tr.anInt[i], tr.aFloat[i], tr.s[i], + '%7.1f %6.3f %6.3f' % (tr.aFourvec[i].Pt(), + tr.aFourvec[i].Eta(), + tr.aFourvec[i].Phi()), + tr.dummy[i]) def dump_def (tr): - print ' %3d %3d' % (ord(tr.c1), ord(tr.c2)) - print ' %3d %3d' % (ord(tr.uc1), ord(tr.uc2)) - print ' %3d %3d' % (tr.s1, tr.s2) - print ' %3d %3d' % (tr.us1, tr.us2) - print ' %3d %3d' % (tr.i1, tr.i2) - print ' %3d %3d' % (tr.ui1, tr.ui2) - print ' %5.1f %5.1f' % (tr.f1, tr.f2) - print ' %5.1f %5.1f' % (tr.d1, tr.d2) - print ' %3d %3d' % (tr.b1, tr.b2) + print (' %3d %3d' % (ord(tr.c1), ord(tr.c2))) + print (' %3d %3d' % (ord(tr.uc1), ord(tr.uc2))) + print (' %3d %3d' % (tr.s1, tr.s2)) + print (' %3d %3d' % (tr.us1, tr.us2)) + print (' %3d %3d' % (tr.i1, tr.i2)) + print (' %3d %3d' % (tr.ui1, tr.ui2)) + print (' %5.1f %5.1f' % (tr.f1, tr.f2)) + print (' %5.1f %5.1f' % (tr.d1, tr.d2)) + print (' %3d %3d' % (tr.b1, tr.b2)) return def dump_mdt (tr): for i in range (tr.n): - print ' ', i, tr.globalTime[i], tr.driftRadius[i], \ - tr.stepLength[i], tr.energyDeposit[i], \ - tr.particleEncoding[i], tr.kineticEnergy[i], \ - tr.MDTid[i], tr.trackNumber[i] + print (' ', i, tr.globalTime[i], tr.driftRadius[i], + tr.stepLength[i], tr.energyDeposit[i], + tr.particleEncoding[i], tr.kineticEnergy[i], + tr.MDTid[i], tr.trackNumber[i]) return def dump_trackrecord (tr): for i in range (tr.n): - print ' ', i, tr.barcode[i], tr.pdgId[i], tr.E[i], tr.pt[i], \ - tr.eta[i], tr.phi[i], tr.pos_x[i], tr.pos_y[i], tr.pos_z[i], \ - tr.time[i] + fprintln (sys.stdout, ' ', + i, tr.barcode[i], tr.pdgId[i], tr.E[i], tr.pt[i], + tr.eta[i], tr.phi[i], tr.pos_x[i], tr.pos_y[i], tr.pos_z[i], + tr.time[i]) return @@ -162,25 +166,25 @@ def dumpit (file): n = tt.GetEntries() for i in range(n): tt.GetEntry(i) - print '\nEvent', i - print '-----------' - print '** Obj1' + print ('\nEvent', i) + print ('-----------') + print ('** Obj1') dump_obj1 (tr_o1, dodef = True) - print '** Obj1_2' + print ('** Obj1_2') dump_obj1_2 (tr_o12) - print '** Obj1filt' + print ('** Obj1filt') dump_obj1 (tr_o1filt, coll = False) - print '** Obj3' + print ('** Obj3') dump_obj3 (tr_o3) - print '** Obj4' + print ('** Obj4') dump_obj4 (tr_o4) - print '** Obj5' + print ('** Obj5') dump_obj5 (tr_o5) - print '** Def' + print ('** Def') dump_def (tr_def) - print '** MDT' + print ('** MDT') dump_mdt (tr_mdt) - print '** TrackRecord' + print ('** TrackRecord') dump_trackrecord (tr_trackrecord) return diff --git a/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/dumptuple_any.py b/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/dumptuple_any.py index 85e0994e09193bc0557dbd868f3b49674ebdcac9..dc9963455a82748f532fed0c61e49bca7a2ad859 100644 --- a/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/dumptuple_any.py +++ b/PhysicsAnalysis/D3PDMaker/D3PDMakerTest/python/dumptuple_any.py @@ -1,7 +1,5 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -# -# $Id$ # # File: D3PDMakerTest/python/dumptuple_any.py # Author: snyder@bnl.gov @@ -9,6 +7,8 @@ # Purpose: Test D3PD making. # +from __future__ import print_function + # Always run in batch mode. import os @@ -163,18 +163,18 @@ def merge_names (blist): def dumptree (tt, by_branch): n = tt.GetEntries() if tt.GetName().startswith ('dum_') and n > 10000000: - print '[Dummy tree skipped]' + print ('[Dummy tree skipped]') return bb = [b.GetName() for b in tt.GetListOfBranches()] bb.sort() if by_branch: bb = merge_names (bb) - print '\nBranches' - print '-----------' + print ('\nBranches') + print ('-----------') lasttag = '' for b in bb: if b[0] == ':': - print b + print (b) lasttag = b[1:] continue if b == '$': @@ -186,21 +186,21 @@ def dumptree (tt, by_branch): for i in range(n): br.GetEntry(i) data.append (topy (getattr(tt, bname))) - print b, tostr (data) + print (b, tostr (data)) else: for i in range(n): tt.GetEntry(i) - print '\nEvent', i - print '-----------' + print ('\nEvent', i) + print ('-----------') for b in bb: - print b, tostr (topy (getattr (tt, b))) + print (b, tostr (topy (getattr (tt, b)))) return def dumphist (h): - print 'bins: ', [h.GetBinContent(i) for i in range(h.GetSize())] + print ('bins: ', [h.GetBinContent(i) for i in range(h.GetSize())]) if h.GetSumw2N(): - print 'errs: ', [h.GetBinError(i) for i in range(h.GetSize())] + print ('errs: ', [h.GetBinError(i) for i in range(h.GetSize())]) return @@ -214,23 +214,23 @@ def dumpdir (f, by_branch, pref=''): if k == 'Schema': pass elif isinstance (o, ROOT.TTree): - print '\n\n\nTree', pref+k + print ('\n\n\nTree', pref+k) dumptree (o, by_branch) elif isinstance (o, ROOT.TH1): - print '\n\n\nTH1', pref+k + print ('\n\n\nTH1', pref+k) dumphist (o) elif isinstance (o, ROOT.TDirectory): dumpdir (o, by_branch, pref + k + '/') elif isinstance (o, ROOT.TObjString): - print '\n\n\nString', pref+k + print ('\n\n\nString', pref+k) if k == '_pickle': - print '[pickle data skipped]' + print ('[pickle data skipped]') else: - print o, - print '__END_OF_STRING__' + print (o, end='') + print ('__END_OF_STRING__') else: - print '\n\n\nKey', pref+k - print o + print ('\n\n\nKey', pref+k) + print (o) return