[Rivet-svn] r2473 - trunk/bin

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Tue Jun 8 23:31:33 BST 2010


Author: buckley
Date: Tue Jun  8 23:31:37 2010
New Revision: 2473

Log:
Adding --rivet-refs arg to compare-histos, which automatically puts *all* Rivet AIDA ref files in the compare-histos command line, before the MC AIDA files

Modified:
   trunk/bin/compare-histos

Modified: trunk/bin/compare-histos
==============================================================================
--- trunk/bin/compare-histos	Tue Jun  8 23:30:12 2010	(r2472)
+++ trunk/bin/compare-histos	Tue Jun  8 23:31:37 2010	(r2473)
@@ -59,15 +59,21 @@
     except ImportError:
         pass
 
-    rivet_data_dir = os.popen('rivet-config --datadir',"r").readline().strip()
-    if not rivet_data_dir:
-        rivet_data_dir = ""
+    ## Get Rivet data dir
+    rivet_data_dir = ""
+    try:
+        import rivet
+        rivet_data_dir = rivet.getRivetDataPath()
+    except:
+        pass
 
     ## Parse command line options
     from optparse import OptionParser
     parser = OptionParser(usage=usage)
     parser.add_option("-o", "--outdir", dest="OUTDIR",
                       default=".", help="write data files into this directory")
+    parser.add_option("-R", "--rivet-refs", dest="RIVETREFS", action="store_true",
+                      default=False, help="try to use Rivet reference data files")
     parser.add_option("-l", "--histogram-list", dest="HISTOGRAMLIST",
                       default=None, help="this file contains a list of histograms to plot in the format /ANALYSIS_ID/histogramname, e.g. '/DELPHI_1996_S3430090/d01-x01-y01', on each line.")
     parser.add_option("--hier-out", action="store_true", dest="HIER_OUTPUT", default=False,
@@ -104,9 +110,9 @@
             rtn = [i for i in os.environ[name].split(":") if i]
         return rtn
     if os.environ.has_key("RIVET_PLOT_PATH"):
-        opts.PLOTINFODIR += getpathvar("RIVET_PLOT_PATH")        
+        opts.PLOTINFODIR += getpathvar("RIVET_PLOT_PATH")
     elif os.environ.has_key("RIVET_REF_PATH"):
-        opts.PLOTINFODIR += getpathvar("RIVET_REF_PATH")        
+        opts.PLOTINFODIR += getpathvar("RIVET_REF_PATH")
 
     ## Configure logging
     try:
@@ -134,6 +140,10 @@
     ## Get file names and labels
     FILES = []
     FILELABELS = { }
+    if opts.RIVETREFS and rivet_data_dir:
+        import glob
+        reffiles = glob.glob(os.path.join(rivet_data_dir, "*.aida"))
+        args = reffiles + args
     for a in args:
         path = a
         label = None
@@ -171,7 +181,7 @@
         tree = ET.parse(aidafilepath)
         for dps in tree.findall("dataPointSet"):
             ## Get this histogram's path name
-            dpsname = os.path.join(dps.get("path"), dps.get("name"))            
+            dpsname = os.path.join(dps.get("path"), dps.get("name"))
             h = Histo.fromDPS(dps)
             ## Is it a data histo?
             h.isdata = dpsname.upper().startswith("/REF")
@@ -293,7 +303,8 @@
             continue
 
         if len(activefiles) == 1 and opts.NO_SHOW_IF_ONLY_ONE:
-            logging.warning("Skipping histo '%s' since only one plot is present" % name)
+            if not opts.RIVETREFS:
+                logging.warning("Skipping histo '%s' since only one plot is present" % name)
             continue
 
         ## Identify reference file for this histo


More information about the Rivet-svn mailing list