Exemple #1
0
def test_children_names():
    """Test particle naming when only children names are given."""
    children_names = [f"pion_{i}" for i in range(3)]
    decay = nbody_decay(B0_MASS, [PION_MASS, PION_MASS, PION_MASS],
                        names=children_names)
    assert decay.name == 'top'
    assert children_names == [part.name for part in decay.children]
Exemple #2
0
def test_top_name():
    """Test particle naming when only top name is given."""
    decay = nbody_decay(B0_MASS, [PION_MASS, PION_MASS, PION_MASS],
                        top_name="B0")
    assert decay.name == 'B0'
    assert all(part.name == f"p_{part_num}"
               for part_num, part in enumerate(decay.children))
Exemple #3
0
 def __init__(
     self, reaction_kinematics_info: ParticleReactionKinematicsInfo
 ) -> None:
     self.phsp_gen = phasespace.nbody_decay(
         reaction_kinematics_info.total_invariant_mass,
         reaction_kinematics_info.final_state_masses,
     )
def test_n_events(n_events):
    """Test 5 B->pi pi pi."""
    decay = phasespace.nbody_decay(B0_MASS, [PION_MASS, PION_MASS, PION_MASS])
    norm_weights, particles = decay.generate(n_events=n_events)
    assert len(norm_weights) == 5
    assert all([weight < 1 for weight in norm_weights])
    assert len(particles) == 3
    assert all([part.shape == (5, 4) for part in particles.values()])
def test_one_event_tf():
    """Test B->pi pi pi."""
    decay = phasespace.nbody_decay(B0_MASS, [PION_MASS, PION_MASS, PION_MASS])
    with tf.Session() as sess:
        norm_weights, particles = sess.run(decay.generate_tensor(n_events=1))

    assert len(norm_weights) == 1
    assert all([weight < 1 for weight in norm_weights])
    assert len(particles) == 3
    assert all([part.shape == (1, 4) for part in particles.values()])
Exemple #6
0
def test_mismatching_names():
    """Test wrong number of names given for children."""
    children_names = [f"pion_{i}" for i in range(4)]
    with pytest.raises(ValueError):
        nbody_decay(B0_MASS, [PION_MASS, PION_MASS, PION_MASS],
                    names=children_names)
Exemple #7
0
def test_no_names():
    """Test particle naming when no name is given."""
    decay = nbody_decay(B0_MASS, [PION_MASS, PION_MASS, PION_MASS])
    assert decay.name == 'top'
    assert all(part.name == f"p_{part_num}"
               for part_num, part in enumerate(decay.children))