Belle II Software development
BeamParameters.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <framework/dataobjects/MCInitialParticles.h>
12#include <framework/logging/Logger.h>
13#include <TMatrixDSym.h>
14#include <Math/Vector4D.h>
15
16namespace Belle2 {
26
27 public:
28
32
35 {
36 // 14 means all the smearings turned on
38 }
39
42 {
43 std::copy_n(b.m_covHER, 6, m_covHER);
44 std::copy_n(b.m_covLER, 6, m_covLER);
45 std::copy_n(b.m_covVertex, 6, m_covVertex);
46 }
47
50 {
52 std::copy_n(b.m_covHER, 6, m_covHER);
53 std::copy_n(b.m_covLER, 6, m_covLER);
54 std::copy_n(b.m_covVertex, 6, m_covVertex);
55 return *this;
56 }
57
59 bool operator==(const BeamParameters& b) const
60 {
61 // since we only save the covariance matrices with float precision we
62 // need to also do the comparison with float precision.
63 auto floatcmp = [](double dbl_a, double dbl_b) { return (float)dbl_a == (float)dbl_b; };
65 std::equal(m_covHER, m_covHER + 6, b.m_covHER, floatcmp) &&
66 std::equal(m_covLER, m_covLER + 6, b.m_covLER, floatcmp) &&
67 std::equal(m_covVertex, m_covVertex + 6, b.m_covVertex, floatcmp);
68 }
69
74 void setGenerationFlags(int flags) override
75 {
76 if (flags != 14)
77 B2WARNING(R"RAW(The generation flags are not set to the default value.
78
79 The default value for the generation flags is 14: a different value means
80 that some smearings (beam energy, vertex position, etc.) may be turned off.
81
82 This is fine only for local tests or for special MC productions, but not
83 for default MC productions.)RAW");
84 m_generationFlags = flags;
85 }
86
91 void setCovHER(const TMatrixDSym& cov) { setCovMatrix(m_covHER, cov); }
92
97 void setCovLER(const TMatrixDSym& cov) { setCovMatrix(m_covLER, cov); }
98
100 void setCovVertex(const TMatrixDSym& cov) { setCovMatrix(m_covVertex, cov); }
101
118 void setHER(double energy, double angleX, double angleY, const std::vector<double>& cov);
119
136 void setLER(double energy, double angleX, double angleY, const std::vector<double>& cov);
137
152 void setVertex(const ROOT::Math::XYZVector& vertex, const std::vector<double>& cov);
153
157 TMatrixDSym getCovHER() const { return getCovMatrix(m_covHER); }
158
162 TMatrixDSym getCovLER() const { return getCovMatrix(m_covLER); }
163
165 TMatrixDSym getCovVertex() const { return getCovMatrix(m_covVertex); }
166
175 static ROOT::Math::PxPyPzEVector getFourVector(double energy, double angleX, double angleY, bool isHER);
176
177 private:
178
198 static void setCovMatrix(Double32_t* member, const std::vector<double>& cov, bool common);
199
201 static void setCovMatrix(Double32_t* member, const TMatrixDSym& cov);
202
204 static TMatrixDSym getCovMatrix(const Double32_t* member);
205
207 Double32_t m_covHER[6];
208
210 Double32_t m_covLER[6];
211
213 Double32_t m_covVertex[6];
214
217 };
218
220} //Belle2 namespace
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.
Double32_t m_covLER[6]
Covariance matrix of the low energy beam at the IP.
TMatrixDSym getCovVertex() const
Get the covariance matrix of the vertex position.
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 TMatrixDSym &cov)
Set covariance matrix from ROOT Matrix object.
BeamParameters(const BeamParameters &b)
Copy constructor.
void setCovLER(const TMatrixDSym &cov)
Set the covariance matrix for LER (E, theta_x, theta_y) where E is the energy, theta_x is the horizon...
static TMatrixDSym getCovMatrix(const Double32_t *member)
Obtain covariance matrix from a given float array.
Double32_t m_covVertex[6]
Covariance matrix of the vertex position.
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...
BeamParameters & operator=(const BeamParameters &b)
Assignment operator.
static void setCovMatrix(Double32_t *member, const std::vector< double > &cov, bool common)
Set covariance matrix from vector of entries.
TMatrixDSym getCovLER() const
Get the covariance matrix of LER (E, theta_x, theta_y) where E is the energy, theta_x is the horizont...
ClassDefOverride(BeamParameters, 3)
ClassDef.
TMatrixDSym getCovHER() const
Get the covariance matrix of HER (E, theta_x, theta_y) where E is the energy, theta_x is the horizont...
bool operator==(const BeamParameters &b) const
Equality operator.
BeamParameters()
Default constructor.
void setVertex(const ROOT::Math::XYZVector &vertex, const std::vector< double > &cov)
Set the vertex position and error matrix.
void setGenerationFlags(int flags) override
Set the generation flags to be used for event generation (ORed combination of EGenerationFlags).
void setCovVertex(const TMatrixDSym &cov)
Set the covariance matrix of the vertex position.
This class contains the initial state for the given event.
int m_generationFlags
Flags to be used when generating events.
bool operator==(const MCInitialParticles &b) const
Equality operator.
void setVertex(const ROOT::Math::XYZVector &vertex)
Set the vertex position.
MCInitialParticles & operator=(const MCInitialParticles &b)
Assignment operator.
void setHER(const ROOT::Math::PxPyPzEVector &her)
Set the High Energy Beam 4-momentum.
void setLER(const ROOT::Math::PxPyPzEVector &ler)
Set the Low Energy Beam 4-momentum.
Abstract base class for different kinds of events.