Skip to content

Commit

Permalink
feat: Add Flatte amplitude
Browse files Browse the repository at this point in the history
  • Loading branch information
denehoffman committed Jul 31, 2024
1 parent 780e689 commit 3b8fe5f
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/rustitude-gluex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ There are a few amplitudes from [halld_sim](https://github.com/JeffersonLab/hall
| [DblRegge_FastEta.cc](https://github.com/JeffersonLab/halld_sim/blob/master/src/libraries/AMPTOOLS_AMPS/DblRegge_FastEta.cc) | | :heavy_exclamation_mark: |
| [DblRegge_FastPi.cc](https://github.com/JeffersonLab/halld_sim/blob/master/src/libraries/AMPTOOLS_AMPS/DblRegge_FastPi.cc) | | :heavy_exclamation_mark: |
| [EtaPb_tdist.cc](https://github.com/JeffersonLab/halld_sim/blob/master/src/libraries/AMPTOOLS_AMPS/EtaPb_tdist.cc) | | :heavy_exclamation_mark: |
| [Flatte.cc](https://github.com/JeffersonLab/halld_sim/blob/master/src/libraries/AMPTOOLS_AMPS/Flatte.cc) | | :bangbang: |
| [Flatte.cc](https://github.com/JeffersonLab/halld_sim/blob/master/src/libraries/AMPTOOLS_AMPS/Flatte.cc) | `rustitude-gluex::resonances::Flatte` | :white_check_mark: |
| [Hist2D.cc](https://github.com/JeffersonLab/halld_sim/blob/master/src/libraries/AMPTOOLS_AMPS/Hist2D.cc) | | :x: |
| [Lambda1520Angles.cc](https://github.com/JeffersonLab/halld_sim/blob/master/src/libraries/AMPTOOLS_AMPS/Lambda1520Angles.cc) | | :x: |
| [Lambda1520tdist.cc](https://github.com/JeffersonLab/halld_sim/blob/master/src/libraries/AMPTOOLS_AMPS/Lambda1520tdist.cc) | | :x: |
| [LowerVertexDelta.cc](https://github.com/JeffersonLab/halld_sim/blob/master/src/libraries/AMPTOOLS_AMPS/LowerVertexDelta.cc) | | :x: |
| [OmegaDalitz.cc](https://github.com/JeffersonLab/halld_sim/blob/master/src/libraries/AMPTOOLS_AMPS/OmegaDalitz.cc) | `rustitude-gluex::dalitz::OmegaDalitz` | :white_check_mark: |
| [PhaseOffset.cc](https://github.com/JeffersonLab/halld_sim/blob/master/src/libraries/AMPTOOLS_AMPS/PhaseOffset.cc) | | :bangbang: |
| [PhaseOffset.cc](https://github.com/JeffersonLab/halld_sim/blob/master/src/libraries/AMPTOOLS_AMPS/PhaseOffset.cc) | `rustitude::amplitude::PCScalar` | :white_check_mark: |
| [Pi0Regge.cc](https://github.com/JeffersonLab/halld_sim/blob/master/src/libraries/AMPTOOLS_AMPS/Pi0Regge.cc) | | :heavy_exclamation_mark: |
| [Pi0ReggeModel.cc](https://github.com/JeffersonLab/halld_sim/blob/master/src/libraries/AMPTOOLS_AMPS/Pi0ReggeModel.cc) | | :x: |
| [Pi0SAID.cc](https://github.com/JeffersonLab/halld_sim/blob/master/src/libraries/AMPTOOLS_AMPS/Pi0SAID.cc) | | :x: |
Expand Down
64 changes: 64 additions & 0 deletions crates/rustitude-gluex/src/resonances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,70 @@ impl<F: Field> Node<F> for BreitWigner<F> {
}
}

#[derive(Clone)]
pub struct Flatte<F: Field> {
channel: usize,
m1s: [F; 2],
m2s: [F; 2],
decay: Decay,
low_channel: usize,
data: Vec<(F, [Complex<F>; 2])>,
}
impl<F: Field> Flatte<F> {
pub fn new(channel: usize, m1s: [F; 2], m2s: [F; 2], decay: Decay) -> Self {
let low_channel = if (m1s[0] + m1s[1]) < (m2s[0] + m2s[1]) {
0
} else {
1
};
Self {
channel,
m1s,
m2s,
decay,
low_channel,
data: Vec::default(),
}
}
}

impl<F: Field> Node<F> for Flatte<F> {
fn precalculate(&mut self, dataset: &Dataset<F>) -> Result<(), RustitudeError> {
self.data = dataset
.events
.par_iter()
.map(|event| {
let res_mass = self.decay.resonance_p4(event).m();
let br_mom_channel_1 =
utils::breakup_momentum_c(F::fsqrt(res_mass), self.m1s[0], self.m1s[1]);
let br_mom_channel_2 =
utils::breakup_momentum_c(F::fsqrt(res_mass), self.m2s[0], self.m2s[1]);
(res_mass, [br_mom_channel_1, br_mom_channel_2])
})
.collect();
Ok(())
}

fn parameters(&self) -> Vec<String> {
vec!["mass".to_string(), "g1".to_string(), "g2".to_string()]
}

fn calculate(&self, parameters: &[F], event: &Event<F>) -> Result<Complex<F>, RustitudeError> {
let (res_mass, br_momenta) = self.data[event.index];
let gammas = [
parameters[1].c() * br_momenta[0],
parameters[2].c() * br_momenta[1],
];
let gamma_low = gammas[self.low_channel];
let gamma_j = gammas[self.channel];
let mass = parameters[0].c();
Ok(
(mass * Complex::sqrt(gamma_low * gamma_j)) / (mass.powi(2) - res_mass.fpowi(2).c())
- F::I * mass * (gammas[0] * gammas[1]),
)
}
}

#[derive(Clone, Copy)]
pub struct AdlerZero<F: Field> {
pub s_0: F,
Expand Down
30 changes: 30 additions & 0 deletions py-rustitude/src/gluex/resonances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,33 @@ fn BreitWigner_32(name: &str, l: usize, decay: Decay) -> Amplitude_32 {
Amplitude_32::new(name, rust::BreitWigner::new(l, decay))
}
#[pyfunction]
#[pyo3(signature = (name, channel, m1s, m2s, decay=Decay::default()))]
fn Flatte(name: &str, channel: usize, m1s: [f64; 2], m2s: [f64; 2], decay: Decay) -> Amplitude_64 {
Amplitude_64::new(name, rust::Flatte::new(channel, m1s, m2s, decay))
}
#[pyfunction]
#[pyo3(signature = (name, channel, m1s, m2s, decay=Decay::default()))]
fn Flatte_64(
name: &str,
channel: usize,
m1s: [f64; 2],
m2s: [f64; 2],
decay: Decay,
) -> Amplitude_64 {
Amplitude_64::new(name, rust::Flatte::new(channel, m1s, m2s, decay))
}
#[pyfunction]
#[pyo3(signature = (name, channel, m1s, m2s, decay=Decay::default()))]
fn Flatte_32(
name: &str,
channel: usize,
m1s: [f32; 2],
m2s: [f32; 2],
decay: Decay,
) -> Amplitude_32 {
Amplitude_32::new(name, rust::Flatte::new(channel, m1s, m2s, decay))
}
#[pyfunction]
#[pyo3(signature = (name, channel, decay=Decay::default()))]
fn KMatrixA0(name: &str, channel: usize, decay: Decay) -> Amplitude_64 {
Amplitude_64::new(name, rust::KMatrixA0::new(channel, decay))
Expand Down Expand Up @@ -112,6 +139,9 @@ pub fn pyo3_module(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(BreitWigner, m)?)?;
m.add_function(wrap_pyfunction!(BreitWigner_64, m)?)?;
m.add_function(wrap_pyfunction!(BreitWigner_32, m)?)?;
m.add_function(wrap_pyfunction!(Flatte, m)?)?;
m.add_function(wrap_pyfunction!(Flatte_64, m)?)?;
m.add_function(wrap_pyfunction!(Flatte_32, m)?)?;
m.add_function(wrap_pyfunction!(KMatrixA0, m)?)?;
m.add_function(wrap_pyfunction!(KMatrixA0_64, m)?)?;
m.add_function(wrap_pyfunction!(KMatrixA0_32, m)?)?;
Expand Down

0 comments on commit 3b8fe5f

Please sign in to comment.