CbmRoot
Loading...
Searching...
No Matches
KfTrajectory.cxx
Go to the documentation of this file.
1/* Copyright (C) 2007-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergey Gorbunov [committer] */
4
5#include "KfTrajectory.h"
6
8
9
10using namespace cbm::algo::kf;
11
12
13template<typename T>
15{
16 // sort the nodes in Z, add missing material layers and set fFirstMeasurementNodeId and fLastMeasurementNodeId
17
18 if (!fKfSetup) {
19 LOG(fatal) << "KfTrajectory::MakeConsistent: fKfSetup is not set!";
20 }
21
25 fIsFitted = false;
28
29 if (fNodes.empty()) {
30 return;
31 }
32
33 std::sort(fNodes.begin(), fNodes.end());
34
35 std::vector<char> isMaterialLayerPresent(fKfSetup->GetNofLayers(), false);
36
37 // mark existing material layers
38 for (const auto& n : fNodes) {
39 if (n.materialLayer >= 0 && n.materialLayer < fKfSetup->GetNofLayers()) {
40 isMaterialLayerPresent[n.materialLayer] = true;
41 }
42 }
43
44 // add missing material layers between the first and the last nodes
45
46 double zMin = fNodes.front().z;
47 double zMax = fNodes.back().z;
48 unsigned int sizeOld = fNodes.size();
49
50 for (int ml = 0; ml < fKfSetup->GetNofLayers(); ++ml) {
51 const auto& mat = fKfSetup->GetMaterial(ml);
52 if (mat.GetZref() < zMin) {
53 continue;
54 }
55 if (mat.GetZref() > zMax) {
56 break;
57 }
58 if (isMaterialLayerPresent[ml]) {
59 continue;
60 }
61 Node matNode;
62 matNode.materialLayer = ml;
63 matNode.z = mat.GetZref();
64 fNodes.push_back(matNode);
65 }
66 // sort again after adding material layers
67 if (fNodes.size() > sizeOld) {
68 std::sort(fNodes.begin(), fNodes.end());
69 }
70
71 // set first and last measurement nodes
72 for (unsigned int i = 0; i < fNodes.size(); i++) {
73 const auto& n = fNodes[i];
74 if (n.isXySet) {
78 }
80 }
81 }
82} // MakeConsistent
83
84
header file for the kf::Trajectory class
The class describes the particle's trajectory along its entire length.
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.
int fFirstMeasurementNodeId
index of the first node with measurement
void MakeConsistent()
sort the nodes in Z, add missing material layers and set fFirstMeasureNode and fLastMeasureNode
std::vector< Node > fNodes
nodes on the trajectory
bool fIsFullyExtrapolated
true if the trajectory is successfully extrapolated beyond the first and last measurements
int fLastMeasurementNodeId
index of the last node with measurement
int fNmeasurements
number of nodes with measurements
The class represent a node on the trajectory.
T z
Z coordinate of the node.
int materialLayer
== Material information (if present)