diff --git a/src/decaylanguage/data/decfile.lark b/src/decaylanguage/data/decfile.lark index 41a6cec5..880ef305 100644 --- a/src/decaylanguage/data/decfile.lark +++ b/src/decaylanguage/data/decfile.lark @@ -61,10 +61,7 @@ model_options : (value | LABEL | _NEWLINE | _COMMA)+ // Model names must either be followed by at least one whitespace (when they have model parameters) or a semicolon (without model parameters) // We must set priorities here to use lalr - match model name above label, and label above something else -MODEL_NAME.2 : ("BaryonPCR"|"BC_SMN"|"BC_TMN"|"BC_VHAD"|"BC_VMN"|"BCL"|"BGL"|"BLLNUL"|"BNOCB0TO4PICP"|"BNOCBPTO3HPI0"|"BNOCBPTOKSHHH"|"BS_MUMUKK"|"BSTOGLLISRFSR"|"BSTOGLLMNT"|"BT02PI_CP_ISO"|"BTO3PI_CP"|"BTODDALITZCPK"|"BToDiBaryonlnupQCD"|"BTOSLLALI"|"BTOSLLBALL"|"BTOSLLMS"|"BTOSLLMSEXT"|"BTOVLNUBALL"|"BTOXSGAMMA"|"BTOXELNU"|"BTOXSLL"|"BQTOLLLLHYPERCP"|"BQTOLLLL"|"CB3PI-MPP"|"CB3PI-P00"|"D_DALITZ"|"D_hhhh"|"D0GAMMADALITZ"|"D0MIXDALITZ"|"DToKpienu"|"ETAPRIME_DALITZ"|"ETA_DALITZ"|"ETA_FULLDALITZ"|"ETA_LLPIPI"|"ETA_PI0DALITZ"|"FLATQ2"|"FLATSQDALITZ"|"FOURBODYPHSP"|"GENERIC_DALITZ"|"GOITY_ROBERTS"|"HELAMP"|"HQET3"|"HQET2"|"HQET"|"ISGW2"|"ISGW"|"KS_PI0MUMU"|"Lb2Baryonlnu"|"Lb2plnuLCSR"|"Lb2plnuLQCD"|"LbAmpGen"|"LLSW"|"LNUGAMMA"|"LQCD"|"MELIKHOV"|"OMEGA_DALITZ"|"PARTWAVE"|"PHI_DALITZ"|"PHSPDECAYTIMECUT"|"PHSPFLATLIFETIME"|"PHSP"|"PI0_DALITZ"|"PROPSLPOLE"|"PTO3P"|"PV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|"ETA_PI0DALITZ"|"FLATQ2"|"FLATSQDALITZ"|"FOURBODYPHSP"|"GENERIC_DALITZ"|"GOITY_ROBERTS"|"HELAMP"|"HQET3"|"HQET2"|"HQET"|"ISGW2"|"ISGW"|"KS_PI0MUMU"|"Lb2Baryonlnu"|"Lb2plnuLCSR"|"Lb2plnuLQCD"|"LbAmpGen"|"LLSW"|"LNUGAMMA"|"MELIKHOV"|"OMEGA_DALITZ"|"PARTWAVE"|"PHI_DALITZ"|"PHSPDECAYTIMECUT"|"PHSPFLATLIFETIME"|"PHSP"|"PI0_DALITZ"|"PROPSLPOLE"|"PTO3P"|"PVV_CPLH"|"PYCONT"|"PYTHIA"|"RareLbToLll"|"SLBKPOLE"|"SLL"|"SLN"|"SLPOLE"|"SSD_CP"|"SSD_DirectCP"|"SSS_CP_PNG"|"SSS_CP"|"SSS_CPT"|"STS_CP"|"STS"|"SVP_CP"|"SVP_HELAMP"|"SVP"|"SVS_CP_ISO"|"SVS_CPLH"|"SVS_CP"|"SVS_NONCPEIGEN"|"SVS"|"SVV_CPLH"|"SVV_CP"|"SVV_HELAMP"|"SVV_NONCPEIGEN"|"SVVHELCPMIX"|"TAUHADNU"|"TAULNUNU"|"TAUOLA"|"TAUSCALARNU"|"TAUVECTORNU"|"THREEBODYPHSP"|"TSS"|"TVP"|"TVS_PWAVE"|"VLL"|"VSP_PWAVE"|"VSS_BMIX"|"VSS_MIX"|"VSS"|"VTOSLL"|"VUB"|"VVPIPI"|"VVP"|"VVS_PWAVE"|"XLL"|"YMSTOYNSPIPICLEO"|"YMSTOYNSPIPICLEOBOOST")/\b/ // Terminal definitions // To use a fast parser, we need to avoid conflicts @@ -79,7 +76,7 @@ _SEMICOLON: /;/ _COMMA: /,/ _WS: WS_INLINE -LABEL : /[a-zA-Z0-9\/\-+*_()'~]+/ +LABEL : /[a-zA-Z0-9\/\-+*_().'~]+/ COMMENT : /[#][^\n]*/ // We should ignore comments diff --git a/src/decaylanguage/dec/dec.py b/src/decaylanguage/dec/dec.py index 5ca53b87..474424e3 100644 --- a/src/decaylanguage/dec/dec.py +++ b/src/decaylanguage/dec/dec.py @@ -1116,8 +1116,16 @@ def _replacement(self, t: Tree) -> None: try: t.children[0].value = float(t.children[0].value) except AttributeError: - if t.value in self.define_defs: - t.value = self.define_defs[t.value] + negative_param = ( + t.value[0] == "-" + ) # account for uncommon cases such as "MODEL_NAME ... -DEFINE_NAME" + value = t.value if not negative_param else t.value[1:] + if value in self.define_defs: + t.value = ( + self.define_defs[value] + if not negative_param + else -self.define_defs[value] + ) def model_options(self, tree: Tree) -> None: """ diff --git a/src/decaylanguage/dec/enums.py b/src/decaylanguage/dec/enums.py index dc9ab26a..8eaec0a9 100644 --- a/src/decaylanguage/dec/enums.py +++ b/src/decaylanguage/dec/enums.py @@ -78,7 +78,6 @@ class PhotosEnum(IntEnum): "LbAmpGen", "LLSW", "LNUGAMMA", - "LQCD", "MELIKHOV", "OMEGA_DALITZ", "PARTWAVE", @@ -92,6 +91,7 @@ class PhotosEnum(IntEnum): "PVV_CPLH", "PYCONT", "PYTHIA", + "RareLbToLll", "SLBKPOLE", "SLL", "SLN", diff --git a/tests/data/models/model-BT02PI_CP_ISO.dec b/tests/data/models/model-BT02PI_CP_ISO.dec new file mode 100644 index 00000000..f07d8d10 --- /dev/null +++ b/tests/data/models/model-BT02PI_CP_ISO.dec @@ -0,0 +1,12 @@ +# File for testing purposes. Contains a single decay mode with a specific model. + +Define dm 0.507e12 +Define beta 0.39 +Define gamma 1.387 + +Decay B0 +1.0 pi+ pi- BT02PI_CP_ISO beta dm 1.0 gamma 1.0 -gamma + 1.0 gamma 1.0 -gamma; +Enddecay + +End diff --git a/tests/data/models/model-BTOXELNU.dec b/tests/data/models/model-BTOXELNU.dec new file mode 100644 index 00000000..d474be39 --- /dev/null +++ b/tests/data/models/model-BTOXELNU.dec @@ -0,0 +1,7 @@ +# File for testing purposes. Contains a single decay mode with a specific model. + +Decay B+ + 1.0 rho0 mu+ nu_mu PHOTOS BTOXELNU BCL -0.861 1.444 0.266 0.378 0.165 0.291 0.718 0.384 0.331 -0.876 1.907; +Enddecay + +End diff --git a/tests/data/models/model-GENERIC_DALITZ.dec b/tests/data/models/model-GENERIC_DALITZ.dec new file mode 100644 index 00000000..d7cef111 --- /dev/null +++ b/tests/data/models/model-GENERIC_DALITZ.dec @@ -0,0 +1,8 @@ +# File for testing purposes. Contains a single decay mode with a specific model. + +# Generic Dalitz model that uses XML files to configure the resonance amplitude parameters +Decay D+ + 1.0 K- pi+ pi+ GENERIC_DALITZ MyDir/MyDalitzParameters.xml; +Enddecay + +End diff --git a/tests/data/models/model-RareLbToLll.dec b/tests/data/models/model-RareLbToLll.dec new file mode 100644 index 00000000..272ee230 --- /dev/null +++ b/tests/data/models/model-RareLbToLll.dec @@ -0,0 +1,7 @@ +# File for testing purposes. Contains a single decay mode with a specific model. + +Decay Lambda_b0 + 1.0 Lambda0 mu+ mu- RareLbToLll LQCD; +Enddecay + +End diff --git a/tests/data/models/model-SVS_CP_ISO.dec b/tests/data/models/model-SVS_CP_ISO.dec new file mode 100644 index 00000000..cf239f78 --- /dev/null +++ b/tests/data/models/model-SVS_CP_ISO.dec @@ -0,0 +1,15 @@ +# File for testing purposes. Contains a single decay mode with a specific model. + +Define dm 0.507e12 +Define beta 0.39 +Define gamma 1.387 + +Decay B0 +1.0 a_1- pi+ SVS_CP_ISO beta dm 0.0 1.0 0.0 1.0 0.0 + 1.0 0.0 1.0 0.0 + 1.0 gamma 3.0 -gamma + 3.0 gamma 1.0 -gamma + 0.0 0.0 0.0 0.0; +Enddecay + +End diff --git a/tests/dec/test_known_decay_models.py b/tests/dec/test_known_decay_models.py index c38edc81..1c82dd83 100644 --- a/tests/dec/test_known_decay_models.py +++ b/tests/dec/test_known_decay_models.py @@ -84,7 +84,10 @@ def test_lark_file_model_list_consistency(): [5.0, 5, 0, 0, 1, 0.000001, 0.8250, 0.22509, 0.1598, 0.3499, 4.5], ), ("BSTOGLLMNT", [5.0, 5, 1, 1, 0.02, 0.88, 0.227, 0.22, 0.34]), - # ("BT02PI_CP_ISO", [0.39, 0.507e12, 1.0, 1.387, 1.0, -1.387, 1.0, 1.387, 1.0, -1.387]), + ( + "BT02PI_CP_ISO", + [0.39, 0.507e12, 1.0, 1.387, 1.0, -1.387, 1.0, 1.387, 1.0, -1.387], + ), ("BTO3PI_CP", [0.507e12, 1.365]), ("BTODDALITZCPK", [1.22, 2.27, 0.10]), ("BToDiBaryonlnupQCD", [67.7, -280.0, -38.3, -840.0, -10.1, -157.0, 800000]), @@ -94,7 +97,23 @@ def test_lark_file_model_list_consistency(): ("BTOSLLMSEXT", [5.0, 5.0, 0.0, 1.0, 0.88, 0.227, 0.22, 0.34, 1.0, 0.0, -1.0, 0.0]), ("BTOVLNUBALL", [0.308, 36.54, -0.054, 0.288, 48.94, 1.484, -1.049, 39.52]), ("BTOXSGAMMA", [2.0]), - # ("BTOXELNU", ""), + ( + "BTOXELNU", + [ + "BCL", + -0.861, + 1.444, + 0.266, + 0.378, + 0.165, + 0.291, + 0.718, + 0.384, + 0.331, + -0.876, + 1.907, + ], + ), ("BTOXSLL", [4.8, 0.2, 0.0, 0.41]), ( "BQTOLLLLHYPERCP", @@ -131,7 +150,7 @@ def test_lark_file_model_list_consistency(): ("FLATQ2", [1.0]), ("FLATSQDALITZ", ""), ("FOURBODYPHSP", [1.3, 2.5, 1.3, 2.5]), - # ("GENERIC_DALITZ", ["MyDir/MyDalitzParameters.xml"]), + ("GENERIC_DALITZ", ["MyDir/MyDalitzParameters.xml"]), ("GOITY_ROBERTS", ""), ("HELAMP", [1.0, 0.0, 1.0, 0.0]), ("HQET3", [0.920, 1.205, 1.21, 1.404, 0.854]), @@ -146,7 +165,6 @@ def test_lark_file_model_list_consistency(): ("LbAmpGen", ["DtoKpipipi"]), ("LLSW", [0.71, -1.6, -0.5, 2.9]), ("LNUGAMMA", [0.35, 3.0, 5.0, 0.0]), - # ("LQCD", ""), ("MELIKHOV", [1]), ("OMEGA_DALITZ", ""), ("PARTWAVE", [0.0, 0.0, 1.0, 0.0, 0.0, 0.0]), @@ -280,6 +298,7 @@ def test_lark_file_model_list_consistency(): ("PVV_CPLH", [0.02, 1.0, 0.49, 2.50, 0.775, 0.0, 0.4, -0.17]), ("PYCONT", ""), ("PYTHIA", [21]), + ("RareLbToLll", ["LQCD"]), ("SLBKPOLE", [1.0, 0.25, 1.0]), ("SLL", ""), ("SLN", ""), @@ -314,7 +333,34 @@ def test_lark_file_model_list_consistency(): ("SVP_CP", [0.39, 0.507e12, 1, 0.03, 0.0, 0.999, 0.0]), ("SVP_HELAMP", [1.0, 0.0, 1.0, 0.0]), ("SVP", ""), - # ("SVS_CP_ISO", ""), # No dec file available for testing from LHCb or Belle-II + ( + "SVS_CP_ISO", + [ + 0.39, + 0.507e12, + 0.0, + 1.0, + 0.0, + 1.0, + 0.0, + 1.0, + 0.0, + 1.0, + 0.0, + 1.0, + 1.387, + 3.0, + -1.387, + 3.0, + 1.387, + 1.0, + -1.387, + 0.0, + 0.0, + 0.0, + 0.0, + ], + ), ("SVS_CPLH", [0.472e12, 0.1, 1.0, 0.7, 1.0, 0.0, 1.0, 0.0]), ( "SVS_CP", @@ -383,9 +429,7 @@ def test_lark_file_model_list_consistency(): def test_parsing_of_all_known_models_are_tested(): - assert ( - len(parsed_models) == len(known_decay_models) - 5 - ) # subtract for now the number of models not yet tested + the number of models presently with no test available + assert len(parsed_models) == len(known_decay_models) @pytest.mark.parametrize(("decay_model", "expected_model_parameters"), parsed_models)