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
tmtt::KalmanState::matV_
TMatrixD matV_
Definition: KalmanState.h:87
tmtt::KalmanState::settings_
const Settings * settings_
Definition: KalmanState.h:79
tmtt::KalmanState::kalmanChi2RphiScale_
unsigned int kalmanChi2RphiScale_
Definition: KalmanState.h:91
tmtt::KalmanState::n_stubs_
unsigned n_stubs_
Definition: KalmanState.h:92
tmtt::Stub::assocTPs
const std::set< const TP * > & assocTPs() const
Definition: Stub.h:164
tmtt::KalmanState::good
bool good(const TP *tp) const
Definition: KalmanState.cc:58
tmtt::Stub::r
float r() const
Definition: Stub.h:108
tmtt::KalmanState::chi2
double chi2() const
Definition: KalmanState.h:61
tmtt::TP
Definition: TP.h:23
tmtt::KalmanState::last_state
const KalmanState * last_state() const
Definition: KalmanState.h:47
tmtt::KalmanState::z_
double z_
Definition: KalmanState.h:82
groupFilesInBlocks.reverse
reverse
Definition: groupFilesInBlocks.py:131
tmtt::KalmanState::reducedChi2
double reducedChi2() const
Definition: KalmanState.cc:72
tmtt::KalmanState::stubs
std::vector< Stub * > stubs() const
Definition: KalmanState.cc:89
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
tmtt::Stub::z
float z() const
Definition: Stub.h:109
tmtt::KalmanState::r_
double r_
Definition: KalmanState.h:81
KalmanState.h
tmtt::KalmanState::matK_
TMatrixD matK_
Definition: KalmanState.h:86
tmtt::KalmanState
Definition: KalmanState.h:22
tmtt::Settings
Definition: Settings.h:17
tmtt::Settings::kalmanChi2RphiScale
unsigned int kalmanChi2RphiScale() const
Definition: Settings.h:326
tmtt::KalmanState::hitPattern_
unsigned int hitPattern_
Definition: KalmanState.h:96
tmtt::KalmanState::vecX_
TVectorD vecX_
Definition: KalmanState.h:84
tmtt::KalmanState::barrel_
bool barrel_
Definition: KalmanState.h:93
tmtt::Stub::barrel
bool barrel() const
Definition: Stub.h:201
std
Definition: JetResolutionObject.h:76
tmtt::KalmanState::last_update_state
const KalmanState * last_update_state() const
Definition: KalmanState.cc:79
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
tmtt::KalmanState::stub
Stub * stub() const
Definition: KalmanState.h:57
tmtt::KalmanState::hitPattern
unsigned int hitPattern() const
Definition: KalmanState.h:66
Settings.h
tmtt::KalmanState::kLayer_
int kLayer_
Definition: KalmanState.h:80
tmtt::KalmanState::nSkipped_
unsigned nSkipped_
Definition: KalmanState.h:94
tmtt::Stub
Definition: Stub.h:43
tmtt::KalmanState::matC_
TMatrixD matC_
Definition: KalmanState.h:85
tmtt::L1track3D
Definition: L1track3D.h:24
tmtt
=== This is the base class for the linearised chi-squared track fit algorithms.
Definition: Array2D.h:16
kLayer
static const std::string kLayer("layer")