[Rivet-svn] r2814 - in trunk: . bin

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Fri Dec 3 12:36:56 GMT 2010


Author: buckley
Date: Fri Dec  3 12:36:56 2010
New Revision: 2814

Log:
Include bin gap removal in compare-histos, and preparing for 1.4.0 release

Modified:
   trunk/ChangeLog
   trunk/bin/compare-histos
   trunk/bin/rivet-rmgaps

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	Fri Dec  3 01:55:57 2010	(r2813)
+++ trunk/ChangeLog	Fri Dec  3 12:36:56 2010	(r2814)
@@ -1,3 +1,11 @@
+2010-12-03  Andy Buckley  <andy at insectnation.org>
+
+	* 1.4.0 release.
+
+	* Add bin-skipping to compare-histos to avoid one use of
+	rivet-rmgaps (it's still needed for non-plotting post-processing
+	like Professor).
+
 2010-11-27  Andy Buckley  <andy at insectnation.org>
 
 	* MathUtils.hh: Adding fuzzyGtrEquals and fuzzyLessEquals, and

Modified: trunk/bin/compare-histos
==============================================================================
--- trunk/bin/compare-histos	Fri Dec  3 01:55:57 2010	(r2813)
+++ trunk/bin/compare-histos	Fri Dec  3 12:36:56 2010	(r2814)
@@ -185,7 +185,6 @@
             import glob
             reffiles += glob.glob(os.path.join(d, "*.aida"))
         args = reffiles + args
-        ## TODO: Really want to behave as if all the Rivet ref files were listed on the command line?
     for a in args:
         asplit = a.split(":")
         path = asplit[0]
@@ -382,7 +381,7 @@
 
         drawonlystr = ""
         for hfile in activefiles:
-            drawonlystr += hfile + HISTOS[hfile][name].fullPath()+" "
+            drawonlystr += hfile + HISTOS[hfile][name].fullPath() + " "
         paramdefaults = {"Title" : title,
                          "XLabel" : xlabel,
                          "YLabel" : ylabel,
@@ -452,8 +451,21 @@
             if hfile in FILEOPTIONS:
                 for option in FILEOPTIONS[hfile]:
                     histstr += '%s\n' % option
-            for bin in HISTOS[hfile][name].getBins():
+            def eq(a, b):
+                if a == 0 and b == 0:
+                    return True
+                return abs((b-a)/(b+a)) < 10e-3
+            numskipped = 0
+            #print hfile, name, HISTOS[hfile][name].numBins(), HISTOS[ref][name].numBins()
+            for ibin, bin in enumerate(HISTOS[hfile][name].getBins()):
                 xmin, xmax = bin.getXRange()
+                ## Skip writing this MC bin if the bin edges don't match, and the MC histo has too many bins
+                if hfile != ref and HISTOS[hfile][name].numBins() > HISTOS[ref][name].numBins():
+                    rxmin, rxmax = HISTOS[ref][name].getBin(ibin-numskipped).getXRange()
+                    if not eq(rxmin, xmin) or not eq(rxmax, xmax):
+                        numskipped += 1
+                        assert(numskipped <= (HISTOS[hfile][name].numBins() - HISTOS[ref][name].numBins()))
+                        continue
                 histstr += '%e\t%e\t%e\t%e\n' % (xmin, xmax, bin.yval, bin.yerr)
             histstr += "# END HISTOGRAM\n"
             histstrs.append(histstr)

Modified: trunk/bin/rivet-rmgaps
==============================================================================
--- trunk/bin/rivet-rmgaps	Fri Dec  3 01:55:57 2010	(r2813)
+++ trunk/bin/rivet-rmgaps	Fri Dec  3 12:36:56 2010	(r2814)
@@ -123,7 +123,7 @@
                 plural = ""
             logging.info("Stripping %d bin%s from %s" % (numrm, plural, self.description['AidaPath']))
             newdata = []
-            for i in range(len(self.data)):
+            for i in xrange(len(self.data)):
                 if self.data[i]['LowEdge'] == refhist.data[i]['LowEdge'] and \
                    self.data[i]['UpEdge'] == refhist.data[i]['UpEdge']:
                     newdata.append(self.data[i])


More information about the Rivet-svn mailing list