[Rivet-svn] r4188 - trunk/bin

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Tue Mar 5 17:31:46 GMT 2013


Author: hoeth
Date: Tue Mar  5 17:31:45 2013
New Revision: 4188

Log:
enable some of the old bells and whistles in rivet-cmphistos

Modified:
   trunk/bin/rivet-cmphistos

Modified: trunk/bin/rivet-cmphistos
==============================================================================
--- trunk/bin/rivet-cmphistos	Tue Mar  5 17:23:49 2013	(r4187)
+++ trunk/bin/rivet-cmphistos	Tue Mar  5 17:31:45 2013	(r4188)
@@ -22,6 +22,15 @@
         return "# BEGIN PLOT\n" + "\n".join("%s=%s" % (k,v) for k,v in self.iteritems()) + "\n# END PLOT\n\n"
 
 
+def sanitiseString(s):
+    #s = s.replace('_','\\_')
+    #s = s.replace('^','\\^{}')
+    #s = s.replace('$','\\$')
+    s = s.replace('#','\\#')
+    s = s.replace('%','\\%')
+    return s
+
+
 def getCommandLineOptions():
     ## Parse command line options
     from optparse import OptionParser, OptionGroup
@@ -38,10 +47,55 @@
                       'to standard Rivet search paths)')
 
     stygroup = OptionGroup(parser, "Plot style")
+#    stygroup.add_option("--refid", dest="REF_ID",
+#                        default="REF", help="ID of reference data set (file path for non-REF data)")
+    stygroup.add_option("--linear", action="store_true", dest="LINEAR",
+                        default=False, help="plot with linear scale")
+    stygroup.add_option("--mc-errs", action="store_true", dest="MC_ERRS",
+                        default=False, help="show vertical error bars on the MC lines")
+    stygroup.add_option("--no-ratio", action="store_false", dest="RATIO",
+                        default=True, help="disable the ratio plot")
+    stygroup.add_option("--rel-ratio", action="store_true", dest="RATIO_DEVIATION",
+                        default=False, help="show the ratio plots scaled to the ref error")
+    stygroup.add_option("--no-plottitle", action="store_true", dest="NOPLOTTITLE",
+                        default=False, help="don't show the plot title on the plot "
+                        "(useful when the plot description should only be given in a caption)")
+#    stygroup.add_option("--style", dest="STYLE", default="default",
+#                        help="change plotting style: default|bw|talk")
     stygroup.add_option("-c", "--config", dest="CONFIGFILES", action="append", default=["~/.make-plots"],
                         help="additional plot config file(s). Settings will be included in the output configuration.")
     parser.add_option_group(stygroup)
 
+#    selgroup = OptionGroup(parser, "Selective plotting")
+#    selgroup.add_option("--show-single", dest="SHOW_SINGLE", choices=("no", "ref", "mc", "all"),
+#                        default="mc", help="control if a plot file is made if there is only one dataset to be plotted "
+#                        "[default=%default]. If the value is 'no', single plots are always skipped, for 'ref' and 'mc', "
+#                        "the plot will be written only if the single plot is a reference plot or an MC "
+#                        "plot respectively, and 'all' will always create single plot files.\n The 'ref' and 'all' values "
+#                        "should be used with great care, as they will also write out plot files for all reference "
+#                        "histograms without MC traces: combined with the -R/--rivet-refs flag, this is a great way to "
+#                        "write out several thousand irrelevant reference data histograms!")
+#    selgroup.add_option("--show-mc-only", "--all", action="store_true", dest="SHOW_IF_MC_ONLY",
+#                        default=False, help="make a plot file even if there is only one dataset to be plotted and "
+#                        "it is an MC one. Deprecated and will be removed: use --show-single instead, which overrides this.")
+#    # selgroup.add_option("-l", "--histogram-list", dest="HISTOGRAMLIST",
+#    #                     default=None, help="specify a file containing a list of histograms to plot, in the format "
+#    #                     "/ANALYSIS_ID/histoname, one per line, e.g. '/DELPHI_1996_S3430090/d01-x01-y01'.")
+#    selgroup.add_option("-m", "--match", action="append",
+#                        help="Only write out histograms whose $path/$name string matches these regexes. The argument "
+#                        "may also be a text file.",
+#                        dest="PATHPATTERNS")
+#    selgroup.add_option("-M", "--unmatch", action="append",
+#                        help="Exclude histograms whose $path/$name string matches these regexes",
+#                        dest="PATHUNPATTERNS")
+#    parser.add_option_group(selgroup)
+
+#    verbgrp = OptionGroup(parser, "Verbosity control")
+#    verbgrp.add_option("-q", "--quiet", help="Suppress normal messages", dest="LOGLEVEL",
+#                       action="store_const", default=logging.INFO, const=logging.WARNING)
+#    verbgrp.add_option("-v", "--verbose", help="Add extra debug messages", dest="LOGLEVEL",
+#                       action="store_const", default=logging.INFO, const=logging.DEBUG)
+#    parser.add_option_group(verbgrp)
     return parser
 
 
@@ -121,7 +175,7 @@
                 has_title = True
             plotoptions[path].append(asplit[i])
         if not has_title:
-            plotoptions[path].append('Title=%s' %path.split('/')[-1].replace('.yoda', ''))
+            plotoptions[path].append('Title=%s' %sanitiseString(path.split('/')[-1].replace('.yoda', '')))
     return filelist, plotoptions
 
 
@@ -238,6 +292,10 @@
         plot['LogY'] = '1'
         for key, val in plotparser.getHeaders(h).iteritems():
             plot[key] = val
+        if opts.LINEAR:
+            plot['LogY'] = '0'
+        if opts.NOPLOTTITLE:
+            plot['Title'] = ''
 
 
         ## DrawOnly is needed to keep the order in the Legend equal to the
@@ -251,17 +309,22 @@
             refdata.setAnnotation('ErrorBars', '1')
             refdata.setAnnotation('PolyMarker', '*')
             refdata.setAnnotation('Title', 'Data')
-            plot['RatioPlot'] = '1'
-            plot['RatioPlotReference'] = '/REF'+h
+            if opts.RATIO:
+                plot['RatioPlot'] = '1'
+                plot['RatioPlotReference'] = '/REF'+h
             anaobjects.append(refdata)
             drawonly += '/REF' + h + ' '
 
+        if opts.RATIO and opts.RATIO_DEVIATION:
+            plot['RatioPlotMode'] = 'deviation'
 
         ## Loop over the MC files to plot all instances of the histogram
         for i,infile in enumerate(filelist):
             if mchistos.has_key(infile) and mchistos[infile].has_key(h):
                 ## default linecolor, linestyle
                 setStyle(mchistos[infile][h], i)
+                if opts.MC_ERRS:
+                    mchistos[infile][h].setAnnotation('ErrorBars', '1')
                 ## plot defaults from .plot files
                 for key, val in plotparser.getHistogramOptions(h).iteritems():
                     mchistos[infile][h].setAnnotation(key, val)


More information about the Rivet-svn mailing list