9#include <framework/dbobjects/BeamParameters.h>
10#include <framework/logging/Logger.h>
11#include <framework/gearbox/Const.h>
22 constexpr int getIndex(
unsigned int i,
unsigned int j)
25 return (i < j) ? ((j + 1) * j / 2 + i) : ((i + 1) * i / 2 + j);
31 ROOT::Math::PxPyPzEVector vec =
getFourVector(energy, angleX, angleY,
false);
38 ROOT::Math::PxPyPzEVector vec =
getFourVector(energy, angleX, angleY,
true);
52 double dir = isHER ? 1 : -1;
54 double pz = dir * p / sqrt(1 + pow(tan(angleX), 2) + pow(tan(angleY), 2));
56 return ROOT::Math::PxPyPzEVector(pz * tan(angleX), pz * tan(angleY), pz, energy);
61 TMatrixDSym matrix(3);
62 for (
int iRow = 0; iRow < 3; ++iRow) {
63 for (
int iCol = iRow; iCol < 3; ++iCol) {
64 matrix(iCol, iRow) = matrix(iRow, iCol) = member[getIndex(iRow, iCol)];
72 for (
int iRow = 0; iRow < 3; ++iRow) {
73 for (
int iCol = iRow; iCol < 3; ++iCol) {
74 matrix[getIndex(iRow, iCol)] = cov(iRow, iCol);
81 std::fill_n(matrix, 6, 0);
96 for (
int i = 0; i < 3; ++i) {
97 matrix[getIndex(i, i)] = cov[i % cov.size()];
101 for (
int iRow = 0, n = 0; iRow < 3; ++iRow) {
102 for (
int iCol = iRow; iCol < 3; ++iCol) {
103 matrix[getIndex(iRow, iCol)] = cov[n++];
108 for (
int iRow = 0; iRow < 3; ++iRow) {
109 for (
int iCol = iRow; iCol < 3; ++iCol) {
110 matrix[getIndex(iRow, iCol)] = cov[iRow * 3 + iCol];
115 B2ERROR(
"Number of elements to set covariance matrix must be either 1, 3, 6 or 9 but "
116 << cov.size() <<
" given");
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.
Double32_t m_covLER[6]
Covariance matrix of the low energy beam at the IP.
static ROOT::Math::PxPyPzEVector getFourVector(double energy, double angleX, double angleY, bool isHER)
Calculate FourVector of a beam from energy and angles in xz and yz planes.
Double32_t m_covHER[6]
Covariance matrix of the high energy beam at the IP.
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.
static void setCovMatrix(Double32_t *member, const std::vector< double > &cov, bool common)
Set covariance matrix from vector of entries.
Double32_t m_covVertex[6]
Covariance matrix of the vertex position.
static TMatrixDSym getCovMatrix(const Double32_t *member)
Obtain covariance matrix from a given float array.
void setVertex(const ROOT::Math::XYZVector &vertex, const std::vector< double > &cov)
Set the vertex position and error matrix.
static const double electronMass
electron mass
Abstract base class for different kinds of events.