8#include <framework/utilities/TestHelpers.h>
9#include <framework/dbobjects/BeamParameters.h>
11#include <gtest/gtest.h>
21 beamparams.
setLER(3.49841, M_PI, 0, std::vector<double>());
22 beamparams.
setHER(7.99638, 0.022, 0, std::vector<double>());
24 const ROOT::Math::PxPyPzEVector upsVec = beamparams.
getHER() + beamparams.
getLER();
25 ROOT::Math::PxPyPzEVector upsVecCMS = beamparams.
getLabToCMS() * upsVec;
27 const double mUpsilon = 10.5794;
28 EXPECT_TRUE(fabs(upsVecCMS.E() - mUpsilon) < 1e-2);
29 EXPECT_TRUE(fabs(upsVecCMS.X()) < 1e-15);
30 EXPECT_TRUE(fabs(upsVecCMS.Y()) < 1e-15);
31 EXPECT_TRUE(fabs(upsVecCMS.Z()) < 2e-15) << fabs(upsVecCMS.Z());
33 EXPECT_TRUE(fabs(beamparams.
getMass() - mUpsilon) < 1e-2);
40 beamparams.
setLER(3.49841, M_PI, 0, std::vector<double>());
41 beamparams.
setHER(7.99638, 0.022, 0, std::vector<double>());
44 ROOT::Math::PxPyPzEVector vec(1, 1, 1, 1);
45 vec = backAndForth * vec;
46 EXPECT_TRUE(fabs(vec.X() - 1) < 1e-15);
47 EXPECT_TRUE(fabs(vec.Y() - 1) < 1e-15);
48 EXPECT_TRUE(fabs(vec.Z() - 1) < 1e-15);
56 TMatrixDSym upper(3), sym(3);
58 for (
int i = 0; i < 3; i++) {
59 for (
int j = 0; j < 3; j++) {
60 upper(i, j) = (j >= i) ? ++n : -1;
61 if (j >= i) sym(i, j) = sym(j, i) = upper(i, j);
72 std::vector<double> cov;
73 TMatrixDSym matrix(3);
74 beamparams.
setHER(0, 0, 0, cov);
75 beamparams.
setVertex(ROOT::Math::XYZVector(0, 0, 0), cov);
76 EXPECT_EQ(matrix, beamparams.
getCovHER());
85 for (
int i = 0; i < 10; ++i) {
86 std::vector<double> cov{1.*i};
87 TMatrixDSym beam(3), vertex(3);
92 beamparams.
setHER(0, 0, 0, cov);
93 beamparams.
setVertex(ROOT::Math::XYZVector(0, 0, 0), cov);
104 std::vector<double> cov{1., 2., 3.};
105 TMatrixDSym matrix(3);
109 beamparams.
setHER(0, 0, 0, cov);
110 beamparams.
setVertex(ROOT::Math::XYZVector(0, 0, 0), cov);
111 EXPECT_EQ(matrix, beamparams.
getCovHER());
119 std::vector<double> cov{1., 2., 3., 4., 5., 6.};
120 TMatrixDSym matrix(3);
122 matrix(0, 1) = matrix(1, 0) = 2;
123 matrix(0, 2) = matrix(2, 0) = 3;
125 matrix(1, 2) = matrix(2, 1) = 5;
127 beamparams.
setHER(0, 0, 0, cov);
128 beamparams.
setVertex(ROOT::Math::XYZVector(0, 0, 0), cov);
129 EXPECT_EQ(matrix, beamparams.
getCovHER());
137 std::vector<double> cov{1., 2., 3., 4., 5., 6., 7., 8., 9.};
138 TMatrixDSym matrix(3);
140 matrix(0, 1) = matrix(1, 0) = 2;
141 matrix(0, 2) = matrix(2, 0) = 3;
143 matrix(1, 2) = matrix(2, 1) = 6;
145 beamparams.
setHER(0, 0, 0, cov);
146 beamparams.
setVertex(ROOT::Math::XYZVector(0, 0, 0), cov);
147 EXPECT_EQ(matrix, beamparams.
getCovHER());
This class contains the nominal beam parameters and the parameters used for smearing of the primary v...
void setHER(double energy, double angleX, double angleY, const std::vector< double > &cov)
Set the HER FourVector and error matrix from beam energy, angle and covariance entries.
TMatrixDSym getCovVertex() const
Get the covariance matrix of the vertex position.
void setLER(double energy, double angleX, double angleY, const std::vector< double > &cov)
Set the LER FourVector and error matrix from beam energy, angle and covariance entries.
void setCovHER(const TMatrixDSym &cov)
Set the covariance matrix for HER (E, theta_x, theta_y) where E is the energy, theta_x is the horizon...
TMatrixDSym getCovHER() const
Get the covariance matrix of HER (E, theta_x, theta_y) where E is the energy, theta_x is the horizont...
void setVertex(const ROOT::Math::XYZVector &vertex, const std::vector< double > &cov)
Set the vertex position and error matrix.
const ROOT::Math::PxPyPzEVector & getHER() const
Get 4vector of the high energy beam.
const ROOT::Math::PxPyPzEVector & getLER() const
Get 4vector of the low energy beam.
const ROOT::Math::LorentzRotation & getLabToCMS() const
Return the LorentzRotation to convert from lab to CMS frame.
const ROOT::Math::LorentzRotation & getCMSToLab() const
Return the LorentzRotation to convert from CMS to lab frame.
double getMass() const
Get the invariant mass of the collision (= energy in CMS)
Abstract base class for different kinds of events.