pyslha.py

changeset 210
0f4f5472b7d8
parent 208
67e368e5f414
child 211
91f559c01cf7
     1.1 --- a/pyslha.py	Sun Apr 28 22:36:32 2013 +0200
     1.2 +++ b/pyslha.py	Mon Apr 29 14:35:12 2013 +0200
     1.3 @@ -41,7 +41,6 @@
     1.4  
     1.5    For 2.1.0:
     1.6     * Preserve comments from read -> write (needs full-line/inline comment separation?)
     1.7 -   * Split writeSLHA into writeSLHA{Blocks,Decays}
     1.8  
     1.9    Later/maybe:
    1.10     * Identify HERWIG decay matrix element to use in ISAWIG
    1.11 @@ -381,19 +380,12 @@
    1.12  
    1.13  
    1.14  
    1.15 -
    1.16 -# TODO: Split writeSLHA into writeSLHA{Blocks,Decays}
    1.17 -
    1.18 -
    1.19 -def writeSLHA(blocks, decays, ignorenobr=False, precision=8):
    1.20 -    """
    1.21 -    Return an SLHA definition as a string, from the supplied blocks and decays dicts.
    1.22 -    """
    1.23 +def writeSLHABlocks(blocks, precision=8):
    1.24 +    """Return an SLHA definition as a string, from the supplied blocks dict."""
    1.25      # TODO: Pay attention to space-padding and minus signs for column alignment
    1.26      fmte = "%." + str(precision) + "e"
    1.27      sep = "   "
    1.28      blockstrs = []
    1.29 -    ## Blocks
    1.30      for bname, b in blocks.iteritems():
    1.31          namestr = b.name
    1.32          if b.q is not None:
    1.33 @@ -410,8 +402,15 @@
    1.34              entrystrs.append(entrystr)
    1.35          blockstr += "\n".join(entrystrs)
    1.36          blockstrs.append(blockstr)
    1.37 -        ##
    1.38 -    ## Decays
    1.39 +    return "\n\n".join(blockstrs)
    1.40 +
    1.41 +
    1.42 +
    1.43 +def writeSLHADecays(decays, ignorenobr=False, precision=8):
    1.44 +    """Return an SLHA decay definition as a string, from the supplied decays dict."""
    1.45 +    fmte = "%." + str(precision) + "e"
    1.46 +    sep = "   "
    1.47 +    blockstrs = []
    1.48      for pid, particle in decays.iteritems():
    1.49          blockstr = ("DECAY %d " + fmte + "\n") % (particle.pid, particle.totalwidth or -1)
    1.50          decaystrs = []
    1.51 @@ -422,11 +421,16 @@
    1.52                  decaystrs.append(decaystr)
    1.53          blockstr += "\n".join(decaystrs)
    1.54          blockstrs.append(blockstr)
    1.55 -    ## Total result
    1.56      return "\n\n".join(blockstrs)
    1.57  
    1.58  
    1.59  
    1.60 +def writeSLHA(blocks, decays, ignorenobr=False, precision=8):
    1.61 +    """Return an SLHA definition as a string, from the supplied blocks and decays dicts."""
    1.62 +    return writeSLHABlocks(blocks, precision) + "\n\n" + writeSLHADecays(decays, ignorenobr, precision)
    1.63 +
    1.64 +
    1.65 +
    1.66  ###############################################################################
    1.67  ## PDG <-> HERWIG particle ID code translations for ISAWIG handling
    1.68  

mercurial