Changes between Initial Version and Version 1 of Plugin


Ignore:
Timestamp:
May 5, 2016, 5:30:31 PM (8 years ago)
Author:
Olivier Mattelaer
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Plugin

    v1 v1  
     1
     2
     3
     4
     5
     6
     7=== Example 1: hello world (adding command to the interface)
     8
     9__init__.py file
     10{{{
     11## import the required files
     12
     13import helloworld as helloworld
     14
     15
     16## Does it define a new interface (will be avaible with ./bin/mg5_aMC --mode=maddm
     17## Put None if no dedicated command are required
     18new_interface = helloworld.NewInterface
     19
     20## Does it define a new output mode. Need to be define
     21new_output = {}
     22
     23## The test/code have been validated up to this version
     24latest_validated_version = '2.3.4'
     25}}}
     26
     27helloworld.py file
     28{{{
     29class Newinterface(master_interface.MasterCmd):
     30
     31    def do_helloworld(self, line):
     32        """print hello world"""
     33        print "hello world"
     34}}}
     35
     36=== Example 2: New Exporter
     37
     38__init__.py file
     39{{{
     40## import the required files
     41
     42import output as output
     43
     44## Define a typical error for the plugin
     45class EVTDECONS_Error(Exception): pass
     46
     47## Does it define a new interface (will be avaible with ./bin/mg5_aMC --mode=maddm
     48## Put None if no dedicated command are required
     49new_interface = False
     50
     51## Does it define a new output mode. Need to be define
     52new_output = {'madweight2': output.NEW_MW_OUTPUT,
     53              'standalone_lib': output.NEW_CPP_LIB}
     54
     55## The test/code have been validated up to this version
     56latest_validated_version = '2.3.4'
     57}}}
     58
     59
     60output.py file
     61{{{
     62import madgraph.iolibs.export_cpp as export_cpp
     63import madgraph.iolibs.export_v4 as export_v4
     64import madgraph.various.misc as misc
     65# Note loop type output are not supported.
     66
     67class My_MW_Exporter(export_v4.ProcessExporterFortranMWGroup):
     68
     69    nb_done = 0
     70
     71    def __init__(self, *args, **opts):
     72        misc.sprint("Initialise the exporter")
     73        return super(My_MW_Exporter, self).__init__(*args, **opts)
     74
     75    def copy_v4template(self, *args, **opts):
     76        misc.sprint("copy the associate template")
     77        return super(My_MW_Exporter, self).copy_v4template(*args, **opts)
     78
     79    def generate_subprocess_directory(self, subproc_group,
     80                                         fortran_model, me=None):
     81
     82        misc.sprint(me)
     83        if me is None:
     84            MyExporter.nb_done +=1
     85            current_generated = MyExporter.nb_done
     86        else:
     87            current_generated = me
     88
     89class MY_CPP_Standalone(export_cpp.ProcessExporterPythia8):
     90
     91    def __init__(self, *args, **opts):
     92        misc.sprint("Initialise the exporter")
     93        return super(MY_CPP_Standalone, self).__init__(*args, **opts)
     94
     95    def setup_cpp_standalone_dir(self, model):
     96
     97        misc.sprint("initialise the directory")
     98        return super(MY_CPP_Standalone, self).setup_cpp_standalone_dir(model)
     99
     100
     101    def generate_subprocess_directory(self, subproc_group,
     102                                         fortran_model, me=None):
     103
     104        misc.sprint('create the directory')
     105        return super(MY_CPP_Standalone, self).generate_subprocess_directory(subproc_group, fortran_model, me)
     106
     107
     108    def convert_model(self, model, wanted_lorentz=[], wanted_coupling=[]):
     109        misc.sprint('create the model')
     110        return super(MY_CPP_Standalone, self).convert_model(model, wanted_lorentz, wanted_coupling)
     111
     112    def finalize(self, matrix_element, cmdhistory, MG5options, outputflag):
     113        """typically creating jpeg/HTML output/ compilation/...
     114           cmdhistory is the list of command used so far.
     115           MG5options are all the options of the main interface
     116           outputflags is a list of options provided when doing the output command"""
     117        misc.sprint("pass here")
     118        return super(MY_CPP_Standalone, self).finalize(matrix_element, cmdhistory, MG5options, outputflag)
     119
     120NEW_CPP_LIB = {
     121    # check status of the directory. Remove it if already exists
     122    'check': True,
     123    # Language type: 'v4' for f77/ 'cpp' for C++ output
     124    'exporter': 'cpp',
     125    # Output type:
     126    #[Template/dir/None] copy the Template, just create dir  or do nothing
     127    'output': 'Template',
     128    # Decide which type of merging if used [madevent/madweight]
     129    'group_mode': 'madweight',
     130    # if no grouping on can decide to merge uu~ and u~u anyway:
     131    'sa_symmetry': True,
     132    # The most important part where the exporter is defined:
     133    # a plugin typically defines this file in another file (here tak one of MG5)
     134    'exporter_class': MY_CPP_Standalone
     135    }
     136
     137NEW_MW_OUTPUT = {
     138    # check status of the directory. Remove it if already exists
     139    'check': True,
     140    # Language type: 'v4' for f77/ 'cpp' for C++ output
     141    'exporter': 'v4',
     142    # Output type:
     143    #[Template/dir/None] copy the Template, just create dir  or do nothing
     144    'output': 'Template',
     145    # Decide which type of merging to used [madevent/madweight]
     146    'group_mode': 'madweight',
     147    # if no grouping on can decide to merge uu~ and u~u anyway:
     148    'sa_symmetry': True,
     149    # The most important part where the exporter is defined:
     150    # a plugin typically defines this file in another file (here tak one of MG5)
     151    'exporter_class': My_MW_Exporter
     152    }
     153}}}
     154
     155
     156=== List of function that need to be defined in the exporter For Fortran output:
     157   
     158   Note: All of them are defined in ProcessExporterFortran. So you need to define them only if you start a class from scratch.
     159         This list correspond to the call to the exporter performed outside the class itself.
     160
     161   1. __init__(self, mgme_dir = "", dir_path = "", opt=None)
     162   2. copy_v4template(self, modelname)
     163   3. generate_subprocess_directory(self, subproc_group, helicity_model, me=None) [for grouped]
     164   4. generate_subprocess_directory(self, matrix_element, helicity_model, me_number) [for ungrouped]
     165   4. convert_model(model, wanted_lorentz=[], wanted_coupling=[])
     166   5. finalize(self,matrix_element, cmdhistory, MG5options, outputflag)     
     167   6. modify_grouping(self, matrix_element)
     168   7. export_model_files(self, model_v4_path) [only if you want to support old model format]
     169   8. export_helas(self, HELAS_PATH) [only if you want to support old model format]
     170
     171=== List of function that need to be defined in the exporter For Cpp output:
     172
     173   Note: All of them are defined in ProcessExporterCPP. So you need to define them only if you start a class from scratch.
     174         This list correspond to the call to the exporter performed outside the class itself.
     175 
     176   1. __init__(self, mgme_dir = "", dir_path = "", opt=None)
     177   2. setup_cpp_standalone_dir(self, model)
     178   3. generate_subprocess_directory(self, subproc_group, helicity_model, me=None) [for grouped]
     179   4. generate_subprocess_directory(self, matrix_element, helicity_model, me_number) [for ungrouped]
     180   4. convert_model(model, wanted_lorentz=[], wanted_coupling=[])
     181   5. finalize(self,matrix_element, cmdhistory, MG5options, outputflag)     
     182   6. modify_grouping(self, matrix_element)
     183   7. make_model_cpp(self, export_dir)
     184
     185=== List of class variable that need to be defined in the exporter:
     186
     187   Note: All of them are defined in ProcessExporterFortran/ProcessExporterCPP. So you need to define them only if you start a class from scratch.
     188         This list correspond to the attribute of the exporter called outside the  exporter class.
     189
     190   1. grouped_mode # says which type of exporter to use.
     191
     192
     193
     194
     195