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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Fri Oct 23 15:09:32 BST 2009


Author: eike
Date: Fri Oct 23 15:09:32 2009
New Revision: 1956

Log:
* rename chop_bins.py and install it during make install
* strip '/REF' from histo-paths to work with reference histos as well (does any plotting/... tool needs /REF in histo paths/?)

Added:
   trunk/bin/chop_bins
      - copied, changed from r1955, trunk/bin/chop_bins.py
Deleted:
   trunk/bin/chop_bins.py
Modified:
   trunk/bin/Makefile.am
   trunk/pyext/lighthisto.py

Modified: trunk/bin/Makefile.am
==============================================================================
--- trunk/bin/Makefile.am	Fri Oct 23 12:32:06 2009	(r1955)
+++ trunk/bin/Makefile.am	Fri Oct 23 15:09:32 2009	(r1956)
@@ -1,5 +1,5 @@
 bin_SCRIPTS = rivet-config 
-dist_bin_SCRIPTS = aida2flat aida2root compare-histos make-html make-plots rivet-mkanalysis 
+dist_bin_SCRIPTS = aida2flat aida2root compare-histos make-html make-plots rivet-mkanalysis chop_bins
 EXTRA_DIST = flat2aida
 
 if ENABLE_PYEXT

Copied and modified: trunk/bin/chop_bins (from r1955, trunk/bin/chop_bins.py)
==============================================================================
--- trunk/bin/chop_bins.py	Fri Oct 23 12:32:06 2009	(r1955, copy source)
+++ trunk/bin/chop_bins	Fri Oct 23 15:09:32 2009	(r1956)
@@ -1,18 +1,24 @@
 #!/usr/bin/env python
-"""%prog [OPTIONS] <AIDAFILE> [...]
+"""%prog -b <HISTO/PATH:min:max> [ -b ... ] <AIDAFILE> [...]
 
-Strip specified bins from data sets. Histgrams not specified will be passed
+Strip specified bins from data sets. Histograms not specified will be passed
 through without any chopping. Bins to be kept can be specified on command
 line via `-b' options. The format is
     -b AIDAPATH:start:stop
 where start and stop are x values contained in the first and last bins,
-respectively, that should be kept. They need not to be the center but must
-only lie somewhere in the bin's x-range.
+respectively, that should be kept. They need not to be the bin-center but
+must only lie somewhere in the bin's x-range.
+
+To chop bins from different observables can be achieved by using the `-b'
+option multiple times.
 
 Example:
     %prog -b /ALEPH_1996_S3486095/d03-x01-y01:0.095:0.27 out.aida
 This will give you the all bins of the ALEPH 1-T distribution that are
 between the bins that contain the x-values 0.095 and 0.27 .
+
+TODO:
+    * what if the same observable is mentioned multiple times?
 """
 
 import os
@@ -84,7 +90,10 @@
         logging.getLogger().addHandler(h)
 
     if len(args) == 0:
-        sys.stderr.write("Must specify at least one AIDA histogram file\n")
+        sys.stderr.write("Must specify at least one AIDA histogram file!\n")
+        sys.exit(1)
+    if len(opts.bins) == 0:
+        sys.stderr.write("No bins specified, so I'm doing nothing!\n")
         sys.exit(1)
 
     bindefs = {}

Modified: trunk/pyext/lighthisto.py
==============================================================================
--- trunk/pyext/lighthisto.py	Fri Oct 23 12:32:06 2009	(r1955)
+++ trunk/pyext/lighthisto.py	Fri Oct 23 15:09:32 2009	(r1956)
@@ -210,6 +210,9 @@
         new.name = dps.get("name")
         new.title = dps.get("title")
         new.path = dps.get("path")
+        # strip /REF from path
+        if new.path.startswith("/REF"):
+            new.path = new.path[4:]
         axes = dps.findall("dimension")
         if (len(axes)==2):
             for a in axes:


More information about the Rivet-svn mailing list