2088
2090
'gauge','lorentz', 'brs']
2089
2091
_import_formats = ['model_v4', 'model', 'proc_v4', 'command', 'banner']
2090
2092
_install_opts = ['pythia-pgs', 'Delphes', 'MadAnalysis', 'ExRootAnalysis', 'MCatNLO-utilities','update']
2091
_v4_export_formats = ['madevent', 'standalone', 'matrix']
2093
_v4_export_formats = ['madevent', 'standalone', 'standalone_ms', 'matrix']
2092
2094
_export_formats = _v4_export_formats + ['standalone_cpp', 'pythia8', 'aloha']
2093
2095
_set_options = ['group_subprocesses',
2094
2096
'ignore_six_quark_processes',
2200
2202
# Clear history, amplitudes and matrix elements when a model is imported
2201
2203
# Remove previous imports, generations and outputs from history
2202
self.clean_history(remove_bef_last='import')
2204
self.history.clean(remove_bef_last='import')
2203
2205
# Reset amplitudes and matrix elements
2204
2206
self._done_export=False
2205
2207
self._curr_amps = diagram_generation.AmplitudeList()
2206
2208
self._curr_matrix_elements = helas_objects.HelasMultiProcess()
2208
self._v4_export_formats = ['madevent', 'standalone', 'matrix']
2210
self._v4_export_formats = ['madevent', 'standalone','standalone_ms', 'matrix']
2209
2211
self._export_formats = self._v4_export_formats + ['standalone_cpp', 'pythia8']
2210
2212
self._nlo_modes_for_completion = ['all','virt','real']
3196
3193
'has_born':HasBorn,
3197
3194
'NLO_mode':LoopOption
3199
# 'is_decay_chain': decay_process\
3196
# 'is_decay_chain': decay_process\
3199
def split_process_line(procline):
3200
"""Takes a valid process and return
3201
a tuple (core_process, options). This removes
3202
- any NLO specifications.
3207
# remove the tag "[*]": this tag is used in aMC@LNO ,
3208
# but it is not a valid syntax for LO
3214
line=line[:pos1]+line[pos2+1:]
3216
# Extract the options:
3218
# A. Remove process number (identified by "@")
3219
proc_number_pattern = re.compile("^(.+)@\s*(\d+)\s*(.*)$")
3220
proc_number_re = proc_number_pattern.match(line)
3222
line = proc_number_re.group(1) + proc_number_re.group(3)
3224
# B. search for the beginning of the option string
3227
order_pattern = re.compile("^(.+)\s+(\w+)\s*=\s*(\d+)\s*$")
3228
order_re = order_pattern.match(line)
3230
pos_order=line.find(order_re.group(2))
3231
if pos_order>0 and pos_order < pos : pos=pos_order
3233
# then look for slash or dollar
3234
slash = line.find("/")
3235
if slash > 0 and slash < pos: pos=slash
3236
dollar = line.find("$")
3237
if dollar > 0 and dollar < pos: pos=dollar
3240
proc_option=line[pos:]
3245
return line, proc_option
3247
def get_final_part(self, procline):
3248
"""Takes a valid process and return
3249
a set of id of final states particles. [Used by MadSpin]
3252
if self._use_lower_part_names:
3253
procline = procline.lower()
3254
pids = self._curr_model.get('name2pdg')
3257
# 1) look for decay.
3258
# in presence of decay call this routine recursively and veto
3259
# the particles which are decayed
3261
# Deal with decay chain
3263
core, decay = procline.split(',', 1)
3264
core_final = self.get_final_part(core)
3267
all_decays = decay.split(',')
3268
nb_level, tmp_decay = 0, ''
3271
for one_decay in all_decays:
3272
if '(' in one_decay:
3274
if ')' in one_decay:
3279
tmp_decay += ', %s' % one_decay
3281
tmp_decay = one_decay
3283
final = '%s,%s' % (tmp_decay, one_decay)
3284
final = final.strip()
3285
assert final[0] == '(' and final[-1] == ')'
3287
decays.append(final)
3290
decays.append(one_decay)
3291
# remove from the final states all particles which are decayed
3292
for one_decay in decays:
3293
first = one_decay.split('>',1)[0].strip()
3295
pid = set([pids[first]])
3296
elif first in self._multiparticles:
3297
pid = set(self._multiparticles[first])
3299
raise Exception, 'invalid particle name: %s. ' % first
3300
core_final.difference_update(pid)
3301
core_final.update(self.get_final_part(one_decay))
3307
final_states = re.search(r'> ([^\/\$\=\@>]*)(\s\S+\=|\$|\/|\@|$)', procline)
3308
particles = final_states.groups()[0]
3309
for particle in particles.split():
3310
if particle in pids:
3311
final.add(pids[particle])
3312
elif particle in self._multiparticles:
3313
final.update(set(self._multiparticles[particle]))
3201
3325
def extract_particle_ids(self, args):
3202
3326
"""Extract particle ids from a list of particle names. If
3349
3473
def do_import(self, line, force=False):
3350
3474
"""Main commands: Import files with external formats"""
3351
3476
args = self.split_arg(line)
3352
3477
# Check argument's validity
3353
3478
self.check_import(args)
3355
3479
if args[0].startswith('model'):
3356
3480
self._model_v4_path = None
3357
# Clear history, amplitudes and matrix elements when a model is imported
3358
# Remove previous imports, generations and outputs from history
3359
self.clean_history(remove_bef_last='import', keep_switch=True,
3360
allow_for_removal=['generate', 'add process', 'output'])
3361
3481
# Reset amplitudes and matrix elements
3362
3482
self._curr_amps = diagram_generation.AmplitudeList()
3363
3483
self._curr_matrix_elements = helas_objects.HelasMultiProcess()
4619
4739
shutil.rmtree(self._export_dir)
4621
4741
# Make a Template Copy
4622
if self._export_format in ['madevent', 'standalone', 'matrix']:
4742
if self._export_format in ['madevent', 'standalone','standalone_ms', 'matrix']:
4623
4743
self._curr_exporter = export_v4.ExportV4Factory(self, noclean)
4624
4744
elif self._export_format == 'standalone_cpp':
4625
4745
export_cpp.setup_cpp_standalone_dir(self._export_dir, self._curr_model)
4626
4746
elif not os.path.isdir(self._export_dir):
4627
4747
os.makedirs(self._export_dir)
4629
if self._export_format in ['madevent', 'standalone']:
4749
if self._export_format in ['madevent', 'standalone', 'standalone_ms']:
4630
4750
self._curr_exporter.copy_v4template(modelname=self._curr_model.get('name'))
4632
4752
# Reset _done_export, since we have new directory
4855
4975
"""Make the html output, write proc_card_mg5.dat and create
4856
4976
madevent.tar.gz for a MadEvent directory"""
4858
if self._export_format in ['madevent', 'standalone', 'NLO']:
4978
if self._export_format in ['madevent', 'standalone', 'standalone_ms', 'NLO']:
4859
4979
# For v4 models, copy the model/HELAS information.
4860
4980
if self._model_v4_path:
4861
4981
logger.info('Copy %s model files to directory %s' % \
4964
5084
self.do_save('options %s' % filename.replace(' ', '\ '), check=False,
4965
5085
to_keep={'mg5_path':MG5DIR})
4967
if self._export_format in ['madevent', 'standalone']:
5087
if self._export_format in ['madevent', 'standalone', 'standalone_ms']:
4969
5089
self._curr_exporter.finalize_v4_directory( \
4970
5090
self._curr_matrix_elements,