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

fix: add mass*width factor to relBW w/o ff #189

Merged
merged 2 commits into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/tensorwaves/physics/helicity_formalism/amplitude.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,15 @@ def __call__(self, dataset: dict) -> tf.Tensor:
return self._call_wrapper(dataset)

def _without_form_factor(self, dataset: dict) -> tf.Tensor:
return relativistic_breit_wigner(
dataset[self._dynamics_props.inv_mass_name],
self._dynamics_props.resonance_mass,
self._dynamics_props.resonance_width,
mass0 = self._dynamics_props.resonance_mass
gamma0 = self._dynamics_props.resonance_width
return (
relativistic_breit_wigner(
dataset[self._dynamics_props.inv_mass_name],
self._dynamics_props.resonance_mass,
self._dynamics_props.resonance_width,
)
* atfi.complex(mass0 * gamma0, atfi.const(0.0))
)

def _with_form_factor(self, dataset: dict) -> tf.Tensor:
Expand Down
35 changes: 20 additions & 15 deletions tests/data/test_generate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# cspell:ignore tolist
from pprint import pprint

import numpy as np
import pytest

Expand All @@ -11,27 +14,29 @@

def test_generate_data(data_sample: np.ndarray):
sub_sample = data_sample[:, :5, :]
print("Expected list, get by running pytest with the -s flag")
pprint(np.round(sub_sample, decimals=11).tolist())
assert pytest.approx(sub_sample) == [
[
[-0.802315863797, 0.178700594344, -1.124458521281, 1.392857355870],
[-0.893880825493, 0.014200873801, 0.794094652102, 1.195747009822],
[1.095206560829, -0.407826696013, -0.712210827094, 1.368592082066],
[-0.111597827921, -0.855676181548, 1.088009508016, 1.388668604239],
[0.494199311030, -0.459114111102, -0.652173184220, 0.938268931731],
[-1.11655564285, -0.65098757279, -0.29889930779, 1.32658287329],
[0.6614259842, -0.67081160216, 0.91253074716, 1.31155819645],
[-0.89388082549, 0.0142008738, 0.7940946521, 1.19574700982],
[1.09520656083, -0.40782669601, -0.71221082709, 1.36859208207],
[-0.91362335417, 0.65774093748, -0.03330470173, 1.12625040612],
],
[
[-0.013664538258, -0.063677496239, 0.790709134631, 0.804786440778],
[-0.047509140382, 0.019741853435, -0.928869183224, 0.940033805392],
[-0.671293601965, 0.030434499723, 0.885454524023, 1.119736491083],
[-0.108188868818, 0.073259826346, 0.136621115257, 0.232284091501],
[-0.053620536930, 0.820055795500, -0.423278811086, 0.934211088656],
[0.99646172468, 0.95461505668, 0.29199575453, 1.4169354722],
[-0.12901200642, 0.8756471174, -0.77276118186, 1.18270053384],
[-0.04750914038, 0.01974185344, -0.92886918322, 0.94003380539],
[-0.67129360197, 0.03043449972, 0.88545452402, 1.11973649108],
[0.68138748966, -1.08237744503, -0.3566346599, 1.33462985945],
],
[
[0.815980402056, -0.115023098105, 0.333749386650, 0.899256203351],
[0.941389965876, -0.033942727236, 0.134774531122, 0.961119184785],
[-0.423912958864, 0.377392196290, -0.173243696929, 0.608571426849],
[0.219786696740, 0.782416355201, -1.224630623273, 1.475947304258],
[-0.440578774100, -0.360941684398, 1.075451995307, 1.224419979611],
[0.12009391817, -0.3036274839, 0.00690355325, 0.35338165451],
[-0.53241397778, -0.20483551524, -0.1397695653, 0.60264126971],
[0.94138996588, -0.03394272724, 0.13477453112, 0.96111918479],
[-0.42391295886, 0.37739219629, -0.17324369693, 0.60857142685],
[0.2322358645, 0.42463650754, 0.38993936163, 0.63601973443],
],
]

Expand Down
10 changes: 5 additions & 5 deletions tests/optimizer/test_minuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ def test_optimize(fit_result: dict, free_parameters: dict):
par_values = result["parameter_values"]
par_errors = result["parameter_errors"]
assert set(par_values) == set(free_parameters)
assert pytest.approx(result["log_likelihood"]) == -19182.154685316204
assert pytest.approx(par_values["Width_f(0)(500)"]) == 0.58052984362816
assert pytest.approx(par_errors["Width_f(0)(500)"]) == 0.01413164631479
assert pytest.approx(result["log_likelihood"]) == -12961.752837852626
assert pytest.approx(par_values["Width_f(0)(500)"]) == 0.5546203338476
assert pytest.approx(par_errors["Width_f(0)(500)"]) == 0.00981961384643
assert (
pytest.approx(par_values["Position_f(0)(980)"])
== 0.9895840830306458
== 0.9897319832688249
)
assert (
pytest.approx(par_errors["Position_f(0)(980)"])
== 0.0004395998899025785
== 0.0007052210121507604
)