Skip to content

Commit

Permalink
[pp4t] finally complete a fully functional CODEGEN with the correct n…
Browse files Browse the repository at this point in the history
…wf (madgraph5/madgraph4gpu#644), clean up and disable debug printouts for nwf

(NB: I checked that pp_tttt now generates and builds correctly in both P1 subdirectories)
  • Loading branch information
valassi committed May 22, 2023
1 parent 31a33de commit 6ccbae2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
3 changes: 2 additions & 1 deletion madgraph/iolibs/template_files/gpu/process_class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
// Hardcoded parameters for this process (constant class variables)
// [NB: this class assumes nprocesses==1 i.e. a single DSIG1 and no DSIG2 in Fortran (#272 and #343)]
// [NB: these parameters (e.g. nwf) are P1-specific, i.e. they are different for different P1 subdirectories (#644)]
static const int nwf = %(nwavefunc)d; // #wavefunctions = #external (npar) + #internal: e.g. 5 for e+ e- -> mu+ mu- (1 internal is gamma or Z)
// [NB: I am currently unable to get the right value of nwf in CPPProcess.h - will hardcode it in CPPProcess.cc instead (#644)]
//static const int nwf = ??; // #wavefunctions = #external (npar) + #internal: e.g. 5 for e+ e- -> mu+ mu- (1 internal is gamma or Z)

// Other variables of this instance (???)
//static const int ninitial = mgOnGpu::npari;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ namespace mg5amcCpu

using mgOnGpu::nw6; // dimensions of each wavefunction (HELAS KEK 91-11): e.g. 6 for e+ e- -> mu+ mu- (fermions and vectors)

using CPPProcess::nwf; // #wavefunctions = #external (npar) + #internal: e.g. 5 for e+ e- -> mu+ mu- (1 internal is gamma or Z)
// [NB: I am currently unable to get the right value of nwf in CPPProcess.h - will hardcode it in CPPProcess.cc instead (#644)]
//using CPPProcess::nwf; // #wavefunctions = #external (npar) + #internal: e.g. 5 for e+ e- -> mu+ mu- (1 internal is gamma or Z)

using Parameters_%(model_name)s_dependentCouplings::ndcoup; // #couplings that vary event by event (depend on running alphas QCD)
using Parameters_%(model_name)s_independentCouplings::nicoup; // #couplings that are fixed for all events (do not depend on running alphas QCD)
Expand Down
48 changes: 28 additions & 20 deletions model_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,9 @@ def __init__(self, *args, **kwargs):
def get_process_class_definitions(self, write=True):
replace_dict = super().get_process_class_definitions(write=False)
replace_dict['process_lines'] = replace_dict['process_lines'].replace('\n','\n ')
replace_dict['nwavefunc'] = self.matrix_elements[0].get_number_of_wavefunctions() # this is the correct P1-specific nwf, now in CPPProcess.h (#644)
###misc.sprint( replace_dict['nwavefuncs'] ) # NB: this (from export_cpp) is the WRONG value of nwf, e.g. 6 for gg_tt (#644)
###misc.sprint( self.matrix_elements[0].get_number_of_wavefunctions() ) # NB: this is a different WRONG value of nwf, e.g. 7 for gg_tt (#644)
###replace_dict['nwavefunc'] = self.matrix_elements[0].get_number_of_wavefunctions() # how do I get HERE the right value of nwf, e.g. 5 for gg_tt?
file = self.read_template_file(self.process_class_template) % replace_dict # HACK! ignore write=False case
file = '\n'.join( file.split('\n')[8:] ) # skip first 8 lines in process_class.inc (copyright)
return file
Expand Down Expand Up @@ -1141,6 +1143,24 @@ def get_all_sigmaKin_lines(self, color_amplitudes, class_name):
ret_lines = []
if self.single_helicities:
###assert self.include_multi_channel # remove this assert: must handle both cases and produce two different code bases (#473)
misc.sprint(type(self.helas_call_writer))
misc.sprint(self.support_multichannel, self.include_multi_channel)
multi_channel = None
if self.include_multi_channel:
if not self.support_multichannel:
raise Exception("link with madevent not supported")
multi_channel = self.get_multi_channel_dictionary(self.matrix_elements[0].get('diagrams'), self.include_multi_channel)
misc.sprint(multi_channel)
###misc.sprint( 'before get_matrix_element_calls', self.matrix_elements[0].get_number_of_wavefunctions() ) # WRONG value of nwf, eg 7 for gg_tt
helas_calls = self.helas_call_writer.get_matrix_element_calls(\
self.matrix_elements[0],
color_amplitudes[0],
multi_channel_map = multi_channel
)
###misc.sprint( 'after get_matrix_element_calls', self.matrix_elements[0].get_number_of_wavefunctions() ) # CORRECT value of nwf, eg 5 for gg_tt
assert len(self.matrix_elements) == 1 # how to handle if this is not true?
self.couplings2order = self.helas_call_writer.couplings2order
self.params2order = self.helas_call_writer.params2order
ret_lines.append("""
// Evaluate |M|^2 for each subprocess
// NB: calculate_wavefunctions ADDS |M|^2 for a given ihel to the running sum of |M|^2 over helicities for the given event(s)
Expand Down Expand Up @@ -1193,8 +1213,13 @@ def get_all_sigmaKin_lines(self, color_amplitudes, class_name):
//printf( \"calculate_wavefunctions: ihel=%2d\\n\", ihel );
#ifndef __CUDACC__
//printf( \"calculate_wavefunctions: ievt00=%d\\n\", ievt00 );
#endif
#endif""")
nwavefuncs = self.matrix_elements[0].get_number_of_wavefunctions()
ret_lines.append("""
// The variable nwf (which is specific to each P1 subdirectory, #644) is only used here
// It is hardcoded here because various attempts to hardcode it in CPPProcess.h at generation time gave the wrong result...
static const int nwf = %i; // #wavefunctions = #external (npar) + #internal: e.g. 5 for e+ e- -> mu+ mu- (1 internal is gamma or Z)"""%nwavefuncs )
ret_lines.append("""
// Local TEMPORARY variables for a subset of Feynman diagrams in the given CUDA event (ievt) or C++ event page (ipagV)
// [NB these variables are reused several times (and re-initialised each time) within the same event or event page]
// ** NB: in other words, amplitudes and wavefunctions still have TRIVIAL ACCESS: there is currently no need
Expand Down Expand Up @@ -1226,23 +1251,6 @@ def get_all_sigmaKin_lines(self, color_amplitudes, class_name):
#ifndef __CUDACC__
const int ievt0 = ievt00 + iParity * neppV;
#endif""")
misc.sprint(type(self.helas_call_writer))
misc.sprint(self.support_multichannel, self.include_multi_channel)
multi_channel = None
if self.include_multi_channel:
if not self.support_multichannel:
raise Exception("link with madevent not supported")
multi_channel = self.get_multi_channel_dictionary(self.matrix_elements[0].get('diagrams'), self.include_multi_channel)
misc.sprint(multi_channel)
helas_calls = self.helas_call_writer.get_matrix_element_calls(\
self.matrix_elements[0],
color_amplitudes[0],
multi_channel_map = multi_channel
)
assert len(self.matrix_elements) == 1 # how to handle if this is not true?
self.couplings2order = self.helas_call_writer.couplings2order
self.params2order = self.helas_call_writer.params2order
nwavefuncs = self.matrix_elements[0].get_number_of_wavefunctions()
ret_lines += helas_calls
else:
ret_lines.extend([self.get_sigmaKin_single_process(i, me) \
Expand Down

0 comments on commit 6ccbae2

Please sign in to comment.