Skip to main content

laddu_core/kinematics/
rest_frame.rs

1use serde::{Deserialize, Serialize};
2
3use super::support::checked_boost_vector;
4use crate::{
5    vectors::{Vec3, Vec4},
6    LadduResult,
7};
8
9/// Rest-frame transform for a parent four-momentum.
10///
11/// Sequential-decay builders start from lab-frame event vectors, then apply one rest-frame
12/// transform per vertex. Each child vertex receives four-vectors that have already been
13/// transformed into its parent's rest frame.
14#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
15pub struct RestFrame {
16    parent: Vec4,
17    boost: Vec3,
18}
19
20impl RestFrame {
21    /// Construct a rest-frame transform for `parent`.
22    pub fn new(parent: Vec4) -> LadduResult<Self> {
23        let boost = checked_boost_vector(-parent.beta(), "parent")?;
24        Ok(Self { parent, boost })
25    }
26
27    /// Return the parent four-momentum.
28    pub const fn parent(self) -> Vec4 {
29        self.parent
30    }
31
32    /// Return the boost vector into the parent rest frame.
33    pub const fn boost(self) -> Vec3 {
34        self.boost
35    }
36
37    /// Transform a four-momentum into the parent rest frame.
38    pub fn transform(self, momentum: Vec4) -> Vec4 {
39        momentum.boost(&self.boost)
40    }
41
42    /// Transform a four-momentum into the parent rest frame and return its three-momentum.
43    pub fn momentum(self, momentum: Vec4) -> Vec3 {
44        self.transform(momentum).vec3()
45    }
46}