CMS 3D CMS Logo

KalmanState.cc
Go to the documentation of this file.
3 #include "TMatrixD.h"
4 
5 using namespace std;
6 
7 namespace tmtt {
8 
9  KalmanState::KalmanState(const Settings *settings,
10  const L1track3D &candidate,
11  unsigned nSkipped,
12  int kLayer,
13  const KalmanState *last_state,
14  const TVectorD &vecX,
15  const TMatrixD &matC,
16  const TMatrixD &matK,
17  const TMatrixD &matV,
18  Stub *stub,
19  double chi2rphi,
20  double chi2rz)
21  : settings_(settings),
22  kLayer_(kLayer),
23  last_state_(last_state),
24  vecX_(vecX),
25  stub_(stub),
26  chi2rphi_(chi2rphi),
27  chi2rz_(chi2rz),
28  nSkipped_(nSkipped),
29  l1track3D_(candidate) {
30  matC_.Clear();
31  matC_.ResizeTo(matC.GetNrows(), matC.GetNcols());
32  matC_ = matC;
33  matK_.ResizeTo(matK.GetNrows(), matK.GetNcols());
34  matK_ = matK;
35  matV_.ResizeTo(matV.GetNrows(), matV.GetNcols());
36  matV_ = matV;
38 
39  hitPattern_ = 0;
40  if (last_state != nullptr)
41  hitPattern_ = last_state->hitPattern(); // Bit encoded list of hit layers
42  if (stub != nullptr && kLayer_ >= 0)
43  hitPattern_ |= (1 << (kLayer_));
44 
45  r_ = 0.1;
46  z_ = 0;
47  barrel_ = true;
48 
49  if (stub != nullptr) {
50  r_ = stub->r();
51  z_ = stub->z();
52  barrel_ = stub->barrel();
53  }
54 
55  n_stubs_ = 1 + kLayer_ - nSkipped_;
56  }
57 
58  bool KalmanState::good(const TP *tp) const {
59  const KalmanState *state = this;
60  while (state) {
61  Stub *stub = state->stub();
62  if (stub != nullptr) {
63  const set<const TP *> &tps = stub->assocTPs();
64  if (tps.find(tp) == tps.end())
65  return false;
66  }
67  state = state->last_state();
68  }
69  return true;
70  }
71 
72  double KalmanState::reducedChi2() const {
73  if (2 * n_stubs_ - vecX_.GetNrows() > 0)
74  return (this->chi2()) / (2 * n_stubs_ - vecX_.GetNrows());
75  else
76  return 0;
77  }
78 
80  const KalmanState *state = this;
81  while (state) {
82  if (state->stub() != nullptr)
83  return state;
84  state = state->last_state();
85  }
86  return nullptr;
87  }
88 
89  std::vector<Stub *> KalmanState::stubs() const {
90  std::vector<Stub *> all_stubs;
91 
92  const KalmanState *state = this;
93  while (state) {
94  Stub *stub = state->stub();
95  if (stub != nullptr)
96  all_stubs.push_back(stub);
97  state = state->last_state();
98  }
99  std::reverse(all_stubs.begin(), all_stubs.end()); // Put innermost stub first.
100  return all_stubs;
101  }
102 
103 } // namespace tmtt
double reducedChi2() const
Definition: KalmanState.cc:72
float r() const
Definition: Stub.h:108
const KalmanState * last_state() const
Definition: KalmanState.h:47
std::vector< Stub * > stubs() const
Definition: KalmanState.cc:89
Stub * stub() const
Definition: KalmanState.h:57
float z() const
Definition: Stub.h:109
const Settings * settings_
Definition: KalmanState.h:79
Definition: TP.h:23
const KalmanState * last_update_state() const
Definition: KalmanState.cc:79
bool good(const TP *tp) const
Definition: KalmanState.cc:58
unsigned nSkipped_
Definition: KalmanState.h:94
unsigned int kalmanChi2RphiScale_
Definition: KalmanState.h:91
double chi2() const
Definition: KalmanState.h:61
static const std::string kLayer("layer")
bool barrel() const
Definition: Stub.h:201
=== This is the base class for the linearised chi-squared track fit algorithms.
Definition: Array2D.h:16
const std::set< const TP * > & assocTPs() const
Definition: Stub.h:164
unsigned int hitPattern_
Definition: KalmanState.h:96
unsigned n_stubs_
Definition: KalmanState.h:92
unsigned int kalmanChi2RphiScale() const
Definition: Settings.h:326
unsigned int hitPattern() const
Definition: KalmanState.h:66