|
[Rivet-svn] r3171 - in trunk: . bin pyextblackhole at projects.hepforge.org blackhole at projects.hepforge.orgThu Jun 30 17:02:10 BST 2011
Author: hoeth Date: Thu Jun 30 17:02:10 2011 New Revision: 3171 Log: flat2aida: preserve histogram ordering Modified: trunk/ChangeLog trunk/bin/flat2aida trunk/pyext/lighthisto.py Modified: trunk/ChangeLog ============================================================================== --- trunk/ChangeLog Thu Jun 30 15:55:25 2011 (r3170) +++ trunk/ChangeLog Thu Jun 30 17:02:10 2011 (r3171) @@ -1,3 +1,10 @@ +2011-06-30 Hendrik Hoeth <hendrik.hoeth at cern.ch> + + * fix fromFlat() in lighthistos: It would ignore histogram paths + before. + + * flat2aida: preserve histogram order from .dat files + 2011-06-27 Andy Buckley <andy at insectnation.org> * pyext/setup.py.in: Use CXXFLAGS and LDFLAGS safely in the Python Modified: trunk/bin/flat2aida ============================================================================== --- trunk/bin/flat2aida Thu Jun 30 15:55:25 2011 (r3170) +++ trunk/bin/flat2aida Thu Jun 30 17:02:10 2011 (r3171) @@ -95,7 +95,7 @@ ## Run over the files and build histo objects selected by the pattern filtering - histos = {} + histos = [] for flatfile in args: if flatfile != "-" and not os.access(flatfile, os.R_OK): logging.error("%s can not be read" % flatfile) @@ -107,7 +107,8 @@ print e sys.exit(1) - for histpath, hist in allhistos.iteritems(): + for hist in allhistos: + histpath = hist.fullPath() useThis = True if opts.PATHPATTERNS: useThis = False @@ -125,26 +126,24 @@ plotparser.updateHistoHeaders(hist) except ValueError, err: logging.debug(err) - histos.setdefault(flatfile, []).append(hist) + histos.append((flatfile, hist)) ## Write output if histos: ## Split output per-histogram if opts.SPLITOUTPUT: - for f, hs in sorted(histos.iteritems()): - for h in sorted(hs): - histo = h.fullPath()[1:].replace("/", "_") - outfile = "%s.aida" % histo - #print "Writing to", outfile - out = open(outfile, "w") - out.write('<?xml version="1.0" ?>\n') - out.write('<!DOCTYPE aida SYSTEM "http://aida.freehep.org/schemas/3.3/aida.dtd">\n') - out.write('<aida version="3.3">\n') - out.write(' <implementation version="1.1" package="Rivet"/>\n') - out.write(h.asAIDA()) - out.write('</aida>\n') - out.close() + for f, h in histos: + histo = h.fullPath()[1:].replace("/", "_") + outfile = "%s.aida" % histo + out = open(outfile, "w") + out.write('<?xml version="1.0" ?>\n') + out.write('<!DOCTYPE aida SYSTEM "http://aida.freehep.org/schemas/3.3/aida.dtd">\n') + out.write('<aida version="3.3">\n') + out.write(' <implementation version="1.1" package="Rivet"/>\n') + out.write(h.asAIDA()) + out.write('</aida>\n') + out.close() ## Write all output to a single file (stdout by default) elif opts.OUTPUT: outfile = opts.OUTPUT @@ -156,15 +155,18 @@ out.write('<!DOCTYPE aida SYSTEM "http://aida.freehep.org/schemas/3.3/aida.dtd">\n') out.write('<aida version="3.3">\n') out.write(' <implementation version="1.1" package="Rivet"/>\n') - for f, hs in sorted(histos.iteritems()): - for h in sorted(hs): - out.write(h.asAIDA()) + for f, h in histos: + out.write(h.asAIDA()) out.write('</aida>\n') if outfile != "-": out.close() ## Split output per-infile else: - for f, hs in sorted(histos.iteritems()): + histodict = dict() + for f, h in histos: + histodict.setdefault(f, []) + histodict[f].append(h) + for f, hs in histodict.iteritems(): outfile = os.path.basename(f).replace(".dat", ".aida") if f == "-": outfile = "out.dat" @@ -173,7 +175,7 @@ out.write('<!DOCTYPE aida SYSTEM "http://aida.freehep.org/schemas/3.3/aida.dtd">\n') out.write('<aida version="3.3">\n') out.write(' <implementation version="1.1" package="Rivet"/>\n') - for h in sorted(hs): + for h in hs: out.write(h.asAIDA()) out.write('</aida>\n') out.close() Modified: trunk/pyext/lighthisto.py ============================================================================== --- trunk/pyext/lighthisto.py Thu Jun 30 15:55:25 2011 (r3170) +++ trunk/pyext/lighthisto.py Thu Jun 30 17:02:10 2011 (r3171) @@ -402,7 +402,7 @@ The keys of the dictionary are the full paths of the histogram, i.e. AnalysisID/HistoID, a leading "/REF" is stripped from the keys. """ - runhistos = dict() + runhistos = [] if path == "-": f = sys.stdin else: @@ -418,7 +418,7 @@ if fullpath: s += line if "END HISTOGRAM" in line: - runhistos[fullpath] = cls.fromFlatHisto(s) + runhistos.append(cls.fromFlatHisto(s)) ## Reset for next histo fullpath = None s = ""
More information about the Rivet-svn mailing list |