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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Fri Dec 30 13:42:00 GMT 2011


Author: buckley
Date: Fri Dec 30 13:42:00 2011
New Revision: 3533

Log:
Tweaking to avoid a very time-consuming debug printout in compare-histos with the -v flag, other minor tidyings, noting some TODOs, and adding a placeholder rivet-which script (not currently installed)

Added:
   trunk/bin/rivet-which   (contents, props changed)
Modified:
   trunk/ChangeLog
   trunk/bin/compare-histos
   trunk/bin/make-plots
   trunk/bin/rivet-mkhtml

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	Fri Dec 16 15:42:17 2011	(r3532)
+++ trunk/ChangeLog	Fri Dec 30 13:42:00 2011	(r3533)
@@ -1,3 +1,10 @@
+2011-12-30  Andy Buckley  <andy.buckley at cern.ch>
+
+	* Tweaking to avoid a very time-consuming debug printout in
+	compare-histos with the -v flag, other minor tidyings, noting some
+	TODOs, and adding a placeholder rivet-which script (not currently
+	installed).
+
 2011-12-12  Andy Buckley  <andy.buckley at cern.ch>
 
 	* Adding a command line completion function for rivet-mkhtml.

Modified: trunk/bin/compare-histos
==============================================================================
--- trunk/bin/compare-histos	Fri Dec 16 15:42:17 2011	(r3532)
+++ trunk/bin/compare-histos	Fri Dec 30 13:42:00 2011	(r3533)
@@ -261,7 +261,7 @@
     if opts.STYLE == 'talk':
         PLOTSTYLES += 'PlotSize=8,6\n'
         HISTSTYLES += 'LineWidth=1pt\n'
-    if opts.STYLE == 'bw':
+    elif opts.STYLE == 'bw':
         PLOTSTYLES += 'RatioPlotErrorBandColor=black!10\n'
         COLORS = ('black!90', 'black!50', 'black!30')
         STYLES = []
@@ -298,14 +298,12 @@
         logging.error(parser.get_usage())
         exit(2)
 
-
     ## Handle a request for a reference dataset other than REF
     if opts.REF_ID != "REF":
         if not os.access(os.path.abspath(opts.REF_ID), os.R_OK):
             logging.error("Error: cannot read reference file %s" % opts.REF_ID)
             sys.exit(2)
 
-
     ## Read histo data from files into data structures
     HISTOS = {}
     TITLES = {}
@@ -340,7 +338,6 @@
         for n, t in ylabels.iteritems():
             YLABELS[n] = t
 
-
     # ## Choose histos - use all histos with MC data, or restrict with a list read from file
     # if opts.HISTOGRAMLIST is not None:
     #     newnames = []
@@ -380,7 +377,6 @@
     NAMES = NAMES.intersection(acceptednames)
     MCNAMES = MCNAMES.intersection(acceptednames)
 
-
     ## Pre-emptively reduce number of files to iterate through
     ## (assuming, reasonably, that there is only one ref file per histo)
     activenames = NAMES
@@ -506,7 +502,8 @@
             histopts = {}
         histstrs = []
         i = 0
-        logging.debug("Active files: %s" % activefiles)
+        # logging.debug("Active files: %s" % activefiles)
+
         for hfile in activefiles:
             histstr = '# BEGIN HISTOGRAM %s%s\n' % (hfile.replace(' ','_'), HISTOS[hfile][name].fullPath().replace(' ','_'))
             if HISTOS[hfile][name].isdata:
@@ -565,4 +562,5 @@
         f.write(headstr + "\n" + "\n".join(histstrs))
         f.close()
         num_written += 1
+
     logging.info("Wrote %d histo files" % num_written)

Modified: trunk/bin/make-plots
==============================================================================
--- trunk/bin/make-plots	Fri Dec 16 15:42:17 2011	(r3532)
+++ trunk/bin/make-plots	Fri Dec 30 13:42:00 2011	(r3533)
@@ -5,7 +5,8 @@
 
 TODO
  * Optimise output for e.g. lots of same-height bins in a row
