Skip to content

Commit

Permalink
ensure that cpp data structure for is_LC is the same in fortran and …
Browse files Browse the repository at this point in the history
…cpp (madgraph4gpu 880) (mg5amcnlo#118)

* remove one useless? call to coloramp

* refactoring part of the writing of color (is_LC)

---------

Co-authored-by: Olivier Mattelaer <olivier.mattelaer@uclouvain.be>
  • Loading branch information
valassi and oliviermattelaer authored Jul 8, 2024
1 parent d73875c commit ff76bb2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
3 changes: 1 addition & 2 deletions madgraph/iolibs/export_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1517,8 +1517,8 @@ def get_sigmaKin_lines(self, color_amplitudes, write=True):
"""
replace_dict['madE_caclwfcts_call'] = '&multi_chanel_num, &multi_chanel_denom'
replace_dict['madE_update_answer'] = ' allMEs[iproc*nprocesses + ievt] *= multi_chanel_num/multi_chanel_denom;'

multi_channel = self.get_multi_channel_dictionary(self.matrix_elements[0].get('diagrams'), self.include_multi_channel)
replace_dict['is_LC'] = self.get_icolamp_lines(multi_channel, self.matrix_elements[0], 1)
replace_dict['nb_channel'] = len(multi_channel)
replace_dict['nb_color'] = max(1, len(self.matrix_elements[0].get('color_basis')))

Expand Down Expand Up @@ -1760,7 +1760,6 @@ def write_process_cc_file(self, writer):
return replace_dict



def get_icolamp_lines(self, mapconfigs, matrix_element, num_matrix_element):
"""Return the ICOLAMP matrix, showing which JAMPs contribute to
which configs (diagrams)."""
Expand Down
39 changes: 30 additions & 9 deletions madgraph/iolibs/export_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -6582,17 +6582,9 @@ def write_coloramps_file(self, writer, diagrams_for_config, maxflows,

# Create a map from subprocess (matrix element) to a list of
# the diagrams corresponding to each config

subproc_to_confdiag = self.get_confdiag_from_group_mapconfig(diagrams_for_config)
lines = []

subproc_to_confdiag = {}
for config in diagrams_for_config:
for subproc, diag in enumerate(config):
try:
subproc_to_confdiag[subproc].append(diag)
except KeyError:
subproc_to_confdiag[subproc] = [diag]

for subproc in sorted(subproc_to_confdiag.keys()):
lines.extend(self.get_icolamp_lines(subproc_to_confdiag[subproc],
matrix_elements[subproc],
Expand Down Expand Up @@ -6695,6 +6687,35 @@ def read_write_good_hel(self, ncomb):
return output


#===========================================================================
# write_configs_file
#===========================================================================
@staticmethod
def get_confdiag_from_group_mapconfig(config_subproc_map, subprocid=None):
""" This is converting the mapconfigs generated from the
subproc_group.get('diagrams_for_configs')
and convert it to a datastructure like expected from the
get_icolamp_lines (which does not handle grouping)
if subproc is None it returns the full output as a dictionary
with subproc_id as key.
if provided it returned the associated list for that subproc id.
Static method since need to be used from cpp case as well.
"""

subproc_to_confdiag = {}
for config in config_subproc_map:
for subproc, diag in enumerate(config):
try:
subproc_to_confdiag[subproc].append(diag)
except KeyError:
subproc_to_confdiag[subproc] = [diag]

if subprocid is None:
return subproc_to_confdiag
else:
return subproc_to_confdiag[subprocid]

#===========================================================================
# write_configs_file
Expand Down

0 comments on commit ff76bb2

Please sign in to comment.