def get_used_couplings(self): """Return the list of ALOHA routines used in these matrix elements""" return helas_objects.HelasMultiProcess({ 'matrix_elements': self.get_matrix_elements() }).get_used_couplings()
def setup(self): """ Special tasks when switching to this interface """ # Refresh all the interface stored value as things like generated # processes and amplitudes are not to be reused in between different # interfaces # Clear history, amplitudes and matrix elements when a model is imported # Remove previous imports, generations and outputs from history self.history.clean(remove_bef_last='import', to_keep=['set','load','import', 'define']) # Reset amplitudes and matrix elements self._done_export=False self._curr_amps = diagram_generation.AmplitudeList() self._curr_matrix_elements = helas_objects.HelasMultiProcess() self._v4_export_formats = [] self._nlo_modes_for_completion = ['all','real'] self._export_formats = [ 'madevent', 'aloha' ] # Do not force NLO model as the user might have asked for reals only. # It will anyway be forced later if he attempts virt= or all=. self.validate_model(loop_type='real_init', stop=False) # Set where to look for CutTools installation. # In further versions, it will be set in the same manner as _mgme_dir so that # the user can chose its own CutTools distribution. self._cuttools_dir=str(pjoin(self._mgme_dir,'vendor','CutTools')) if not os.path.isdir(pjoin(self._cuttools_dir, 'src','cts')): logger.warning(('Warning: Directory %s is not a valid CutTools directory.'+\ 'Using default CutTools instead.') % \ self._cuttools_dir) self._cuttools_dir=str(pjoin(self._mgme_dir,'vendor','CutTools'))
def do_add(self, line, *args,**opt): """Generate an amplitude for a given process and add to existing amplitudes """ args = self.split_arg(line) # Check the validity of the arguments self.check_add(args) self.validate_model() if args[0] == 'process': # Rejoin line line = ' '.join(args[1:]) # store the first process (for the perl script) if not self._generate_info: self._generate_info = line # Reset Helas matrix elements self._curr_matrix_elements = helas_objects.HelasMultiProcess() # Extract process from process definition self.validate_model('virtual') if ',' in line: myprocdef, line = self.extract_decay_chain_process(line) else: myprocdef = self.extract_process(line) self.proc_validity(myprocdef,'ML5') cpu_time1 = time.time() # Decide here wether one needs a LoopMultiProcess or a MultiProcess multiprocessclass=None if myprocdef['perturbation_couplings']!=[]: multiprocessclass=loop_diagram_generation.LoopMultiProcess else: multiprocessclass=diagram_generation.MultiProcess myproc = multiprocessclass(myprocdef, collect_mirror_procs = False, ignore_six_quark_processes = False) for amp in myproc.get('amplitudes'): if amp not in self._curr_amps: self._curr_amps.append(amp) else: warning = "Warning: Already in processes:\n%s" % \ amp.nice_string_processes() logger.warning(warning) # Reset _done_export, since we have new process self._done_export = False cpu_time2 = time.time() ndiags = sum([len(amp.get('loop_diagrams')) for \ amp in myproc.get('amplitudes')]) logger.info("Process generated in %0.3f s" % \ (cpu_time2 - cpu_time1))
def setUp(self): # Set up model mypartlist = base_objects.ParticleList() myinterlist = base_objects.InteractionList() # u and c quarkd and their antiparticles mypartlist.append( base_objects.Particle({ 'name': 'u', 'antiname': 'u~', 'spin': 2, 'color': 3, 'mass': 'ZERO', 'width': 'ZERO', 'texname': 'u', 'antitexname': '\bar u', 'line': 'straight', 'charge': 2. / 3., 'pdg_code': 2, 'propagating': True, 'is_part': True, 'self_antipart': False })) u = mypartlist[len(mypartlist) - 1] antiu = copy.copy(u) antiu.set('is_part', False) mypartlist.append( base_objects.Particle({ 'name': 'c', 'antiname': 'c~', 'spin': 2, 'color': 3, 'mass': 'MC', 'width': 'ZERO', 'texname': 'c', 'antitexname': '\bar c', 'line': 'straight', 'charge': 2. / 3., 'pdg_code': 4, 'propagating': True, 'is_part': True, 'self_antipart': False })) c = mypartlist[len(mypartlist) - 1] antic = copy.copy(c) antic.set('is_part', False) # A gluon mypartlist.append( base_objects.Particle({ 'name': 'g', 'antiname': 'g', 'spin': 3, 'color': 8, 'mass': 'ZERO', 'width': 'ZERO', 'texname': 'g', 'antitexname': 'g', 'line': 'curly', 'charge': 0., 'pdg_code': 21, 'propagating': True, 'is_part': True, 'self_antipart': True })) g = mypartlist[len(mypartlist) - 1] # A photon mypartlist.append( base_objects.Particle({ 'name': 'Z', 'antiname': 'Z', 'spin': 3, 'color': 1, 'mass': 'MZ', 'width': 'WZ', 'texname': 'Z', 'antitexname': 'Z', 'line': 'wavy', 'charge': 0., 'pdg_code': 23, 'propagating': True, 'is_part': True, 'self_antipart': True })) z = mypartlist[len(mypartlist) - 1] # Gluon couplings to quarks myinterlist.append(base_objects.Interaction({ 'id': 1, 'particles': base_objects.ParticleList(\ [antiu, \ u, \ g]), 'color': [color.ColorString([color.T(2, 1, 0)])], 'lorentz':['FFV1'], 'couplings':{(0, 0):'GC_10'}, 'orders':{'QCD':1}})) # Gamma couplings to quarks myinterlist.append(base_objects.Interaction({ 'id': 2, 'particles': base_objects.ParticleList(\ [antiu, \ u, \ z]), 'color': [color.ColorString([color.T(1, 0)])], 'lorentz':['FFV2', 'FFV5'], 'couplings':{(0,0): 'GC_35', (0,1): 'GC_47'}, 'orders':{'QED':1}})) self.mymodel.set('particles', mypartlist) self.mymodel.set('interactions', myinterlist) self.mymodel.set('name', 'sm') self.mypythonmodel = helas_call_writers.PythonUFOHelasCallWriter( self.mymodel) myleglist = base_objects.LegList() myleglist.append(base_objects.Leg({'id': 2, 'state': False})) myleglist.append(base_objects.Leg({'id': -2, 'state': False})) myleglist.append(base_objects.Leg({'id': 2, 'state': True})) myleglist.append(base_objects.Leg({'id': -2, 'state': True})) myproc = base_objects.Process({ 'legs': myleglist, 'model': self.mymodel }) myamplitude = diagram_generation.Amplitude({'process': myproc}) self.mymatrixelement = helas_objects.HelasMultiProcess(myamplitude) myleglist = base_objects.LegList() myleglist.append( base_objects.Leg({ 'id': 4, 'state': False, 'number': 1 })) myleglist.append( base_objects.Leg({ 'id': -4, 'state': False, 'number': 2 })) myleglist.append( base_objects.Leg({ 'id': 4, 'state': True, 'number': 3 })) myleglist.append( base_objects.Leg({ 'id': -4, 'state': True, 'number': 4 })) myproc = base_objects.Process({ 'legs': myleglist, 'model': self.mymodel }) self.mymatrixelement.get('matrix_elements')[0].\ get('processes').append(myproc) self.exporter = export_python.ProcessExporterPython(\ self.mymatrixelement, self.mypythonmodel)
def do_add(self, line, *args, **opt): """Generate an amplitude for a given process and add to existing amplitudes """ args = self.split_arg(line) # Check the validity of the arguments self.check_add(args) perturbation_couplings_pattern = \ re.compile("^(?P<proc>.+)\s*\[\s*((?P<option>\w+)\s*\=)?\s*(?P<pertOrders>(\w+\s*)*)\s*\]\s*(?P<rest>.*)$") perturbation_couplings_re = perturbation_couplings_pattern.match(line) perturbation_couplings = "" if perturbation_couplings_re: perturbation_couplings = perturbation_couplings_re.group( "pertOrders") QED_found = re.search('QED', perturbation_couplings) if QED_found: self.validate_model(coupling_type='QED') else: self.validate_model() loop_filter = None if args[0] == 'process': # Extract potential loop_filter for arg in args: if arg.startswith('--loop_filter='): loop_filter = arg[14:] if not isinstance(self, extended_cmd.CmdShell): raise InvalidCmd, "loop_filter is not allowed in web mode" args = [a for a in args if not a.startswith('--loop_filter=')] # Rejoin line line = ' '.join(args[1:]) # store the first process (for the perl script) if not self._generate_info: self._generate_info = line # Reset Helas matrix elements self._curr_matrix_elements = helas_objects.HelasMultiProcess() # Extract process from process definition myprocdef = self.extract_process(line) # hack for multiprocess: if myprocdef.has_multiparticle_label(): # split it in a loop succes, failed = 0, 0 for base_proc in myprocdef: try: self.exec_cmd("add process %s" % base_proc.nice_string( prefix=False, print_weighted=True)) succes += 1 except Exception: failed += 1 logger.info("%s/%s processes succeeded" % (succes, failed + succes)) if succes == 0: raise else: return # If it is a process for MadLoop standalone, make sure it has a # unique ID. It is important for building a BLHA library which # contains unique entry point for each process generated. all_ids = [amp.get('process').get('id') for amp in self._curr_amps] if myprocdef.get('id') in all_ids: myprocdef.set('id', max(all_ids) + 1) self.proc_validity(myprocdef, 'ML5') cpu_time1 = time.time() # Decide here wether one needs a LoopMultiProcess or a MultiProcess multiprocessclass = None if myprocdef['perturbation_couplings'] != []: multiprocessclass = loop_diagram_generation.LoopMultiProcess else: multiprocessclass = diagram_generation.MultiProcess myproc = multiprocessclass(myprocdef, collect_mirror_procs=False, ignore_six_quark_processes=False, loop_filter=loop_filter) for amp in myproc.get('amplitudes'): if amp not in self._curr_amps: self._curr_amps.append(amp) else: warning = "Warning: Already in processes:\n%s" % \ amp.nice_string_processes() logger.warning(warning) # Reset _done_export, since we have new process self._done_export = False cpu_time2 = time.time() ndiags = sum([len(amp.get('loop_diagrams')) for \ amp in myproc.get('amplitudes')]) logger.info("Process generated in %0.3f s" % \ (cpu_time2 - cpu_time1))
def do_add(self, line, *args, **opt): """Generate an amplitude for a given process and add to existing amplitudes """ args = self.split_arg(line) # Check the validity of the arguments self.check_add(args) perturbation_couplings_pattern = \ re.compile("^(?P<proc>.+)\s*\[\s*((?P<option>\w+)\s*\=)?\s*(?P<pertOrders>(\w+\s*)*)\s*\]\s*(?P<rest>.*)$") perturbation_couplings_re = perturbation_couplings_pattern.match(line) perturbation_couplings = "" if perturbation_couplings_re: perturbation_couplings = perturbation_couplings_re.group( "pertOrders") QED_found = re.search('QED', perturbation_couplings) if QED_found: self.validate_model(coupling_type='QED') else: self.validate_model() if args[0] == 'process': # Rejoin line line = ' '.join(args[1:]) # store the first process (for the perl script) if not self._generate_info: self._generate_info = line # Reset Helas matrix elements self._curr_matrix_elements = helas_objects.HelasMultiProcess() # Extract process from process definition myprocdef = self.extract_process(line) # If it is a process for MadLoop standalone, make sure it has a # unique ID. It is important for building a BLHA library which # contains unique entry point for each process generated. all_ids = [amp.get('process').get('id') for amp in self._curr_amps] if myprocdef.get('id') in all_ids: myprocdef.set('id', max(all_ids) + 1) self.proc_validity(myprocdef, 'ML5') cpu_time1 = time.time() # Decide here wether one needs a LoopMultiProcess or a MultiProcess multiprocessclass = None if myprocdef['perturbation_couplings'] != []: multiprocessclass = loop_diagram_generation.LoopMultiProcess else: multiprocessclass = diagram_generation.MultiProcess myproc = multiprocessclass(myprocdef, collect_mirror_procs=False, ignore_six_quark_processes=False) for amp in myproc.get('amplitudes'): if amp not in self._curr_amps: self._curr_amps.append(amp) else: warning = "Warning: Already in processes:\n%s" % \ amp.nice_string_processes() logger.warning(warning) # Reset _done_export, since we have new process self._done_export = False cpu_time2 = time.time() ndiags = sum([len(amp.get('loop_diagrams')) for \ amp in myproc.get('amplitudes')]) logger.info("Process generated in %0.3f s" % \ (cpu_time2 - cpu_time1))