[Rivet-svn] r2102 - in trunk: bin pyext

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Thu Nov 26 13:23:13 GMT 2009


Author: eike
Date: Thu Nov 26 13:23:13 2009
New Revision: 2102

Log:
update Histo title,{x,y}labels from PlotParser in aida2flat

Modified:
   trunk/bin/aida2flat
   trunk/bin/compare-histos
   trunk/pyext/lighthisto.py

Modified: trunk/bin/aida2flat
==============================================================================
--- trunk/bin/aida2flat	Thu Nov 26 12:52:09 2009	(r2101)
+++ trunk/bin/aida2flat	Thu Nov 26 13:23:13 2009	(r2102)
@@ -37,20 +37,26 @@
 
 if __name__ == "__main__":
 
+    rivet_data_dir=os.popen('rivet-config --datadir',"r").readline().strip()
+    if not rivet_data_dir:
+        rivet_data_dir=""
+
     ## Parse command line options
     from optparse import OptionParser, OptionGroup
     parser = OptionParser(usage="%prog aidafile [aidafile2 ...]")
-    parser.add_option("-s", "--split", action="store_true", default=False, 
-                      help="Write each histo to a separate output file, with names based on the histo path", 
+    parser.add_option("-s", "--split", action="store_true", default=False,
+                      help="Write each histo to a separate output file, with names based on the histo path",
                       dest="SPLITOUTPUT")
-    parser.add_option("-g", "--gnuplot", action="store_true", default=False, 
+    parser.add_option("-g", "--gnuplot", action="store_true", default=False,
                       help="Provide output suitable for Gnuplot's 'plot \"foo.dat\" with xye'. Implies --split",
                       dest="GNUPLOT")
-    parser.add_option("-S", "--smart-output", action="store_true", default=False, 
-                      help="Write to output files with names based on the corresponding input filename", 
+    parser.add_option("--plot-info-dir", dest="PLOTINFODIR", action="append",
+                      default=["./", rivet_data_dir], help="directory which may contain plot header information")
+    parser.add_option("-S", "--smart-output", action="store_true", default=False,
+                      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")
     verbgroup = OptionGroup(parser, "Verbosity control")
     verbgroup.add_option("-V", "--verbose", action="store_const", const=logging.DEBUG, dest="LOGLEVEL",
@@ -86,6 +92,8 @@
         sys.stderr.write("Must specify at least one AIDA histogram file\n")
         sys.exit(1)
 
+    plotparser = lighthisto.PlotParser(filter(lambda s: len(s) > 0, opts.PLOTINFODIR))
+
 
     ## Run over the files, make histos and write out those that match the patterns
     import re
@@ -110,7 +118,9 @@
                         useThisDps = True
                         break
             if useThisDps:
-                histos.append(lighthisto.Histo.fromDPS(dps))
+                hist = lighthisto.Histo.fromDPS(dps)
+                plotparser.updateHistoHeaders(hist)
+                histos.append(hist)
         if len(histos) > 0:
             if opts.SPLITOUTPUT:
                 paper = os.path.basename(aidafile).replace(".aida", "")

Modified: trunk/bin/compare-histos
==============================================================================
--- trunk/bin/compare-histos	Thu Nov 26 12:52:09 2009	(r2101)
+++ trunk/bin/compare-histos	Thu Nov 26 13:23:13 2009	(r2102)
@@ -69,7 +69,7 @@
                       default=".", help="write data files into this directory")
     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, 
+    parser.add_option("--hier-out", action="store_true", dest="HIER_OUTPUT", default=False,
                       help="write output dat files into a directory hierarchy which matches the analysis paths")
     parser.add_option("--linear", action="store_true", dest="LINEAR",
                       default=False, help="plot with linear scale")
@@ -241,7 +241,7 @@
     ## For < 2.4 compatibility, since Set has no 'sort' method
     NAMES = [i for i in NAMES]
     num_written = 0
-    plotparser = PlotParser(opts.PLOTINFODIR)
+    plotparser = PlotParser(filter(lambda s: len(s) > 0, opts.PLOTINFODIR))
     for name in sorted(NAMES):
         logging.debug("Writing histos for plot '%s'" % name)
 

Modified: trunk/pyext/lighthisto.py
==============================================================================
--- trunk/pyext/lighthisto.py	Thu Nov 26 12:52:09 2009	(r2101)
+++ trunk/pyext/lighthisto.py	Thu Nov 26 13:23:13 2009	(r2102)
@@ -457,3 +457,9 @@
 
     def isComment(self, line):
         return self.pat_comment.match(line) is not None
+
+    def updateHistoHeaders(self, hist):
+        headers = self.getHeaders(hist.histopath)
+        hist.title = headers["Title"]
+        hist.xlabel = headers["XLabel"]
+        hist.ylabel = headers["YLabel"]


More information about the Rivet-svn mailing list