Split writeSLHA implementation into distinct writeSLHA{Blocks,Decays}.

Mon, 29 Apr 2013 14:35:12 +0200

author
Andy Buckley <andy@insectnation.org>
date
Mon, 29 Apr 2013 14:35:12 +0200
changeset 210
0f4f5472b7d8
parent 209
42fe24d30c22
child 211
91f559c01cf7

Split writeSLHA implementation into distinct writeSLHA{Blocks,Decays}.

ChangeLog file | annotate | diff | comparison | revisions
pyslha.py file | annotate | diff | comparison | revisions
     1.1 --- a/ChangeLog	Sun Apr 28 22:36:32 2013 +0200
     1.2 +++ b/ChangeLog	Mon Apr 29 14:35:12 2013 +0200
     1.3 @@ -1,3 +1,7 @@
     1.4 +2013-04-29  Andy Buckley  <andy.buckley@cern.ch>
     1.5 +
     1.6 +	* Split writeSLHA implementation into distinct writeSLHA{Blocks,Decays}.
     1.7 +
     1.8  2013-04-28  Andy Buckley  <andy.buckley@cern.ch>
     1.9  
    1.10  	* Adding a dict arg (compatible with dict.update) to the Block
     2.1 --- a/pyslha.py	Sun Apr 28 22:36:32 2013 +0200
     2.2 +++ b/pyslha.py	Mon Apr 29 14:35:12 2013 +0200
     2.3 @@ -41,7 +41,6 @@
     2.4  
     2.5    For 2.1.0:
     2.6     * Preserve comments from read -> write (needs full-line/inline comment separation?)
     2.7 -   * Split writeSLHA into writeSLHA{Blocks,Decays}
     2.8  
     2.9    Later/maybe:
    2.10     * Identify HERWIG decay matrix element to use in ISAWIG
    2.11 @@ -381,19 +380,12 @@
    2.12  
    2.13  
    2.14  
    2.15 -
    2.16 -# TODO: Split writeSLHA into writeSLHA{Blocks,Decays}
    2.17 -
    2.18 -
    2.19 -def writeSLHA(blocks, decays, ignorenobr=False, precision=8):
    2.20 -    """
    2.21 -    Return an SLHA definition as a string, from the supplied blocks and decays dicts.
    2.22 -    """
    2.23 +def writeSLHABlocks(blocks, precision=8):
    2.24 +    """Return an SLHA definition as a string, from the supplied blocks dict."""
    2.25      # TODO: Pay attention to space-padding and minus signs for column alignment
    2.26      fmte = "%." + str(precision) + "e"
    2.27      sep = "   "
    2.28      blockstrs = []
    2.29 -    ## Blocks
    2.30      for bname, b in blocks.iteritems():
    2.31          namestr = b.name
    2.32          if b.q is not None:
    2.33 @@ -410,8 +402,15 @@
    2.34              entrystrs.append(entrystr)
    2.35          blockstr += "\n".join(entrystrs)
    2.36          blockstrs.append(blockstr)
    2.37 -        ##
    2.38 -    ## Decays
    2.39 +    return "\n\n".join(blockstrs)
    2.40 +
    2.41 +
    2.42 +
    2.43 +def writeSLHADecays(decays, ignorenobr=False, precision=8):
    2.44 +    """Return an SLHA decay definition as a string, from the supplied decays dict."""
    2.45 +    fmte = "%." + str(precision) + "e"
    2.46 +    sep = "   "
    2.47 +    blockstrs = []
    2.48      for pid, particle in decays.iteritems():
    2.49          blockstr = ("DECAY %d " + fmte + "\n") % (particle.pid, particle.totalwidth or -1)
    2.50          decaystrs = []
    2.51 @@ -422,11 +421,16 @@
    2.52                  decaystrs.append(decaystr)
    2.53          blockstr += "\n".join(decaystrs)
    2.54          blockstrs.append(blockstr)
    2.55 -    ## Total result
    2.56      return "\n\n".join(blockstrs)
    2.57  
    2.58  
    2.59  
    2.60 +def writeSLHA(blocks, decays, ignorenobr=False, precision=8):
    2.61 +    """Return an SLHA definition as a string, from the supplied blocks and decays dicts."""
    2.62 +    return writeSLHABlocks(blocks, precision) + "\n\n" + writeSLHADecays(decays, ignorenobr, precision)
    2.63 +
    2.64 +
    2.65 +
    2.66  ###############################################################################
    2.67  ## PDG <-> HERWIG particle ID code translations for ISAWIG handling
    2.68  

mercurial