Belle II Software development
ReferenceFrame.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 <Math/Rotation3D.h>
12#include <Math/Boost.h>
13#include <Math/Vector3D.h>
14#include <Math/Vector4D.h>
15#include <analysis/dataobjects/Particle.h>
16#include <analysis/utility/PCmsLabTransform.h>
17
18#include <stack>
19
20namespace Belle2 {
30 public:
36 virtual ROOT::Math::XYZVector getVertex(const ROOT::Math::XYZVector& vector) const = 0;
37
43 virtual ROOT::Math::XYZVector getVertex(const Particle* particle) const
44 {
45 return getVertex(particle->getVertex());
46 }
47
53 virtual ROOT::Math::PxPyPzEVector getMomentum(const ROOT::Math::PxPyPzEVector& vector) const = 0;
54
60 virtual ROOT::Math::PxPyPzEVector getMomentum(const Particle* particle) const
61 {
62 return getMomentum(particle->get4Vector());
63 }
64
70 virtual TMatrixFSym getMomentumErrorMatrix(const TMatrixFSym& matrix) const = 0;
71
77 virtual TMatrixFSym getMomentumErrorMatrix(const Particle* particle) const
78 {
79 return getMomentumErrorMatrix(particle->getMomentumErrorMatrix());
80 }
81
87 virtual TMatrixFSym getVertexErrorMatrix(const TMatrixFSym& matrix) const = 0;
88
94 virtual TMatrixFSym getVertexErrorMatrix(const Particle* particle) const
95 {
96 return getVertexErrorMatrix(particle->getVertexErrorMatrix());
97 }
98
103 static const ReferenceFrame& GetCurrent();
104
105 private:
110 static void Push(const ReferenceFrame* frame)
111 {
112 m_reference_frames.push(frame);
113 }
114
118 static void Pop()
119 {
120 m_reference_frames.pop();
121 }
122
123 static std::stack<const ReferenceFrame*> m_reference_frames;
125 template<class T>
126 friend class UseReferenceFrame;
127 };
128
132 class RestFrame : public ReferenceFrame {
133
134 public:
138 explicit RestFrame(const Particle* particle);
139
145 virtual ROOT::Math::XYZVector getVertex(const ROOT::Math::XYZVector& vector) const override;
146
152 virtual ROOT::Math::PxPyPzEVector getMomentum(const ROOT::Math::PxPyPzEVector& vector) const override;
153
159 virtual TMatrixFSym getMomentumErrorMatrix(const TMatrixFSym& matrix) const override;
160
166 virtual TMatrixFSym getVertexErrorMatrix(const TMatrixFSym& matrix) const override;
167
168 private:
169 ROOT::Math::PxPyPzEVector m_momentum;
170 ROOT::Math::XYZVector m_displacement;
171 ROOT::Math::XYZVector m_boost;
172 ROOT::Math::Boost m_lab2restframe;
173 };
174
178 class LabFrame : public ReferenceFrame {
179
180 public:
181
187 virtual ROOT::Math::XYZVector getVertex(const ROOT::Math::XYZVector& vector) const override;
188
194 virtual ROOT::Math::PxPyPzEVector getMomentum(const ROOT::Math::PxPyPzEVector& vector) const override;
195
201 virtual TMatrixFSym getMomentumErrorMatrix(const TMatrixFSym& matrix) const override;
202
208 virtual TMatrixFSym getVertexErrorMatrix(const TMatrixFSym& matrix) const override;
209
210 };
211
215 class CMSFrame : public ReferenceFrame {
216
217 public:
223 virtual ROOT::Math::XYZVector getVertex(const ROOT::Math::XYZVector& vector) const override;
224
230 virtual ROOT::Math::PxPyPzEVector getMomentum(const ROOT::Math::PxPyPzEVector& vector) const override;
231
237 virtual TMatrixFSym getMomentumErrorMatrix(const TMatrixFSym& matrix) const override;
238
244 virtual TMatrixFSym getVertexErrorMatrix(const TMatrixFSym& matrix) const override;
245
246 private:
248 };
249
254
255 public:
259 explicit RotationFrame(const ROOT::Math::XYZVector& newX, const ROOT::Math::XYZVector& newY, const ROOT::Math::XYZVector& newZ);
260
266 virtual ROOT::Math::XYZVector getVertex(const ROOT::Math::XYZVector& vector) const override;
267
273 virtual ROOT::Math::PxPyPzEVector getMomentum(const ROOT::Math::PxPyPzEVector& vector) const override;
274
280 virtual TMatrixFSym getMomentumErrorMatrix(const TMatrixFSym& matrix) const override;
281
287 virtual TMatrixFSym getVertexErrorMatrix(const TMatrixFSym& matrix) const override;
288
289 private:
290 ROOT::Math::Rotation3D m_rotation;
291 };
292
297
298 public:
302 explicit CMSRotationFrame(const ROOT::Math::XYZVector& newX, const ROOT::Math::XYZVector& newY, const ROOT::Math::XYZVector& newZ);
303
309 virtual ROOT::Math::XYZVector getVertex(const ROOT::Math::XYZVector& vector) const override;
310
316 virtual ROOT::Math::PxPyPzEVector getMomentum(const ROOT::Math::PxPyPzEVector& vector) const override;
317
323 virtual TMatrixFSym getMomentumErrorMatrix(const TMatrixFSym& matrix) const override;
324
330 virtual TMatrixFSym getVertexErrorMatrix(const TMatrixFSym& matrix) const override;
331
332 private:
336 };
337
339 template<class T>
341 public:
343 template<class ...Args>
344 explicit UseReferenceFrame(Args&& ... params) : m_frame(std::forward<Args>(params)...)
345 {
347 }
348
351 {
353 }
354 private:
356 };
357
359} // Belle2 namespace
360
virtual TMatrixFSym getVertexErrorMatrix(const TMatrixFSym &matrix) const override
Get Vertex error matrix in cms frame.
virtual TMatrixFSym getMomentumErrorMatrix(const TMatrixFSym &matrix) const override
Get Momentum error matrix in cms frame.
virtual ROOT::Math::XYZVector getVertex(const ROOT::Math::XYZVector &vector) const override
Get vertex 3-vector in cms frame.
PCmsLabTransform m_transform
Lab to CMS Transform.
virtual ROOT::Math::PxPyPzEVector getMomentum(const ROOT::Math::PxPyPzEVector &vector) const override
Get Lorentz vector in cms frame.
Stack frame for cms and Rotation frame.
virtual TMatrixFSym getVertexErrorMatrix(const TMatrixFSym &matrix) const override
Get Vertex error matrix in rotation frame.
virtual TMatrixFSym getMomentumErrorMatrix(const TMatrixFSym &matrix) const override
Get Momentum error matrix in rotation frame.
virtual ROOT::Math::XYZVector getVertex(const ROOT::Math::XYZVector &vector) const override
Get vertex 3-vector in rotation frame.
RotationFrame rotationframe
Rotationframe.
CMSFrame cmsframe
CMSFrame.
virtual ROOT::Math::PxPyPzEVector getMomentum(const ROOT::Math::PxPyPzEVector &vector) const override
Get Lorentz vector in rotation frame.
virtual TMatrixFSym getVertexErrorMatrix(const TMatrixFSym &matrix) const override
Get Vertex error matrix in lab frame.
virtual TMatrixFSym getMomentumErrorMatrix(const TMatrixFSym &matrix) const override
Get Momentum error matrix in lab frame.
virtual ROOT::Math::XYZVector getVertex(const ROOT::Math::XYZVector &vector) const override
Get vertex 3-vector in lab frame.
virtual ROOT::Math::PxPyPzEVector getMomentum(const ROOT::Math::PxPyPzEVector &vector) const override
Get Lorentz vector in lab frame.
Class to hold Lorentz transformations from/to CMS and boost vector.
Class to store reconstructed particles.
Definition: Particle.h:75
Abstract base class of all reference frames.
virtual TMatrixFSym getVertexErrorMatrix(const Particle *particle) const
Wrapper for particles.
virtual ROOT::Math::XYZVector getVertex(const ROOT::Math::XYZVector &vector) const =0
Get vertex 3-vector in reference frame.
virtual TMatrixFSym getVertexErrorMatrix(const TMatrixFSym &matrix) const =0
Get Vertex error matrix in reference frame.
virtual TMatrixFSym getMomentumErrorMatrix(const TMatrixFSym &matrix) const =0
Get Momentum error matrix in reference frame.
static std::stack< const ReferenceFrame * > m_reference_frames
Stack of current rest frames.
virtual TMatrixFSym getMomentumErrorMatrix(const Particle *particle) const
Wrapper for particles.
virtual ROOT::Math::PxPyPzEVector getMomentum(const Particle *particle) const
Wrapper for particles.
static void Pop()
Pop current rest frame.
virtual ROOT::Math::PxPyPzEVector getMomentum(const ROOT::Math::PxPyPzEVector &vector) const =0
Get momentum 4-vector in reference frame.
virtual ROOT::Math::XYZVector getVertex(const Particle *particle) const
Wrapper for particles.
static const ReferenceFrame & GetCurrent()
Get current rest frame.
static void Push(const ReferenceFrame *frame)
Push rest frame of given particle.
Rest frame of a particle.
virtual TMatrixFSym getVertexErrorMatrix(const TMatrixFSym &matrix) const override
Get Vertex error matrix in rest frame.
virtual TMatrixFSym getMomentumErrorMatrix(const TMatrixFSym &matrix) const override
Get Momentum error matrix in rest frame.
ROOT::Math::PxPyPzEVector m_momentum
momentum of RF in the lab frame
ROOT::Math::XYZVector m_displacement
displacement of RF origin in th lab frame
virtual ROOT::Math::XYZVector getVertex(const ROOT::Math::XYZVector &vector) const override
Get vertex 3-vector in rest frame system.
ROOT::Math::XYZVector m_boost
boost of RF relative to the lab frame
virtual ROOT::Math::PxPyPzEVector getMomentum(const ROOT::Math::PxPyPzEVector &vector) const override
Get Lorentz vector in rest frame System.
ROOT::Math::Boost m_lab2restframe
Lorentz transformation connecting lab and rest frame.
Rotation frame around vector.
virtual TMatrixFSym getVertexErrorMatrix(const TMatrixFSym &matrix) const override
Get Vertex error matrix in rotation frame.
virtual TMatrixFSym getMomentumErrorMatrix(const TMatrixFSym &matrix) const override
Get Momentum error matrix in rotation frame.
virtual ROOT::Math::XYZVector getVertex(const ROOT::Math::XYZVector &vector) const override
Get vertex 3-vector in rotation frame.
ROOT::Math::Rotation3D m_rotation
Rotation.
virtual ROOT::Math::PxPyPzEVector getMomentum(const ROOT::Math::PxPyPzEVector &vector) const override
Get Lorentz vector in rotation frame.
A template class to apply the reference frame.
UseReferenceFrame(Args &&... params)
Constructor which applies the reference frame
T m_frame
the reference frame
Abstract base class for different kinds of events.
STL namespace.