=== 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. 1. __init__(self, mgme_dir = "", dir_path = "", opt=None) 2. copy_v4template(self, modelname) 3. generate_subprocess_directory(self, subproc_group, helicity_model, me=None) [for grouped] 4. generate_subprocess_directory(self, matrix_element, helicity_model, me_number) [for ungrouped] 4. convert_model(model, wanted_lorentz=[], wanted_coupling=[]) 5. finalize(self,matrix_element, cmdhistory, MG5options, outputflag) 6. modify_grouping(self, matrix_element) 7. export_model_files(self, model_v4_path) [only if you want to support old model format] 8. 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. 1. __init__(self, mgme_dir = "", dir_path = "", opt=None) 2. setup_cpp_standalone_dir(self, model) 3. generate_subprocess_directory(self, subproc_group, helicity_model, me=None) [for grouped] 4. generate_subprocess_directory(self, matrix_element, helicity_model, me_number) [for ungrouped] 4. convert_model(model, wanted_lorentz=[], wanted_coupling=[]) 5. finalize(self,matrix_element, cmdhistory, MG5options, outputflag) 6. modify_grouping(self, matrix_element) 7. 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. 1. grouped_mode # says which type of exporter to use.