Skip to content

Fix stale flavortag on shared wavefunctions in HelasDiagram.check_flavor#18

Open
oliviermattelaer wants to merge 2 commits into
mainfrom
fix_flavortag2
Open

Fix stale flavortag on shared wavefunctions in HelasDiagram.check_flavor#18
oliviermattelaer wants to merge 2 commits into
mainfrom
fix_flavortag2

Conversation

@oliviermattelaer

Copy link
Copy Markdown
Contributor

HelasDiagram.check_flavor only cleared the flavortag attribute on the wavefunctions introduced by the diagram (self['wavefunctions']). In a HELAS-optimised matrix element a diagram also reuses wavefunctions (and their sub-trees) introduced by earlier diagrams, which appear here only as mothers. Those shared mothers kept a stale flavortag computed for a different flavor, and propagate_flavor_tag silently reused it instead of recomputing it. This made check_flavor order-dependent: a diagram whose internal lines are all reused (e.g. the t-channel gluon diagrams of q q > q q g and q q~ > q q~ g where the external gluon is radiated off a final quark) was wrongly rejected for a valid same-flavor assignment when checked after another flavor.

Clear the flavortag over the whole ancestor closure of every wavefunction and amplitude instead. External leaves are re-tagged as before; cleared internal shared mothers are recomputed by propagate_flavor_tag. This is the same bug class previously patched at the check_flavor_for_all_diagrams level; the fix here makes the lower-level HelasDiagram.check_flavor correct on its own.

Add regression tests (TestDiagramFlavorCheck, TestDiagramFlavorCheckQQG, TestDiagramFlavorCheckQQbarG) covering d d~ > d d~, q q > q q g and q q~ > q q~ g; the latter two fail without this fix.

oliviermattelaer and others added 2 commits June 25, 2026 14:17
HelasDiagram.check_flavor only cleared the `flavortag` attribute on the
wavefunctions *introduced* by the diagram (self['wavefunctions']). In a
HELAS-optimised matrix element a diagram also reuses wavefunctions (and their
sub-trees) introduced by earlier diagrams, which appear here only as mothers.
Those shared mothers kept a stale flavortag computed for a different flavor,
and propagate_flavor_tag silently reused it instead of recomputing it. This
made check_flavor order-dependent: a diagram whose internal lines are all
reused (e.g. the t-channel gluon diagrams of q q > q q g and q q~ > q q~ g
where the external gluon is radiated off a final quark) was wrongly rejected
for a valid same-flavor assignment when checked after another flavor.

Clear the flavortag over the whole ancestor closure of every wavefunction and
amplitude instead. External leaves are re-tagged as before; cleared internal
shared mothers are recomputed by propagate_flavor_tag. This is the same bug
class previously patched at the check_flavor_for_all_diagrams level; the fix
here makes the lower-level HelasDiagram.check_flavor correct on its own.

Add regression tests (TestDiagramFlavorCheck, TestDiagramFlavorCheckQQG,
TestDiagramFlavorCheckQQbarG) covering d d~ > d d~, q q > q q g and
q q~ > q q~ g; the latter two fail without this fix.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@oliviermattelaer

Copy link
Copy Markdown
Contributor Author

@theoheimel do you want to do some test on this or we can merge it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant