GooFit  v2.1.3
UserUtils.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <Eigen/Dense>
6 #include <mcbooster/EvaluateArray.h>
7 
8 namespace GooFit {
9 
11 Eigen::Matrix<fptype, 5, Eigen::Dynamic> to_5param(const Eigen::Matrix<fptype, 16, Eigen::Dynamic> &mat) {
12  mcbooster::Particles_h h_p0(mat.cols());
13  mcbooster::Particles_h h_p1(mat.cols());
14  mcbooster::Particles_h h_p2(mat.cols());
15  mcbooster::Particles_h h_p3(mat.cols());
16 
17  for(int i = 0; i < mat.cols(); i++) {
18  h_p0[i].set(mat(3, i), mat(0, i), mat(1, i), mat(2, i));
19  h_p1[i].set(mat(7, i), mat(4, i), mat(5, i), mat(6, i));
20  h_p2[i].set(mat(11, i), mat(8, i), mat(9, i), mat(10, i));
21  h_p3[i].set(mat(15, i), mat(12, i), mat(13, i), mat(14, i));
22  }
23 
24  mcbooster::Particles_d d_p0(h_p0.begin(), h_p0.end());
25  mcbooster::Particles_d d_p1(h_p1.begin(), h_p1.end());
26  mcbooster::Particles_d d_p2(h_p2.begin(), h_p2.end());
27  mcbooster::Particles_d d_p3(h_p3.begin(), h_p3.end());
28 
29  mcbooster::RealVector_d d_m12(mat.cols());
30  mcbooster::RealVector_d d_m34(mat.cols());
31  mcbooster::RealVector_d d_cos12(mat.cols());
32  mcbooster::RealVector_d d_cos34(mat.cols());
33  mcbooster::RealVector_d d_phi(mat.cols());
34 
35  mcbooster::ParticlesSet_d particles = {&d_p0, &d_p1, &d_p2, &d_p3};
36  mcbooster::VariableSet_d variables = {&d_m12, &d_m34, &d_cos12, &d_cos34, &d_phi};
37 
38  Dim5 eval = Dim5();
39  mcbooster::EvaluateArray<Dim5>(eval, particles, variables);
40 
41  mcbooster::RealVector_h h_m12(d_m12.begin(), d_m12.end());
42  mcbooster::RealVector_h h_m34(d_m34.begin(), d_m34.end());
43  mcbooster::RealVector_h h_cos12(d_cos12.begin(), d_cos12.end());
44  mcbooster::RealVector_h h_cos34(d_cos34.begin(), d_cos34.end());
45  mcbooster::RealVector_h h_phi(d_phi.begin(), d_phi.end());
46 
47  Eigen::Matrix<fptype, 5, Eigen::Dynamic> output(5, mat.cols());
48 
49  for(int i = 0; i < mat.cols(); i++) {
50  output(0, i) = h_m12[i];
51  output(1, i) = h_m34[i];
52  output(2, i) = h_cos12[i];
53  output(3, i) = h_cos34[i];
54  output(4, i) = h_phi[i];
55  }
56 
57  return output;
58 }
59 
60 } // namespace GooFit
Eigen::Matrix< fptype, 5, Eigen::Dynamic > to_5param(const Eigen::Matrix< fptype, 16, Eigen::Dynamic > &mat)
This is a helper to convert values. It copies back and forth, so is only to be used in scripts...
Definition: UserUtils.h:11