- * Tidy LaTeX-writing code
+ * Add a RatioFullRange directive to show the full range of error bars + MC envelope in the ratio
+ * Tidy LaTeX-writing code -- faster to compile one doc only, then split it?
  * Handle boolean values flexibly (yes, no, true, false, etc. as well as 1, 0)
 """
 

Modified: trunk/bin/rivet-mkhtml
==============================================================================
--- trunk/bin/rivet-mkhtml	Fri Dec 16 15:42:17 2011	(r3532)
+++ trunk/bin/rivet-mkhtml	Fri Dec 30 13:42:00 2011	(r3533)
@@ -14,7 +14,7 @@
 You can overwrite an existing output directory.
 """
 
-import sys
+import sys, os
 if sys.version_info[:3] < (2,4,0):
     sys.stderr.write("rivet scripts require Python version >= 2.4.0... exiting\n")
     sys.exit(1)
@@ -143,12 +143,13 @@
         if reffile and reffile not in reffiles:
             reffiles.append(reffile)
 
+
 def anasort(name):
     if name.startswith("MC"):
         return "0"+name
     else:
         return name
-analyses=sorted(analyses, key=anasort, reverse=True)
+analyses = sorted(analyses, key=anasort, reverse=True)
 
 
 ## Run compare-histos to get plain .dat files from .aida
@@ -161,8 +162,7 @@
 if opts.REF_ID is not None:
     ch_cmd.append("--refid=%s" % os.path.abspath(opts.REF_ID))
 ch_cmd.append("--hier-out")
-ch_cmd.append("--rivet-refs")
-# TODO: This isn't very sensible... what's the intention? Provide --plotinfodir cmd line option?
+# TODO: Need to be able to override this: provide a --plotinfodir cmd line option?
 ch_cmd.append("--plotinfodir=../")
 for af in aidafiles:
     aidafilepath = os.path.abspath(af.split(":")[0])
@@ -174,14 +174,18 @@
             newarg += ":%s" % opt
     # print newarg
     ch_cmd.append(newarg)
+# TODO: Pass rivet-mkhtml -m and -M args to compare-histos
 if opts.VERBOSE:
     ch_cmd.append("--verbose")
-    print "Calling compare-histos with the following options:"
-    print ch_cmd
+    print "Calling compare-histos with the following command:"
     print " ".join(ch_cmd)
-# print " ".join(ch_cmd)
-Popen(ch_cmd, cwd=opts.OUTPUTDIR, stderr=PIPE).wait()
 
+## Run compare-histos in a subdir, after fixing any relative paths in Rivet env vars
+for var in ("RIVET_ANALYSIS_PATH", "RIVET_REF_PATH", "RIVET_INFO_PATH", "RIVET_PLOT_PATH"):
+    if var in os.environ:
+        abspaths = map(os.path.abspath, os.environ[var].split(":"))
+        os.environ[var] = ":".join(abspaths)
+Popen(ch_cmd, cwd=opts.OUTPUTDIR, stderr=PIPE).wait()
 
 ## Write web page containing all (matched) plots
 ## Make web pages first so that we can load it locally in

Added: trunk/bin/rivet-which
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/bin/rivet-which	Fri Dec 30 13:42:00 2011	(r3533)
@@ -0,0 +1,27 @@
+#! /usr/bin/env python
+
+"""
+Path searching tool for files associated with the Rivet analysis toolkit.
+
+TODO:
+ * Add auto-categorising of the searches based on file extension
+ * Add a switch to return all or just the first match
+ * Add switches to force searching in a particular file category (libs, info, ref data, plo files)
+ * Add partial name / regex searching? (Requires extending the Rivet library)
+"""
+
+import sys, os, optparse
+op = optparse.OptionParser()
+ops, args = op.parse_args()
+
+import rivet
+
+# print rivet.findAnalysisPlotFile()
+# print rivet.findAnalysisLibFile()
+# print rivet.findAnalysisInfoFile()
+# print rivet.findAnalysisRefFile()
+for a in args:
+    try:
+        print rivet.findAnalysisRefFile(a)
+    except:
+        print "No match for '%s'"


More information about the Rivet-svn mailing list