pyslha.py

Sun, 27 Feb 2011 00:14:05 +0100

author
Andy Buckley <andy@insectnation.org>
date
Sun, 27 Feb 2011 00:14:05 +0100
changeset 123
c85e29bc13c4
parent 120
bffefe12df80
child 124
7bd52be093b2
permissions
-rw-r--r--

Enabling simultaneous rendering of multiple input files.

andy@1 1 #! /usr/bin/env python
andy@1 2
andy@8 3 """\
andy@8 4 A simple but flexible parser of SUSY Les Houches Accord (SLHA) model and decay files.
andy@25 5
andy@52 6 pyslha is a parser/writer module for particle physics SUSY Les Houches Accord
andy@52 7 (SLHA) supersymmetric spectrum/decay files, and a collection of scripts which
andy@52 8 use the interface, e.g. for conversion to and from the legacy ISAWIG format, or
andy@52 9 to plot the mass spectrum and decay chains.
andy@52 10
andy@52 11 The current release supports SLHA version 1. Assistance with supporting version
andy@52 12 2 will be gladly accepted!
andy@52 13
andy@99 14 The plotting script provides output in PDF via LaTeX and the TikZ graphics package,
andy@99 15 as LaTeX/TikZ source for direct embedding into documents, and in the format used by
andy@99 16 the Rivet make-plots system.
andy@64 17
andy@52 18 TODOs:
andy@64 19 * Identify HERWIG decay matrix element to use in ISAWIG
andy@52 20 * Split writeSLHA into writeSLHA{Blocks,Decays}
andy@52 21 * Handle SLHA2
andy@52 22 * Handle RPV SUSY in ISAWIG
andy@8 23 """
andy@8 24
andy@8 25 __author__ = "Andy Buckley <andy.buckley@cern.ch"
andy@120 26 __version__ = "1.0.8"
andy@8 27
andy@1 28
andy@4 29 def _autotype(var):
andy@30 30 """Automatically convert strings to numerical types if possible."""
andy@30 31 if type(var) is not str:
andy@4 32 return var
andy@36 33 if var.isdigit() or (var.startswith("-") and var[1:].isdigit()):
andy@4 34 return int(var)
andy@4 35 try:
andy@4 36 f = float(var)
andy@4 37 return f
andy@4 38 except ValueError:
andy@4 39 return var
andy@4 40
andy@30 41 def _autostr(var):
andy@30 42 """Automatically numerical types to the right sort of string."""
andy@30 43 if type(var) is float:
andy@30 44 return "%e" % var
andy@30 45 return str(var)
andy@30 46
andy@30 47
andy@4 48
andy@12 49 class Block(object):
andy@8 50 """
andy@8 51 Object representation of any BLOCK elements read from the SLHA file. Blocks
andy@8 52 have a name, may have an associated Q value, and then a collection of data
andy@8 53 entries, stored as a recursive dictionary. Types in the dictionary are
andy@8 54 numeric (int or float) when a cast from the string in the file has been
andy@8 55 possible.
andy@8 56 """
andy@5 57 def __init__(self, name, q=None):
andy@1 58 self.name = name
andy@1 59 self.entries = {}
andy@5 60 self.q = _autotype(q)
andy@1 61
andy@1 62 def add_entry(self, entry):
andy@1 63 #print entry
andy@1 64 nextparent = self.entries
andy@1 65 if len(entry) < 2:
andy@1 66 raise Exception("Block entries must be at least a 2-tuple")
andy@4 67 #print "in", entry
andy@4 68 entry = map(_autotype, entry)
andy@4 69 #print "out", entry
andy@1 70 for e in entry[:-2]:
andy@1 71 if e is not entry[-1]:
andy@1 72 nextparent = nextparent.setdefault(e, {})
andy@1 73 nextparent[entry[-2]] = entry[-1]
andy@1 74 #print self.entries
andy@1 75
andy@1 76 def __cmp__(self, other):
andy@31 77 return cmp(self.name, other.name)
andy@1 78
andy@1 79 def __str__(self):
andy@1 80 s = self.name
andy@5 81 if self.q is not None:
andy@5 82 s += " (Q=%s)" % self.q
andy@1 83 s += "\n"
andy@1 84 s += str(self.entries)
andy@1 85 return s
andy@1 86
andy@123 87 def __repr__(self):
andy@123 88 return self.__str__()
andy@123 89
andy@1 90
andy@12 91 class Decay(object):
andy@8 92 """
andy@8 93 Object representing a decay entry on a particle decribed by the SLHA file.
andy@8 94 'Decay' objects are not a direct representation of a DECAY block in an SLHA
andy@8 95 file... that role, somewhat confusingly, is taken by the Particle class.
andy@8 96
andy@8 97 Decay objects have three properties: a branching ratio, br, an nda number
andy@12 98 (number of daughters == len(ids)), and a tuple of PDG PIDs to which the
andy@12 99 decay occurs. The PDG ID of the particle whose decay this represents may
andy@12 100 also be stored, but this is normally known via the Particle in which the
andy@12 101 decay is stored.
andy@8 102 """
andy@8 103 def __init__(self, br, nda, ids, parentid=None):
andy@8 104 self.parentid = parentid
andy@6 105 self.br = br
andy@6 106 self.nda = nda
andy@6 107 self.ids = ids
andy@29 108 assert(self.nda == len(self.ids))
andy@6 109
andy@6 110 def __cmp__(self, other):
andy@31 111 return cmp(other.br, self.br)
andy@6 112
andy@6 113 def __str__(self):
andy@12 114 return "%e %s" % (self.br, self.ids)
andy@6 115
andy@123 116 def __repr__(self):
andy@123 117 return self.__str__()
andy@123 118
andy@6 119
andy@12 120 class Particle(object):
andy@8 121 """
andy@8 122 Representation of a single, specific particle, decay block from an SLHA
andy@8 123 file. These objects are not themselves called 'Decay', since that concept
andy@8 124 applies more naturally to the various decays found inside this
andy@8 125 object. Particle classes store the PDG ID (pid) of the particle being
andy@8 126 represented, and optionally the mass (mass) and total decay width
andy@8 127 (totalwidth) of that particle in the SLHA scenario. Masses may also be found
andy@8 128 via the MASS block, from which the Particle.mass property is filled, if at
andy@8 129 all. They also store a list of Decay objects (decays) which are probably the
andy@8 130 item of most interest.
andy@8 131 """
andy@6 132 def __init__(self, pid, totalwidth=None, mass=None):
andy@6 133 self.pid = pid
andy@6 134 self.totalwidth = totalwidth
andy@6 135 self.mass = mass
andy@6 136 self.decays = []
andy@6 137
andy@6 138 def add_decay(self, br, nda, ids):
andy@6 139 self.decays.append(Decay(br, nda, ids))
andy@6 140 self.decays.sort()
andy@6 141
andy@6 142 def __cmp__(self, other):
andy@6 143 if abs(self.pid) == abs(other.pid):
andy@31 144 return cmp(self.pid, other.pid)
andy@31 145 return cmp(abs(self.pid), abs(other.pid))
andy@6 146
andy@6 147 def __str__(self):
andy@6 148 s = str(self.pid)
andy@7 149 if self.mass is not None:
andy@7 150 s += " : mass = %e GeV" % self.mass
andy@6 151 if self.totalwidth is not None:
andy@7 152 s += " : total width = %e GeV" % self.totalwidth
andy@6 153 for d in self.decays:
andy@12 154 if d.br > 0.0:
andy@12 155 s += "\n %s" % d
andy@6 156 return s
andy@1 157
andy@123 158 def __repr__(self):
andy@123 159 return self.__str__()
andy@123 160
andy@123 161
andy@1 162
andy@31 163 def readSLHAFile(spcfilename, **kwargs):
andy@21 164 """
andy@21 165 Read an SLHA file, returning dictionaries of blocks and decays.
andy@31 166
andy@31 167 Other keyword parameters are passed to readSLHA.
andy@21 168 """
andy@68 169 f = open(spcfilename, "r")
andy@68 170 rtn = readSLHA(f.read(), kwargs)
andy@68 171 f.close()
andy@68 172 return rtn
andy@21 173
andy@21 174
andy@31 175 def readSLHA(spcstr, ignorenobr=False):
andy@21 176 """
andy@31 177 Read an SLHA definition from a string, returning dictionaries of blocks and
andy@31 178 decays.
andy@31 179
andy@31 180 If the ignorenobr parameter is True, do not store decay entries with a
andy@31 181 branching ratio of zero.
andy@21 182 """
andy@1 183 blocks = {}
andy@1 184 decays = {}
andy@21 185 #
andy@34 186 import re
andy@21 187 currentblock = None
andy@21 188 currentdecay = None
andy@21 189 for line in spcstr.splitlines():
andy@21 190 ## Handle (ignore) comment lines
andy@21 191 if line.startswith("#"):
andy@21 192 continue
andy@21 193 if "#" in line:
andy@21 194 line = line[:line.index("#")]
andy@21 195
andy@21 196 ## Handle BLOCK/DECAY start lines
andy@21 197 if line.upper().startswith("BLOCK"):
andy@47 198 #print line
andy@47 199 match = re.match(r"BLOCK\s+(\w+)(\s+Q=\s*.+)?", line.upper())
andy@21 200 if not match:
andy@8 201 continue
andy@21 202 blockname = match.group(1)
andy@21 203 qstr = match.group(2)
andy@21 204 if qstr is not None:
andy@21 205 qstr = qstr[2:].strip()
andy@21 206 currentblock = blockname
andy@21 207 currentdecay = None
andy@21 208 blocks[blockname] = Block(blockname, q=qstr)
andy@21 209 elif line.upper().startswith("DECAY"):
andy@21 210 match = re.match(r"DECAY\s+(\d+)\s+([\d\.E+-]+).*", line.upper())
andy@21 211 if not match:
andy@21 212 continue
andy@21 213 pdgid = int(match.group(1))
andy@21 214 width = float(match.group(2))
andy@21 215 currentblock = "DECAY"
andy@21 216 currentdecay = pdgid
andy@21 217 decays[pdgid] = Particle(pdgid, width)
andy@21 218 else:
andy@21 219 ## In-block line
andy@21 220 if currentblock is not None:
andy@21 221 items = line.split()
andy@21 222 if len(items) < 1:
andy@6 223 continue
andy@21 224 if currentblock != "DECAY":
andy@21 225 if len(items) < 2:
andy@21 226 ## Treat the ALPHA block differently
andy@21 227 blocks[currentblock].value = _autotype(items[0])
andy@33 228 blocks[currentblock].entries = _autotype(items[0])
andy@8 229 else:
andy@21 230 blocks[currentblock].add_entry(items)
andy@21 231 else:
andy@21 232 br = float(items[0])
andy@21 233 nda = int(items[1])
andy@21 234 ids = map(int, items[2:])
andy@31 235 if br > 0.0 or not ignorenobr:
andy@31 236 decays[currentdecay].add_decay(br, nda, ids)
andy@1 237
andy@8 238 ## Try to populate Particle masses from the MASS block
andy@47 239 # print blocks.keys()
andy@47 240 try:
andy@47 241 for pid in blocks["MASS"].entries.keys():
andy@47 242 if decays.has_key(pid):
andy@47 243 decays[pid].mass = blocks["MASS"].entries[pid]
andy@47 244 except:
andy@47 245 raise Exception("No MASS block found, from which to populate particle masses")
andy@8 246
andy@1 247 return blocks, decays
andy@1 248
andy@1 249
andy@33 250 def readISAWIGFile(isafilename, **kwargs):
andy@33 251 """
andy@33 252 Read a spectrum definition from a file in the ISAWIG format, returning
andy@33 253 dictionaries of blocks and decays. While this is not an SLHA format, it is
andy@33 254 informally supported as a useful mechanism for converting ISAWIG spectra to
andy@33 255 SLHA.
andy@33 256
andy@33 257 Other keyword parameters are passed to readSLHA.
andy@33 258 """
andy@68 259 f = open(isafilename, "r")
andy@68 260 rtn = readISAWIG(f.read(), kwargs)
andy@68 261 f.close()
andy@68 262 return rtn
andy@33 263
andy@33 264
andy@120 265
andy@33 266 def readISAWIG(isastr, ignorenobr=False):
andy@33 267 """
andy@33 268 Read a spectrum definition from a string in the ISAWIG format, returning
andy@33 269 dictionaries of blocks and decays. While this is not an SLHA format, it is
andy@33 270 informally supported as a useful mechanism for converting ISAWIG spectra to
andy@33 271 SLHA.
andy@33 272
andy@33 273 ISAWIG parsing based on the HERWIG SUSY specification format, from
andy@33 274 http://www.hep.phy.cam.ac.uk/~richardn/HERWIG/ISAWIG/file.html
andy@33 275
andy@33 276 If the ignorenobr parameter is True, do not store decay entries with a
andy@33 277 branching ratio of zero.
andy@33 278 """
andy@33 279
andy@120 280 ## PDG MC ID codes mapped to HERWIG IDHW codes, based on
andy@33 281 ## http://www.hep.phy.cam.ac.uk/~richardn/HERWIG/ISAWIG/susycodes.html
andy@120 282 ## + the IDPDG array and section 4.13 of the HERWIG manual.
andy@33 283 HERWIGID2PDGID = {}
andy@120 284 HERWIGID2PDGID[7] = -1
andy@120 285 HERWIGID2PDGID[8] = -2
andy@120 286 HERWIGID2PDGID[9] = -3
andy@120 287 HERWIGID2PDGID[10] = -4
andy@120 288 HERWIGID2PDGID[11] = -5
andy@120 289 HERWIGID2PDGID[12] = -6
andy@120 290 HERWIGID2PDGID[13] = 21
andy@120 291 HERWIGID2PDGID[59] = 22
andy@120 292 HERWIGID2PDGID[121] = 11
andy@120 293 HERWIGID2PDGID[122] = 12
andy@120 294 HERWIGID2PDGID[123] = 13
andy@120 295 HERWIGID2PDGID[124] = 14
andy@120 296 HERWIGID2PDGID[125] = 15
andy@120 297 HERWIGID2PDGID[126] = 16
andy@120 298 HERWIGID2PDGID[127] = -11
andy@120 299 HERWIGID2PDGID[128] = -12
andy@120 300 HERWIGID2PDGID[129] = -13
andy@120 301 HERWIGID2PDGID[130] = -14
andy@120 302 HERWIGID2PDGID[131] = -15
andy@120 303 HERWIGID2PDGID[132] = -16
andy@120 304 HERWIGID2PDGID[203] = 25 ## HIGGSL0 (== PDG standard in this direction)
andy@33 305 HERWIGID2PDGID[204] = 35 ## HIGGSH0
andy@33 306 HERWIGID2PDGID[205] = 36 ## HIGGSA0
andy@33 307 HERWIGID2PDGID[206] = 37 ## HIGGS+
andy@33 308 HERWIGID2PDGID[207] = -37 ## HIGGS-
andy@33 309 HERWIGID2PDGID[401] = 1000001 ## SSDLBR
andy@33 310 HERWIGID2PDGID[407] = -1000001 ## SSDLBR
andy@33 311 HERWIGID2PDGID[402] = 1000002 ## SSULBR
andy@33 312 HERWIGID2PDGID[408] = -1000002 ## SSUL
andy@33 313 HERWIGID2PDGID[403] = 1000003 ## SSSLBR
andy@33 314 HERWIGID2PDGID[409] = -1000003 ## SSSL
andy@33 315 HERWIGID2PDGID[404] = 1000004 ## SSCLBR
andy@33 316 HERWIGID2PDGID[410] = -1000004 ## SSCL
andy@33 317 HERWIGID2PDGID[405] = 1000005 ## SSB1BR
andy@33 318 HERWIGID2PDGID[411] = -1000005 ## SSB1
andy@33 319 HERWIGID2PDGID[406] = 1000006 ## SST1BR
andy@33 320 HERWIGID2PDGID[412] = -1000006 ## SST1
andy@33 321 HERWIGID2PDGID[413] = 2000001 ## SSDR
andy@33 322 HERWIGID2PDGID[419] = -2000001 ## SSDRBR
andy@33 323 HERWIGID2PDGID[414] = 2000002 ## SSUR
andy@33 324 HERWIGID2PDGID[420] = -2000002 ## SSURBR
andy@33 325 HERWIGID2PDGID[415] = 2000003 ## SSSR
andy@33 326 HERWIGID2PDGID[421] = -2000003 ## SSSRBR
andy@33 327 HERWIGID2PDGID[416] = 2000004 ## SSCR
andy@33 328 HERWIGID2PDGID[422] = -2000004 ## SSCRBR
andy@33 329 HERWIGID2PDGID[417] = 2000005 ## SSB2
andy@33 330 HERWIGID2PDGID[423] = -2000005 ## SSB2BR
andy@33 331 HERWIGID2PDGID[418] = 2000006 ## SST2
andy@33 332 HERWIGID2PDGID[424] = -2000006 ## SST2BR
andy@33 333 HERWIGID2PDGID[425] = 1000011 ## SSEL-
andy@33 334 HERWIGID2PDGID[431] = -1000011 ## SSEL+
andy@33 335 HERWIGID2PDGID[426] = 1000012 ## SSNUEL
andy@33 336 HERWIGID2PDGID[432] = -1000012 ## SSNUELBR
andy@33 337 HERWIGID2PDGID[427] = 1000013 ## SSMUL-
andy@33 338 HERWIGID2PDGID[433] = -1000013 ## SSMUL+
andy@33 339 HERWIGID2PDGID[428] = 1000014 ## SSNUMUL
andy@33 340 HERWIGID2PDGID[434] = -1000014 ## SSNUMLBR
andy@33 341 HERWIGID2PDGID[429] = 1000015 ## SSTAU1-
andy@33 342 HERWIGID2PDGID[435] = -1000015 ## SSTAU1+
andy@33 343 HERWIGID2PDGID[430] = 1000016 ## SSNUTL
andy@33 344 HERWIGID2PDGID[436] = -1000016 ## SSNUTLBR
andy@33 345 HERWIGID2PDGID[437] = 2000011 ## SSEL-
andy@33 346 HERWIGID2PDGID[443] = -2000011 ## SSEL+
andy@33 347 HERWIGID2PDGID[438] = 2000012 ## SSNUEL
andy@33 348 HERWIGID2PDGID[444] = -2000012 ## SSNUELBR
andy@33 349 HERWIGID2PDGID[439] = 2000013 ## SSMUL-
andy@33 350 HERWIGID2PDGID[445] = -2000013 ## SSMUL+
andy@33 351 HERWIGID2PDGID[440] = 2000014 ## SSNUMUL
andy@33 352 HERWIGID2PDGID[446] = -2000014 ## SSNUMLBR
andy@33 353 HERWIGID2PDGID[441] = 2000015 ## SSTAU1-
andy@33 354 HERWIGID2PDGID[447] = -2000015 ## SSTAU1+
andy@33 355 HERWIGID2PDGID[442] = 2000016 ## SSNUTL
andy@33 356 HERWIGID2PDGID[448] = -2000016 ## SSNUTLBR
andy@33 357 HERWIGID2PDGID[449] = 1000021 ## GLUINO
andy@33 358 HERWIGID2PDGID[450] = 1000022 ## NTLINO1
andy@33 359 HERWIGID2PDGID[451] = 1000023 ## NTLINO2
andy@33 360 HERWIGID2PDGID[452] = 1000025 ## NTLINO3
andy@33 361 HERWIGID2PDGID[453] = 1000035 ## NTLINO4
andy@33 362 HERWIGID2PDGID[454] = 1000024 ## CHGINO1+
andy@33 363 HERWIGID2PDGID[456] = -1000024 ## CHGINO1-
andy@33 364 HERWIGID2PDGID[455] = 1000037 ## CHGINO2+
andy@33 365 HERWIGID2PDGID[457] = -1000037 ## CHGINO2-
andy@33 366 HERWIGID2PDGID[458] = 1000039 ## GRAVTINO
andy@33 367
andy@33 368 blocks = {}
andy@33 369 decays = {}
andy@35 370 LINES = isastr.splitlines()
andy@33 371
andy@33 372 def getnextvalidline():
andy@35 373 while LINES:
andy@35 374 s = LINES.pop(0).strip()
andy@33 375 ## Return None if EOF reached
andy@33 376 if len(s) == 0:
andy@33 377 continue
andy@33 378 ## Strip comments
andy@33 379 if "#" in s:
andy@33 380 s = s[:s.index("#")].strip()
andy@33 381 ## Return if non-empty
andy@33 382 if len(s) > 0:
andy@33 383 return s
andy@33 384
andy@34 385 def getnextvalidlineitems():
andy@34 386 return map(_autotype, getnextvalidline().split())
andy@34 387
andy@34 388 ## Populate MASS block and create decaying particle objects
andy@35 389 masses = Block("MASS")
andy@33 390 numentries = int(getnextvalidline())
andy@33 391 for i in xrange(numentries):
andy@34 392 hwid, mass, lifetime = getnextvalidlineitems()
andy@34 393 width = 1.0/(lifetime * 1.51926778e24) ## width in GeV == hbar/lifetime in seconds
andy@34 394 pdgid = HERWIGID2PDGID.get(hwid, hwid)
andy@34 395 masses.add_entry((pdgid, mass))
andy@34 396 decays[pdgid] = Particle(pdgid, width, mass)
andy@34 397 #print pdgid, mass, width
andy@34 398 blocks["MASS"] = masses
andy@33 399
andy@34 400 ## Populate decays
andy@34 401 for n in xrange(numentries):
andy@34 402 numdecays = int(getnextvalidline())
andy@34 403 for d in xrange(numdecays):
andy@40 404 #print n, numentries-1, d, numdecays-1
andy@34 405 decayitems = getnextvalidlineitems()
andy@34 406 hwid = decayitems[0]
andy@34 407 pdgid = HERWIGID2PDGID.get(hwid, hwid)
andy@34 408 br = decayitems[1]
andy@34 409 nme = decayitems[2]
andy@34 410 daughter_hwids = decayitems[3:]
andy@34 411 daughter_pdgids = []
andy@34 412 for hw in daughter_hwids:
andy@34 413 if hw != 0:
andy@34 414 daughter_pdgids.append(HERWIGID2PDGID.get(hw, hw))
andy@35 415 if not decays.has_key(pdgid):
andy@40 416 #print "Decay for unlisted particle %d, %d" % (hwid, pdgid)
andy@38 417 decays[pdgid] = Particle(pdgid)
andy@38 418 decays[pdgid].add_decay(br, len(daughter_pdgids), daughter_pdgids)
andy@33 419
andy@33 420
andy@34 421 ## Now the SUSY parameters
andy@34 422 TANB, ALPHAH = getnextvalidlineitems()
andy@34 423 blocks["MINPAR"] = Block("MINPAR")
andy@34 424 blocks["MINPAR"].add_entry((3, TANB))
andy@34 425 blocks["ALPHA"] = Block("ALPHA")
andy@34 426 blocks["ALPHA"].entries = ALPHAH
andy@34 427 #
andy@34 428 ## Neutralino mixing matrix
andy@34 429 blocks["NMIX"] = Block("NMIX")
andy@34 430 for i in xrange(1, 5):
andy@34 431 nmix_i = getnextvalidlineitems()
andy@34 432 for j, v in enumerate(nmix_i):
andy@34 433 blocks["NMIX"].add_entry((i, j+1, v))
andy@34 434 #
andy@34 435 ## Chargino mixing matrices V and U
andy@34 436 blocks["VMIX"] = Block("VMIX")
andy@34 437 vmix = getnextvalidlineitems()
andy@34 438 blocks["VMIX"].add_entry((1, 1, vmix[0]))
andy@34 439 blocks["VMIX"].add_entry((1, 2, vmix[1]))
andy@34 440 blocks["VMIX"].add_entry((2, 1, vmix[2]))
andy@34 441 blocks["VMIX"].add_entry((2, 2, vmix[3]))
andy@34 442 blocks["UMIX"] = Block("UMIX")
andy@34 443 umix = getnextvalidlineitems()
andy@34 444 blocks["UMIX"].add_entry((1, 1, umix[0]))
andy@34 445 blocks["UMIX"].add_entry((1, 2, umix[1]))
andy@34 446 blocks["UMIX"].add_entry((2, 1, umix[2]))
andy@34 447 blocks["UMIX"].add_entry((2, 2, umix[3]))
andy@34 448 #
andy@34 449 THETAT, THETAB, THETAL = getnextvalidlineitems()
andy@34 450 import math
andy@34 451 blocks["STOPMIX"] = Block("STOPMIX")
andy@34 452 blocks["STOPMIX"].add_entry((1, 1, math.cos(THETAT)))
andy@34 453 blocks["STOPMIX"].add_entry((1, 2, -math.sin(THETAT)))
andy@34 454 blocks["STOPMIX"].add_entry((2, 1, math.sin(THETAT)))
andy@34 455 blocks["STOPMIX"].add_entry((2, 2, math.cos(THETAT)))
andy@34 456 blocks["SBOTMIX"] = Block("SBOTMIX")
andy@34 457 blocks["SBOTMIX"].add_entry((1, 1, math.cos(THETAB)))
andy@34 458 blocks["SBOTMIX"].add_entry((1, 2, -math.sin(THETAB)))
andy@34 459 blocks["SBOTMIX"].add_entry((2, 1, math.sin(THETAB)))
andy@34 460 blocks["SBOTMIX"].add_entry((2, 2, math.cos(THETAB)))
andy@34 461 blocks["STAUMIX"] = Block("STAUMIX")
andy@34 462 blocks["STAUMIX"].add_entry((1, 1, math.cos(THETAL)))
andy@34 463 blocks["STAUMIX"].add_entry((1, 2, -math.sin(THETAL)))
andy@34 464 blocks["STAUMIX"].add_entry((2, 1, math.sin(THETAL)))
andy@34 465 blocks["STAUMIX"].add_entry((2, 2, math.cos(THETAL)))
andy@34 466 #
andy@34 467 ATSS, ABSS, ALSS = getnextvalidlineitems()
andy@34 468 blocks["AU"] = Block("AU")
andy@34 469 blocks["AU"].add_entry((3, 3, ATSS))
andy@34 470 blocks["AD"] = Block("AD")
andy@34 471 blocks["AD"].add_entry((3, 3, ABSS))
andy@34 472 blocks["AE"] = Block("AE")
andy@34 473 blocks["AE"].add_entry((3, 3, ALSS))
andy@34 474 #
andy@34 475 MUSS = getnextvalidlineitems()[0]
andy@34 476 blocks["MINPAR"].add_entry((4, MUSS))
andy@34 477 #
andy@34 478 return blocks, decays
andy@33 479
andy@21 480
andy@31 481 def writeSLHAFile(spcfilename, blocks, decays, **kwargs):
andy@29 482 """
andy@29 483 Write an SLHA file from the supplied blocks and decays dicts.
andy@31 484
andy@31 485 Other keyword parameters are passed to writeSLHA.
andy@29 486 """
andy@68 487 f = open(spcfilename, "w")
andy@68 488 f.write(writeSLHA(blocks, decays, kwargs))
andy@68 489 f.close()
andy@29 490
andy@29 491
andy@68 492 # TODO: Split writeSLHA into writeSLHA{Blocks,Decays}
andy@68 493
andy@33 494
andy@31 495 def writeSLHA(blocks, decays, ignorenobr=False):
andy@29 496 """
andy@29 497 Return an SLHA definition as a string, from the supplied blocks and decays dicts.
andy@29 498 """
andy@31 499 sep = " "
andy@29 500 out = ""
andy@30 501 def dict_hier_strs(d, s=""):
andy@30 502 if type(d) is dict:
andy@30 503 for k, v in sorted(d.iteritems()):
andy@31 504 for s2 in dict_hier_strs(v, s + sep + _autostr(k)):
andy@30 505 yield s2
andy@30 506 else:
andy@31 507 yield s + sep + _autostr(d)
andy@30 508 ## Blocks
andy@30 509 for bname, b in sorted(blocks.iteritems()):
andy@29 510 namestr = b.name
andy@29 511 if b.q is not None:
andy@29 512 namestr += " Q= %e" % b.q
andy@29 513 out += "BLOCK %s\n" % namestr
andy@30 514 for s in dict_hier_strs(b.entries):
andy@31 515 out += sep + s + "\n"
andy@29 516 out += "\n"
andy@30 517 ## Decays
andy@30 518 for pid, particle in sorted(decays.iteritems()):
andy@40 519 out += "DECAY %d %e\n" % (particle.pid, particle.totalwidth or -1)
andy@30 520 for d in sorted(particle.decays):
andy@31 521 if d.br > 0.0 or not ignorenobr:
andy@31 522 products_str = " ".join(map(str, d.ids))
andy@31 523 out += sep + "%e" % d.br + sep + "%d" % len(d.ids) + sep + products_str + "\n"
andy@29 524 out += "\n"
andy@29 525 return out
andy@29 526
andy@29 527
andy@29 528
andy@48 529 def writeISAWIGFile(isafilename, blocks, decays, **kwargs):
andy@48 530 """
andy@48 531 Write an ISAWIG file from the supplied blocks and decays dicts.
andy@48 532
andy@48 533 Other keyword parameters are passed to writeISAWIG.
andy@48 534
andy@48 535 TODO: Handle RPV SUSY
andy@48 536 """
andy@68 537 f = open(isafilename, "w")
andy@68 538 f.write(writeISAWIG(blocks, decays, kwargs))
andy@68 539 f.close()
andy@48 540
andy@48 541
andy@48 542 def writeISAWIG(blocks, decays, ignorenobr=False):
andy@48 543 """
andy@48 544 Return an ISAWIG definition as a string, from the supplied blocks and decays dicts.
andy@48 545
andy@48 546 ISAWIG parsing based on the HERWIG SUSY specification format, from
andy@48 547 http://www.hep.phy.cam.ac.uk/~richardn/HERWIG/ISAWIG/file.html
andy@48 548
andy@48 549 If the ignorenobr parameter is True, do not write decay entries with a
andy@48 550 branching ratio of zero.
andy@48 551 """
andy@120 552 ## PDG MC ID codes mapped to HERWIG IDHW codes, based on
andy@48 553 ## http://www.hep.phy.cam.ac.uk/~richardn/HERWIG/ISAWIG/susycodes.html
andy@120 554 ## + the IDPDG array and section 4.13 of the HERWIG manual.
andy@48 555 PDGID2HERWIGID = {}
andy@120 556 PDGID2HERWIGID[ -1] = 7
andy@120 557 PDGID2HERWIGID[ -2] = 8
andy@120 558 PDGID2HERWIGID[ -3] = 9
andy@120 559 PDGID2HERWIGID[ -4] = 10
andy@120 560 PDGID2HERWIGID[ -5] = 11
andy@120 561 PDGID2HERWIGID[ -6] = 12
andy@120 562 PDGID2HERWIGID[ 21] = 13
andy@120 563 PDGID2HERWIGID[ 22] = 59
andy@120 564 PDGID2HERWIGID[ 11] = 121
andy@120 565 PDGID2HERWIGID[ 12] = 122
andy@120 566 PDGID2HERWIGID[ 13] = 123
andy@120 567 PDGID2HERWIGID[ 14] = 124
andy@120 568 PDGID2HERWIGID[ 15] = 125
andy@120 569 PDGID2HERWIGID[ 16] = 126
andy@120 570 PDGID2HERWIGID[ -11] = 127
andy@120 571 PDGID2HERWIGID[ -12] = 128
andy@120 572 PDGID2HERWIGID[ -13] = 129
andy@120 573 PDGID2HERWIGID[ -14] = 130
andy@120 574 PDGID2HERWIGID[ -15] = 131
andy@120 575 PDGID2HERWIGID[ -16] = 132
andy@120 576 PDGID2HERWIGID[ 25] = 203 ## HIGGSL0 (added for PDG standard -> HERWIG IDHW)
andy@48 577 PDGID2HERWIGID[ 26] = 203 ## HIGGSL0
andy@48 578 PDGID2HERWIGID[ 35] = 204 ## HIGGSH0
andy@48 579 PDGID2HERWIGID[ 36] = 205 ## HIGGSA0
andy@48 580 PDGID2HERWIGID[ 37] = 206 ## HIGGS+
andy@48 581 PDGID2HERWIGID[ -37] = 207 ## HIGGS-
andy@48 582 PDGID2HERWIGID[ 1000001] = 401 ## SSDLBR
andy@48 583 PDGID2HERWIGID[-1000001] = 407 ## SSDLBR
andy@48 584 PDGID2HERWIGID[ 1000002] = 402 ## SSULBR
andy@48 585 PDGID2HERWIGID[-1000002] = 408 ## SSUL
andy@48 586 PDGID2HERWIGID[ 1000003] = 403 ## SSSLBR
andy@48 587 PDGID2HERWIGID[-1000003] = 409 ## SSSL
andy@48 588 PDGID2HERWIGID[ 1000004] = 404 ## SSCLBR
andy@48 589 PDGID2HERWIGID[-1000004] = 410 ## SSCL
andy@48 590 PDGID2HERWIGID[ 1000005] = 405 ## SSB1BR
andy@48 591 PDGID2HERWIGID[-1000005] = 411 ## SSB1
andy@48 592 PDGID2HERWIGID[ 1000006] = 406 ## SST1BR
andy@48 593 PDGID2HERWIGID[-1000006] = 412 ## SST1
andy@48 594 PDGID2HERWIGID[ 2000001] = 413 ## SSDR
andy@48 595 PDGID2HERWIGID[-2000001] = 419 ## SSDRBR
andy@48 596 PDGID2HERWIGID[ 2000002] = 414 ## SSUR
andy@48 597 PDGID2HERWIGID[-2000002] = 420 ## SSURBR
andy@48 598 PDGID2HERWIGID[ 2000003] = 415 ## SSSR
andy@48 599 PDGID2HERWIGID[-2000003] = 421 ## SSSRBR
andy@48 600 PDGID2HERWIGID[ 2000004] = 416 ## SSCR
andy@48 601 PDGID2HERWIGID[-2000004] = 422 ## SSCRBR
andy@48 602 PDGID2HERWIGID[ 2000005] = 417 ## SSB2
andy@48 603 PDGID2HERWIGID[-2000005] = 423 ## SSB2BR
andy@48 604 PDGID2HERWIGID[ 2000006] = 418 ## SST2
andy@48 605 PDGID2HERWIGID[-2000006] = 424 ## SST2BR
andy@48 606 PDGID2HERWIGID[ 1000011] = 425 ## SSEL-
andy@48 607 PDGID2HERWIGID[-1000011] = 431 ## SSEL+
andy@48 608 PDGID2HERWIGID[ 1000012] = 426 ## SSNUEL
andy@48 609 PDGID2HERWIGID[-1000012] = 432 ## SSNUELBR
andy@48 610 PDGID2HERWIGID[ 1000013] = 427 ## SSMUL-
andy@48 611 PDGID2HERWIGID[-1000013] = 433 ## SSMUL+
andy@48 612 PDGID2HERWIGID[ 1000014] = 428 ## SSNUMUL
andy@48 613 PDGID2HERWIGID[-1000014] = 434 ## SSNUMLBR
andy@48 614 PDGID2HERWIGID[ 1000015] = 429 ## SSTAU1-
andy@48 615 PDGID2HERWIGID[-1000015] = 435 ## SSTAU1+
andy@48 616 PDGID2HERWIGID[ 1000016] = 430 ## SSNUTL
andy@48 617 PDGID2HERWIGID[-1000016] = 436 ## SSNUTLBR
andy@48 618 PDGID2HERWIGID[ 2000011] = 437 ## SSEL-
andy@48 619 PDGID2HERWIGID[-2000011] = 443 ## SSEL+
andy@48 620 PDGID2HERWIGID[ 2000012] = 438 ## SSNUEL
andy@48 621 PDGID2HERWIGID[-2000012] = 444 ## SSNUELBR
andy@48 622 PDGID2HERWIGID[ 2000013] = 439 ## SSMUL-
andy@48 623 PDGID2HERWIGID[-2000013] = 445 ## SSMUL+
andy@48 624 PDGID2HERWIGID[ 2000014] = 440 ## SSNUMUL
andy@48 625 PDGID2HERWIGID[-2000014] = 446 ## SSNUMLBR
andy@48 626 PDGID2HERWIGID[ 2000015] = 441 ## SSTAU1-
andy@48 627 PDGID2HERWIGID[-2000015] = 447 ## SSTAU1+
andy@48 628 PDGID2HERWIGID[ 2000016] = 442 ## SSNUTL
andy@48 629 PDGID2HERWIGID[-2000016] = 448 ## SSNUTLBR
andy@48 630 PDGID2HERWIGID[ 1000021] = 449 ## GLUINO
andy@48 631 PDGID2HERWIGID[ 1000022] = 450 ## NTLINO1
andy@48 632 PDGID2HERWIGID[ 1000023] = 451 ## NTLINO2
andy@48 633 PDGID2HERWIGID[ 1000025] = 452 ## NTLINO3
andy@48 634 PDGID2HERWIGID[ 1000035] = 453 ## NTLINO4
andy@48 635 PDGID2HERWIGID[ 1000024] = 454 ## CHGINO1+
andy@48 636 PDGID2HERWIGID[-1000024] = 456 ## CHGINO1-
andy@48 637 PDGID2HERWIGID[ 1000037] = 455 ## CHGINO2+
andy@48 638 PDGID2HERWIGID[-1000037] = 457 ## CHGINO2-
andy@48 639 PDGID2HERWIGID[ 1000039] = 458 ## GRAVTINO
andy@48 640
andy@48 641 masses = blocks["MASS"].entries
andy@48 642
andy@48 643 ## Init output string
andy@48 644 out = ""
andy@48 645
andy@48 646 ## First write out masses section:
andy@48 647 ## Number of SUSY + top particles
andy@48 648 ## IDHW, RMASS(IDHW), RLTIM(IDHW)
andy@48 649 ## repeated for each particle
andy@48 650 ## IDHW is the HERWIG identity code.
andy@48 651 ## RMASS and RTLIM are the mass in GeV, and lifetime in seconds respectively.
andy@48 652 massout = ""
andy@48 653 for pid in masses.keys():
andy@48 654 lifetime = -1
andy@48 655 try:
andy@48 656 width = decays[pid].totalwidth
andy@48 657 if width and width > 0:
andy@48 658 lifetime = 1.0/(width * 1.51926778e24) ## lifetime in seconds == hbar/width in GeV
andy@48 659 except:
andy@48 660 pass
andy@48 661 massout += "%d %e %e\n" % (PDGID2HERWIGID.get(pid, pid), masses[pid], lifetime)
andy@48 662 out += "%d\n" % massout.count("\n")
andy@48 663 out += massout
andy@48 664
andy@48 665 assert(len(masses) == len(decays))
andy@48 666
andy@48 667 ## Next each particles decay modes together with their branching ratios and matrix element codes
andy@48 668 ## Number of decay modes for a given particle (IDK)
andy@48 669 ## IDK(*), BRFRAC(*), NME(*) & IDKPRD(1-5,*)
andy@48 670 ## repeated for each mode.
andy@48 671 ## Repeated for each particle.
andy@48 672 ## IDK is the HERWIG code for the decaying particle, BRFRAC is the branching ratio of
andy@48 673 ## the decay mode. NME is a code for the matrix element to be used, either from the
andy@48 674 ## SUSY elements or the main HERWIG MEs. IDKPRD are the HERWIG identity codes of the decay products.
andy@48 675 for i, pid in enumerate(decays.keys()):
andy@48 676 # if not decays.has_key(pid):
andy@48 677 # continue
andy@48 678 hwid = PDGID2HERWIGID.get(pid, pid)
andy@48 679 decayout = ""
andy@48 680 #decayout += "@@@@ %d %d %d\n" % (i, pid, hwid)
andy@48 681 for i_d, d in enumerate(decays[pid].decays):
andy@48 682 ## Skip decay if it has no branching ratio
andy@48 683 if ignorenobr and d.br == 0:
andy@48 684 continue
andy@71 685
andy@71 686 ## Identify decay matrix element to use
andy@59 687 ## From std HW docs, or from this pair:
andy@59 688 ## Two new matrix element codes have been added for these new decays:
andy@59 689 ## NME = 200 3 body top quark via charged Higgs
andy@59 690 ## 300 3 body R-parity violating gaugino and gluino decays
andy@71 691 nme = 0
andy@71 692 # TODO: Get correct condition for using ME 100... this guessed from some ISAWIG output
andy@71 693 if abs(pid) in (6, 12):
andy@71 694 nme = 100
andy@71 695 ## Extra SUSY MEs
andy@71 696 if len(d.ids) == 3:
andy@71 697 # TODO: How to determine the conditions for using 200 and 300 MEs? Enumeration of affected decays?
andy@71 698 pass
andy@71 699 decayout += "%d %e %d " % (hwid, d.br, nme)
andy@71 700
andy@71 701 def is_quark(pid):
andy@71 702 return (abs(pid) in range(1, 7))
andy@71 703
andy@71 704 def is_lepton(pid):
andy@71 705 return (abs(pid) in range(11, 17))
andy@71 706
andy@71 707 def is_squark(pid):
andy@71 708 if abs(pid) in range(1000001, 1000007):
andy@71 709 return True
andy@71 710 if abs(pid) in range(2000001, 2000007):
andy@71 711 return True
andy@71 712 return False
andy@71 713
andy@71 714 def is_slepton(pid):
andy@71 715 if abs(pid) in range(1000011, 1000017):
andy@71 716 return True
andy@71 717 if abs(pid) in range(2000011, 2000016, 2):
andy@71 718 return True
andy@71 719 return False
andy@71 720
andy@71 721 def is_gaugino(pid):
andy@71 722 if abs(pid) in range(1000022, 1000026):
andy@71 723 return True
andy@71 724 if abs(pid) in (1000035, 1000037):
andy@71 725 return True
andy@71 726 return False
andy@71 727
andy@71 728 def is_susy(pid):
andy@71 729 return (is_squark(pid) or is_slepton(pid) or is_gaugino(pid) or pid == 1000021)
andy@71 730
andy@71 731 absids = map(abs, d.ids)
andy@71 732
andy@66 733 ## Order decay products as required by HERWIG
andy@66 734 ## Top
andy@66 735 if abs(pid) == 6:
andy@66 736 def cmp_bottomlast(a, b):
andy@66 737 """Comparison function which always puts b/bbar last"""
andy@66 738 if abs(a) == 5:
andy@66 739 return True
andy@71 740 if abs(b) == 5:
andy@66 741 return False
andy@66 742 return cmp(a, b)
andy@66 743 if len(absids) == 2:
andy@66 744 ## 2 body mode, to Higgs: Higgs; Bottom
andy@66 745 if (25 in absids or 26 in absids) and 5 in absids:
andy@66 746 d.ids = sorted(d.ids, key=cmp_bottomlast)
andy@66 747 elif len(absids) == 3:
andy@66 748 ## 3 body mode, via charged Higgs/W: quarks or leptons from W/Higgs; Bottom
andy@66 749 if 37 in absids or 23 in absids:
andy@66 750 d.ids = sorted(d.ids, key=cmp_bottomlast)
andy@66 751 ## Gluino
andy@66 752 elif abs(pid) == 1000021:
andy@66 753 if len(absids) == 2:
andy@66 754 ## 2 body mode
andy@66 755 ## without gluon: any order
andy@66 756 ## with gluon: gluon; colour neutral
andy@66 757 if 21 in absids:
andy@66 758 def cmp_gluonfirst(a, b):
andy@66 759 """Comparison function which always puts gluon first"""
andy@66 760 if a == 21:
andy@66 761 return False
andy@71 762 if b == 21:
andy@66 763 return True
andy@66 764 return cmp(a, b)
andy@66 765 d.ids = sorted(d.ids, key=cmp_gluonfirst)
andy@66 766 elif len(absids) == 3:
andy@66 767 ## 3-body modes, R-parity conserved: colour neutral; q or qbar
andy@70 768 def cmp_quarkslast(a, b):
andy@70 769 """Comparison function which always puts quarks last"""
andy@71 770 if is_quark(a):
andy@70 771 return True
andy@71 772 if is_quark(b):
andy@71 773 return False
andy@71 774 return cmp(a, b)
andy@71 775 d.ids = sorted(d.ids, key=cmp_quarkslast)
andy@71 776 ## Squark/Slepton
andy@71 777 elif is_squark(pid) or is_slepton(pid):
andy@73 778 def cmp_susy_quark_lepton(a, b):
andy@71 779 if is_susy(a):
andy@71 780 return False
andy@71 781 if is_susy(b):
andy@71 782 return True
andy@71 783 if is_quark(a):
andy@71 784 return False
andy@71 785 if is_quark(b):
andy@71 786 return True
andy@71 787 return cmp(a, b)
andy@71 788 ## 2 body modes: Gaugino/Gluino with Quark/Lepton Gaugino quark
andy@71 789 ## Gluino lepton
andy@71 790 ## 3 body modes: Weak sparticle particles from W decay
andy@71 791 ## Squark
andy@71 792 ## 2 body modes: Lepton Number Violated quark lepton
andy@71 793 ## Baryon number violated quark quark
andy@71 794 ## Slepton
andy@71 795 ## 2 body modes: Lepton Number Violated q or qbar
andy@71 796 d.ids = sorted(d.ids, key=cmp_bottomlast)
andy@71 797 ## Higgs
andy@71 798 elif pid in (25, 26):
andy@71 799 # TODO: Includes SUSY Higgses?
andy@71 800 ## Higgs
andy@71 801 ## 2 body modes: (s)quark-(s)qbar (s)q or (s)qbar
andy@71 802 ## (s)lepton-(s)lepton (s)l or (s)lbar
andy@71 803 ## 3 body modes: colour neutral q or qbar
andy@71 804 if len(absids) == 3:
andy@71 805 def cmp_quarkslast(a, b):
andy@71 806 """Comparison function which always puts quarks last"""
andy@71 807 if is_quark(a):
andy@71 808 return True
andy@71 809 if is_quark(b):
andy@71 810 return False
andy@71 811 return cmp(a, b)
andy@71 812 d.ids = sorted(d.ids, key=cmp_quarkslast)
andy@71 813 elif is_gaugino(pid):
andy@71 814 # TODO: Is there actually anything to do here?
andy@71 815 ## Gaugino
andy@71 816 ## 2 body modes: Squark-quark q or sq
andy@71 817 ## Slepton-lepton l or sl
andy@71 818 ##
andy@71 819 ## 3 body modes: R-parity conserved colour neutral q or qbar
andy@71 820 ## l or lbar
andy@71 821 if len(absids) == 3:
andy@71 822 def cmp_quarkslast(a, b):
andy@71 823 """Comparison function which always puts quarks last"""
andy@71 824 if is_quark(a):
andy@71 825 return True
andy@71 826 if is_quark(b):
andy@70 827 return False
andy@70 828 return cmp(a, b)
andy@70 829 d.ids = sorted(d.ids, key=cmp_quarkslast)
andy@66 830
andy@71 831 # TODO: Gaugino/Gluino
andy@67 832 ## 3 body modes: R-parity violating: Particles in the same order as the R-parity violating superpotential
andy@66 833
andy@66 834 ## Pad out IDs list with zeros
andy@48 835 ids = [0,0,0,0,0]
andy@48 836 for i, pid in enumerate(d.ids):
andy@48 837 ids[i] = pid
andy@48 838 ids = map(str, ids)
andy@48 839 decayout += " ".join(ids) + "\n"
andy@48 840 decayout = "%d\n" % decayout.count("\n") + decayout
andy@48 841 out += decayout
andy@48 842
andy@48 843 ## Now the SUSY parameters
andy@48 844 ## TANB, ALPHAH:
andy@48 845 out += "%e %e\n" % (blocks["MINPAR"].entries[3], blocks["ALPHA"].entries)
andy@48 846 ## Neutralino mixing matrix
andy@48 847 nmix = blocks["NMIX"].entries
andy@48 848 for i in xrange(1, 5):
andy@48 849 out += "%e %e %e %e\n" % (nmix[i][1], nmix[i][2], nmix[i][3], nmix[i][4])
andy@48 850 ## Chargino mixing matrices V and U
andy@48 851 vmix = blocks["VMIX"].entries
andy@48 852 out += "%e %e %e %e\n" % (vmix[1][1], vmix[1][2], vmix[2][1], vmix[2][2])
andy@48 853 umix = blocks["UMIX"].entries
andy@48 854 out += "%e %e %e %e\n" % (umix[1][1], umix[1][2], umix[2][1], umix[2][2])
andy@48 855 # THETAT,THETAB,THETAL
andy@48 856 import math
andy@48 857 out += "%e %e %e\n" % (math.acos(blocks["STOPMIX"].entries[1][1]),
andy@48 858 math.acos(blocks["SBOTMIX"].entries[1][1]),
andy@48 859 math.acos(blocks["STAUMIX"].entries[1][1]))
andy@48 860 # ATSS,ABSS,ALSS
andy@48 861 out += "%e %e %e\n" % (blocks["AU"].entries[3][3],
andy@48 862 blocks["AD"].entries[3][3],
andy@48 863 blocks["AE"].entries[3][3])
andy@48 864 # MUSS == sign(mu)
andy@48 865 out += "%f\n" % blocks["MINPAR"].entries[4]
andy@48 866
andy@48 867 ## TODO: Handle RPV SUSY
andy@48 868
andy@48 869 return out
andy@48 870
andy@48 871
andy@48 872
andy@1 873 if __name__ == "__main__":
andy@1 874 import sys
andy@1 875 for a in sys.argv[1:]:
andy@35 876 if a.endswith(".isa"):
andy@35 877 blocks, decays = readISAWIGFile(a)
andy@35 878 else:
andy@35 879 blocks, decays = readSLHAFile(a)
andy@3 880
andy@5 881 for bname, b in sorted(blocks.iteritems()):
andy@5 882 print b
andy@5 883 print
andy@3 884
andy@47 885 print blocks.keys()
andy@47 886
andy@4 887 print blocks["MASS"].entries[25]
andy@6 888 print
andy@6 889
andy@6 890 for p in sorted(decays.values()):
andy@6 891 print p
andy@6 892 print
andy@29 893
andy@31 894 print writeSLHA(blocks, decays, ignorenobr=True)

mercurial