Changes between Version 6 and Version 7 of Plugin


Ignore:
Timestamp:
Jun 20, 2016, 2:47:53 PM (8 years ago)
Author:
Olivier Mattelaer
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Plugin

    v6 v7  
    1 === Plugin idea
    2 
    3 === init file:
     1=== Structure
     2
     3The idea of the plugin idea is to allow some modification of the code behavior without the need to modify the internal code.
     4Allowing an easy support of many modification in the future release of MG5aMC.
     5So far three type of modification are supported by this module:
     6  1. New output type (for LO processes)
     7  2. New cluster type
     8  3. Modification of the interface (new command/modification of the command)
     9
     10The plugin is a directory to placed inside the PLUGIN directory of MG5aMC.
     11It should at least have one file named "!__init!__.py" which should contains some minimal information (see below).
     12This file should link to other python file if needed.
     13
     14
     15=== !__init!__.py file:
     16
     17The minimal information that need to be present in that file is:
    418
    519{{{
     
    2135#    example new_cluster = {'mycluster': MYCLUSTERCLASS}
    2236#    allow "set cluster_type mycluster" in madgraph
    23 #    MYCLUSTERCLASSshould inherated from madgraph.various.cluster.Cluster
     37#    MYCLUSTERCLASS should inherated from madgraph.various.cluster.Cluster
    2438new_cluster = {}
    2539
     
    4660=== Example 1: hello world (adding command to the interface)
    4761
    48 __init__.py file
     62!__init!__.py file
    4963{{{
    5064## import the required files
    51 
    52 import helloworld as helloworld
    53 
    54 
    55 ## Does it define a new interface (will be avaible with ./bin/mg5_aMC --mode=maddm
     65# example: import maddm_interface as maddm_interface # local file
     66#          import madgraph.various.cluster as cluster #MG5 distribution file
     67# Three types of functionality are allowed in a plugin
     68#   1. new output mode
     69#   2. new cluster support
     70#   3. new interface
     71
     72# 1. Define new output mode
     73#    example: new_output = {'myformat': MYCLASS}
     74#    madgraph will then allow the command "output myformat PATH"
     75#    MYCLASS should inherated of the class madgraph.iolibs.export_v4.VirtualExporter
     76new_output = {}
     77
     78# 2. Define new way to handle the cluster.
     79#    example new_cluster = {'mycluster': MYCLUSTERCLASS}
     80#    allow "set cluster_type mycluster" in madgraph
     81#    MYCLUSTERCLASS should inherated from madgraph.various.cluster.Cluster
     82new_cluster = {}
     83
     84
     85# 3. Define a new interface (allow to add/modify MG5 command)
     86#    This can be activated via ./bin/mg5_aMC --mode=PLUGINNAME
    5687## Put None if no dedicated command are required
     88import helloworld as helloworld # local file
    5789new_interface = helloworld.NewInterface
    58 
    59 ## Does it define a new output mode. Need to be define
    60 new_output = {}
    61 
    62 ## The test/code have been validated up to this version
    63 latest_validated_version = '2.3.4'
     90 
     91 
     92########################## CONTROL VARIABLE ####################################
     93__author__ = 'Mattelaer Olivier'
     94__email__ = 'o.p.c.mattelaer@durham.ac.uk'
     95__version__ = (1,0,0)
     96minimal_mg5amcnlo_version = (2,5,0)
     97maximal_mg5amcnlo_version = (1000,1000,1000)
     98latest_validated_version = (2,5,0)
    6499}}}
    65100
    66101helloworld.py file
    67102{{{
    68 class Newinterface(master_interface.MasterCmd):
     103
     104import madgraph.interface.master_interface as master_interface
     105
     106class NewInterface(master_interface.MasterCmd):
    69107
    70108    def do_helloworld(self, line):
     
    73111}}}
    74112
     113Now you can run the standard executable with
     114{{{
     115./bin/mg5_aMC --mode=helloworld
     116}}}
     117Note that "helloworld" is the name of the DIRECTORY where the above file have been placed.
     118
     119The above command create you a shell where you have access to one additional command "helloworld"
     120{{{
     121MG5_aMC>helloworld
     122hello world
     123}}}
     124
    75125=== Example 2: New Exporter
    76126
    77 __init__.py file
     127!__init!__.py file
    78128{{{
    79129## import the required files