[Rivet-svn] rivet: Rewrite cmphistos to remove /REF prefixes internally, and...

Rivet Mercurial rivet at projects.hepforge.org
Thu Dec 17 21:00:01 GMT 2015


details:   https://rivet.hepforge.org/hg/rivet/rev/a1ffbb403e4a
branches:  release-2-4-x
changeset: 4960:a1ffbb403e4a
user:      Andy Buckley <andy at insectnation.org>
date:      Thu Dec 17 20:50:43 2015 +0000
description:
Rewrite cmphistos to remove /REF prefixes internally, and a few other tweaks needed to get ref data points displaying again

diffs (truncated from 107 to 50 lines):

--- a/bin/rivet-cmphistos	Thu Dec 17 16:38:43 2015 +0000
+++ b/bin/rivet-cmphistos	Thu Dec 17 20:50:43 2015 +0000
@@ -98,14 +98,14 @@
     refhistos = {}
     mchistos = {}
     import re
-    re_path = re.compile(r"^/(REF/)?([^\[\]\@\#]+)(\[\d+\])?$")
+    re_path = re.compile(r"^(/REF)?(/[^\[\]\@\#]+)(\[\d+\])?$")
     for infile in filelist:
         mchistos.setdefault(infile, {})
         analysisobjects = yoda.read(infile, patterns=opts.PATHPATTERNS, unpatterns=opts.PATHUNPATTERNS)
         for path, ao in analysisobjects.iteritems():
             m = re_path.match(path)
             if m is None:
-                print "Found analysis object", path, "with non-standard path structure"
+                print "Found analysis object with non-standard path structure:", path
                 continue
             isref = bool(m.group(1))
             basepath = m.group(2)
@@ -114,16 +114,20 @@
             ## Conventionally don't plot data objects whose names start with an underscore
             if os.path.basename(basepath).startswith("_"):
                 continue
-            if isref and not refhistos.has_key(path):
-                refhistos[path] = ao
+            if isref and not refhistos.has_key(basepath):
+                # TODO: Update to the brave new world without /REF prefixes
+                if ao.path.startswith("/REF"):
+                    ao.path = ao.path[4:]
+                refhistos[basepath] = ao
                 continue
             #if not mchistos[infile].has_key(basepath):
             mchistos[infile].setdefault(basepath, {})[index] = ao
     return refhistos, mchistos
 
 
-def getRivetRefData(refhistos, anas=None):
+def getRivetRefData(anas=None):
     "Find all Rivet reference data files"
+    refhistos = {}
     rivet_data_dirs = rivet.getAnalysisRefPaths()
     dirlist = []
     for d in rivet_data_dirs:
@@ -137,9 +141,11 @@
         for infile in filelist:
             analysisobjects = yoda.read(infile, patterns=opts.PATHPATTERNS, unpatterns=opts.PATHUNPATTERNS)
             for path, ao in analysisobjects.iteritems():
-                if path.startswith('/REF/'):
-                    if not refhistos.has_key(path):
-                        refhistos[path] = ao


More information about the Rivet-svn mailing list