Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5d773a5
[susy] in CODEGEN add susy_gg_tt
valassi Mar 31, 2023
217fcac
[susy] in CODEGEN fix "TypeError: exceptions must derive from BaseExc…
valassi Mar 31, 2023
4126fd6
[susy] in CODEGEN add a fix for couplings printed out with a minus in…
valassi Mar 31, 2023
7e596e4
[susy] in CODEGEN attempt a fix for "ValueError : not enough values t…
valassi Mar 31, 2023
d51a6e0
[susy] in CODEGEN add debug printouts for pardef and parset sizes #62…
valassi Mar 31, 2023
f01dc12
[susy] in CODEGEN, skip line after if, assuming a two-line if stateme…
valassi Mar 31, 2023
b667330
[susy] in CODEGEN, skip line with leading "indices", before slha.get_…
valassi Mar 31, 2023
f2bcfcc
[susy] in CODEGEN improve the assert for "pardef is empty but parset …
valassi Mar 31, 2023
f9348a4
[susy] in CODEGEN add various printouts for dep/indep coups/params
valassi Mar 31, 2023
a01157e
[susy] in CODEGEN add a debug printout at the top of write_hardcoded_…
valassi Apr 1, 2023
2b06de3
[susy] in CODEGEN add a sanity check that params=[] gives empty outpu…
valassi Apr 1, 2023
735da27
[susy] in CODEGEN add super_write_set_parameters to eventually split …
valassi Apr 1, 2023
115578c
[susy] in CODEGEN split writing of parameters and fixes for Majorana …
valassi Apr 1, 2023
95eab09
[susy] in CODEGEN simplify checkFormatting.sh script: remove useless/…
valassi Mar 31, 2023
0e86554
[susy] in CODEGEN add fixes for Majorana particles only in the aS-ind…
valassi Apr 1, 2023
c7ebd80
[susy] in CODEGEN, add a few formatting post-fixes for clang-format i…
valassi Apr 1, 2023
6d0db41
[susy] in CODEGEN add missing '\n' before onlyfixMajorana
valassi Apr 2, 2023
0170ebf
[susy] in CODEGEN fix formatting inside onlyfixMajorana
valassi Apr 3, 2023
806e7d7
[susy] regenerate 6 processes SA, all ok with no change
valassi Apr 3, 2023
acbe689
[susy] ** COMPLETE SUSY (PART 1) ** regenerate five processes mad, al…
valassi Apr 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 59 additions & 11 deletions epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/model_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ def write_parameters(self, params):

# AV - overload export_cpp.UFOModelConverterCPP method (improve formatting)
def write_set_parameters(self, params):
res = super().write_set_parameters(params)
res = self.super_write_set_parameters_donotfixMajorana(params)
res = res.replace('(','( ')
res = res.replace(')',' )')
res = res.replace('+',' + ')
Expand All @@ -676,16 +676,19 @@ def write_set_parameters(self, params):
res = res.replace('std::complex<','cxsmpl<') # custom simplex complex class (with constexpr arithmetics)
if res == '' : res = '// (none)'
res = res.replace('\n','\n ')
res = res.replace('( - ','( -') # post-fix for susy
res = res.replace(', - ',', -') # post-fix for susy
return res

