Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several EvtGen model enhancements and a fix #396

Merged
merged 11 commits into from
Nov 17, 2023
7 changes: 2 additions & 5 deletions src/decaylanguage/data/decfile.lark
Original file line number Diff line number Diff line change
Expand Up @@ -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"|"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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"|"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
Expand All @@ -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
Expand Down
12 changes: 10 additions & 2 deletions src/decaylanguage/dec/dec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
2 changes: 1 addition & 1 deletion src/decaylanguage/dec/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class PhotosEnum(IntEnum):
"LbAmpGen",
"LLSW",
"LNUGAMMA",
"LQCD",
"MELIKHOV",
"OMEGA_DALITZ",
"PARTWAVE",
Expand All @@ -92,6 +91,7 @@ class PhotosEnum(IntEnum):
"PVV_CPLH",
"PYCONT",
"PYTHIA",
"RareLbToLll",
"SLBKPOLE",
"SLL",
"SLN",
Expand Down
12 changes: 12 additions & 0 deletions tests/data/models/model-BT02PI_CP_ISO.dec
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions tests/data/models/model-BTOXELNU.dec
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions tests/data/models/model-GENERIC_DALITZ.dec
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions tests/data/models/model-RareLbToLll.dec
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tests/data/models/model-SVS_CP_ISO.dec
Original file line number Diff line number Diff line change
@@ -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
60 changes: 52 additions & 8 deletions tests/dec/test_known_decay_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand All @@ -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",
Expand Down Expand Up @@ -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]),
Expand All @@ -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]),
Expand Down Expand Up @@ -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", ""),
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down