From 478d52ab4e9f2783603091dba298dc0cec3a95c6 Mon Sep 17 00:00:00 2001 From: Eduardo Rodrigues Date: Mon, 24 Jul 2023 12:32:21 +0200 Subject: [PATCH 1/4] Allow for 'Decay' statements with no decay lines, a means to make a particle stable for EvtGen --- src/decaylanguage/data/decfile.lark | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/decaylanguage/data/decfile.lark b/src/decaylanguage/data/decfile.lark index a752ef96..6aa3182d 100644 --- a/src/decaylanguage/data/decfile.lark +++ b/src/decaylanguage/data/decfile.lark @@ -12,7 +12,7 @@ jetset_def : "JetSetPar" LABEL "=" SIGNED_NUMBER ls_def : ("LSFLAT" | "LSNONRELBW") label // Choose a lineshape for a particle -inc_factor: ("IncludeBirthFactor" | "IncludeDecayFactor") label ("yes" | "no") // Presence of the birth/decay factor and form-factor +inc_factor: ("IncludeBirthFactor" | "IncludeDecayFactor") label ("yes" | "no") // Presence of the birth/decay momentum factor and form-factor setlsbw : "BlattWeisskopf" label value // Set Blatt-Weisskopf barrier factor for a lineshape @@ -39,7 +39,7 @@ global_photos : boolean_photos boolean_photos : "yesPhotos" -> yes | "noPhotos" -> no -decay : "Decay" particle _NEWLINE+ decayline+ "Enddecay" +decay : "Decay" particle _NEWLINE+ decayline* "Enddecay" decayline : value particle* photos? model _NEWLINE+ value : SIGNED_NUMBER photos : "PHOTOS" From 39b3decb7194233a70f36e1abce87ec82be4c8b6 Mon Sep 17 00:00:00 2001 From: Eduardo Rodrigues Date: Mon, 24 Jul 2023 12:33:19 +0200 Subject: [PATCH 2/4] Add dec file to test --- tests/data/test_stable-particle.dec | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tests/data/test_stable-particle.dec diff --git a/tests/data/test_stable-particle.dec b/tests/data/test_stable-particle.dec new file mode 100644 index 00000000..59deec62 --- /dev/null +++ b/tests/data/test_stable-particle.dec @@ -0,0 +1,7 @@ +# Example decay chain for testing purposes: +# An empty list of decay modes makes the particle stable! + +Decay K_S0 +Enddecay + +End From 89a618d53f48a1278dff86d9f0614f0e74e25525 Mon Sep 17 00:00:00 2001 From: Eduardo Rodrigues Date: Mon, 24 Jul 2023 12:39:12 +0200 Subject: [PATCH 3/4] Add actual test --- tests/data/minimalistic.dec | 2 +- tests/dec/test_dec.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/data/minimalistic.dec b/tests/data/minimalistic.dec index c83e133f..7b2ab869 100644 --- a/tests/data/minimalistic.dec +++ b/tests/data/minimalistic.dec @@ -1,7 +1,7 @@ # Example decfile for testing purposes: # Line with "End" is strictly speaking not necessary -# Such "empty" files are relevant in LHCb for example when special decays are all defined in PYthon code +# Such "empty" files are relevant in LHCb for example when special decays are all defined in Python code # inserted in commented-out lines End # diff --git a/tests/dec/test_dec.py b/tests/dec/test_dec.py index dd4e31d3..f6c4b8ac 100644 --- a/tests/dec/test_dec.py +++ b/tests/dec/test_dec.py @@ -101,6 +101,14 @@ def test_non_parsed_decfile(): p.list_decay_mother_names() +def test_decfile_defining_stable_particle(): + p = DecFileParser(DIR / "../data/test_stable-particle.dec") + p.parse() + + assert p.number_of_decays == 1 # The decay of K_S0, even if no decay modes are defined + assert p.list_decay_modes("K_S0") == [] + + def test_non_existent_decay(): p = DecFileParser(DIR / "../data/test_example_Dst.dec") p.parse() From dd2e6e59be07ff308dd4833d375d6e13283bcb17 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 10:46:49 +0000 Subject: [PATCH 4/4] style: pre-commit fixes --- tests/dec/test_dec.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/dec/test_dec.py b/tests/dec/test_dec.py index f6c4b8ac..64fda8be 100644 --- a/tests/dec/test_dec.py +++ b/tests/dec/test_dec.py @@ -105,7 +105,9 @@ def test_decfile_defining_stable_particle(): p = DecFileParser(DIR / "../data/test_stable-particle.dec") p.parse() - assert p.number_of_decays == 1 # The decay of K_S0, even if no decay modes are defined + assert ( + p.number_of_decays == 1 + ) # The decay of K_S0, even if no decay modes are defined assert p.list_decay_modes("K_S0") == []