Skip to content

Commit

Permalink
First version of SmeftFR converter
Browse files Browse the repository at this point in the history
  • Loading branch information
David Straub committed Jul 5, 2019
1 parent 15bf66b commit 773643e
Show file tree
Hide file tree
Showing 4 changed files with 25,191 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -33,6 +33,7 @@
'wcxf2dsixtools = wcxf.cli:wcxf2dsixtools',
'dsixtools2wcxf = wcxf.cli:dsixtools2wcxf',
'wcxf2smeftsim = wcxf.cli:smeftsim',
'wcxf2smeftfr = wcxf.cli:wcxf2smeftfr',
]
},
)
15 changes: 15 additions & 0 deletions wcxf/cli.py
Expand Up @@ -222,3 +222,18 @@ def dsixtools2wcxf():
args = parser.parse_args()
dsixtools.dsixtools2wcxf(tuple(f for f in args.FILE), stream=args.output)
return 0


def wcxf2smeftfr():
from wcxf.converters import smeftfr
parser = argparse.ArgumentParser(description="""Command line script to convert a WCxf file to a MadGraph param_card file for SmeftFR.""",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("FILE", nargs='?', help="Input file. If \"-\", read from standard input",
type=argparse.FileType('r'), default=sys.stdin)
parser.add_argument("--output", nargs='?', help="Output file. If absent, print to standard output",
type=argparse.FileType('w'), default=sys.stdout)
args = parser.parse_args()
wc = wcxf.WC.load(args.FILE)
wc.validate()
smeftfr.wcxf2smeftfr(wc, stream=args.output)
return 0
45 changes: 45 additions & 0 deletions wcxf/converters/smeftfr.py
@@ -0,0 +1,45 @@
import pylha
import json
import pkgutil
from wilson.util import smeftutil


smeftfr_info = json.loads(
pkgutil.get_data('wcxf', 'data/smeftfr_block_info.json').decode('utf-8')
)


def wcxf2smeftfr_dict(wc):
"""Take a WC instance and turn it into a dictionary suitable for producing
and LHA file for SmeftFR using pylha."""
# go from flat dict to dict of arrays, symmetrizing them
C = smeftutil.wcxf2arrays_symmetrized(wc.dict)
# go back to flat dict but keeping non-redundant WCs an symm. fac.s
d = smeftutil.arrays2wcxf(C)
# rearrange to dict in right format for SmeftFR
card = {}
for block_name, block in smeftfr_info.items():
card[block_name] = {'values': []}
for info in block:
line = [*info['index'], d[info['coeff']].real, info['comment']]
card[block_name]['values'].append(line)
return card


def wcxf2smeftfr(wc, stream):
"""Take a WC instance and dump it into an LHA file (or return as string)
in a format suitable for use as `param_card.dat` file for MadGraph
with SmeftFR
"""
if (wc.eft, wc.basis) == ('SMEFT', 'Warsaw mass'):
wc_m = wc
else:
if wc.eft != 'SMEFT':
raise ValueError("wcxf2smeftfr only support SMEFT Wilson coefficients")
else:
try:
wc_m = wc.translate('Warsaw mass')
except ValueError:
raise ValueError("wcxf2smeftfr requires a basis that can be translated to the Warsaw mass basis")
return pylha.dump({'BLOCK': wcxf2smeftfr_dict(wc_m)},
fmt='lha', stream=stream)

0 comments on commit 773643e

Please sign in to comment.