Allow ignoring of missing MASS block in SLHA reader

Mon, 15 Jul 2013 14:29:27 +0200

author
Andy Buckley <andy@insectnation.org>
date
Mon, 15 Jul 2013 14:29:27 +0200
changeset 241
401d5e64948f
parent 240
84b1c74e0020
child 242
41ec8fb352b3

Allow ignoring of missing MASS block in SLHA reader

pyslha.py file | annotate | diff | comparison | revisions
     1.1 --- a/pyslha.py	Mon Jul 15 14:26:47 2013 +0200
     1.2 +++ b/pyslha.py	Mon Jul 15 14:29:27 2013 +0200
     1.3 @@ -33,9 +33,6 @@
     1.4  
     1.5  TODOs:
     1.6  
     1.7 -  For 2.1.3:
     1.8 -   * Allow ignoring of missing MASS block in SLHA reader
     1.9 -
    1.10    For 2.1.4:
    1.11     * In set_value, if first item is non-int, treat as None-indexed
    1.12     * Refine value string heuristic for strings with ints in them?
    1.13 @@ -355,13 +352,16 @@
    1.14  ###############################################################################
    1.15  ## SLHA parsing and writing functions
    1.16  
    1.17 -def readSLHA(spcstr, ignorenobr=False):
    1.18 +def readSLHA(spcstr, ignorenobr=False, ignorenomass=False):
    1.19      """
    1.20      Read an SLHA definition from a string, returning dictionaries of blocks and
    1.21      decays.
    1.22  
    1.23      If the ignorenobr parameter is True, do not store decay entries with a
    1.24      branching ratio of zero.
    1.25 +
    1.26 +    If the ignorenomass parameter is True, parse file even if mass block is
    1.27 +    absent in the file (default is to raise a ParseError).
    1.28      """
    1.29      blocks = _mkdict()
    1.30      decays = _mkdict()
    1.31 @@ -439,7 +439,8 @@
    1.32              if decays.has_key(pid):
    1.33                  decays[pid].mass = blocks["MASS"][pid]
    1.34      except:
    1.35 -        raise ParseError("No MASS block found: cannot populate particle masses")
    1.36 +        if not ignorenomass:
    1.37 +            raise ParseError("No MASS block found: cannot populate particle masses")
    1.38  
    1.39      return blocks, decays
    1.40  

mercurial