Changes between Version 3 and Version 4 of Plugin
- Timestamp:
- May 7, 2016, 12:41:06 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Plugin
v3 v4 40 40 ## import the required files 41 41 42 import output as output 42 import output as output 43 43 44 44 ## Define a typical error for the plugin … … 48 48 ## Put None if no dedicated command are required 49 49 new_interface = False 50 50 51 51 ## 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}52 new_output = {'madweight2': output.My_MW_Exporter, 53 'standalone_lib': output.MY_CPP_Standalone} 54 54 55 55 ## The test/code have been validated up to this version 56 latest_validated_version = '2.3.4' 56 latest_validated_version = '2.5.0' 57 minimal_version_required = '2.5.0' 58 maximal_version_required = None 57 59 }}} 58 60 … … 60 62 output.py file 61 63 {{{ 62 import madgraph.iolibs.export_cpp as export_cpp63 import madgraph.iolibs.export_v4 as export_v464 import madgraph.various.misc as misc65 # Note loop type output are not supported.66 67 64 class My_MW_Exporter(export_v4.ProcessExporterFortranMWGroup): 68 65 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 69 78 nb_done = 0 70 79 71 80 def __init__(self, *args, **opts): 72 81 misc.sprint("Initialise the exporter") 73 82 return super(My_MW_Exporter, self).__init__(*args, **opts) 74 83 75 def copy_ v4template(self, *args, **opts):84 def copy_template(self, *args, **opts): 76 85 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) 78 87 79 88 def generate_subprocess_directory(self, subproc_group, 80 89 fortran_model, me=None): 81 90 82 91 misc.sprint(me) 83 92 if me is None: … … 86 95 else: 87 96 current_generated = me 97 return super(My_MW_Exporter, self).generate_subprocess_directory(subproc_group, fortran_model, current_generated) 88 98 89 99 class 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 90 112 91 113 def __init__(self, *args, **opts): … … 93 115 return super(MY_CPP_Standalone, self).__init__(*args, **opts) 94 116 95 def setup_cpp_standalone_dir(self, model):117 def copy_template(self, model): 96 118 97 119 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) 99 121 100 122 101 123 def generate_subprocess_directory(self, subproc_group, 102 124 fortran_model, me=None): 103 125 104 126 misc.sprint('create the directory') 105 127 return super(MY_CPP_Standalone, self).generate_subprocess_directory(subproc_group, fortran_model, me) … … 118 140 return super(MY_CPP_Standalone, self).finalize(matrix_element, cmdhistory, MG5options, outputflag) 119 141 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 136 149 137 NEW_MW_OUTPUT = {138 # check status of the directory. Remove it if already exists139 'check': True,140 # Language type: 'v4' for f77/ 'cpp' for C++ output141 'exporter': 'v4',142 # Output type:143 #[Template/dir/None] copy the Template, just create dir or do nothing144 '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_Exporter152 }153 150 }}} 154 151 155 152 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: 157 154 158 155 Note: All of them are defined in ProcessExporterFortran. So you need to define them only if you start a class from scratch. 159 156 This list correspond to the call to the exporter performed outside the class itself. 160 157 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) 163 160 3. generate_subprocess_directory(self, subproc_group, helicity_model, me=None) [for grouped] 164 161 4. generate_subprocess_directory(self, matrix_element, helicity_model, me_number) [for ungrouped] … … 169 166 8. export_helas(self, HELAS_PATH) [only if you want to support old model format] 170 167 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)186 168 187 169 === List of class variable that need to be defined in the exporter: … … 190 172 This list correspond to the attribute of the exporter called outside the exporter class. 191 173 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 193 186 194 187 195 188 === Base class which can be use to create a new exporter from scratch: 196 189 197 {{{ 198 class MyV4EmptyOutput(object): 190 at the beginning of madgraph/various/iolibs/export_v4.py. 191 A virtual class "VirtualExporter" is defined all exporter class should derive from that class. 192 That virtual class list all the functions called by the interface that you can define (that class in itself does nothing) 199 193 200 grouped_mode=True201 202 def __init__(self, mgme_dir = "", dir_path = "", opt=None):203 return204 205 def copy_v4template(self, modelname):206 return207 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 routine211 def convert_model(self, model, wanted_lorentz=[], wanted_coupling=[]):212 return213 def finalize(self,matrix_element, cmdhistory, MG5options, outputflag):214 return215 def modify_grouping(self, matrix_element):216 return False, matrix_element217 def export_model_files(self, model_v4_path):218 return219 def export_helas(self, HELAS_PATH):220 return221 222 223 class MyCPPEmptyOutput(object):224 225 grouped_mode=True226 227 def __init__(self, mgme_dir = "", dir_path = "", opt=None):228 return229 230 def setup_cpp_standalone_dir(self, model):231 return232 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 routine236 def convert_model(self, model, wanted_lorentz=[], wanted_coupling=[]):237 return238 239 def finalize(self,matrix_element, cmdhistory, MG5options, outputflag):240 return241 242 def modify_grouping(self, matrix_element):243 return False, matrix_element244 245 def compile_model(self):246 #compile the model to create a library247 return248 249 }}}250 251