slha2isawig

Mon, 29 Apr 2013 15:04:31 +0200

author
Andy Buckley <andy@insectnation.org>
date
Mon, 29 Apr 2013 15:04:31 +0200
changeset 214
fa07ed634b18
parent 209
42fe24d30c22
permissions
-rwxr-xr-x

Better newline handling in final SLHA output formatting

     1 #! /usr/bin/env python
     3 """\
     4 Usage: %prog IN.slha [OUT.isa]
     6 Convert an SLHA model/decay spectrum file to a HERWIG/ISAWIG SUSY spectrum input
     7 file, in the format written by ISAWIG. The intention of this script is to allow
     8 HERWIG to be used with spectra generated by codes other than ISAWIG,
     9 e.g. SoftSUSY, SPheno, etc. And fundamentally because the author was fed up with
    10 having to make ISASUSY compile with gfortran on platforms where CERNLIB wasn't
    11 available!
    13 Conversion based on the HERWIG SUSY specification format, from
    14 http://www.hep.phy.cam.ac.uk/~richardn/HERWIG/ISAWIG/file.html
    16 Author:
    17   Andy Buckley <andy.buckley@cern.ch>
    18   http://insectnation.org/projects/pyslha
    19 """
    21 __author__ = "Andy Buckley <andy.buckley@cern.ch"
    23 import pyslha
    24 import sys, optparse
    25 parser = optparse.OptionParser(usage=__doc__, version=pyslha.__version__)
    26 opts, args = parser.parse_args()
    27 if len(args) < 1 or len(args) > 2:
    28     parser.print_help()
    29     sys.exit(1)
    31 ## Choose output file
    32 import os
    33 o = os.path.basename(args[0])
    34 if "." in o:
    35     o = o[:o.rindex(".")]
    36 opts.OUTFILE = o + ".isa"
    37 if len(args) == 2:
    38     opts.OUTFILE = args[1]
    40 ## Read spectrum file
    41 BLOCKS, DECAYS = pyslha.readSLHAFile(args[0])
    43 ## And write it out again!
    44 if opts.OUTFILE == "-":
    45     sys.stdout.write(pyslha.writeISAWIG(opts.OUTFILE))
    46 else:
    47     pyslha.writeISAWIGFile(opts.OUTFILE, BLOCKS, DECAYS)

mercurial