BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnKalmanFilter.h
Go to the documentation of this file.
1/*
2 * File: BmnKalmanFilter.h
3 *
4 * Created on July 29, 2015, 9:48 AM
5 */
6
7#ifndef BmnKalmanFilter_H
8#define BmnKalmanFilter_H
9
10#include "BmnEnums.h"
11#include "BmnFitNode.h"
12#include "BmnGeoNavigator.h"
13#include "BmnHit.h"
14#include "BmnMaterialEffects.h"
15#include "BmnMath.h"
16#include "BmnMatrixMath.h"
17#include "CbmStsTrack.h"
18#include "FairField.h"
19#include "FairRunAna.h"
20#include "FairTrackParam.h"
21#include "TClonesArray.h"
22#include "TMath.h"
23#include "TMatrixD.h"
24
25#include <vector>
26
28{
29 public:
31 virtual ~BmnKalmanFilter();
32
33 static const Int_t kMaxHits = 11; // 4 FSD + 7 GEM
34
35 BmnStatus Update(FairTrackParam* par, const BmnHit* hit, Double_t& chiSq);
36 BmnStatus Smooth(BmnFitNode* thisNode, BmnFitNode* prevNode);
37 BmnStatus TGeoTrackPropagate(FairTrackParam* par,
38 Double_t zOut,
39 Int_t pdg,
40 vector<Double_t>* F,
41 Double_t* length,
42 Bool_t isField);
43 BmnStatus TGeoTrackPropagate(FairTrackParam* par, Double_t zOut, Int_t pdg, vector<Double_t>* F, Double_t* length);
44
45 // === Residuals ===
47 BmnHit** hitsArray,
48 Int_t nHits,
49 Int_t pdg,
50 Double_t* resX,
51 Double_t* resY,
52 Int_t* station,
53 Int_t& nRes);
54
56 BmnHit** hitsArray,
57 Int_t nHits,
58 Int_t station,
59 Int_t pdg,
60 Double_t& resX,
61 Double_t& resY);
62
63 private:
64 void RK4Order(const Double_t* xIn, Double_t zIn, Double_t* xOut, Double_t zOut, Double_t* derivs, FairField* field);
65
66 inline void UpdateF(Double_t* F, const Double_t* newF)
67 {
68 Double_t A[25];
69 A[0] = newF[0] * F[0] + newF[1] * F[5] + newF[2] * F[10] + newF[3] * F[15] + newF[4] * F[20];
70 A[1] = newF[0] * F[1] + newF[1] * F[6] + newF[2] * F[11] + newF[3] * F[16] + newF[4] * F[21];
71 A[2] = newF[0] * F[2] + newF[1] * F[7] + newF[2] * F[12] + newF[3] * F[17] + newF[4] * F[22];
72 A[3] = newF[0] * F[3] + newF[1] * F[8] + newF[2] * F[13] + newF[3] * F[18] + newF[4] * F[23];
73 A[4] = newF[0] * F[4] + newF[1] * F[9] + newF[2] * F[14] + newF[3] * F[19] + newF[4] * F[24];
74 A[5] = newF[5] * F[0] + newF[6] * F[5] + newF[7] * F[10] + newF[8] * F[15] + newF[9] * F[20];
75 A[6] = newF[5] * F[1] + newF[6] * F[6] + newF[7] * F[11] + newF[8] * F[16] + newF[9] * F[21];
76 A[7] = newF[5] * F[2] + newF[6] * F[7] + newF[7] * F[12] + newF[8] * F[17] + newF[9] * F[22];
77 A[8] = newF[5] * F[3] + newF[6] * F[8] + newF[7] * F[13] + newF[8] * F[18] + newF[9] * F[23];
78 A[9] = newF[5] * F[4] + newF[6] * F[9] + newF[7] * F[14] + newF[8] * F[19] + newF[9] * F[24];
79 A[10] = newF[10] * F[0] + newF[11] * F[5] + newF[12] * F[10] + newF[13] * F[15] + newF[14] * F[20];
80 A[11] = newF[10] * F[1] + newF[11] * F[6] + newF[12] * F[11] + newF[13] * F[16] + newF[14] * F[21];
81 A[12] = newF[10] * F[2] + newF[11] * F[7] + newF[12] * F[12] + newF[13] * F[17] + newF[14] * F[22];
82 A[13] = newF[10] * F[3] + newF[11] * F[8] + newF[12] * F[13] + newF[13] * F[18] + newF[14] * F[23];
83 A[14] = newF[10] * F[4] + newF[11] * F[9] + newF[12] * F[14] + newF[13] * F[19] + newF[14] * F[24];
84 A[15] = newF[15] * F[0] + newF[16] * F[5] + newF[17] * F[10] + newF[18] * F[15] + newF[19] * F[20];
85 A[16] = newF[15] * F[1] + newF[16] * F[6] + newF[17] * F[11] + newF[18] * F[16] + newF[19] * F[21];
86 A[17] = newF[15] * F[2] + newF[16] * F[7] + newF[17] * F[12] + newF[18] * F[17] + newF[19] * F[22];
87 A[18] = newF[15] * F[3] + newF[16] * F[8] + newF[17] * F[13] + newF[18] * F[18] + newF[19] * F[23];
88 A[19] = newF[15] * F[4] + newF[16] * F[9] + newF[17] * F[14] + newF[18] * F[19] + newF[19] * F[24];
89 A[20] = newF[20] * F[0] + newF[21] * F[5] + newF[22] * F[10] + newF[23] * F[15] + newF[24] * F[20];
90 A[21] = newF[20] * F[1] + newF[21] * F[6] + newF[22] * F[11] + newF[23] * F[16] + newF[24] * F[21];
91 A[22] = newF[20] * F[2] + newF[21] * F[7] + newF[22] * F[12] + newF[23] * F[17] + newF[24] * F[22];
92 A[23] = newF[20] * F[3] + newF[21] * F[8] + newF[22] * F[13] + newF[23] * F[18] + newF[24] * F[23];
93 A[24] = newF[20] * F[4] + newF[21] * F[9] + newF[22] * F[14] + newF[23] * F[19] + newF[24] * F[24];
94 for (Int_t i = 0; i < 25; i++)
95 F[i] = A[i];
96 }
97
98 // === TransportC inline ===
99 inline void TransportC(const Double_t* cIn, const Double_t* F, Double_t* cOut)
100 {
101 Double_t A = cIn[2] + F[2] * cIn[9] + F[3] * cIn[10] + F[4] * cIn[11];
102 Double_t B = cIn[3] + F[2] * cIn[10] + F[3] * cIn[12] + F[4] * cIn[13];
103 Double_t C = cIn[4] + F[2] * cIn[11] + F[3] * cIn[13] + F[4] * cIn[14];
104
105 Double_t D = cIn[6] + F[7] * cIn[9] + F[8] * cIn[10] + F[9] * cIn[11];
106 Double_t E = cIn[7] + F[7] * cIn[10] + F[8] * cIn[12] + F[9] * cIn[13];
107 Double_t G = cIn[8] + F[7] * cIn[11] + F[8] * cIn[13] + F[9] * cIn[14];
108
109 Double_t H = cIn[9] + F[13] * cIn[10] + F[14] * cIn[11];
110 Double_t I = cIn[10] + F[13] * cIn[12] + F[14] * cIn[13];
111 Double_t J = cIn[11] + F[13] * cIn[13] + F[14] * cIn[14];
112
113 Double_t K = cIn[13] + F[17] * cIn[11] + F[19] * cIn[14];
114
115 cOut[0] = cIn[0] + F[2] * cIn[2] + F[3] * cIn[3] + F[4] * cIn[4] + A * F[2] + B * F[3] + C * F[4];
116 cOut[1] = cIn[1] + F[2] * cIn[6] + F[3] * cIn[7] + F[4] * cIn[8] + A * F[7] + B * F[8] + C * F[9];
117 cOut[2] = A + B * F[13] + C * F[14];
118 cOut[3] = B + A * F[17] + C * F[19];
119 cOut[4] = C;
120
121 cOut[5] = cIn[5] + F[7] * cIn[6] + F[8] * cIn[7] + F[9] * cIn[8] + D * F[7] + E * F[8] + G * F[9];
122 cOut[6] = D + E * F[13] + G * F[14];
123 cOut[7] = E + D * F[17] + G * F[19];
124 cOut[8] = G;
125
126 cOut[9] = H + I * F[13] + J * F[14];
127 cOut[10] = I + H * F[17] + J * F[19];
128 cOut[11] = J;
129
130 cOut[12] = cIn[12] + F[17] * cIn[10] + F[19] * cIn[13] + (F[17] * cIn[9] + cIn[10] + F[19] * cIn[11]) * F[17]
131 + K * F[19];
132 cOut[13] = K;
133
134 cOut[14] = cIn[14];
135 }
136
137 // === CalcOut inline ===
138 inline Double_t CalcOut(Double_t in, const Double_t k[4])
139 {
140 return in + k[0] / 6. + k[1] / 3. + k[2] / 3. + k[3] / 6.;
141 }
142 BmnStatus RK4TrackExtrapolate(FairTrackParam* par, Double_t zOut, Double_t* F);
143 void UpdateF(vector<Double_t>& F, const vector<Double_t>& newF);
146};
147
148#endif /* BmnKalmanFilter_H */
int i
Definition P4_F32vec4.h:22
bool Bool_t
int Int_t
double Double_t
BmnStatus
Define status code.
Definition BmnEnums.h:93
Interface for material effects calculation algorithm.
BmnStatus GetResidual(CbmStsTrack *track, BmnHit **hitsArray, Int_t nHits, Int_t station, Int_t pdg, Double_t &resX, Double_t &resY)
void RK4Order(const Double_t *xIn, Double_t zIn, Double_t *xOut, Double_t zOut, Double_t *derivs, FairField *field)
void UpdateF(Double_t *F, const Double_t *newF)
BmnMaterialEffects * fMaterial
void UpdateF(vector< Double_t > &F, const vector< Double_t > &newF)
static const Int_t kMaxHits
BmnGeoNavigator * fNavigator
BmnStatus RK4TrackExtrapolate(FairTrackParam *par, Double_t zOut, Double_t *F)
BmnStatus TGeoTrackPropagate(FairTrackParam *par, Double_t zOut, Int_t pdg, vector< Double_t > *F, Double_t *length, Bool_t isField)
BmnStatus ComputeResiduals(CbmStsTrack *track, BmnHit **hitsArray, Int_t nHits, Int_t pdg, Double_t *resX, Double_t *resY, Int_t *station, Int_t &nRes)
BmnStatus Update(FairTrackParam *par, const BmnHit *hit, Double_t &chiSq)
BmnStatus Smooth(BmnFitNode *thisNode, BmnFitNode *prevNode)
virtual ~BmnKalmanFilter()
void TransportC(const Double_t *cIn, const Double_t *F, Double_t *cOut)
Double_t CalcOut(Double_t in, const Double_t k[4])
Interface for material effects calculation algorithm.