CbmRoot
Loading...
Searching...
No Matches
KfTrajectory.h
Go to the documentation of this file.
1/* Copyright (C) 2007-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergey Gorbunov [committer] */
4
5
10
11#ifndef KF_CORE_KfTrajectory_h
12#define KF_CORE_KfTrajectory_h 1
13
14#include "KfDefs.h"
15#include "KfMeasurementTime.h"
16#include "KfMeasurementXy.h"
17#include "KfSetup.h"
18#include "KfSimd.h"
19#include "KfTrackParam.h"
20
21template<cbm::algo::kf::DoFitTime>
23
24class CbmBbaAlignTask;
26
27namespace cbm::algo::kf
28{
48 template<typename T = double>
49 class alignas(VcMemAlign) Trajectory {
50
51 public:
52 template<cbm::algo::kf::DoFitTime>
53 friend class ::CbmKfTrackFitter;
54
55 friend class ::CbmBbaAlignTask;
56 friend class ::CbmBbaAlignmentMcbmTask;
57
58
62 struct alignas(VcMemAlign) Node {
63
64
65 T z{0.};
66
69
71
72 int materialLayer{-1};
73
76 T radThick{0.};
77
79
82
84
85 bool isXySet{false};
86 bool isTimeSet{false};
87 bool isFitted{false};
88
90 std::array<int, 10> userReferences{{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}};
91
92 public:
94 bool operator<(const Node& other) const
95 {
96 if (materialLayer >= 0 && other.materialLayer >= 0 && materialLayer != other.materialLayer) {
97 return materialLayer < other.materialLayer;
98 }
99 return z < other.z;
100 }
101
102 }; // struct Node
103
104
106 Trajectory() = default;
107
109 Trajectory(std::shared_ptr<const Setup<T>> kfSetup) : fKfSetup(kfSetup) {}
110
112 ~Trajectory() = default;
113
115 Trajectory(const Trajectory& other) = default;
116
118 Trajectory& operator=(const Trajectory& other) = default;
119
121 Trajectory(Trajectory&& other) noexcept = default;
122
124 Trajectory& operator=(Trajectory&& other) noexcept = default;
125
127 void SetKfSetup(std::shared_ptr<const Setup<T>> kfSetup) { fKfSetup = kfSetup; }
128
130 size_t GetNofNodes() const { return fNodes.size(); }
131
133 const Node& GetNode(const size_t index) const { return fNodes[index]; }
134
136 const std::vector<Node>& GetNodes() const { return fNodes; }
137
139 const std::array<int, 10>& GetNodeUserReferences(const size_t index) const { return fNodes[index].userReferences; }
140
142 std::array<int, 10>& GetNodeUserReferences(const size_t index) { return fNodes[index].userReferences; }
143
146
149
152 {
153 assert(fFirstMeasurementNodeId >= 0 && fFirstMeasurementNodeId < static_cast<int>(fNodes.size()));
155 }
156
159 {
160 assert(fLastMeasurementNodeId >= 0 && fLastMeasurementNodeId < static_cast<int>(fNodes.size()));
162 }
163
165 int GetNofMeasurements() const { return fNmeasurements; }
166
168 bool IsFitted() const { return fIsFitted; }
169
172
174 double GetQaChi2Downstream() const { return fQaChi2Downstream; }
175
177 void Clear()
178 {
179 fNodes.clear();
180 fIsFitted = false;
181 fIsFullyExtrapolated = false;
184 fNmeasurements = -1;
185 fQaChi2Downstream = -1.;
186 }
187
189 void AddNode(const Node& node)
190 {
191 fNodes.push_back(node);
193 }
194
196 void AddNodes(const std::vector<Node>& nodes)
197 {
198 fNodes.reserve(fNodes.size() + nodes.size());
199 for (const auto& n : nodes) {
200 fNodes.push_back(n);
201 }
203 }
204
206 void DisableMeasurementAtNode(const size_t index)
207 {
208 if (index >= fNodes.size()) {
209 LOG(fatal) << "KfTrajectory::DisableMeasurementAtNode: index " << index << " is out of range!";
210 }
211 fNodes[index].isXySet = false;
212 fNodes[index].isTimeSet = false;
214 if (index == static_cast<size_t>(fFirstMeasurementNodeId)) {
216 for (size_t i = index + 1; i < fNodes.size(); ++i) {
217 if (fNodes[i].isXySet) {
219 break;
220 }
221 }
222 }
223 if (index == static_cast<size_t>(fLastMeasurementNodeId)) {
225 for (int i = static_cast<int>(index) - 1; i >= 0; --i) {
226 if (fNodes[i].isXySet) {
228 break;
229 }
230 }
231 }
232 }
233
235 void ModifyNode(const size_t index, const Node& node)
236 {
237 fNodes[index] = node;
239 }
240
241 protected:
243 void MakeConsistent();
244
246 Node& GetNodeReference(const size_t index) { return fNodes[index]; }
247
248 protected:
249 std::shared_ptr<const Setup<T>> fKfSetup{};
250
251 std::vector<Node> fNodes{};
252
256
258 false};
259
261 false};
262
264 };
265
266} // namespace cbm::algo::kf
267
268#endif // KF_CORE_KfTrajectory_h
Common constant definitions for the Kalman Filter library.
Definition of the KfMeasurementXy class.
Setup representation for the Kalman-filter framework (header)
Implementation selection for the SIMD utilities (VS or pseudo)
an example of alignment using BBA package
The class describes a time measurement.
The class describes a 2D - measurement (x, y) in XY coordinate system.
KF-framework representation of the detector setup.
Definition KfSetup.h:37
TrackParam classes of different types.
Trajectory(std::shared_ptr< const Setup< T > > kfSetup)
void Clear()
Clear the trajectory.
T fQaChi2Downstream
chi2 from the downstream fit iteration, needed for QA
bool fIsFitted
true if the trajectory at all the nodes between the first and the last measurements are fitted
std::shared_ptr< const Setup< T > > fKfSetup
Kalman Filter setup.
bool IsFullyExtrapolated() const
Check if the trajectory is extrapolated beyond the first and last measurements.
int fFirstMeasurementNodeId
index of the first node with measurement
std::array< int, 10 > & GetNodeUserReferences(const size_t index)
Get reference to the user references of the node by its index.
int GetNofMeasurements() const
Get number of nodes with measurements.
const Node & GetLastMeasurementNode() const
Get reference to the last node with measurement.
void MakeConsistent()
sort the nodes in Z, add missing material layers and set fFirstMeasureNode and fLastMeasureNode
void AddNode(const Node &node)
Add a node to the trajectory.
void AddNodes(const std::vector< Node > &nodes)
Add multiple nodes to the trajectory.
Trajectory(Trajectory &&other) noexcept=default
Move constructor.
double GetQaChi2Downstream() const
Get chi2 from the downstream fit iteration, needed for QA.
Trajectory & operator=(const Trajectory &other)=default
Assignment operator.
void ModifyNode(const size_t index, const Node &node)
Modify node at the given index.
size_t GetNofNodes() const
Get number of nodes on the trajectory.
bool IsFitted() const
Check if the trajectory is fitted.
void SetKfSetup(std::shared_ptr< const Setup< T > > kfSetup)
Set Kalman Filter setup.
const std::array< int, 10 > & GetNodeUserReferences(const size_t index) const
Get user reference of the node by its index.
std::vector< Node > fNodes
nodes on the trajectory
Node & GetNodeReference(const size_t index)
Get reference to the node by its index.
const std::vector< Node > & GetNodes() const
Get reference to the vector of nodes.
void DisableMeasurementAtNode(const size_t index)
Disable measurement at the given node.
const Node & GetNode(const size_t index) const
Get const reference to the node by its index.
int GetLastMeasurementNodeId() const
Get index of the last node with measurement.
Trajectory(const Trajectory &other)=default
Copy constructor.
bool fIsFullyExtrapolated
true if the trajectory is successfully extrapolated beyond the first and last measurements
~Trajectory()=default
Destructor.
const Node & GetFirstMeasurementNode() const
Get reference to the first node with measurement.
int fLastMeasurementNodeId
index of the last node with measurement
int fNmeasurements
number of nodes with measurements
int GetFirstMeasurementNodeId() const
Get index of the first node with measurement.
Trajectory & operator=(Trajectory &&other) noexcept=default
Move assignment operator.
Trajectory()=default
Default constructor.
The class represent a node on the trajectory.
MeasurementXy< T > measurementXY
== Measurement information ( if present )
T z
Z coordinate of the node.
TrackParam< T > paramDn
fitted track parameters downstream the node
int materialLayer
== Material information (if present)
bool isTimeSet
true if the time measurement is set
TrackParam< T > paramUp
fitted track parameters upstream the node
bool operator<(const Node &other) const
Comparison operator for sorting nodes in Z.
MeasurementTime< T > measurementTime
time measurement at z
bool isFitted
true if the track parameters at the node are fitted and radThick is set
std::array< int, 10 > userReferences
user references (to store e.g. hit index or index of the node description in some external array)