@@ -1834,14 +1834,14 @@ def get_process_info_lines(self, matrix_element):
18341834 def generate_process_files (self ):
18351835 """Generate mgOnGpuConfig.h, CPPProcess.cc, CPPProcess.h, check_sa.cc, gXXX.cu links"""
18361836 ###misc.sprint('Entering OneProcessExporterMadMatrix.generate_process_files')
1837- super ().generate_process_files ()
18381837 self .edit_mgonGPU ()
18391838 self .edit_processidfile () # AV new file (NB this is Sigma-specific, should not be a symlink to Subprocesses)
18401839 self .edit_processConfig () # sub process specific, not to be symlinked from the Subprocesses directory
18411840 self .edit_colorsum () # AV new file (NB this is Sigma-specific, should not be a symlink to Subprocesses)
1842- self .edit_testxxx () # AV new file (NB this is generic in Subprocesses and then linked in Sigma-specific )
1841+ self .edit_coloramps ( )
18431842 self .edit_memorybuffers () # AV new file (NB this is generic in Subprocesses and then linked in Sigma-specific)
18441843 self .edit_memoryaccesscouplings () # AV new file (NB this is generic in Subprocesses and then linked in Sigma-specific)
1844+ super ().generate_process_files ()
18451845 # NB: symlink of cudacpp.mk to makefile is overwritten by madevent makefile if this exists (#480)
18461846 # NB: this relies on the assumption that cudacpp code is generated before madevent code
18471847 #files.ln(pjoin(self.path, 'cudacpp.mk'), self.path, 'makefile')
@@ -1905,19 +1905,25 @@ def generate_subprocess_directory_end(self, **opt):
19051905 self .edit_coloramps ( subproc_diagrams_for_config )
19061906
19071907 # AV - new method
1908- def edit_coloramps (self , config_subproc_map ):
1908+ def edit_coloramps (self ):
19091909 """Generate coloramps.h"""
19101910
1911+ # we don't sort self.multi_channel_map, and we rely on MadSpace sorting
1912+ # so, diagrams there may be unsorted
1913+ config_subproc_map_C = self .multi_channel_map .values () # this has C-indexing
1914+ config_subproc_map = [] # this has Fortran indexing
1915+ for config in config_subproc_map_C :
1916+ config_subproc_map .append ([c + 1 for c in config ])
1917+
19111918 ###misc.sprint('Entering OneProcessExporterMadMatrix.edit_coloramps')
19121919 template = open (pjoin (self .template_path ,'madmatrix' ,'coloramps.h' ),'r' ).read ()
19131920 ff = open (pjoin (self .path , 'coloramps.h' ),'w' )
19141921 # The following five lines from OneProcessExporterCPP.get_sigmaKin_lines (using OneProcessExporterCPP.get_icolamp_lines)
19151922 replace_dict = {}
19161923
1917-
19181924 iconfig_to_diag = {}
19191925 diag_to_iconfig = {}
1920- iconfig = 0
1926+ iconfig = 0
19211927 for config in config_subproc_map :
19221928 if set (config ) == set ([0 ]):
19231929 continue
@@ -1937,7 +1943,6 @@ def edit_coloramps(self, config_subproc_map):
19371943 lines = []
19381944 for diag in range (1 , nb_diag + 1 ):
19391945 channelidf = diag
1940- channelidc = channelidf - 1 # C convention
19411946 if diag in diag_to_iconfig :
19421947 iconfigf = diag_to_iconfig [diag ]
19431948 iconfigftxt = '%i' % iconfigf
@@ -1948,20 +1953,20 @@ def edit_coloramps(self, config_subproc_map):
19481953 lines .append (text % {'diag' :diag , 'channelidf' :channelidf , 'iconfigf' :iconfigf , 'iconfigftxt' :iconfigftxt })
19491954 replace_dict ['channelc2iconfig_lines' ] = '\n ' .join (lines )
19501955
1951- subproc_to_confdiag = export_v4 . ProcessExporterFortranMEGroup . get_confdiag_from_group_mapconfig ( config_subproc_map , 0 )
1952- replace_dict [ 'is_LC' ] = self . get_icolamp_lines ( subproc_to_confdiag , self . matrix_elements [ 0 ], 1 )
1953- replace_dict ['nb_channel ' ] = len ( subproc_to_confdiag )
1954- replace_dict [ 'nb_diag' ] = max (config [ 0 ] for config in config_subproc_map )
1955- replace_dict ['nb_color' ] = max ( 1 , len ( self . matrix_elements [ 0 ]. get ( 'color_basis' )))
1956+ replace_dict [ 'nb_channel' ] = len ( self . active_color_map )
1957+ # here I can do the conversion in between the active color map and true, false, and obtain a C++ compatible thing immediately
1958+ replace_dict ['nb_diag ' ] = nb_diag
1959+ nb_color = max (1 , len ( self . color_basis ) )
1960+ replace_dict ['nb_color' ] = nb_color
19561961 # AV extra formatting (e.g. gg_tt was "{{true,true};,{true,false};,{false,true};};")
19571962 ###misc.sprint(replace_dict['is_LC'])
1958- split = replace_dict ['is_LC' ].replace ('{{' ,'{' ).replace ('};};' ,'}' ).split (';,' )
19591963 text = ', // ICONFIG=%-{0}i <-- CHANNEL_ID=%i' .format (ndigits )
1960- for iconfigc in range (len (split )):
1961- ###misc.sprint(split[iconfigc])
1962- split [iconfigc ] = ' ' + split [iconfigc ].replace (',' ,', ' ).replace ('true' ,' true' ).replace ('{' ,'{ ' ).replace ('}' ,' }' )
1963- split [iconfigc ] += text % (iconfigc + 1 , iconfig_to_diag [iconfigc + 1 ])
1964- replace_dict ['is_LC' ] = '\n ' .join (split )
1964+ icolamp = []
1965+ for iconfigc , active in enumerate (self .active_color_map ):
1966+ icolamp_text = " { " + ", " .join (["true" if i in active else "false" for i in range (nb_color )]) + "}"
1967+ icolamp_text += text % (iconfigc + 1 , iconfig_to_diag [iconfigc + 1 ])
1968+ icolamp .append (icolamp_text )
1969+ replace_dict ['is_LC' ] = '\n ' .join (icolamp )
19651970 ff .write (template % replace_dict )
19661971 ff .close ()
19671972
@@ -2231,7 +2236,7 @@ def format_call(call):
22312236 return call .replace ('(' ,'( ' ).replace (')' ,' )' ).replace (',' ,', ' )
22322237
22332238 # AV - replace helas_call_writers.GPUFOHelasCallWriter method (improve formatting)
2234- def super_get_matrix_element_calls (self , matrix_element , color_amplitudes ):
2239+ def super_get_matrix_element_calls (self , matrix_element , color_amplitudes , multi_channel_map ):
22352240 """Return a list of strings, corresponding to the Helas calls for the matrix element"""
22362241 import madgraph .core .helas_objects as helas_objects
22372242 import madgraph .loop .loop_helas_objects as loop_helas_objects
@@ -2309,10 +2314,10 @@ def super_get_matrix_element_calls(self, matrix_element, color_amplitudes):
23092314""" )
23102315 diagrams = matrix_element .get ('diagrams' )
23112316 diag_to_config = {}
2312- for config in sorted (self . multi_channel_map .keys ()):
2317+ for config in sorted (multi_channel_map .keys ()):
23132318 amp = [a .get ('number' ) for a in \
23142319 sum ([diagrams [idiag ].get ('amplitudes' ) for \
2315- idiag in self . multi_channel_map [config ]], [])]
2320+ idiag in multi_channel_map [config ]], [])]
23162321 diag_to_config [amp [0 ]] = config
23172322 ###misc.sprint(diag_to_config)
23182323 id_amp = 0
0 commit comments