Merge in a version of decay line color scaling in proportion to branching ratio, from Martin Spinrath pyslha-1.0.6

Wed, 26 Jan 2011 16:10:01 +0000

author
Andy Buckley <andy@insectnation.org>
date
Wed, 26 Jan 2011 16:10:01 +0000
changeset 111
4f426f1f5923
parent 110
0064d3bcda09
child 112
053699571fd2

Merge in a version of decay line color scaling in proportion to branching ratio, from Martin Spinrath

pyslha.py file | annotate | diff | comparison | revisions
slhaplot file | annotate | diff | comparison | revisions
     1.1 --- a/pyslha.py	Fri Jan 21 13:51:06 2011 +0000
     1.2 +++ b/pyslha.py	Wed Jan 26 16:10:01 2011 +0000
     1.3 @@ -23,7 +23,7 @@
     1.4  """
     1.5  
     1.6  __author__ = "Andy Buckley <andy.buckley@cern.ch"
     1.7 -__version__ = "1.0.5"
     1.8 +__version__ = "1.0.6"
     1.9  
    1.10  
    1.11  def _autotype(var):
     2.1 --- a/slhaplot	Fri Jan 21 13:51:06 2011 +0000
     2.2 +++ b/slhaplot	Wed Jan 26 16:10:01 2011 +0000
     2.3 @@ -15,10 +15,10 @@
     2.4  
     2.5  TODOs:
     2.6    * Allow user control over aspect ratio / geometry
     2.7 +  * PNG output (use PIL if available?)
     2.8    * Use proper distinction between physical, plot-logical, and plot output coords
     2.9    * Use scaling to allow the y coordinates to be in units of 100 GeV in TikZ output.
    2.10 -  * PNG output (use PIL if available?)
    2.11 -  * Decay arrow colour (greyscale) according to BR?
    2.12 +  * Distribute decay arrow start/end positions along mass lines rather than always to/from their centres?
    2.13    * Drop make-plots support?
    2.14  """
    2.15  
    2.16 @@ -131,12 +131,12 @@
    2.17  parser.add_option("--minbr", "--br", metavar="BR",
    2.18                    help="show decay lines for decays with a branching ratio of > BR (default: %default)",
    2.19                    dest="DECAYS_MINBR", type=float, default=1.0)
    2.20 -parser.add_option("--decaystyle", choices=["const", "brwidth"], metavar="STYLE",
    2.21 +parser.add_option("--decaystyle", choices=["const", "brwidth", "brcolor", "brwidth+brcolor"], metavar="STYLE",
    2.22                    help="drawing style of decay arrows, from const/brwidth. The 'const' style draws "
    2.23                    "all decay lines with the same width, 'brwidth' linearly scales the width of the "
    2.24                    "decay arrow according to the decay branching ratio. Other modes such as BR-dependent "
    2.25                    "colouring may be added later. (default: %default)",
    2.26 -                  dest="DECAYS_STYLE", default="brwidth")
    2.27 +                  dest="DECAYS_STYLE", default="brwidth+brcolor")
    2.28  parser.add_option("--labels", choices=["none", "merge", "shift"], metavar="MODE",
    2.29                    help="treatment of labels for particle IDs, from none/merge/shift. 'none' shows "
    2.30                    "no labels at all, 'merge' combines would-be-overlapping labels into a single "
    2.31 @@ -455,15 +455,27 @@
    2.32          for pidfrom, todict in sorted(DDETAILS.iteritems()):
    2.33              for pidto, dd in sorted(todict.iteritems()):
    2.34                  out += "  %% decay_%d_%d, BR=%0.1f%%\n" % (dd.pidfrom, dd.pidto, dd.br*100)
    2.35 +
    2.36                  def scalethickness(br):
    2.37                      if opts.DECAYS_STYLE == "const":
    2.38                          return 0.8
    2.39 -                    elif opts.DECAYS_STYLE == "brwidth":
    2.40 +                    elif "brwidth" in opts.DECAYS_STYLE:
    2.41                          return 1.0 * br
    2.42                      else:
    2.43 -                        raise Exception("Unexpected problem with unknown decay line style option: please contact the PySLHA author!")
    2.44 +                        raise Exception("Unexpected problem with unknown decay line style option: please contact the PySLHA authors!")
    2.45 +
    2.46 +                def scalecolor(br):
    2.47 +                    if opts.DECAYS_STYLE == "const":
    2.48 +                        return None
    2.49 +                    elif "brcolor" in opts.DECAYS_STYLE:
    2.50 +                        return "black!"+str(50*dd.br + 20)
    2.51 +                    else:
    2.52 +                        raise Exception("Unexpected problem with unknown decay line style option: please contact the PySLHA authors!")
    2.53 +
    2.54                  out += "  \\draw[-stealth,line width=%0.2fpt,dashed,color=%s] (%f,%f) -- (%f,%f);\n" % \
    2.55 -                    (scalethickness(dd.br), dd.color, scalex(dd.xyfrom[0]), yscale*dd.xyfrom[1], scalex(dd.xyto[0]), yscale*dd.xyto[1])
    2.56 +                    (scalethickness(dd.br), scalecolor(dd.br) or dd.color,
    2.57 +                     scalex(dd.xyfrom[0]), yscale*dd.xyfrom[1], scalex(dd.xyto[0]), yscale*dd.xyto[1])
    2.58 +
    2.59  
    2.60      ## Draw mass lines
    2.61      if PDETAILS:

mercurial