[Rivet-svn] r2445 - trunk/bin

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Tue May 11 14:05:35 BST 2010


Author: buckley
Date: Tue May 11 14:14:12 2010
New Revision: 2445

Log:
Using scientific rather than decimal notation for all floating-point printouts, to avoid numerical precision problems

Modified:
   trunk/bin/aida2root
   trunk/bin/rivet-mergeruns
   trunk/bin/rivet-rescale

Modified: trunk/bin/aida2root
==============================================================================
--- trunk/bin/aida2root	Tue May 11 14:05:55 2010	(r2444)
+++ trunk/bin/aida2root	Tue May 11 14:14:12 2010	(r2445)
@@ -15,7 +15,7 @@
 import sys, os
 from array import array
 try:
-    from ROOT import TGraphAsymmErrors, TFile 
+    from ROOT import TGraphAsymmErrors, TFile
 except:
     sys.stderr.write("Couldn't find PyROOT module. If ROOT is installed, PyROOT probably is too, but it's not currently accessible\n")
     foundpyroot = False
@@ -136,11 +136,11 @@
         self.focus= focus
 
     def __str__(self):
-        out = "%f to %f: %f +- %f" % (self.xval-self.xerrminus, self.xval+self.xerrplus, self._yval, self._yerr)
+        out = "%e to %e: %e +- %e" % (self.xval-self.xerrminus, self.xval+self.xerrplus, self._yval, self._yerr)
         return out
 
     def asFlat(self):
-        out = "%f %f %f %f %f" % (self.xval-self.xerrminus, self.xval+self.xerrplus, self.yval, self.yerrminus, self.yerrplus)
+        out = "%e %e %e %e %e" % (self.xval-self.xerrminus, self.xval+self.xerrplus, self.yval, self.yerrminus, self.yerrplus)
         return out
 
     def __cmp__(self, other):
@@ -238,11 +238,11 @@
 
 from optparse import OptionParser
 parser = OptionParser(usage="%prog aidafile [aidafile2 ...]")
-parser.add_option("-s", "--smart-output", action="store_true", default=True, 
-                  help="Write to output files with names based on the corresponding input filename", 
+parser.add_option("-s", "--smart-output", action="store_true", default=True,
+                  help="Write to output files with names based on the corresponding input filename",
                   dest="SMARTOUTPUT")
 parser.add_option("-m", "--match", action="append",
-                  help="Only write out histograms whose $path/$name string matches these regexes", 
+                  help="Only write out histograms whose $path/$name string matches these regexes",
                   dest="PATHPATTERNS")
 opts, args = parser.parse_args()
 if opts.PATHPATTERNS is None:

Modified: trunk/bin/rivet-mergeruns
==============================================================================
--- trunk/bin/rivet-mergeruns	Tue May 11 14:05:55 2010	(r2444)
+++ trunk/bin/rivet-mergeruns	Tue May 11 14:14:12 2010	(r2445)
@@ -14,9 +14,9 @@
 ##
 ## Usage example:
 ##  $ uemerge hwpp/hpp-1800-{030.aida:1800:30,090.aida:1800:90} > hpp-hists.dat
-##  $ flat2aida hpp-hists.dat 
+##  $ flat2aida hpp-hists.dat
 ##  $ mkdir plots && cd plots
-##  $ compare_histos.py ../ref04.aida ../hpp-hists.aida 
+##  $ compare_histos.py ../ref04.aida ../hpp-hists.aida
 ##  $ make_plot.py --pdf *.dat
 
 
@@ -164,7 +164,7 @@
         global opts
 #         if opts.GNUPLOT:
 #             out = "%e\t%e\t%e\t%e\t%e\t%e" % (self.getBinCenter(), self.yval,
-#                                               self.xlow, self.xhigh, 
+#                                               self.xlow, self.xhigh,
 #                                               self.yval-self.yerrminus, self.yval+self.yerrplus)
 #         else:
         out = "%e\t%e\t%e\t%e" % (self.xlow, self.xhigh, self.yval, 0.5*(self.yerrminus+self.yerrplus))
@@ -280,7 +280,7 @@
                 desthisto.setBin(i, newb)
                 ##### This logging line breaks the output!!!!!!!
                 ####logging.debug("Copied: %s / %s" % (str(b), str(histosS[hpath][sqrts].getBin(i))) )
-    
+
 def mergeByPt(hpath, sqrts):
     global inhistos
     global outhistos
@@ -302,7 +302,7 @@
                 closest_ptmin = float(ptm)
         if closest_ptmin != float(ptmin):
             logging.warning("Inexact match for requested pTmin=%s: " % ptmin + \
-                                "using pTmin=%f instead" % closest_ptmin)
+                                "using pTmin=%e instead" % closest_ptmin)
         outhistos[hpath] =  inhistos[hpath][sqrts][closest_ptmin]
     except:
         pass

Modified: trunk/bin/rivet-rescale
==============================================================================
--- trunk/bin/rivet-rescale	Tue May 11 14:05:55 2010	(r2444)
+++ trunk/bin/rivet-rescale	Tue May 11 14:14:12 2010	(r2445)
@@ -102,7 +102,7 @@
         try:
             refhistos=getHistosFromAIDA(refpath)
             logging.info("Read ref histos from file %s"%refpath)
-        # Otherwise assume refpath is a directory    
+        # Otherwise assume refpath is a directory
         except:
             for aida in os.listdir(refpath):
                 if aida.endswith(".aida"):
@@ -172,9 +172,9 @@
     if len(splitline) == 2:
         try:
             area = float(splitline[1])
-            logging.debug("Success: %f"%area)
+            logging.debug("Success: %e" % area)
         except:
-            logging.debug("Failed: %s"%splitline[1])
+            logging.debug("Failed: %s" % splitline[1])
             pass
     return (low, high, area)
 
@@ -298,8 +298,7 @@
                 newarea = tempref.getArea()
 
             # Renormalise histo
-            logging.info("Rescaling %s from %f to %f"%(name, oldarea,
-                newarea))
+            logging.info("Rescaling %s from %e to %e" % (name, oldarea, newarea))
             renormed = tempold.renormalise(newarea)
 
             # Write to file
@@ -312,4 +311,4 @@
     if opts.AIDA:
         f.write("</aida>")
 
-    logging.info("Done. Written output to %s."%outfile)
+    logging.info("Done. Written output to %s." % outfile)


More information about the Rivet-svn mailing list