|
29 | 29 | # FD gauge check |
30 | 30 | fd_gauge = (unitary_gauge == 3) |
31 | 31 |
|
| 32 | +def strip_banner(file_text, banner_mark): |
| 33 | + # skip leading lines that start with '!' |
| 34 | + start = 0 |
| 35 | + file_lines = file_text.split('\n') |
| 36 | + for i, line in enumerate(file_lines): |
| 37 | + if line.startswith(banner_mark): |
| 38 | + start = i + 1 |
| 39 | + else: |
| 40 | + break |
| 41 | + return '\n'.join(file_lines[start:]) |
| 42 | + |
32 | 43 | # AV - define a custom ALOHAWriter |
33 | 44 | # (NB: enable this via MadMatrixUFOModelConverter.aloha_writer) |
34 | 45 | class MadMatrixALOHAWriter(aloha_writers.ALOHAWriterForGPU): |
@@ -888,7 +899,7 @@ def read_aloha_template_files(self, ext): |
888 | 899 |
|
889 | 900 | if ext == 'h': file = open(pjoin(path, helas_temp_file)).read() |
890 | 901 | else: file = open(pjoin(path, self.helas_cc)).read() |
891 | | - file = '\n'.join( file.split('\n')[9:] ) # skip first 9 lines in helas.h/cu (copyright including ALOHA) |
| 902 | + file = strip_banner(file, banner_mark = "!") # skip first 9 lines in helas.h/cu (copyright including ALOHA) |
892 | 903 | out.append( file ) |
893 | 904 | return out |
894 | 905 |
|
@@ -1353,7 +1364,7 @@ def write_aloha_routines(self): |
1353 | 1364 | if (fd_gauge): replace_dict['nwave'] += 1 |
1354 | 1365 | file_h = self.read_template_file(self.aloha_template_h) % replace_dict |
1355 | 1366 | file_cc = self.read_template_file(self.aloha_template_cc) % replace_dict |
1356 | | - file_cc = '\n'.join( file_cc.split('\n')[9:] ) # skip first 9 lines in cpp_hel_amps_cc.inc (copyright including ALOHA) |
| 1367 | + file_cc = strip_banner(file_cc, banner_mark = "!") # skip first 9 lines in cpp_hel_amps_cc.inc (copyright including ALOHA) |
1357 | 1368 | # Write the HelAmps_sm.h and HelAmps_sm.cc files |
1358 | 1369 | ###MadMatrixwriters.CPPWriter(model_h_file).writelines(file_h) |
1359 | 1370 | ###MadMatrixwriters.CPPWriter(model_cc_file).writelines(file_cc) |
@@ -1461,7 +1472,7 @@ def get_process_class_definitions(self, write=True): |
1461 | 1472 |
|
1462 | 1473 | if( write ): # ZW: added dict return for uses in child exporters. Default argument is True so no need to modify other calls to this function |
1463 | 1474 | file = self.read_template_file(self.process_class_template) % replace_dict |
1464 | | - file = '\n'.join( file.split('\n')[8:] ) # skip first 8 lines in process_class.inc (copyright) |
| 1475 | + file = strip_banner(file, banner_mark = "!") # skip first 8 lines in process_class.inc (copyright) |
1465 | 1476 | return file |
1466 | 1477 | else: |
1467 | 1478 | return replace_dict |
@@ -1633,7 +1644,7 @@ def get_process_function_definitions(self, write=True): |
1633 | 1644 | file_lines = file.split('\n') |
1634 | 1645 | file_lines = [l.replace('cIPC, cIPD','cIPC') for l in file_lines] # remove cIPD from OpenMP pragma |
1635 | 1646 | file = '\n'.join( file_lines ) |
1636 | | - file = '\n'.join( file.split('\n')[8:] ) # skip first 8 lines in process_function_definitions.inc (copyright) |
| 1647 | + file = strip_banner(file, banner_mark = "!") # skip first 8 lines in process_function_definitions.inc (copyright) |
1637 | 1648 | return file |
1638 | 1649 |
|
1639 | 1650 | # AV - modify export_cpp.OneProcessExporterCPP method (add debug printouts for multichannel #342) |
@@ -1664,7 +1675,7 @@ def get_sigmaKin_lines(self, color_amplitudes, write=True): |
1664 | 1675 |
|
1665 | 1676 | if write: |
1666 | 1677 | file = self.read_template_file(self.process_sigmaKin_function_template) % replace_dict |
1667 | | - file = '\n'.join( file.split('\n')[8:] ) # skip first 8 lines in process_sigmaKin_function.inc (copyright) |
| 1678 | + file = strip_banner(file, banner_mark = "!") # skip first 8 lines in process_sigmaKin_function.inc (copyright) |
1668 | 1679 | return file, replace_dict |
1669 | 1680 | else: |
1670 | 1681 | return replace_dict |
@@ -1816,7 +1827,7 @@ def get_all_sigmaKin_lines(self, color_amplitudes, class_name): |
1816 | 1827 | file_extend = [] |
1817 | 1828 | for i, me in enumerate(self.matrix_elements): |
1818 | 1829 | file = self.get_matrix_single_process( i, me, color_amplitudes[i], class_name ) |
1819 | | - file = '\n'.join( file.split('\n')[8:] ) # skip first 8 lines in process_matrix.inc (copyright) |
| 1830 | + file = strip_banner(file, banner_mark = "!") # skip first 8 lines in process_matrix.inc (copyright) |
1820 | 1831 | file_extend.append( file ) |
1821 | 1832 | assert i == 0, "more than one ME in get_all_sigmaKin_lines" # AV sanity check (added for color_sum.cc but valid independently) |
1822 | 1833 | ret_lines.extend( file_extend ) |
|
0 commit comments