diff --git a/README.md b/README.md index f7afe5d..85cdc8f 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,11 @@ This repository contains the files that are necessary for setting up a `genprodu - If you are running the script from `cmsconnect`, it will create the directory in your `/local-scratch` area - Files in `/local-scratch` are deleted 30 days after their last modification, so if you would like to keep your gridpacks, be sure to move them to a permanent location after they are completed - +# Gridpack Options: +- The `replace_model` option expects a list of length 2. The first element is the name of the old Madgraph model as it exists in the process card and the second element is the name of the new model that should replace the old one. +```python +from helpers.Gridpack import Gridpack +gp = Gridpack(replace_model=['dim6top_LO_UFO','smloop']) +# Alternatively via setOptions +gp.setOptions(replace_model=['dim6top_LO_UFO','smloop']) +``` diff --git a/mcgeneration/configure_gridpack.py b/mcgeneration/configure_gridpack.py index bb6d028..3fdce7d 100644 --- a/mcgeneration/configure_gridpack.py +++ b/mcgeneration/configure_gridpack.py @@ -471,9 +471,9 @@ def main(): gridpack = Gridpack(stype=stype,btype=btype,default_limits=[-20.0,20.0]) gridpack.setOptions(runcard_ops=rc_ops) # For using a different model - gridpack.setOptions(coupling_string="FCNC=0 DIM6=1",replace_model="dim6top_LO_UFO_19-05-20") + gridpack.setOptions(coupling_string="FCNC=0 DIM6=1",replace_model=["dim6top_LO_UFO","dim6top_LO_UFO_19-05-20"]) # For creating feynman diagrams - #gridpack.setOptions(btype=BatchType.LOCAL,save_diagrams=True,replace_model="dim6top_LO_UFO_each_coupling_order_v2020-05-19") + #gridpack.setOptions(btype=BatchType.LOCAL,save_diagrams=True,replace_model=["dim6top_LO_UFO","dim6top_LO_UFO_each_coupling_order_v2020-05-19"]) #gridpack.setOptions(coupling_string="FCNC=0 DIM6^2=1 DIM6_ctZ^2=1 DIM6_ctW^2=1") # For example if stype == ScanType.SLINSPACE: diff --git a/mcgeneration/helpers/Gridpack.py b/mcgeneration/helpers/Gridpack.py index d773de9..631f70c 100644 --- a/mcgeneration/helpers/Gridpack.py +++ b/mcgeneration/helpers/Gridpack.py @@ -62,7 +62,7 @@ def __init__(self,**kwargs): 'save_diagrams': False, # Runs a modified version of the generation script that exits early to keep feynman diagrams 'use_coupling_model': False, # Use the 'coupling_orders' version of the dim6 model 'coupling_string': None, # If not None replaces "DIM6=1" with the specified string in the process card - 'replace_model': None, # If not None overwrites the import model line of the process card + 'replace_model': None, # If not None needs to be a tuple/list of length 2 that specifies the old and new model to be replaced 'flavor_scheme': 5, 'default_limits': [-10,10], } @@ -200,10 +200,10 @@ def saveProcessCard(self,indent=0): run_process(['sed','-i','-e',sed_str,fpath]) if self.ops['replace_model']: - rep_model = self.ops['replace_model'] - print "{ind}Using {model} model".format(model=rep_model,ind=indent_str) - old = "dim6top_LO_UFO" - sed_str = "s|import model {old}|import model {new}|g".format(old=old,new=rep_model) + old = self.ops['replace_model'][0] + new = self.ops['replace_model'][1] + print "{ind}Using {model} model".format(model=old,ind=indent_str) + sed_str = "s|import model {old}|import model {new}|g".format(old=old,new=new) run_process(['sed','-i','-e',sed_str,fpath]) # Replace SUBSETUP in the process card with the correct name @@ -498,10 +498,16 @@ def setup(self,indent=0): print "[ERROR] Invalid BatchType for saving diagrams: {btype}".format(btype=self.ops['btype']) return False + if self.ops['replace_model'] and len(self.ops['replace_model']) != 2: + # Note: This won't catch the very unlikely edge case where the input is a string of length 2 + print "[ERROR] Invalid option for 'replace_model': {op}".format(op=self.ops['replace_model']) + return False + if self.ops['stype'] == ScanType.NONE: # Don't do any reweighting self.scan_pts = [] + print "{0:>{w}}Setup gridpack: {setup}...".format("",setup=setup,w=4*indent) # Set the random seed adding extra events to the pilotrun