Changes between Version 8 and Version 9 of Plugin


Ignore:
Timestamp:
Jun 20, 2016, 3:21:57 PM (8 years ago)
Author:
Olivier Mattelaer
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Plugin

    v8 v9  
    1 === Structure
     1= Structure
    22
    33The idea of the plugin idea is to allow some modification of the code behavior without the need to modify the internal code.
     
    1313
    1414
    15 === !__init!__.py file:
     15== !__init!__.py file:
    1616
    1717The minimal information that need to be present in that file is:
     
    5454}}}
    5555
    56 
    57 
     56== create new output mode
     57
     58=== Base class which can be use to create a new exporter from scratch:
     59
     60At the beginning of madgraph/various/iolibs/export_v4.py.
     61A virtual class "VirtualExporter" is defined all exporter class should derive from that class.
     62That virtual class list all the functions called by the interface that you can define (that class in itself does nothing)
     63and list all the common attribute that need to be defined with the explanation of their impact.
     64
     65In Most of the case, it is more convenient to subclass one of the class creating a real output like ProcessExporterFortran.
     66
     67
     68=== List of function that need to be defined in the exporter For Fortran/CPP output:
     69   
     70   This list correspond to the call to the exporter performed outside the class itself. Please check the VirtualExporter class (begin of madgraph/various/iolibs/export_v4.py) to check that the following list is up-to-date with your version of MG5aMC.
     71
     72   1. __init__(self, dir_path = "", opt=None)
     73   2. copy_template(self, modelname)
     74   3. generate_subprocess_directory(self, subproc_group, helicity_model, me=None) [for grouped]
     75   4. generate_subprocess_directory(self, matrix_element, helicity_model, me_number) [for ungrouped]
     76   4. convert_model(model, wanted_lorentz=[], wanted_coupling=[])
     77   5. finalize(self,matrix_element, cmdhistory, MG5options, outputflag)     
     78   6. modify_grouping(self, matrix_element)
     79   7. export_model_files(self, model_v4_path) [only if you want to support old model format]
     80   8. export_helas(self, HELAS_PATH) [only if you want to support old model format]
     81
     82
     83=== List of class variable that need to be defined in the exporter:
     84
     85    This list correspond to the attribute of the exporter called outside the  exporter class. Please check the VirtualExporter class (begin of madgraph/various/iolibs/export_v4.py) to check that the following list is up-to-date with your version of MG5aMC.
     86
     87    1. '''grouped_mode'''  This variable changes the type of object called within 'generate_subprocess_directory' functions.
     88       a. '''False''' to avoid grouping (only identical matrix element are merged)
     89       b. ''' 'madevent' ''' group the massless quark and massless lepton
     90       c. ''' 'madweight' ''' group the gluon with the massless quark
     91    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.
     92    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
     93    4. '''output'''  [Template, None, dir]
     94       a. ''''Template'''', madgraph will call copy_template
     95       b. ''''dir'''', madgraph will just create an empty directory for initialisation
     96       c. '''None''', madgraph do nothing for initialisation
     97    5. '''exporter'''  ['v4'/'cpp'] language of the output 'v4' for Fortran output, 'cpp' for C++ output
     98
     99
     100
     101= Example
    58102
    59103
     
    266310
    267311
    268 === List of function that need to be defined in the exporter For Fortran/CPP output:
    269    
    270    Note: All of them are defined in ProcessExporterFortran. So you need to define them only if you start a class from scratch.
    271          This list correspond to the call to the exporter performed outside the class itself.
    272 
    273    1. __init__(self, dir_path = "", opt=None)
    274    2. copy_template(self, modelname)
    275    3. generate_subprocess_directory(self, subproc_group, helicity_model, me=None) [for grouped]
    276    4. generate_subprocess_directory(self, matrix_element, helicity_model, me_number) [for ungrouped]
    277    4. convert_model(model, wanted_lorentz=[], wanted_coupling=[])
    278    5. finalize(self,matrix_element, cmdhistory, MG5options, outputflag)     
    279    6. modify_grouping(self, matrix_element)
    280    7. export_model_files(self, model_v4_path) [only if you want to support old model format]
    281    8. export_helas(self, HELAS_PATH) [only if you want to support old model format]
    282 
    283 
    284 === List of class variable that need to be defined in the exporter:
    285 
    286    Note: All of them are defined in ProcessExporterFortran/ProcessExporterCPP. So you need to define them only if you start a class from scratch.
    287          This list correspond to the attribute of the exporter called outside the  exporter class.
    288 
    289     1. '''grouped_mode'''  This variable changes the type of object called within 'generate_subprocess_directory' functions.
    290        a. '''False''' to avoid grouping (only identical matrix element are merged)
    291        b. ''' 'madevent' ''' group the massless quark and massless lepton
    292        c. ''' 'madweight' ''' group the gluon with the massless quark
    293     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.
    294     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
    295     4. '''output'''  [Template, None, dir]
    296        a. ''''Template'''', madgraph will call copy_template
    297        b. ''''dir'''', madgraph will just create an empty directory for initialisation
    298        c. '''None''', madgraph do nothing for initialisation
    299     5. '''exporter'''  ['v4'/'cpp'] language of the output 'v4' for Fortran output, 'cpp' for C++ output
    300 
    301 
    302 
    303 === Base class which can be use to create a new exporter from scratch:
    304 
    305 at the beginning of madgraph/various/iolibs/export_v4.py.
    306 A virtual class "VirtualExporter" is defined all exporter class should derive from that class.
    307 That virtual class list all the functions called by the interface that you can define (that class in itself does nothing)
    308 
     312=== Example 3: New Cluster
     313
     314A condor cluster not submitting more than a given number of job simultaneously:
     315
     316
     317!__init!__.py
     318{{{
     319## import the required files
     320# example: import maddm_interface as maddm_interface # local file
     321#          import madgraph.various.cluster as cluster #MG5 distribution file
     322
     323import magraph.various.cluster as cluster
     324import time
     325
     326#local file
     327
     328class MYcluster(cluster.MultiCore):
     329
     330    maximum_submited_jobs = 100
     331    restart_submission = 50
     332
     333    def submit(self,  prog, argument=[], cwd=None, stdout=None, stderr=None, log=None,
     334               required_output=[], nb_submit=0):
     335        """pause the submission of jobs if more than """
     336
     337        me_dir = self.get_jobs_identifier(cwd, prog)
     338        if len(self.submitted_ids) > self.maximum_submited_jobs:
     339            fct = lambda idle, run, finish: logger.info('Waiting for free slot: %s %s %s' % (idle, run, finish))
     340            self.wait(me_dir, fct, self.restart_submission)
     341
     342
     343        # call the normal submission scheme
     344        super(MYcluster, self).submit( prog, argument, cwd, stdout, stderr, log, required_output, nb_submit)
     345
     346
     347# Three types of functionality are allowed in a plugin
     348#   1. new output mode
     349#   2. new cluster support
     350#   3. new interface
     351
     352# 1. Define new output mode
     353#    example: new_output = {'myformat': MYCLASS}
     354#    madgraph will then allow the command "output myformat PATH"
     355#    MYCLASS should inherated of the class madgraph.iolibs.export_v4.VirtualExporter
     356new_output = {}
     357
     358# 2. Define new way to handle the cluster.
     359#    example new_cluster = {'mycluster': MYCLUSTERCLASS}
     360#    allow "set cluster_type mycluster" in madgraph
     361#    MYCLUSTERCLASS should inherated from madgraph.various.cluster.Cluster
     362new_cluster = {'new_condor': MYcluster}
     363
     364
     365# 3. Define a new interface (allow to add/modify MG5 command)
     366#    This can be activated via ./bin/mg5_aMC --mode=PLUGINNAME
     367## Put None if no dedicated command are required
     368new_interface = None
     369 
     370 
     371########################## CONTROL VARIABLE ####################################
     372__author__ = 'Mattelaer Olivier'
     373__email__ = 'o.p.c.mattelaer@durham.ac.uk'
     374__version__ = (1,0,0)
     375minimal_mg5amcnlo_version = (2,5,0)
     376maximal_mg5amcnlo_version = (1000,1000,1000)
     377latest_validated_version = (2,5,0)
     378}}}
     379
     380