Changes between Version 3 and Version 4 of Plugin


Ignore:
Timestamp:
May 7, 2016, 12:41:06 AM (8 years ago)
Author:
Olivier Mattelaer
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Plugin

    v3 v4  
    4040## import the required files
    4141
    42 import output as output
     42import output as output 
    4343
    4444## Define a typical error for the plugin
     
    4848## Put None if no dedicated command are required
    4949new_interface = False
    50 
     50 
    5151## Does it define a new output mode. Need to be define
    52 new_output = {'madweight2': output.NEW_MW_OUTPUT,
    53               'standalone_lib': output.NEW_CPP_LIB}
     52new_output = {'madweight2': output.My_MW_Exporter,
     53              'standalone_lib': output.MY_CPP_Standalone}
    5454
    5555## The test/code have been validated up to this version
    56 latest_validated_version = '2.3.4'
     56latest_validated_version = '2.5.0'
     57minimal_version_required = '2.5.0'
     58maximal_version_required = None
    5759}}}
    5860
     
    6062output.py file
    6163{{{
    62 import madgraph.iolibs.export_cpp as export_cpp
    63 import madgraph.iolibs.export_v4 as export_v4
    64 import madgraph.various.misc as misc
    65 # Note loop type output are not supported.
    66 
    6764class My_MW_Exporter(export_v4.ProcessExporterFortranMWGroup):
    6865
     66    check = True
     67    # check status of the directory. Remove it if already exists
     68    # Language type: 'v4' for f77/ 'cpp' for C++ output
     69    exporter = 'v4'
     70    # Output type:
     71    #[Template/dir/None] copy the Template, just create dir  or do nothing
     72    output = 'Template'
     73    # Decide which type of merging to used [madevent/madweight]
     74    grouped_mode = 'madweight'   
     75    # if no grouping on can decide to merge uu~ and u~u anyway:
     76    sa_symmetry = True
     77
    6978    nb_done = 0
    70 
     79   
    7180    def __init__(self, *args, **opts):
    7281        misc.sprint("Initialise the exporter")
    7382        return super(My_MW_Exporter, self).__init__(*args, **opts)
    7483
    75     def copy_v4template(self, *args, **opts):
     84    def copy_template(self, *args, **opts):
    7685        misc.sprint("copy the associate template")
    77         return super(My_MW_Exporter, self).copy_v4template(*args, **opts)
     86        return super(My_MW_Exporter, self).copy_template(*args, **opts)
    7887
    7988    def generate_subprocess_directory(self, subproc_group,
    8089                                         fortran_model, me=None):
    81 
     90       
    8291        misc.sprint(me)
    8392        if me is None:
     
    8695        else:
    8796            current_generated = me
     97        return super(My_MW_Exporter, self).generate_subprocess_directory(subproc_group, fortran_model, current_generated)
    8898
    8999class MY_CPP_Standalone(export_cpp.ProcessExporterPythia8):
     100
     101    # check status of the directory. Remove it if already exists
     102    check = True
     103    # Language type: 'v4' for f77/ 'cpp' for C++ output
     104    exporter = 'cpp'
     105    # Output type:
     106    #[Template/dir/None] copy the Template, just create dir  or do nothing
     107    output = 'Template'
     108    # Decide which type of merging if used [madevent/madweight]
     109    grouped_mode = False
     110    # if no grouping on can decide to merge uu~ and u~u anyway:
     111    sa_symmetry = True
    90112
    91113    def __init__(self, *args, **opts):
     
    93115        return super(MY_CPP_Standalone, self).__init__(*args, **opts)
    94116
    95     def setup_cpp_standalone_dir(self, model):
     117    def copy_template(self, model):
    96118
    97119        misc.sprint("initialise the directory")
    98         return super(MY_CPP_Standalone, self).setup_cpp_standalone_dir(model)
     120        return super(MY_CPP_Standalone, self).copy_template(model)
    99121
    100122
    101123    def generate_subprocess_directory(self, subproc_group,
    102124                                         fortran_model, me=None):
    103 
     125       
    104126        misc.sprint('create the directory')
    105127        return super(MY_CPP_Standalone, self).generate_subprocess_directory(subproc_group, fortran_model, me)
     
    118140        return super(MY_CPP_Standalone, self).finalize(matrix_element, cmdhistory, MG5options, outputflag)
    119141
    120 NEW_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     }
     142    def modify_grouping(self, matrix_element):
     143        """allow to modify the grouping (if grouping is in place)
     144            return two value:
     145            - True/False if the matrix_element was modified
     146            - the new(or old) matrix element"""
     147        #irrelevant here since group_mode=False so this function is never called
     148        return False, matrix_element
    136149
    137 NEW_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     }
    153150}}}
    154151
    155152
    156 === List of function that need to be defined in the exporter For Fortran output:
     153=== List of function that need to be defined in the exporter For Fortran/CPP output:
    157154   
    158155   Note: All of them are defined in ProcessExporterFortran. So you need to define them only if you start a class from scratch.
    159156         This list correspond to the call to the exporter performed outside the class itself.
    160157
    161    1. __init__(self, mgme_dir = "", dir_path = "", opt=None)
    162    2. copy_v4template(self, modelname)
     158   1. __init__(self, dir_path = "", opt=None)
     159   2. copy_template(self, modelname)
    163160   3. generate_subprocess_directory(self, subproc_group, helicity_model, me=None) [for grouped]
    164161   4. generate_subprocess_directory(self, matrix_element, helicity_model, me_number) [for ungrouped]
     
    169166   8. export_helas(self, HELAS_PATH) [only if you want to support old model format]
    170167
    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        returns an integer (used only to print info to screen as the number of call to helicity routine)
    180    4. generate_subprocess_directory(self, matrix_element, helicity_model, me_number) [for ungrouped]
    181        returns an integer (used only to print info to screen as the number of call to helicity routine)
    182    4. convert_model(model, wanted_lorentz=[], wanted_coupling=[])
    183    5. finalize(self,matrix_element, cmdhistory, MG5options, outputflag)     
    184    6. modify_grouping(self, matrix_element)
    185    7. compile_model(self)
    186168
    187169=== List of class variable that need to be defined in the exporter:
     
    190172         This list correspond to the attribute of the exporter called outside the  exporter class.
    191173
    192    1. grouped_mode # says which type of exporter to use.
     174    1. '''grouped_mode'''  This variable changes the type of object called within 'generate_subprocess_directory' functions.
     175       a. '''False''' to avoid grouping (only identical matrix element are merged)
     176       b. ''' 'madevent' ''' group the massless quark and massless lepton
     177       c. ''' 'madweight' ''' group the gluon with the massless quark
     178    2. '''sa_symmetry''' If no grouped_mode=False, uu~ and u~u will be called independently. Putting sa_symmetry generates only one of the two matrix-element. (might not work for cpp output.
     179    3. '''check''' Ask madgraph to check if the directory already exists and propose to the user to remove it first if this is the case
     180    4. '''output'''  [Template, None, dir]
     181       a. ''''Template'''', madgraph will call copy_template
     182       b. ''''dir'''', madgraph will just create an empty directory for initialisation
     183       c. '''None''', madgraph do nothing for initialisation
     184    5. '''exporter'''  ['v4'/'cpp'] language of the output 'v4' for Fortran output, 'cpp' for C++ output
     185
    193186
    194187
    195188=== Base class which can be use to create a new exporter from scratch:
    196189
    197 {{{
    198 class MyV4EmptyOutput(object):
     190at the beginning of madgraph/various/iolibs/export_v4.py.
     191A virtual class "VirtualExporter" is defined all exporter class should derive from that class.
     192That virtual class list all the functions called by the interface that you can define (that class in itself does nothing)
    199193
    200     grouped_mode=True
    201 
    202     def __init__(self, mgme_dir = "", dir_path = "", opt=None):
    203         return
    204 
    205     def copy_v4template(self, modelname):
    206         return
    207 
    208     def generate_subprocess_directory(self, subproc_group, helicity_model, me=None):
    209     #    generate_subprocess_directory(self, matrix_element, helicity_model, me_number) [for ungrouped]
    210         return 0 # return an integer stating the number of call to helicity routine
    211     def convert_model(self, model, wanted_lorentz=[], wanted_coupling=[]):
    212         return
    213     def finalize(self,matrix_element, cmdhistory, MG5options, outputflag):
    214         return
    215     def modify_grouping(self, matrix_element):
    216         return False, matrix_element
    217     def export_model_files(self, model_v4_path):
    218         return
    219     def export_helas(self, HELAS_PATH):
    220         return
    221 
    222 
    223 class MyCPPEmptyOutput(object):
    224 
    225     grouped_mode=True
    226 
    227     def __init__(self, mgme_dir = "", dir_path = "", opt=None):
    228         return
    229 
    230     def setup_cpp_standalone_dir(self, model):
    231         return
    232 
    233     def generate_subprocess_directory(self, subproc_group, helicity_model, me=None):
    234     #    generate_subprocess_directory(self, matrix_element, helicity_model, me_number) [for ungrouped]
    235         return 0 # return an integer stating the number of call to helicity routine
    236     def convert_model(self, model, wanted_lorentz=[], wanted_coupling=[]):
    237         return
    238 
    239     def finalize(self,matrix_element, cmdhistory, MG5options, outputflag):
    240         return
    241 
    242     def modify_grouping(self, matrix_element):
    243         return False, matrix_element
    244 
    245     def compile_model(self):
    246         #compile the model to create a library
    247         return
    248 
    249 }}}
    250 
    251