diff --git a/.github/workflows/acceptancetest.yml b/.github/workflows/acceptancetest.yml index 2493c3aee0..7509348dfd 100644 --- a/.github/workflows/acceptancetest.yml +++ b/.github/workflows/acceptancetest.yml @@ -678,6 +678,13 @@ jobs: cd $GITHUB_WORKSPACE ./tests/test_manager.py test_loop_induced_ggh -pA -t0 -l INFO + # ---- acceptancetest_104_nogroup (from mg5 3.8.2, issue #486) ---- + - name: test loop-induced gg>h output with group_subprocesses=False + if: ${{ !cancelled() }} + run: | + cd $GITHUB_WORKSPACE + ./tests/test_manager.py test_loop_induced_ggh_nogroup -pA -t0 -l INFO + # ---- acceptancetest_fks_standalone_limits_pp_ttx ---- # soft and collinear limits of p p > t t~ [QCD] via the FKS standalone # output ('output standalone_fortran --fks --limits'): launch runs @@ -1359,6 +1366,10 @@ jobs: - uses: ./.github/actions/restore-pip-cache - name: Check real-emission helicity sums across frames run: ./tests/test_manager.py test_real_helicity_sum_survives_a_boost -pA -t0 -l INFO + # from mg5 3.8.2: the MadLoop loop filter of a 2>1 process across frames + - name: Check MadLoop loop filters across frames + if: ${{ !cancelled() }} + run: ./tests/test_manager.py test_ML_loop_filter_survives_a_boost -pA -t0 -l INFO - name: Cancel the other CI runs of this commit (fail fast) if: ${{ failure() && github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'run-ci') }} env: diff --git a/.github/workflows/acceptancetest_madevent.yml b/.github/workflows/acceptancetest_madevent.yml index b572e0e50f..f43bf73ebe 100644 --- a/.github/workflows/acceptancetest_madevent.yml +++ b/.github/workflows/acceptancetest_madevent.yml @@ -101,6 +101,14 @@ jobs: ./tests/test_manager.py test_group_subprocess_permuted_scale -pA -t0 -l INFO ./tests/test_manager.py test_mlm_pdfrwt_flavour -pA -t0 -l INFO + # ---- acceptancetest_51_2 (from mg5 3.8.2) ---- + # lower bound on shat (smin, setcuts.f) below the cut threshold + - name: "acceptancetest_51_2" + if: ${{ !cancelled() }} + run: | + cd $GITHUB_WORKSPACE + ./tests/test_manager.py test_smin_below_cut_threshold -pA -t0 -l INFO + # ---- acceptancetest_contur ---- - name: "acceptancetest_contur: run the test" if: ${{ !cancelled() }} diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 8497a2d951..113b9f48f6 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -704,7 +704,7 @@ jobs: if: ${{ !cancelled() }} run: | cd $GITHUB_WORKSPACE - ./tests/test_manager.py test_cluster test_collect_events test_make_opts test_mg7_plots test_systematics test_test_finder TestHistogramRegressions TestLorentzStructureCanonicalisation TestRestrictionDoesNotLeakIntoTheUFO TEST_pythia8_main164 TestPhotonPDFDefault test_same_cpp_code TestPrecisionCheck test_write_inc_file_running_scale test_scan_summary_json test_collapse_duplicate_lorentz test_goldstone_mass_mismatches test_goldstone_merge_is_atomic test_goldstone_merge_keeps_coupling_orders_apart test_goldstone_phase_detects_a_rotated_convention test_goldstone_phase_of_the_sm_is_trivial test_lorentz_info_cache_refresh test_optimise_iden_coup_lorentz_added_after_cache test_optimise_iden_coup_unknown_lorentz_is_skipped test_parse_fermion_structure test_rotate_coupling test_fd_gauge_interaction_ids_stay_unique test_configure_gzip_resets_pigz_threads test_external_gzip_failure_removes_partial_archive test_external_gzip_keep_passes_thread_limit test_gzip_failure_keeps_source_and_leaves_no_archive test_gzip_keep_preserves_plain_source test_interrupted_gzip_removes_partial_archive -t0 + ./tests/test_manager.py test_cluster test_collect_events test_make_opts test_mg7_plots test_systematics test_test_finder TestHistogramRegressions TestLorentzStructureCanonicalisation TestRestrictionDoesNotLeakIntoTheUFO TEST_pythia8_main164 TestPhotonPDFDefault TestRunCardLOResetSimd test_same_cpp_code TestPrecisionCheck test_write_inc_file_running_scale test_scan_summary_json test_collapse_duplicate_lorentz test_goldstone_mass_mismatches test_goldstone_merge_is_atomic test_goldstone_merge_keeps_coupling_orders_apart test_goldstone_phase_detects_a_rotated_convention test_goldstone_phase_of_the_sm_is_trivial test_lorentz_info_cache_refresh test_optimise_iden_coup_lorentz_added_after_cache test_optimise_iden_coup_unknown_lorentz_is_skipped test_parse_fermion_structure test_rotate_coupling test_fd_gauge_interaction_ids_stay_unique test_configure_gzip_resets_pigz_threads test_external_gzip_failure_removes_partial_archive test_external_gzip_keep_passes_thread_limit test_gzip_failure_keeps_source_and_leaves_no_archive test_gzip_keep_preserves_plain_source test_interrupted_gzip_removes_partial_archive -t0 # gamma-UPC run_card labels, makefiles and exporters, plus the gamma-UPC # Fortran library compiled and checked directly (needs gfortran: the diff --git a/Template/LO/Source/PDF/ddilog.f b/Template/LO/Source/PDF/ddilog.f new file mode 100644 index 0000000000..f3a49ec0f1 --- /dev/null +++ b/Template/LO/Source/PDF/ddilog.f @@ -0,0 +1,90 @@ +c CERNLIB DDILOG (C332), the real dilogarithm. Used by the dressed- +c lepton densities (lep_densities/isrbet*ll/eepdf.f). +c It sits in its own member of libpdf, not in setrun.f (libgeneric): +c CutTools and IREGI (qcdloop) define the same symbol, and with GNU ld +c a loop-induced madevent link pulls both copies when ddilog is in +c setrun.o ("multiple definition of ddilog_"). As its own archive +c member it is only loaded when no earlier library defines it. + + double precision FUNCTION DDILOG(X) +* +* $Id: imp64.inc,v 1.1.1.1 1996/04/01 15:02:59 mclareni Exp $ +* +* $Log: imp64.inc,v $ +* Revision 1.1.1.1 1996/04/01 15:02:59 mclareni +* Mathlib gen +* +* +* imp64.inc +* + IMPLICIT DOUBLE PRECISION (A-H,O-Z) + DIMENSION C(0:19) + PARAMETER (Z1 = 1, HF = Z1/2) + PARAMETER (PI = 3.14159 26535 89793 24D0) + PARAMETER (PI3 = PI**2/3, PI6 = PI**2/6, PI12 = PI**2/12) + DATA C( 0) / 0.42996 69356 08136 97D0/ + DATA C( 1) / 0.40975 98753 30771 05D0/ + DATA C( 2) /-0.01858 84366 50145 92D0/ + DATA C( 3) / 0.00145 75108 40622 68D0/ + DATA C( 4) /-0.00014 30418 44423 40D0/ + DATA C( 5) / 0.00001 58841 55418 80D0/ + DATA C( 6) /-0.00000 19078 49593 87D0/ + DATA C( 7) / 0.00000 02419 51808 54D0/ + DATA C( 8) /-0.00000 00319 33412 74D0/ + DATA C( 9) / 0.00000 00043 45450 63D0/ + DATA C(10) /-0.00000 00006 05784 80D0/ + DATA C(11) / 0.00000 00000 86120 98D0/ + DATA C(12) /-0.00000 00000 12443 32D0/ + DATA C(13) / 0.00000 00000 01822 56D0/ + DATA C(14) /-0.00000 00000 00270 07D0/ + DATA C(15) / 0.00000 00000 00040 42D0/ + DATA C(16) /-0.00000 00000 00006 10D0/ + DATA C(17) / 0.00000 00000 00000 93D0/ + DATA C(18) /-0.00000 00000 00000 14D0/ + DATA C(19) /+0.00000 00000 00000 02D0/ + IF(X .EQ. 1) THEN + H=PI6 + ELSEIF(X .EQ. -1) THEN + H=-PI12 + ELSE + T=-X + IF(T .LE. -2) THEN + Y=-1/(1+T) + S=1 + A=-PI3+HF*(LOG(-T)**2-LOG(1+1/T)**2) + ELSEIF(T .LT. -1) THEN + Y=-1-T + S=-1 + A=LOG(-T) + A=-PI6+A*(A+LOG(1+1/T)) + ELSE IF(T .LE. -HF) THEN + Y=-(1+T)/T + S=1 + A=LOG(-T) + A=-PI6+A*(-HF*A+LOG(1+T)) + ELSE IF(T .LT. 0) THEN + Y=-T/(1+T) + S=-1 + A=HF*LOG(1+T)**2 + ELSE IF(T .LE. 1) THEN + Y=T + S=1 + A=0 + ELSE + Y=1/T + S=-1 + A=PI6+HF*LOG(T)**2 + ENDIF + H=Y+Y-1 + ALFA=H+H + B1=0 + B2=0 + DO 1 I = 19,0,-1 + B0=C(I)+ALFA*B1-B2 + B2=B1 + 1 B1=B0 + H=-(S*(B0-H*B2)+A) + ENDIF + DDILOG=H + RETURN + END diff --git a/Template/LO/Source/PDF/makefile b/Template/LO/Source/PDF/makefile index f1aeae4915..c4a3ac6ab9 100644 --- a/Template/LO/Source/PDF/makefile +++ b/Template/LO/Source/PDF/makefile @@ -46,7 +46,7 @@ ifdef lhapdf endif else TOREMOVE += pdfwrap_lhapdf.o - PDF += Ctq6Pdf.o pdfwrap.o pdf.o pdg2pdf.o NNPDFDriver.o eepdf.o gridpdfaux.o dfint.o kerset.o + PDF += Ctq6Pdf.o pdfwrap.o pdf.o pdg2pdf.o NNPDFDriver.o eepdf.o ddilog.o gridpdfaux.o dfint.o kerset.o endif diff --git a/Template/LO/Source/setrun.f b/Template/LO/Source/setrun.f index 2190163c1d..6bf8bf5730 100644 --- a/Template/LO/Source/setrun.f +++ b/Template/LO/Source/setrun.f @@ -298,87 +298,3 @@ subroutine get_pdfup(pdfin,pdfgup,pdfsup,lhaid) return end - - - double precision FUNCTION DDILOG(X) -* -* $Id: imp64.inc,v 1.1.1.1 1996/04/01 15:02:59 mclareni Exp $ -* -* $Log: imp64.inc,v $ -* Revision 1.1.1.1 1996/04/01 15:02:59 mclareni -* Mathlib gen -* -* -* imp64.inc -* - IMPLICIT DOUBLE PRECISION (A-H,O-Z) - DIMENSION C(0:19) - PARAMETER (Z1 = 1, HF = Z1/2) - PARAMETER (PI = 3.14159 26535 89793 24D0) - PARAMETER (PI3 = PI**2/3, PI6 = PI**2/6, PI12 = PI**2/12) - DATA C( 0) / 0.42996 69356 08136 97D0/ - DATA C( 1) / 0.40975 98753 30771 05D0/ - DATA C( 2) /-0.01858 84366 50145 92D0/ - DATA C( 3) / 0.00145 75108 40622 68D0/ - DATA C( 4) /-0.00014 30418 44423 40D0/ - DATA C( 5) / 0.00001 58841 55418 80D0/ - DATA C( 6) /-0.00000 19078 49593 87D0/ - DATA C( 7) / 0.00000 02419 51808 54D0/ - DATA C( 8) /-0.00000 00319 33412 74D0/ - DATA C( 9) / 0.00000 00043 45450 63D0/ - DATA C(10) /-0.00000 00006 05784 80D0/ - DATA C(11) / 0.00000 00000 86120 98D0/ - DATA C(12) /-0.00000 00000 12443 32D0/ - DATA C(13) / 0.00000 00000 01822 56D0/ - DATA C(14) /-0.00000 00000 00270 07D0/ - DATA C(15) / 0.00000 00000 00040 42D0/ - DATA C(16) /-0.00000 00000 00006 10D0/ - DATA C(17) / 0.00000 00000 00000 93D0/ - DATA C(18) /-0.00000 00000 00000 14D0/ - DATA C(19) /+0.00000 00000 00000 02D0/ - IF(X .EQ. 1) THEN - H=PI6 - ELSEIF(X .EQ. -1) THEN - H=-PI12 - ELSE - T=-X - IF(T .LE. -2) THEN - Y=-1/(1+T) - S=1 - A=-PI3+HF*(LOG(-T)**2-LOG(1+1/T)**2) - ELSEIF(T .LT. -1) THEN - Y=-1-T - S=-1 - A=LOG(-T) - A=-PI6+A*(A+LOG(1+1/T)) - ELSE IF(T .LE. -HF) THEN - Y=-(1+T)/T - S=1 - A=LOG(-T) - A=-PI6+A*(-HF*A+LOG(1+T)) - ELSE IF(T .LT. 0) THEN - Y=-T/(1+T) - S=-1 - A=HF*LOG(1+T)**2 - ELSE IF(T .LE. 1) THEN - Y=T - S=1 - A=0 - ELSE - Y=1/T - S=-1 - A=PI6+HF*LOG(T)**2 - ENDIF - H=Y+Y-1 - ALFA=H+H - B1=0 - B2=0 - DO 1 I = 19,0,-1 - B0=C(I)+ALFA*B1-B2 - B2=B1 - 1 B1=B0 - H=-(S*(B0-H*B2)+A) - ENDIF - DDILOG=H - RETURN - END diff --git a/Template/LO/SubProcesses/setcuts.f b/Template/LO/SubProcesses/setcuts.f index fc8a61686c..0eed795097 100644 --- a/Template/LO/SubProcesses/setcuts.f +++ b/Template/LO/SubProcesses/setcuts.f @@ -119,6 +119,9 @@ SUBROUTINE SETCUTS c integer nb_j, nb_b, nb_a, nb_l, nb_nocut,nb_pdg double precision smin_p, smin_m ! local variable to compute smin + double precision ptk + integer nb_pair + logical has_ptll c c setup masses for the final-state particles c @@ -539,6 +542,11 @@ SUBROUTINE SETCUTS c smin = 0d0 c check for the jet +c ptj/ej only apply to the jets with do_cuts, while ptjNmin, xptj, htNmin +c and htjmin apply to all the jets (ordered in pT, see cuts.f). +c The k-th hardest jet then has E >= pT >= max(ptjNmin, N>=k) and at least +c (nb_j-nb_nocut) jets have E >= max(ej,ptj), so the k-th largest +c E is bounded by max(ptjNmin (N>=k), ej, ptj (if k<=nb_j-nb_nocut)). smin_m = 0d0 smin_p = 0d0 nb_j = 0 @@ -547,71 +555,60 @@ SUBROUTINE SETCUTS if (is_a_j(i)) then nb_j = nb_j + 1 smin_m = smin_m - pmass(i)**2 - if (do_cuts(i))then - if (nb_j.eq.1) then - smin_p = smin_p + max(ej,ptj,xptj,0d0, - & max(ptj1min,ptj2min,ptj3min,ptj4min)) - elseif(nb_j.eq.2) then - smin_p = max(ht2min, smin_p + max(ej,ptj,0d0, - & max(ptj2min,ptj3min,ptj4min))) - elseif(nb_j.eq.3) then - smin_p = max(ht3min, smin_p + max(ej,ptj,0d0, - & max(ptj3min,ptj4min))) - elseif(nb_j.eq.4) then - smin_p = max(ht4min, smin_p + max(ej,ptj,ptj4min,0d0)) - else - smin_p = smin_p + max(ej,ptj,0d0) - endif - else - nb_nocut = nb_nocut + 1 - if (nb_j.eq.1) then - smin_p = smin_p + max(0d0,ptj1min,ptj2min,ptj3min,ptj4min) - elseif(nb_j.eq.2) then - smin_p = max(ht2min, smin_p + max(ptj2min,ptj3min,ptj4min,0d0)) - elseif(nb_j.eq.3) then - smin_p = max(ht3min, smin_p + max(0d0,ptj3min,ptj4min)) - elseif(nb_j.eq.4) then - smin_p = max(ht4min, smin_p + max(ptj4min,0d0)) - endif - endif + if (.not.do_cuts(i)) nb_nocut = nb_nocut + 1 endif - enddo + enddo + do k=1,nb_j + ptk = 0d0 + if (jetor) then + do j=k,4 + ptk = max(ptk, ptjmin4(j)) + enddo + elseif (k.eq.1) then +c cutuse=1: only one of the min(nb_j,4) leading jets has to pass + ptk = ptjmin4(1) + do j=2,min(nb_j,4) + ptk = min(ptk, ptjmin4(j)) + enddo + endif + if (k.eq.1) ptk = max(ptk, xptj) + if (k.le.nb_j-nb_nocut) ptk = max(ptk, ej, ptj) + smin_p = smin_p + max(ptk, 0d0) + if (k.ge.2.and.k.le.4) smin_p = max(smin_p, htjmin4(k)) + enddo if (nb_j.gt.0)then if ((nb_j-nb_nocut).gt.0)then smin_m = smin_m + (nb_j-nb_nocut)*(nb_j-nb_nocut-1)/2d0*mmjj**2 endif - smin = smin + max(smin_p**2, smin_m, htjmin**2) + smin = smin + max(smin_p**2, smin_m, max(htjmin,0d0)**2) endif c check for the bjet +c b's without cuts (decays with cut_decays=F) are skipped on purpose: +c xptb on the first b with cuts, ptb on the others, is then a safe bound +c (xptb can be satisfied by a skipped b, which still adds its energy). smin_m = 0d0 smin_p = 0d0 nb_b = 0 - nb_nocut = 0 do i=nincoming+1,nexternal if (is_a_b(i).and.do_cuts(i)) then nb_b = nb_b + 1 smin_m = smin_m - pmass(i)**2 - if (do_cuts(i)) then - if (nb_b.eq.1) then - smin_p = smin_p + max(eb,ptb,xptb,0d0) - else - smin_p = smin_p + max(eb,ptb,0d0) - endif + if (nb_b.eq.1) then + smin_p = smin_p + max(eb,ptb,xptb,0d0) else - nb_nocut = nb_nocut +1 - if (nb_b.eq.1) then - smin_p = smin_p + max(xptb,0d0) - endif + smin_p = smin_p + max(eb,ptb,0d0) endif endif enddo if (nb_b.gt.0)then - if ((nb_b-nb_nocut).gt.0) then - smin_m = smin_m + (nb_b-nb_nocut)*(nb_b-nb_nocut-1)/2d0*mmbb**2 - endif - smin = smin + max(smin_p**2, smin_m, (ihtmin**2-htjmin**2)) + smin_m = smin_m + nb_b*(nb_b-1)/2d0*mmbb**2 + smin = smin + max(smin_p**2, smin_m) endif +c inclusive Ht cut (all jets+b, cut_decays not used in cuts.f): sqrt(shat) >= sum pT +c This cannot be attributed to the b-block alone since it constrains HTj+HTb. + smin = max(smin, max(ihtmin,0d0)**2) c check for the photon +c pta/ea only apply to the photons with do_cuts, xpta to all of them smin_m = 0d0 smin_p = 0d0 nb_a = 0 @@ -619,24 +616,17 @@ SUBROUTINE SETCUTS do i=nincoming+1,nexternal if (is_a_a(i))then nb_a = nb_a + 1 - if (do_cuts(i))then - if (ptgmin.eq.0d0) then - if (nb_a.eq.1) then - smin_p = smin_p + max(ea,pta,xpta,0d0) - else - smin_p = smin_p + max(ea,pta,0d0) - endif - endif - else - nb_nocut = nb_nocut + 1 - if(ptgmin.eq.0d0)then - if (nb_a.eq.1) then - smin_p = smin_p + max(xpta,0d0) - endif - endif - endif + if (.not.do_cuts(i)) nb_nocut = nb_nocut + 1 endif enddo + if (ptgmin.eq.0d0) then + do k=1,nb_a + ptk = 0d0 + if (k.eq.1) ptk = xpta + if (k.le.nb_a-nb_nocut) ptk = max(ptk, ea, pta) + smin_p = smin_p + max(ptk, 0d0) + enddo + endif if (nb_a.gt.0) then if ((nb_a-nb_nocut).gt.0)then smin_m = (nb_a-nb_nocut)*(nb_a-nb_nocut-1)/2d0*mmaa**2 @@ -644,47 +634,49 @@ SUBROUTINE SETCUTS smin = smin + max(smin_p**2, smin_m) endif c check for lepton +c ptl/el only apply to the leptons with do_cuts, ptlNmin and xptl to all +c the leptons (ordered in pT): same bound as for the jets. +c mmll only applies to same-flavour opposite-sign pairs with do_cuts, +c ptllmin only if such a pair (or a lepton/neutrino pair) exists and +c mmnl only for exactly two leptons/neutrinos (see above). smin_m = 0d0 smin_p = 0d0 nb_l = 0 nb_nocut = 0 - do i=nincoming+1,nexternal-1 + nb_pair = 0 + ncheck = 0 + has_ptll = .false. + do i=nincoming+1,nexternal + if (is_a_l(i).or.is_a_nu(i)) ncheck = ncheck + 1 if (is_a_l(i))then nb_l = nb_l + 1 smin_m = smin_m - pmass(i)**2 - if (do_cuts(i))then - if (nb_l.eq.1) then - smin_p = smin_p + max(el,ptl,xptl,0d0, - & max(ptl1min,ptl2min,ptl3min,ptl4min)) - elseif(nb_l.eq.2) then - smin_p = smin_p + max(el,ptl,0d0,max(ptl2min,ptl3min,ptl4min)) - elseif(nb_l.eq.3) then - smin_p = smin_p + max(el,ptl,0d0, max(ptl3min,ptl4min)) - elseif(nb_l.eq.4) then - smin_p = smin_p + max(el,ptl,ptl4min,0d0) - else - smin_p = smin_p + max(el,ptl,0d0) - endif - else - nb_nocut = nb_nocut + 1 - if (nb_l.eq.1) then - smin_p = smin_p + max(xptl,0d0, - & max(ptl1min,ptl2min,ptl3min,ptl4min)) - elseif(nb_l.eq.2) then - smin_p = smin_p + max(0d0,ptl2min,ptl3min,ptl4min) - elseif(nb_l.eq.3) then - smin_p = smin_p + max(0d0,ptl3min,ptl4min) - elseif(nb_l.eq.4) then - smin_p = smin_p + max(ptl4min,0d0) - endif - endif + if (.not.do_cuts(i)) nb_nocut = nb_nocut + 1 endif + do j=i+1,nexternal + if (ptll_min(j,i).gt.0d0) has_ptll = .true. + if (is_a_l(i).and.is_a_l(j).and.do_cuts(i).and.do_cuts(j) + & .and.abs(idup(i,1,iproc)).eq.abs(idup(j,1,iproc)) + & .and.idup(i,1,iproc)*idup(j,1,iproc).lt.0) + & nb_pair = nb_pair + 1 + enddo enddo - if (nb_l.gt.0)then - if ((nb_l-nb_nocut).gt.0)then - smin_m = smin_m + (nb_l-nb_nocut)*((nb_l-nb_nocut)-1)/2d0*mmll**2 - endif - smin = smin + max(smin_p**2, smin_m, mmnl**2, ptllmin**2, misset**2) + do k=1,nb_l + ptk = 0d0 + do j=k,4 + ptk = max(ptk, ptlmin4(j)) + enddo + if (k.eq.1) ptk = max(ptk, xptl) + if (k.le.nb_l-nb_nocut) ptk = max(ptk, el, ptl) + smin_p = smin_p + max(ptk, 0d0) + enddo +c this block bounds the energy of the leptons and neutrinos together + if (ncheck.gt.0)then + smin_m = smin_m + nb_pair*max(mmll,0d0)**2 + smin_p = smin_p**2 + if (has_ptll) smin_p = max(smin_p, ptllmin**2) + if (ncheck.eq.2) smin_p = max(smin_p, max(mmnl,0d0)**2) + smin = smin + max(smin_p, smin_m, max(misset,0d0)**2) endif c check for other PDG particle do i = 1,pdg_cut(0) diff --git a/bin/create_release.py b/bin/create_release.py index 6ee832c706..9d5cce9ad6 100755 --- a/bin/create_release.py +++ b/bin/create_release.py @@ -47,6 +47,7 @@ import os import os.path as path import re +import shlex import shutil import subprocess import sys @@ -257,8 +258,16 @@ def make_tarball(workdir, filepath, output_dir, version): os.makedirs(output_dir, exist_ok=True) tarname = pjoin(output_dir, f"MG7_v{version}.tar.gz") - subprocess.run(['tar', 'czf', tarname, '-C', workdir, path.basename(filepath)], - check=True) + # Do not ship macOS metadata (xattrs such as com.apple.provenance, ACLs, + # AppleDouble ._ files, generated or already on disk): GNU tar on linux + # warns about every such entry. + tar_env = dict(os.environ, COPYFILE_DISABLE='1') + tar_options = ['--no-xattrs', '--no-acls', '--exclude=._*'] + if b'bsdtar' in subprocess.check_output(['tar', '--version']): + tar_options += ['--no-mac-metadata', '--no-fflags'] + subprocess.run(['tar'] + tar_options + + ['-czf', tarname, '-C', workdir, path.basename(filepath)], + check=True, env=tar_env) return tarname diff --git a/madgraph/iolibs/template_files/auto_dsig_v4.inc b/madgraph/iolibs/template_files/auto_dsig_v4.inc index 1b7cb1e3be..3c86ecb866 100644 --- a/madgraph/iolibs/template_files/auto_dsig_v4.inc +++ b/madgraph/iolibs/template_files/auto_dsig_v4.inc @@ -143,10 +143,11 @@ C Set up process information from file symfact NFACT=IFACT ENDIF ENDDO - DSIG%(proc_id)s = NFACT 10 CLOSE(LUN) + DSIG%(proc_id)s = NFACT RETURN 20 WRITE(*,*)'Error opening symfact.dat. No symmetry factor used.' + DSIG%(proc_id)s = NFACT RETURN ENDIF C Continue only if IMODE is 0, 4 or 5 diff --git a/madgraph/iolibs/template_files/loop/loop_matrix_standalone.inc b/madgraph/iolibs/template_files/loop/loop_matrix_standalone.inc index 7ff65454cc..3a4d50fe5c 100644 --- a/madgraph/iolibs/template_files/loop/loop_matrix_standalone.inc +++ b/madgraph/iolibs/template_files/loop/loop_matrix_standalone.inc @@ -509,9 +509,11 @@ OPEN(1, FILE=LoopFilterFN, err=100, status='OLD', action='READ') GOTO 101 100 CONTINUE FOUNDLOOPFILTER=.FALSE. +C Keep all loop amplitudes for 2>1 and 1>2 processes: this filter +C stores zeros per helicity, which can depend on the frame too. DO J=1,NCOMB DO I=NCTAMPS+1,NLOOPAMPS - GOODAMP(I,J)=(.NOT.USELOOPFILTER) + GOODAMP(I,J)=(.NOT.USELOOPFILTER).OR.(NEXTERNAL.LE.3) ENDDO ENDDO 101 CONTINUE diff --git a/madgraph/iolibs/template_files/matrix_loop_induced_madevent.inc b/madgraph/iolibs/template_files/matrix_loop_induced_madevent.inc index 8feeb10380..cc4dc3024e 100644 --- a/madgraph/iolibs/template_files/matrix_loop_induced_madevent.inc +++ b/madgraph/iolibs/template_files/matrix_loop_induced_madevent.inc @@ -21,6 +21,7 @@ C Include 'maxconfigs.inc' Include 'nexternal.inc' Include 'maxamps.inc' + Include '../../Source/vector.inc' ! defines VECSIZE_MEMMAX (needed by run.inc) include 'run.inc' INTEGER NCOMB PARAMETER ( NCOMB=%(ncomb)d) @@ -305,7 +306,8 @@ c Include the Jacobian from helicity sampling ENDIF ENDIF - call select_color(rcol, jamp2, iconfig,%(proc_id)s, icol, ivec) +C no grouping: a single matrix element per directory, so iproc=1 + call select_color(rcol, jamp2, iconfig, 1, icol, ivec) IF (MULTI_CHANNEL) THEN XTOT=0D0 diff --git a/madgraph/loop/loop_exporters.py b/madgraph/loop/loop_exporters.py index 6040a189e0..6a457d07c4 100755 --- a/madgraph/loop/loop_exporters.py +++ b/madgraph/loop/loop_exporters.py @@ -4160,11 +4160,15 @@ def finalize(self, *args, **opts): # care of MadLoop virtuals initialization LoopInducedExporterME.finalize(self, *args, **opts) - def generate_subprocess_directory(self, matrix_element, fortran_model, me_number): + def generate_subprocess_directory(self, matrix_element, fortran_model, me_number, + second_exporter=None, second_helas=None): """Generate the Pn directory for a subprocess group in MadEvent, including the necessary matrix_N.f files, configs.inc and various other helper files""" - + # export_processes always forwards these; no second exporter is + # supported for the loop-induced output (same as the grouped case) + assert second_exporter is None + self.unique_id += 1 # Then generate the MadLoop files calls = self.generate_loop_subprocess(matrix_element,fortran_model, diff --git a/madgraph/various/banner.py b/madgraph/various/banner.py index 95d965adc0..0c26e9a0c1 100644 --- a/madgraph/various/banner.py +++ b/madgraph/various/banner.py @@ -4046,6 +4046,10 @@ def write_include_file(self, output_dir, output_file=None): for incname in self.includepath: self.write_one_include_file(output_dir, incname, output_file) + # directory of the include files, for the fct_mod functions + # (keep their signature: plugins can overwrite them) + self.include_output_dir = output_dir + self.simd_reset_done = False for name,value in value_in_old_include.items(): if value != self[name]: self.fct_mod[name][0](value, self[name], name, *self.fct_mod[name][1],**self.fct_mod[name][2]) @@ -4615,6 +4619,12 @@ def post_set_pdlabel(card, value, change_userdefine, raiseerror, **opt): def post_set(card, value, change_userdefine, raiseerror, name="unknown", **opt): """call when change to pdlabel1 or pdlabel2 --do not know which one """ + # only a user-defined pdlabel1/2 supersedes pdlabel. Internal + # assignments (e.g. get_default filling a hidden pdlabel1/2 while + # writing run_card.inc) must not drop pdlabel from user_set, otherwise + # the next write takes pdlabel from run_card_default.dat (issue 481) + if name not in card.user_set: + return if 'pdlabel' in card.user_set: card.user_set.remove('pdlabel') @@ -5421,6 +5431,30 @@ def add_citation(self, cite_fn): except Exception: pass + def reset_simd(self, old_value, new_value, name, *args, **opts): + """vector_size/nb_warp changed: VECSIZE_MEMMAX (vector.inc) sets the + size of arrays/common blocks shared by the code of Source and of + SubProcesses, while the makefiles do not track that dependency. + Keeping old object files gives a code mixing both sizes (wrong or zero + cross-section) -> clean the compiled code of Source and of all P*.""" + + if getattr(self, 'simd_reset_done', False): + return + source_dir = getattr(self, 'include_output_dir', None) + if not source_dir or not os.path.exists(pjoin(source_dir, 'makefile')): + return + if 'MAKELEVEL' in os.environ: + # called by make (run_card.inc rule): cleaning would remove the + # object files of the running make + logger.warning('%s changed from %s to %s: run "make clean" in %s ' + 'before compiling again', name, old_value, new_value, + source_dir) + return + logger.info('%s changed from %s to %s: removing the compiled code', + name, old_value, new_value) + misc.compile(['clean'], cwd=source_dir) + self.simd_reset_done = True + def update_system_parameter_for_include(self): """system parameter need to be setupe""" diff --git a/tests/acceptance_tests/test_cmd_madevent.py b/tests/acceptance_tests/test_cmd_madevent.py index 6cdff155b6..00f7f8773a 100755 --- a/tests/acceptance_tests/test_cmd_madevent.py +++ b/tests/acceptance_tests/test_cmd_madevent.py @@ -523,6 +523,97 @@ def test_madevent_ptj_bias(self): 'biased %s +- %s vs unbiased %s' % (biased_events.cross, stat_err, unbiased_events.cross)) + def get_smin(self, processes, cuts): + """generate the processes, run a survey with the given run_card + values and return {process number: set of smin (Define smin to)}""" + + try: + shutil.rmtree(self.run_dir) + except Exception: + pass + interface = MGCmd.MasterCmd() + interface.no_notification() + interface.run_cmd('import model sm') + interface.run_cmd('generate %s' % processes[0]) + for proc in processes[1:]: + interface.run_cmd('add process %s' % proc) + interface.onecmd('output madevent %s -f' % self.run_dir) + + run_card = banner.RunCardLO(pjoin(self.run_dir, 'Cards', 'run_card.dat')) + # no MLM matching (it resets ptj): exact values are checked + for name, value in [('nevents', 100), ('use_syst', False), + ('ickkw', 0), ('xqcut', 0)] + cuts: + run_card.set(name, value, user=True) + run_card.write(pjoin(self.run_dir, 'Cards', 'run_card.dat')) + + self.cmd_line = MECmd.MadEventCmdShell(me_dir=self.run_dir) + self.cmd_line.no_notification() + self.do('survey -f') + + smin = {} + for pdir in os.listdir(pjoin(self.run_dir, 'SubProcesses')): + if not pdir.startswith('P'): + continue + iproc = int(pdir[1:pdir.index('_')]) + for root, _, files_in in os.walk(pjoin(self.run_dir, 'SubProcesses', pdir)): + for name in files_in: + if not name.endswith('.log'): + continue + with open(pjoin(root, name)) as fsock: + for line in fsock: + if 'Define smin to' in line: + smin.setdefault(iproc, set()).add(float(line.split()[-1])) + return smin + + def check_smin(self, smin, expected): + """compare to the expected smin of each process""" + self.assertEqual(sorted(smin), sorted(expected)) + for iproc, values in smin.items(): + for value in values: + self.assertAlmostEqual(value, expected[iproc], delta=1e-6*expected[iproc], + msg='process %s: smin=%s (expected %s)' % (iproc, value, expected[iproc])) + + def test_smin_below_cut_threshold(self): + """ Check the lower bound on shat (smin, setcuts.f): it must never be + above the minimal shat allowed by the cuts (cuts.f), otherwise allowed + phase space is removed, and it should keep the bounds that are safe. + Exact values are checked; the comments give the value of 3.5.17. + A: ihtmin, jets from decays (cut_decays=F) with ptj1min, neutrinos only + with a negative misset. + B: leptons and photons from decays with ptl1min/xpta, misset for + neutrinos only, negative ihtmin/htjmin. + C: mmll (same-flavour opposite-sign only), ptllmin (only with a pair + it applies to), mmnl (exactly two leptons/neutrinos), negative misset. + """ + + # A: ptj1min=160 on top of ptj=150, ihtmin=300 + smin = self.get_smin(['p p > b b~ j', 'p p > w+ j j, w+ > j j', + 'p p > z j, z > vl vl~'], + [('cut_decays', False), ('ptj', 150), ('ptj1min', 160), + ('ptb', 20), ('etab', -1), ('drbb', 0), ('drbj', 0), + ('ihtmin', 300), ('misset', -500)]) + self.check_smin(smin, {1: 300.**2, # 3.5.17: 160^2+300^2 (allowed at ~320^2) + 2: 310.**2, # 3.5.17: 460^2 (allowed at ~390^2) + 3: 300.**2}) # 3.5.17: 160^2 (ihtmin ignored) + + # B: ptl1min=160 on top of ptl=150, xpta=100 on top of pta=50 + smin = self.get_smin(['p p > w+ e+ e- j, w+ > mu+ vm', 'p p > z j, z > vl vl~', + 'p p > w+ a, w+ > e+ ve a'], + [('cut_decays', False), ('ptl', 150), ('ptl1min', 160), + ('pta', 50), ('xpta', 100), ('misset', 30), + ('ihtmin', -500), ('htjmin', -500)]) + self.check_smin(smin, {1: 20.**2 + 310.**2, # 3.5.17: 500^2+20^2+460^2 + 2: 20.**2 + 30.**2, # 3.5.17: 500^2 (no neutrino block) + 3: 100.**2 + 160.**2}) # 3.5.17: 150^2+160^2 + + # C: pair cuts + smin = self.get_smin(['p p > e+ ve mu- vm~', 'p p > e+ ve', 'p p > e+ e-'], + [('ptl', 10), ('mmll', 300), ('ptllmin', 200), + ('mmnl', 250), ('misset', -500)]) + self.check_smin(smin, {1: 200.**2, # 3.5.17: 500^2 + 2: 250.**2, # 3.5.17: 500^2 + 3: 300.**2}) # 3.5.17: 500^2 + def test_madspin_gridpack(self): self.out_dir = self.run_dir @@ -4535,6 +4626,31 @@ def test_loop_induced_ggh(self): # previously PDF was nn23lo1 (lhaid 230000) with this reference value cross=15.73, error=0.04 self.check_parton_output(cross=12.18, error=0.514) + def test_loop_induced_ggh_nogroup(self): + """Same as test_loop_induced_ggh but with group_subprocesses=False, + i.e. through LoopInducedExporterMENoGroup (issue #486: the output + crashed on the second_exporter keyword)""" + + cmd = MGCmd.MasterCmd() + cmd.no_notification() + cmd.run_cmd('set automatic_html_opening False --no_save') + cmd.run_cmd('set group_subprocesses False --no_save') + cmd.run_cmd('generate g g > h QCD=0 [QCD]') + cmd.run_cmd('output madevent %s -f' % self.run_dir) + self.assertTrue(os.path.isdir(pjoin(self.run_dir, 'SubProcesses', + 'P0_gg_h'))) + #modify the run_card + run_card = banner.RunCardLO(pjoin(self.run_dir, 'Cards','run_card.dat')) + run_card['nevents'] = 100 + run_card['use_syst'] = 'F' + run_card.write('%s/Cards/run_card.dat'% self.run_dir, + '%s/Cards/run_card_default.dat'% self.run_dir) + + cmd.run_cmd('launch -f') + + # same reference as test_loop_induced_ggh (default PDF of MadGraph7) + self.check_parton_output(cross=12.18, error=0.514) + def _get_delphes_path(self): """Return the configured delphes_path from the MG5 configuration, or None when Delphes is not configured (used to skip the parallel-Delphes diff --git a/tests/acceptance_tests/test_cmd_madloop.py b/tests/acceptance_tests/test_cmd_madloop.py index 4be7714b52..9777d8dd22 100755 --- a/tests/acceptance_tests/test_cmd_madloop.py +++ b/tests/acceptance_tests/test_cmd_madloop.py @@ -25,6 +25,8 @@ import sys import logging import time +import contextlib +from unittest import mock import tests.IOTests as IOTests logger = logging.getLogger('test_cmd') @@ -35,6 +37,8 @@ import madgraph.interface.launch_ext_program as launch_ext import madgraph.various.misc as misc import madgraph.core.color_amp as color_amp +import madgraph.loop.loop_exporters as loop_exporters +import madgraph.various.banner as banner import tests.IOTests as IOTests import madgraph.various.lhe_parser as lhe_parser @@ -424,6 +428,72 @@ def test_loop_nc_memo_not_poisoned_across_generations(self): for f in coloramps: self.assertIn('ICOLAMP', open(f).read()) + def test_ML_loop_filter_survives_a_boost(self): + """A loop amplitude vanishing for a W at rest need not vanish in + another frame, even when the main helicity filter is disabled. + """ + with tempfile.TemporaryDirectory(prefix='madloop_frame_') as tmpdir: + output_dir = pjoin(tmpdir, 'MLProcess') + for command in ('set loop_optimized_output False --no_save', + 'import model loop_sm', + 'generate u d~ > w+ [virt=QCD]', + 'output %s -f' % output_dir): + self.interface.exec_cmd(command, errorhandling=False, + printcmd=False, precmd=True, postcmd=True) + + proc_dir = pjoin(output_dir, 'SubProcesses', 'P0_udx_wp') + resources = pjoin(output_dir, 'SubProcesses', 'MadLoop5_resources') + with open(pjoin(proc_dir, 'proc_prefix.txt')) as stream: + prefix = stream.read().strip() + with open(pjoin(_pickle_path, 'madloop_loop_filter_frame_driver.f')) as stream: + driver = stream.read().replace('__PFX__', prefix) + # Use the generated makefile to link the driver with the same model, + # helicity amplitudes and reduction library as the standalone check. + with open(pjoin(proc_dir, 'check_sa.f'), 'w') as stream: + stream.write(driver) + for directory, command in ( + (pjoin(output_dir, 'Source'), ['make', 'libdhelas', 'libmodel']), + (proc_dir, ['make', 'check'])): + build = subprocess.run(command, cwd=directory, + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + self.assertEqual(build.returncode, 0, build.stdout.decode()) + + card_path = pjoin(output_dir, 'Cards', 'MadLoopParams.dat') + card = banner.MadLoopParam(card_path) + card['UseLoopFilter'] = True + card['MLReductionLib'] = '1' + card['CheckCycle'] = 3 + # Test the loop filter independently of the main helicity filter: + # a guard nested inside HelicityFilterLevel != 0 misses level zero. + for level in (0, 2): + with self.subTest(HelicityFilterLevel=level): + card['HelicityFilterLevel'] = level + card.write(card_path) + for name in ('HelFilter.dat', 'LoopFilter.dat'): + filename = pjoin(resources, prefix + name) + if os.path.exists(filename): + os.remove(filename) + run = subprocess.run([pjoin(proc_dir, 'check')], cwd=proc_dir, + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + out = run.stdout.decode() + self.assertEqual(run.returncode, 0, out) + results = [line.split() for line in out.splitlines() + if line.startswith('RESULT ')] + self.assertEqual(len(results), 1, out) + values = [float(value) for value in results[0][1:]] + self.assertEqual(len(values), 6, out) + filtered, unfiltered = values[:3], values[3:] + self.assertNotEqual(unfiltered[0], 0., out) + for actual, expected in zip(filtered, unfiltered): + self.assertLess(abs(actual - expected), + 1e-10 * abs(expected), out) + # MadLoop's Python initializer still requires this file + # when the card requested filtering but all loops are kept. + with open(pjoin(resources, prefix + 'LoopFilter.dat')) as stream: + loop_filter = stream.read().split() + self.assertTrue(loop_filter) + self.assertEqual(set(loop_filter), {'T'}) + def test_ML_check_full_epem_ttx(self): """ Test that check full e+ e- > t t~ works fine """ @@ -1427,6 +1497,33 @@ def test_density_mode_vs_standalone_LI1(self): self.assertAlmostEqual(density_check[j].imag, rho_standalone[j].imag, places=7) +# Tensor Integral Reduction libraries considered as installed by the IOTests +# below. Which of them are available changes the generated code +# (LOOPLIBS_AVAILABLE, the NINJA/COLLIER interfaces, QP_NLOOPLIB), so the +# reference files must not depend on what is installed on the machine +# running the test. +IOTEST_TIR_AVAILABLE = ['iregi', 'ninja', 'collier'] +IOTEST_NINJA_QUAD_PREC = True + +@contextlib.contextmanager +def pinned_tir_libraries(available=IOTEST_TIR_AVAILABLE, + ninja_quad_prec=IOTEST_NINJA_QUAD_PREC): + """Generate the loop output as if exactly the TIR libraries in + 'available' were installed (ninja with quadruple precision support if + ninja_quad_prec), without looking for, installing or compiling any of + them. Only usable for tests that do not compile the output.""" + + def link_TIR(self, targetPath, libpath, libname, tir_name='TIR'): + self.tir_available_dict[tir_name] = tir_name in available + return '' + + with mock.patch.object(loop_exporters.LoopProcessOptimizedExporterFortranSA, + 'link_TIR', link_TIR), \ + mock.patch.object(misc, 'get_ninja_quad_prec_support', + lambda ninja_lib_path: ninja_quad_prec): + yield + + class TestCmdMatchBox(IOTests.IOTestManager): def setUp(self): @@ -1438,13 +1535,6 @@ def setUp(self): # first the handlers and second the level. self.logger_saved_info = {} - # Select the Tensor Integral to include in the test - misc.deactivate_dependence('pjfry', cmd = self.interface, log='stdout') - misc.deactivate_dependence('samurai', cmd = self.interface, log='stdout') - misc.deactivate_dependence('golem', cmd = self.interface, log='stdout') - misc.activate_dependence('ninja', cmd = self.interface, log='stdout',MG5dir=MG5DIR) - misc.activate_dependence('collier', cmd = self.interface, log='stdout',MG5dir=MG5DIR) - @IOTests.createIOTest() def testIO_MatchBoxOutput(self): r""" target: TEST/SubProcesses/P1_uux_uux/[.+\.(inc|f)] @@ -1460,8 +1550,10 @@ def testIO_MatchBoxOutput(self): output matchbox %(path)s/TEST -f """ % {'path': self.IOpath} - for line in cmd.split('\n'): - self.interface.exec_cmd(line) + # the Tensor Integral libraries are fixed (see pinned_tir_libraries) + with pinned_tir_libraries(): + for line in cmd.split('\n'): + self.interface.exec_cmd(line) #=============================================================================== @@ -1481,17 +1573,10 @@ def run_cmd(cmd): interface.exec_cmd(cmd, errorhandling=False, printcmd=False, precmd=True, postcmd=True) - # Select the Tensor Integral to include in the test - misc.deactivate_dependence('pjfry', cmd = interface, log='stdout') - misc.deactivate_dependence('samurai', cmd = interface, log='stdout') - misc.deactivate_dependence('golem', cmd = interface, log='stdout') - misc.activate_dependence('ninja', cmd = interface, log='stdout',MG5dir=MG5DIR) - - # The reference includes COLLIER interfaces on every runner. - misc.activate_dependence('collier', cmd = interface, log='stdout',MG5dir=MG5DIR) - - run_cmd('generate g g > t t~ [virt=QCD]') - interface.onecmd('output %s -f' % str(pjoin(self.IOpath,'ggttx_IOTest'))) + # the Tensor Integral libraries are fixed (see pinned_tir_libraries) + with pinned_tir_libraries(): + run_cmd('generate g g > t t~ [virt=QCD]') + interface.onecmd('output %s -f' % str(pjoin(self.IOpath,'ggttx_IOTest'))) #remove some function from some file: IOTests.IOTest.remove_f77_function_from_file( diff --git a/tests/input_files/IOTestsComparison/IOExportV4IOTest/export_matrix_element_v4_madevent_group/auto_dsig.f b/tests/input_files/IOTestsComparison/IOExportV4IOTest/export_matrix_element_v4_madevent_group/auto_dsig.f index 474401a300..86fdbbf1db 100644 --- a/tests/input_files/IOTestsComparison/IOExportV4IOTest/export_matrix_element_v4_madevent_group/auto_dsig.f +++ b/tests/input_files/IOTestsComparison/IOExportV4IOTest/export_matrix_element_v4_madevent_group/auto_dsig.f @@ -154,10 +154,11 @@ DOUBLE PRECISION FUNCTION DSIG1(PP,IFLAV,WGT,IMODE) NFACT=IFACT ENDIF ENDDO - DSIG1 = NFACT 10 CLOSE(LUN) + DSIG1 = NFACT RETURN 20 WRITE(*,*)'Error opening symfact.dat. No symmetry factor used.' + DSIG1 = NFACT RETURN ENDIF C Continue only if IMODE is 0, 4 or 5 @@ -695,6 +696,7 @@ DOUBLE PRECISION FUNCTION DSIG1_VEC(ALL_PP, ALL_XBK, ALL_Q2FACT, + SUBROUTINE PRINT_ZERO_AMP1() RETURN diff --git a/tests/input_files/IOTestsComparison/IOExportV4IOTest/export_matrix_element_v4_madevent_nogroup/auto_dsig.f b/tests/input_files/IOTestsComparison/IOExportV4IOTest/export_matrix_element_v4_madevent_nogroup/auto_dsig.f index 9785d27784..d3929dcbaa 100644 --- a/tests/input_files/IOTestsComparison/IOExportV4IOTest/export_matrix_element_v4_madevent_nogroup/auto_dsig.f +++ b/tests/input_files/IOTestsComparison/IOExportV4IOTest/export_matrix_element_v4_madevent_nogroup/auto_dsig.f @@ -153,10 +153,11 @@ DOUBLE PRECISION FUNCTION DSIG(PP,IFLAV,WGT,IMODE) NFACT=IFACT ENDIF ENDDO - DSIG = NFACT 10 CLOSE(LUN) + DSIG = NFACT RETURN 20 WRITE(*,*)'Error opening symfact.dat. No symmetry factor used.' + DSIG = NFACT RETURN ENDIF C Continue only if IMODE is 0, 4 or 5 diff --git a/tests/input_files/IOTestsComparison/long_ML_SMQCD_default/dux_mumvmxg/loop_matrix.f b/tests/input_files/IOTestsComparison/long_ML_SMQCD_default/dux_mumvmxg/loop_matrix.f index ccbe83e0ae..67019f1b59 100644 --- a/tests/input_files/IOTestsComparison/long_ML_SMQCD_default/dux_mumvmxg/loop_matrix.f +++ b/tests/input_files/IOTestsComparison/long_ML_SMQCD_default/dux_mumvmxg/loop_matrix.f @@ -569,9 +569,11 @@ SUBROUTINE ML5_0_SLOOPMATRIX(P_USER,ANSRETURNED) GOTO 101 100 CONTINUE FOUNDLOOPFILTER=.FALSE. +C Keep all loop amplitudes for 2>1 and 1>2 processes: this filter +C stores zeros per helicity, which can depend on the frame too. DO J=1,NCOMB DO I=NCTAMPS+1,NLOOPAMPS - GOODAMP(I,J)=(.NOT.USELOOPFILTER) + GOODAMP(I,J)=(.NOT.USELOOPFILTER).OR.(NEXTERNAL.LE.3) ENDDO ENDDO 101 CONTINUE diff --git a/tests/input_files/IOTestsComparison/long_ML_SMQCD_default/gg_wmtbx/loop_matrix.f b/tests/input_files/IOTestsComparison/long_ML_SMQCD_default/gg_wmtbx/loop_matrix.f index 6a07ffa6b0..5783cafcfd 100644 --- a/tests/input_files/IOTestsComparison/long_ML_SMQCD_default/gg_wmtbx/loop_matrix.f +++ b/tests/input_files/IOTestsComparison/long_ML_SMQCD_default/gg_wmtbx/loop_matrix.f @@ -569,9 +569,11 @@ SUBROUTINE ML5_0_SLOOPMATRIX(P_USER,ANSRETURNED) GOTO 101 100 CONTINUE FOUNDLOOPFILTER=.FALSE. +C Keep all loop amplitudes for 2>1 and 1>2 processes: this filter +C stores zeros per helicity, which can depend on the frame too. DO J=1,NCOMB DO I=NCTAMPS+1,NLOOPAMPS - GOODAMP(I,J)=(.NOT.USELOOPFILTER) + GOODAMP(I,J)=(.NOT.USELOOPFILTER).OR.(NEXTERNAL.LE.3) ENDDO ENDDO 101 CONTINUE diff --git a/tests/input_files/IOTestsComparison/short_ML_SMQCD_LoopInduced/gg_hh/loop_matrix.f b/tests/input_files/IOTestsComparison/short_ML_SMQCD_LoopInduced/gg_hh/loop_matrix.f index 965040c531..f7dd955d7d 100644 --- a/tests/input_files/IOTestsComparison/short_ML_SMQCD_LoopInduced/gg_hh/loop_matrix.f +++ b/tests/input_files/IOTestsComparison/short_ML_SMQCD_LoopInduced/gg_hh/loop_matrix.f @@ -566,9 +566,11 @@ SUBROUTINE ML5_0_SLOOPMATRIX(P_USER,ANSRETURNED) GOTO 101 100 CONTINUE FOUNDLOOPFILTER=.FALSE. +C Keep all loop amplitudes for 2>1 and 1>2 processes: this filter +C stores zeros per helicity, which can depend on the frame too. DO J=1,NCOMB DO I=NCTAMPS+1,NLOOPAMPS - GOODAMP(I,J)=(.NOT.USELOOPFILTER) + GOODAMP(I,J)=(.NOT.USELOOPFILTER).OR.(NEXTERNAL.LE.3) ENDDO ENDDO 101 CONTINUE diff --git a/tests/input_files/IOTestsComparison/short_ML_SMQCD_default/ddx_ttx/loop_matrix.f b/tests/input_files/IOTestsComparison/short_ML_SMQCD_default/ddx_ttx/loop_matrix.f index 91c66fe1ba..fa7fafa74f 100644 --- a/tests/input_files/IOTestsComparison/short_ML_SMQCD_default/ddx_ttx/loop_matrix.f +++ b/tests/input_files/IOTestsComparison/short_ML_SMQCD_default/ddx_ttx/loop_matrix.f @@ -568,9 +568,11 @@ SUBROUTINE ML5_0_SLOOPMATRIX(P_USER,ANSRETURNED) GOTO 101 100 CONTINUE FOUNDLOOPFILTER=.FALSE. +C Keep all loop amplitudes for 2>1 and 1>2 processes: this filter +C stores zeros per helicity, which can depend on the frame too. DO J=1,NCOMB DO I=NCTAMPS+1,NLOOPAMPS - GOODAMP(I,J)=(.NOT.USELOOPFILTER) + GOODAMP(I,J)=(.NOT.USELOOPFILTER).OR.(NEXTERNAL.LE.3) ENDDO ENDDO 101 CONTINUE diff --git a/tests/input_files/IOTestsComparison/short_ML_SMQCD_default/gg_ttx/loop_matrix.f b/tests/input_files/IOTestsComparison/short_ML_SMQCD_default/gg_ttx/loop_matrix.f index 58c12fcc98..6f84cc4546 100644 --- a/tests/input_files/IOTestsComparison/short_ML_SMQCD_default/gg_ttx/loop_matrix.f +++ b/tests/input_files/IOTestsComparison/short_ML_SMQCD_default/gg_ttx/loop_matrix.f @@ -568,9 +568,11 @@ SUBROUTINE ML5_0_SLOOPMATRIX(P_USER,ANSRETURNED) GOTO 101 100 CONTINUE FOUNDLOOPFILTER=.FALSE. +C Keep all loop amplitudes for 2>1 and 1>2 processes: this filter +C stores zeros per helicity, which can depend on the frame too. DO J=1,NCOMB DO I=NCTAMPS+1,NLOOPAMPS - GOODAMP(I,J)=(.NOT.USELOOPFILTER) + GOODAMP(I,J)=(.NOT.USELOOPFILTER).OR.(NEXTERNAL.LE.3) ENDDO ENDDO 101 CONTINUE diff --git a/tests/input_files/madloop_loop_filter_frame_driver.f b/tests/input_files/madloop_loop_filter_frame_driver.f new file mode 100644 index 0000000000..fb99e20a23 --- /dev/null +++ b/tests/input_files/madloop_loop_filter_frame_driver.f @@ -0,0 +1,41 @@ + PROGRAM MADLOOP_LOOP_FILTER_FRAME +C Learn filters with the W at rest, then compare a rotated and +C boosted event against an evaluation bypassing all filters. + IMPLICIT NONE + INCLUDE 'coupl.inc' + INCLUDE 'nsquaredSO.inc' + REAL*8 P(0:3,3),Q(0:3,3),RESULT(0:3,0:NSQUAREDSO) + REAL*8 REFERENCE(0:3,0:NSQUAREDSO),ACC(0:NSQUAREDSO) + REAL*8 CA,SA,BZ,GZ,PY,PZ,TOL + INTEGER I,K,RET + LOGICAL BYPASS,ALWAYS + COMMON/__PFX__BYPASS_CHECK/BYPASS,ALWAYS + CALL SETPARA('../MadLoop5_resources/param_card.dat') + P=0D0 + P(0,1)=MDL_MW/2D0 + P(3,1)=MDL_MW/2D0 + P(0,2)=MDL_MW/2D0 + P(3,2)=-MDL_MW/2D0 + P(0,3)=MDL_MW + TOL=1D-7 + DO K=1,7 + CALL __PFX__SLOOPMATRIX_THRES(P,RESULT,TOL,ACC,RET) + ENDDO + CA=COS(1D0) + SA=SIN(1D0) + BZ=0.5D0 + GZ=1D0/SQRT(1D0-BZ**2) + DO I=1,3 + PY=CA*P(2,I)-SA*P(3,I) + PZ=SA*P(2,I)+CA*P(3,I) + Q(0,I)=GZ*(P(0,I)+BZ*PZ) + Q(1,I)=P(1,I) + Q(2,I)=PY + Q(3,I)=GZ*(PZ+BZ*P(0,I)) + ENDDO + CALL __PFX__SLOOPMATRIX_THRES(Q,RESULT,TOL,ACC,RET) + BYPASS=.TRUE. + CALL __PFX__SLOOPMATRIX_THRES(Q,REFERENCE,TOL,ACC,RET) + WRITE(*,'(A,6E25.16)') 'RESULT ',RESULT(1:3,0), + $ REFERENCE(1:3,0) + END diff --git a/tests/parallel_tests/test_madspin_factory.py b/tests/parallel_tests/test_madspin_factory.py index 088a0754a9..d61f143379 100644 --- a/tests/parallel_tests/test_madspin_factory.py +++ b/tests/parallel_tests/test_madspin_factory.py @@ -446,6 +446,20 @@ def test_short_madspin_multicore(self): # signal (see below) 0.2126 0.0334 0.0014 # signal / replica sd 8.2 1.2 0.1 # +# Recalibration: the 8 degrees of freedom above under-estimated the scatter (the +# joint_replica control failed m(l+ vl) at 0.112 GeV against a 0.110 tolerance, +# 2.6 sigma of the runs' own errors). Two campaigns of 16 joint replicas +# (seeds 42-57) off one 5000-event production sample each, one with the code of +# PR #466 and one with its base -- they agree within their errors, so the +# three campaigns are pooled (38 degrees of freedom): +# +# m(l+ vl b) m(l+ vl) dphi(l+,l-) +# replica sd (PR #466) 0.0411 0.0495 0.0077 +# replica sd (base) 0.0398 0.0416 0.0124 +# replica sd (pooled) 0.0379 0.0425 0.0114 +# naive per-run error 0.0318 0.0434 0.0128 +# signal / replica sd 5.6 0.8 0.1 +# # The *signal* is the bias this test exists to catch. The PR #334 bug made the # offshell scheme sample the PA/Breit-Wigner lineshape instead of the offshell # one, so a PA run off the same production sample reproduces it: the row above @@ -455,7 +469,7 @@ def test_short_madspin_multicore(self): # Three things fall out, and they are the whole design of the test: # # 1. **Only the lineshape can see it.** m(l+ vl) and dphi(l+,l-) have a -# signal-to-noise of 1.2 and 0.1 -- they would not have moved measurably had +# signal-to-noise of 0.8 and 0.1 -- they would not have moved measurably had # the bug still been there. They are asserted below as no-regression checks # and must not be read as standing in for the lineshape. # @@ -470,19 +484,19 @@ def test_short_madspin_multicore(self): # The plan document's two-replica estimate had joint scattering by 0.005 # against a naive error of 0.023, suggesting the runs were strongly # correlated through the shared production events and the naive error was 4x -# too loose. Over nine replicas the ratio of replica sd to naive error is -# 0.82 (lineshape), 0.65 (W mass) and 1.14 (dphi): mildly correlated at -# most. The 0.005 was a small-sample fluctuation. The tolerances below are -# therefore built on the measured replica sd, which is the thing the test -# actually has to survive. +# too loose. Over the 41 replicas the ratio of pooled replica sd to naive +# error is 1.19 (lineshape), 0.98 (W mass) and 0.89 (dphi): no sign of a +# correlation that would shrink it. The 0.005 was a small-sample +# fluctuation. The tolerances below are therefore built on the measured +# replica sd, which is the thing the test actually has to survive. LINESHAPE_CALIB_NEVENTS = 5000 -# Replica sd (GeV, GeV, rad) at LINESHAPE_CALIB_NEVENTS, from the table above. -CALIB_SD = {'lineshape': 0.0261, 'w_mass': 0.0275, 'dphi': 0.0146} +# Replica sd (GeV, GeV, rad) at LINESHAPE_CALIB_NEVENTS, pooled recalibration. +CALIB_SD = {'lineshape': 0.0379, 'w_mass': 0.0425, 'dphi': 0.0114} # Two runs differ by sqrt(2) times a single run's scatter, and 4 sigma of that # leaves a per-comparison false-positive rate around 6e-5 -- with four # comparisons per test, a flake roughly once in four thousand runs. Even if the -# sd above is underestimated by the ~25% its 8 degrees of freedom allow, that -# only relaxes to 3.2 sigma. +# sd above is underestimated by the ~12% its 38 degrees of freedom allow, that +# only relaxes to 3.6 sigma. CALIB_NSIGMA = 4.0 # Measured offshell-minus-PA on the lineshape: the size of the bias to catch. LINESHAPE_SIGNAL = 0.213 @@ -655,7 +669,7 @@ def test_long_madspin_unweighting_consistency(self): **The reconstructed resonance lineshape is that observable.** ``m(l+ vl b)`` -- the top reconstructed from its decay products -- is what the original bug shifted by 0.25 GeV, and the calibration above measures its - signal-to-noise at 8.2 against 1.2 for ``m(l+ vl)`` and 0.1 for + signal-to-noise at 5.6 against 0.8 for ``m(l+ vl)`` and 0.1 for ``dphi(l+, l-)``. The other two are asserted as no-regression checks and nothing more: at those ratios they would not have moved measurably even with the bug still in place, so they must never be read as standing in @@ -731,7 +745,7 @@ def test_long_madspin_unweighting_consistency(self): assert_observable_consistent( self, lineshape, lineshape_tol, 'm(l+ vl b) [GeV]', reference='joint') - # No-regression only (S/N 1.2 and 0.1 against this class of bug). + # No-regression only (S/N 0.8 and 0.1 against this class of bug). assert_observable_consistent( self, w_mass, _consistency_tolerance('w_mass', NEVENTS), 'm(l+ vl) [GeV] (no-regression only, blind to the lineshape bias)', diff --git a/tests/unit_tests/various/test_banner.py b/tests/unit_tests/various/test_banner.py index 15da8525cc..7c5f264e9b 100755 --- a/tests/unit_tests/various/test_banner.py +++ b/tests/unit_tests/various/test_banner.py @@ -19,6 +19,7 @@ import copy import json import shutil +from unittest import mock import tempfile import madgraph.various.banner as bannermod import madgraph.various.misc as misc @@ -3988,6 +3989,40 @@ def test_no_process_no_histograms(self): self.assertEqual(dict(rc['histograms']), {}) +class TestRunCardLOResetSimd(unittest.TestCase): + """RunCardLO.reset_simd""" + + def test_reset_simd_cleans_compiled_code(self): + """changing vector_size/nb_warp must remove the compiled code + (VECSIZE_MEMMAX is shared by Source and SubProcesses but not + tracked by the makefiles)""" + + source_dir = tempfile.mkdtemp(prefix='mg_simd_') + try: + with open(pjoin(source_dir, 'makefile'), 'w') as fsock: + fsock.write('clean:\n\techo cleaned >> clean_calls\n') + marker = pjoin(source_dir, 'clean_calls') + run_card = bannermod.RunCardLO() + run_card.include_output_dir = source_dir + run_card.simd_reset_done = False + + env = dict(os.environ) + env.pop('MAKELEVEL', None) + # called from make (run_card.inc rule): no clean + env_make = dict(env, MAKELEVEL='1') + with mock.patch.dict(os.environ, env_make, clear=True): + run_card.reset_simd(1, 16, 'vector_size') + self.assertFalse(os.path.exists(marker)) + + with mock.patch.dict(os.environ, env, clear=True): + run_card.reset_simd(1, 16, 'vector_size') + # nb_warp changed in the same write: a single clean + run_card.reset_simd(1, 2, 'nb_warp') + with open(marker) as fsock: + self.assertEqual(fsock.read().split(), ['cleaned']) + finally: + shutil.rmtree(source_dir) + MadLoopParam = bannermod.MadLoopParam class TestMadLoopParam(unittest.TestCase): """ A class to test the MadLoopParam functionality """