# AV - new method (merging write_parameters and write_set_parameters)
def write_hardcoded_parameters(self, params):
###misc.sprint(params) # for debugging
pardef = super().write_parameters(params)
parset = super().write_set_parameters(params)
parset = self.super_write_set_parameters_donotfixMajorana(params)
###print( '"' + pardef + '"' )
###print( '"' + parset + '"' )
if ( pardef == '' ):
assert( parset == '' ) # AV sanity check (both are empty)
assert parset == '', "pardef is empty but parset is not: '%s'"%parset # AV sanity check (both are empty)
res = '// (none)\n'
return res
pardef = pardef.replace('std::complex<','cxsmpl<') # custom simplex complex class (with constexpr arithmetics)
Expand All @@ -705,24 +708,61 @@ def write_hardcoded_parameters(self, params):
parset = parset.replace(',',', ')
pardef_lines = {}
for line in pardef.split('\n'):
###print(line) # for debugging
type, pars = line.rstrip(';').split(' ') # strip trailing ';'
for par in pars.split(','):
###print(len(pardef_lines), par) # for debugging
pardef_lines[par] = ( 'constexpr ' + type + ' ' + par )
###print( pardef_lines )
misc.sprint( 'pardef_lines size =', len(pardef_lines), ', keys size =', len(pardef_lines.keys()) )
###print( pardef_lines ) # for debugging
###for line in pardef_lines: misc.sprint(line) # for debugging
parset_pars = []
parset_lines = {}
for line in parset.split('\n'):
skipnextline = False
for iline, line in enumerate(parset.split('\n')):
###print(iline, line) # for debugging
if line.startswith('indices'):
###print('WARNING! Skip line with leading "indices" :', line)
continue # skip line with leading "indices", before slha.get_block_entry (#622)
par, parval = line.split(' = ')
###misc.sprint(len(parset_pars), len(parset_lines), par, parval) # for debugging
if parval.startswith('slha.get_block_entry'): parval = parval.split(',')[2].lstrip(' ').rstrip(');') + ';'
parset_pars.append( par )
parset_lines[par] = parval # includes a trailing ';'
###print( parset_lines )
assert( len(pardef_lines) == len(parset_lines) ) # AV sanity check (same number of parameters)
misc.sprint( 'parset_pars size =', len(parset_pars) )
misc.sprint( 'parset_lines size =', len(parset_lines), ', keys size =', len(parset_lines.keys()) )
###print( parset_lines ) # for debugging
###for line in parset_lines: misc.sprint(line) # for debugging
assert len(pardef_lines) == len(parset_lines), 'len(pardef_lines) != len(parset_lines)' # AV sanity check (same number of parameters)
res = ' '.join( pardef_lines[par] + ' = ' + parset_lines[par] + '\n' for par in parset_pars ) # no leading ' ' on first row
res = res.replace(' ;',';')
res = res.replace('= - ','= -') # post-fix for susy
res = res.replace('( - ','( -') # post-fix for susy
###print(res); assert(False)
return res

# AV - replace export_cpp.UFOModelConverterCPP method (split writing of parameters and fixes for Majorana particles #622)
def super_write_set_parameters_donotfixMajorana(self, params):
"""Write out the lines of independent parameters"""
res_strings = []
# For each parameter, write name = expr;
for param in params:
res_strings.append("%s" % param.expr)
return "\n".join(res_strings)

# AV - replace export_cpp.UFOModelConverterCPP method (eventually split writing of parameters and fixes for Majorana particles #622)
def super_write_set_parameters_onlyfixMajorana(self, hardcoded): # FIXME! split hardcoded (constexpr) and not-hardcoded code
"""Write out the lines of independent parameters"""
print( 'super_write_set_parameters_onlyfixMajorana (hardcoded=%s)'%hardcoded )
res_strings = []
# Correct width sign for Majorana particles (where the width and mass need to have the same sign)
for particle in self.model.get('particles'):
if particle.is_fermion() and particle.get('self_antipart') and \
particle.get('width').lower() != 'zero':
res_strings.append(" if( %s < 0 )" % particle.get('mass'))
res_strings.append(" %(width)s = -abs( %(width)s );" % {"width": particle.get('width')})
return '\n' + '\n'.join(res_strings) if res_strings else ''

