Version 2 (modified by 9 years ago) ( diff ) | ,
---|
Example 1: hello world (adding command to the interface)
init.py file
## import the required files import helloworld as helloworld ## Does it define a new interface (will be avaible with ./bin/mg5_aMC --mode=maddm ## Put None if no dedicated command are required new_interface = helloworld.NewInterface ## Does it define a new output mode. Need to be define new_output = {} ## The test/code have been validated up to this version latest_validated_version = '2.3.4'
helloworld.py file
class Newinterface(master_interface.MasterCmd): def do_helloworld(self, line): """print hello world""" print "hello world"
Example 2: New Exporter
init.py file
## import the required files import output as output ## Define a typical error for the plugin class EVTDECONS_Error(Exception): pass ## Does it define a new interface (will be avaible with ./bin/mg5_aMC --mode=maddm ## Put None if no dedicated command are required new_interface = False ## Does it define a new output mode. Need to be define new_output = {'madweight2': output.NEW_MW_OUTPUT, 'standalone_lib': output.NEW_CPP_LIB} ## The test/code have been validated up to this version latest_validated_version = '2.3.4'
output.py file
import madgraph.iolibs.export_cpp as export_cpp import madgraph.iolibs.export_v4 as export_v4 import madgraph.various.misc as misc # Note loop type output are not supported. class My_MW_Exporter(export_v4.ProcessExporterFortranMWGroup): nb_done = 0 def __init__(self, *args, **opts): misc.sprint("Initialise the exporter") return super(My_MW_Exporter, self).__init__(*args, **opts) def copy_v4template(self, *args, **opts): misc.sprint("copy the associate template") return super(My_MW_Exporter, self).copy_v4template(*args, **opts) def generate_subprocess_directory(self, subproc_group, fortran_model, me=None): misc.sprint(me) if me is None: MyExporter.nb_done +=1 current_generated = MyExporter.nb_done else: current_generated = me class MY_CPP_Standalone(export_cpp.ProcessExporterPythia8): def __init__(self, *args, **opts): misc.sprint("Initialise the exporter") return super(MY_CPP_Standalone, self).__init__(*args, **opts) def setup_cpp_standalone_dir(self, model): misc.sprint("initialise the directory") return super(MY_CPP_Standalone, self).setup_cpp_standalone_dir(model) def generate_subprocess_directory(self, subproc_group, fortran_model, me=None): misc.sprint('create the directory') return super(MY_CPP_Standalone, self).generate_subprocess_directory(subproc_group, fortran_model, me) def convert_model(self, model, wanted_lorentz=[], wanted_coupling=[]): misc.sprint('create the model') return super(MY_CPP_Standalone, self).convert_model(model, wanted_lorentz, wanted_coupling) def finalize(self, matrix_element, cmdhistory, MG5options, outputflag): """typically creating jpeg/HTML output/ compilation/... cmdhistory is the list of command used so far. MG5options are all the options of the main interface outputflags is a list of options provided when doing the output command""" misc.sprint("pass here") return super(MY_CPP_Standalone, self).finalize(matrix_element, cmdhistory, MG5options, outputflag) NEW_CPP_LIB = { # check status of the directory. Remove it if already exists 'check': True, # Language type: 'v4' for f77/ 'cpp' for C++ output 'exporter': 'cpp', # Output type: #[Template/dir/None] copy the Template, just create dir or do nothing 'output': 'Template', # Decide which type of merging if used [madevent/madweight] 'group_mode': 'madweight', # if no grouping on can decide to merge uu~ and u~u anyway: 'sa_symmetry': True, # The most important part where the exporter is defined: # a plugin typically defines this file in another file (here tak one of MG5) 'exporter_class': MY_CPP_Standalone } NEW_MW_OUTPUT = { # check status of the directory. Remove it if already exists 'check': True, # Language type: 'v4' for f77/ 'cpp' for C++ output 'exporter': 'v4', # Output type: #[Template/dir/None] copy the Template, just create dir or do nothing 'output': 'Template', # Decide which type of merging to used [madevent/madweight] 'group_mode': 'madweight', # if no grouping on can decide to merge uu~ and u~u anyway: 'sa_symmetry': True, # The most important part where the exporter is defined: # a plugin typically defines this file in another file (here tak one of MG5) 'exporter_class': My_MW_Exporter }
List of function that need to be defined in the exporter For Fortran output:
Note: All of them are defined in ProcessExporterFortran. So you need to define them only if you start a class from scratch.
This list correspond to the call to the exporter performed outside the class itself.
- init(self, mgme_dir = "", dir_path = "", opt=None)
- copy_v4template(self, modelname)
- generate_subprocess_directory(self, subproc_group, helicity_model, me=None) [for grouped]
- generate_subprocess_directory(self, matrix_element, helicity_model, me_number) [for ungrouped]
- convert_model(model, wanted_lorentz=[], wanted_coupling=[])
- finalize(self,matrix_element, cmdhistory, MG5options, outputflag)
- modify_grouping(self, matrix_element)
- export_model_files(self, model_v4_path) [only if you want to support old model format]
- export_helas(self, HELAS_PATH) [only if you want to support old model format]
List of function that need to be defined in the exporter For Cpp output:
Note: All of them are defined in ProcessExporterCPP. So you need to define them only if you start a class from scratch.
This list correspond to the call to the exporter performed outside the class itself.
- init(self, mgme_dir = "", dir_path = "", opt=None)
- setup_cpp_standalone_dir(self, model)
- generate_subprocess_directory(self, subproc_group, helicity_model, me=None) [for grouped]
returns an integer (used only to print info to screen as the number of call to helicity routine)
- generate_subprocess_directory(self, matrix_element, helicity_model, me_number) [for ungrouped]
returns an integer (used only to print info to screen as the number of call to helicity routine)
- convert_model(model, wanted_lorentz=[], wanted_coupling=[])
- finalize(self,matrix_element, cmdhistory, MG5options, outputflag)
- modify_grouping(self, matrix_element)
- make_model_cpp(self, export_dir)
List of class variable that need to be defined in the exporter:
Note: All of them are defined in ProcessExporterFortran/ProcessExporterCPP. So you need to define them only if you start a class from scratch.
This list correspond to the attribute of the exporter called outside the exporter class.
- grouped_mode # says which type of exporter to use.
Base class which can be use to create a new exporter from scratch:
class MyV4EmptyOutput(object): grouped_mode=True def __init__(self, mgme_dir = "", dir_path = "", opt=None): return def copy_v4template(self, modelname): return def generate_subprocess_directory(self, subproc_group, helicity_model, me=None): # generate_subprocess_directory(self, matrix_element, helicity_model, me_number) [for ungrouped] return 0 # return an integer stating the number of call to helicity routine def convert_model(self, model, wanted_lorentz=[], wanted_coupling=[]): return def finalize(self,matrix_element, cmdhistory, MG5options, outputflag): return def modify_grouping(self, matrix_element): return False, matrix_element def export_model_files(self, model_v4_path): return def export_helas(self, HELAS_PATH): return class MyCPPEmptyOutput(object): grouped_mode=True def __init__(self, mgme_dir = "", dir_path = "", opt=None): return def setup_cpp_standalone_dir(self, model) return def generate_subprocess_directory(self, subproc_group, helicity_model, me=None): # generate_subprocess_directory(self, matrix_element, helicity_model, me_number) [for ungrouped] return 0 # return an integer stating the number of call to helicity routine def convert_model(self, model, wanted_lorentz=[], wanted_coupling=[]): return def finalize(self,matrix_element, cmdhistory, MG5options, outputflag): return def modify_grouping(self, matrix_element): return False, matrix_element def make_model_cpp(self, model): return
Attachments (1)
-
SLAC_cluster.tar.gz
(1.8 KB
) - added by 8 years ago.
plugin for handling LSF SLAC cluster
Download all attachments as: .zip