[Rivet-svn] r2041 - trunk/doc

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Sun Nov 8 16:29:45 GMT 2009


Author: buckley
Date: Sun Nov  8 16:29:45 2009
New Revision: 2041

Log:
Adding hacky plot listings to LaTeX manual

Added:
   trunk/doc/readplot.py
Modified:
   trunk/doc/mk-analysis-latex

Modified: trunk/doc/mk-analysis-latex
==============================================================================
--- trunk/doc/mk-analysis-latex	Sat Nov  7 17:38:16 2009	(r2040)
+++ trunk/doc/mk-analysis-latex	Sun Nov  8 16:29:45 2009	(r2041)
@@ -73,7 +73,7 @@
 
 
     if ana.authors():
-        page += "\\textbf{Authors:}\n \\penalty 100"
+        page += "\\textbf{Authors:}\n \\penalty 100\n"
         page += "\\begin{itemize}\n"
         for a in ana.authors():
             s = a
@@ -90,7 +90,7 @@
 
 
     if ana.references():
-        page += "\\textbf{References:}\n \\penalty 100"
+        page += "\\textbf{References:}\n \\penalty 100\n"
         page += "\\begin{itemize}\n"
         for r in ana.references():
             if r.startswith("arXiv:"):
@@ -109,7 +109,7 @@
 
 
     if ana.runInfo():
-        page += "\\textbf{Run details:}\n \\penalty 100"
+        page += "\\textbf{Run details:}\n \\penalty 100\n"
         page += "\\begin{itemize}\n"
         #print ana.runInfo()
         for l in ana.runInfo().split("\n*"):
@@ -125,6 +125,21 @@
     for para in ana.description().split("\n\n"):
         page += "\n\\noindent " + para + "\n"
 
+
+    try:
+        import readplot
+        info = readplot.plotinfo(ana.name())
+        if info:
+            page += "\n\\vspace{1em}\\noindent"
+            page += "\\textbf{Histograms:}\n \\penalty 100\n"
+            page += "\\begin{itemize}\n"
+            for hpath in info.keys():
+                htitle = info[hpath]["TITLE"]
+                page += "  \\item %s (\kbd{%s})\n" % (htitle, hpath)
+            page += "\\end{itemize}\n"
+    except:
+        pass 
+
     page += "\n\\clearpage\n"
 
     page = texify(page)

Added: trunk/doc/readplot.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/doc/readplot.py	Sun Nov  8 16:29:45 2009	(r2041)
@@ -0,0 +1,85 @@
+#! /usr/bin/env python
+
+## Make "set" a builtin type on Python < 2.4
+if not 'set' in dir(__builtins__):
+    from sets import Set as set
+
+## Make "sorted" a builtin function on Python < 2.4
+if not 'sorted' in dir(__builtins__):
+    def sorted(iterable, cmp=None, key=None, reverse=None):
+        rtn = iterable
+        rtn.sort(cmp)#, key, reverse)
+        return rtn
+
+
+## Get input paths to allow rivet module to be imported from the src dir
+import os, re, glob, sys
+pybuild = os.path.abspath(os.path.join(os.getcwd(), "..", "pyext", "build"))
+dirs = []
+for d in os.listdir(pybuild):
+    if re.match(r"lib\..*-.*-%d\.%d" % (sys.version_info[0], sys.version_info[1]), d):
+        dirs.append(os.path.join(pybuild, d))
+sys.path = dirs + sys.path
+os.environ["LD_LIBRARY_PATH"] = os.environ["LD_LIBRARY_PATH"] + ":" + \
+    os.path.abspath(os.path.join(os.getcwd(), "..", "src", ".libs"))
+anadirs = glob.glob(os.path.join(os.getcwd(), "..", "src", "Analyses", "*", ".libs"))
+#print anadirs
+os.environ["RIVET_ANALYSIS_PATH"] = ":".join(anadirs)
+
+        
+## Change dlopen status to GLOBAL for Rivet lib
+try:
+    import ctypes
+    sys.setdlopenflags(sys.getdlopenflags() | ctypes.RTLD_GLOBAL)
+except:
+    import dl
+    sys.setdlopenflags(sys.getdlopenflags() | dl.RTLD_GLOBAL)
+import rivet
+
+
+# all_analyses = rivet.AnalysisLoader.analysisNames()
+# for a in 
+#plotinfos = glob.glob(os.path.join(os.getcwd(), "..", "data", "plotinfo", "*"))
+
+
+## Get list of plots for each analysis
+def plotinfo(aname):
+    finfo = None
+    rtn = {}
+    try:
+        import yaml, glob
+        files = glob.glob(os.path.join(os.getcwd(), "..", "data", "plotinfo", aname+"*"))
+        plotinfofile = files[0]
+        finfo = open(plotinfofile, "r")
+    except:
+        return rtn
+    import re
+    pat_begin_block = re.compile('^# BEGIN ([A-Z0-9_]+) ?(\S+)?')
+    pat_end_block =   re.compile('^#+ END ([A-Z0-9_]+)')
+    pat_comment = re.compile('^#|^\s*$')
+    pat_property = re.compile('^(\w+?)=(.*)$')
+    pat_path_property  = re.compile('^(\S+?)::(\w+?)=(.*)$')
+
+    current_histo = None
+    for line in finfo:
+        mbegin = pat_begin_block.match(line)        
+        if mbegin:
+            current_histo = mbegin.group(2)
+            rtn.setdefault(current_histo, dict())
+            continue
+        mend = pat_end_block.match(line)
+        if mend:
+            current_histo = None
+            continue
+        if pat_comment.match(line):
+            continue
+        mprop = pat_property.match(line)
+        if mprop and mprop.group(1) == "Title":
+            rtn[current_histo]["TITLE"] = mprop.group(2)
+    finfo.close()
+    return rtn
+
+
+if __name__ == "__main__":
+    for i in sys.argv[1:]:
+        print plotinfo(i)


More information about the Rivet-svn mailing list