# AV - replace export_cpp.UFOModelConverterCPP method (add hardcoded parameters and couplings)
def super_generate_parameters_class_files(self):
"""Create the content of the Parameters_model.h and .cc files"""
Expand All @@ -748,16 +788,23 @@ def super_generate_parameters_class_files(self):
if '"aS =' in line else
line for line in self.write_print_parameters(self.params_indep).split('\n') ]
replace_dict['print_independent_parameters'] = '\n'.join( print_params_indep )
replace_dict['print_independent_parameters'] += self.super_write_set_parameters_onlyfixMajorana( hardcoded=False ) # add fixes for Majorana particles only in the aS-indep parameters #622
replace_dict['print_independent_couplings'] = self.write_print_parameters(self.coups_indep)
replace_dict['print_dependent_parameters'] = self.write_print_parameters(self.params_dep)
replace_dict['print_dependent_couplings'] = self.write_print_parameters(list(self.coups_dep.values()))
if 'include_prefix' not in replace_dict:
replace_dict['include_prefix'] = ''
assert super().write_parameters([]) == '', 'super().write_parameters([]) is not empty' # AV sanity check (#622)
assert self.super_write_set_parameters_donotfixMajorana([]) == '', 'super_write_set_parameters_donotfixMajorana([]) is not empty' # AV sanity check (#622)
###misc.sprint(self.params_indep) # for debugging
hrd_params_indep = [ line.replace('constexpr','//constexpr') + ' // now retrieved event-by-event (as G) from Fortran (running alphas #373)' if 'aS =' in line else line for line in self.write_hardcoded_parameters(self.params_indep).split('\n') ]
replace_dict['hardcoded_independent_parameters'] = '\n'.join( hrd_params_indep )
replace_dict['hardcoded_independent_parameters'] = '\n'.join( hrd_params_indep ) + self.super_write_set_parameters_onlyfixMajorana( hardcoded=True ) # add fixes for Majorana particles only in the aS-indep parameters #622
###misc.sprint(self.coups_indep) # for debugging
replace_dict['hardcoded_independent_couplings'] = self.write_hardcoded_parameters(self.coups_indep)
###misc.sprint(self.params_dep) # for debugging
hrd_params_dep = [ line.replace('constexpr','//constexpr') + ' // now computed event-by-event (running alphas #373)' if line != '' else line for line in self.write_hardcoded_parameters(self.params_dep).split('\n') ]
replace_dict['hardcoded_dependent_parameters'] = '\n'.join( hrd_params_dep )
###misc.sprint(self.coups_dep) # for debugging
hrd_coups_dep = [ line.replace('constexpr','//constexpr') + ' // now computed event-by-event (running alphas #373)' if line != '' else line for line in self.write_hardcoded_parameters(list(self.coups_dep.values())).split('\n') ]
replace_dict['hardcoded_dependent_couplings'] = '\n'.join( hrd_coups_dep )
replace_dict['nicoup'] = len( self.coups_indep )
Expand Down Expand Up @@ -1811,17 +1858,18 @@ def generate_helas_call(self, argument):
# AV FOR PR #434: determine if this call needs aS-dependent or aS-independent parameters
usesdepcoupl = None
for coup in argument.get('coupling'):
if coup.startswith('-'): coup = coup[1:]
# Use the same implementation as in UFOModelConverterCPP.prepare_couplings (assume self.model is the same)
for key, coup_list in self.get('model')['couplings'].items():
if coup in coup_list:
if "aS" in key:
if usesdepcoupl is None: usesdepcoupl = True
elif not usesdepcoupl: raise "PANIC! this call seems to use both aS-dependent and aS-independent couplings?"
elif not usesdepcoupl: raise Exception('PANIC! this call seems to use both aS-dependent and aS-independent couplings?')
else:
if usesdepcoupl is None: usesdepcoupl = False
elif usesdepcoupl: raise "PANIC! this call seems to use both aS-dependent and aS-independent couplings?"
elif usesdepcoupl: raise Exception('PANIC! this call seems to use both aS-dependent and aS-independent couplings?')
# AV FOR PR #434: CI_ACCESS for independent couplings and CD_ACCESS for dependent couplings
if usesdepcoupl is None: raise "PANIC! could not determine if this call uses aS-dependent or aS-independent couplings?"
if usesdepcoupl is None: raise Exception('PANIC! could not determine if this call uses aS-dependent or aS-independent couplings?')
elif usesdepcoupl: caccess = 'CD_ACCESS'
else: caccess = 'CI_ACCESS'
###if arg['routine_name'].endswith( '_0' ) : arg['routine_name'] += '<W_ACCESS, A_ACCESS, C_ACCESS>'
Expand Down
35 changes: 18 additions & 17 deletions epochX/cudacpp/CODEGEN/checkFormatting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@ function checkProcdir()
else
proc=${procdir%.sa}
fi
case "${proc}" in
ee_mumu) ;;
gg_tt) ;;
gg_ttg) ;;
gg_ttgg) ;;
gg_ttggg) ;;
pp_tt) ;;
uu_tt) ;;
uu_dd) ;;
bb_tt) ;;
heft_gg_h) ;;
*)
echo "ERROR! Unknown process: '$proc'"
exit 1
return
;;
esac
# Check if this is a "known" process
#case "${proc}" in
# ee_mumu) ;;
# gg_tt) ;;
# gg_ttg) ;;
# gg_ttgg) ;;
# gg_ttggg) ;;
# pp_tt) ;;
# uu_tt) ;;
# uu_dd) ;;
# bb_tt) ;;
# heft_gg_h) ;;
# *)
# echo "ERROR! Unknown process: '$proc'"
# exit 1
# return
# ;;
#esac
# Check if the chosen procdir exists
cd $TOPDIR
if [ ! -d $procdir ]; then echo "ERROR! Directory not found $TOPDIR/$procdir"; exit 1; fi
Expand Down
3 changes: 3 additions & 0 deletions epochX/cudacpp/CODEGEN/generateAndCompare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ function codeGenAndDiff()
heft_gg_h)
cmd="set auto_convert_model T; import model heft; generate g g > h"
;;
susy_gg_tt)
cmd="import model MSSM_SLHA2; generate g g > t t~"
;;
*)
echo -e "\nWARNING! Skipping unknown process '$proc'"
return
Expand Down
Loading