CbmRoot
Loading...
Searching...
No Matches
CbmLitMath.cxx
Go to the documentation of this file.
1/* Copyright (C) 2008-2017 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer], Timur Ablyazimov */
4
5#include "utils/CbmLitMath.h"
6
7#include "data/CbmLitHit.h"
10#include "data/CbmLitTrack.h"
12
13#include <cmath>
14#include <iostream>
15
16namespace lit
17{
18
19 litfloat ChiSq(const CbmLitTrackParam* par, const CbmLitHit* hit)
20 {
21 litfloat chisq = 0.;
22 if (hit->GetType() == kLITSTRIPHIT) {
23 chisq = ChiSq(par, static_cast<const CbmLitStripHit*>(hit));
24 }
25 else if (hit->GetType() == kLITPIXELHIT) {
26 chisq = ChiSq(par, static_cast<const CbmLitPixelHit*>(hit));
27 }
28 return chisq;
29 }
30
32 {
33 litfloat duu = hit->GetDu() * hit->GetDu();
34 litfloat phiCos = hit->GetCosPhi();
35 litfloat phiSin = hit->GetSinPhi();
36 litfloat phiCosSq = phiCos * phiCos;
37 litfloat phiSinSq = phiSin * phiSin;
38 litfloat phi2SinCos = 2 * phiCos * phiSin;
39 litfloat C0 = par->GetCovariance(0);
40 litfloat C1 = par->GetCovariance(1);
41 litfloat C5 = par->GetCovariance(5);
42
43 litfloat ru = hit->GetU() - par->GetX() * phiCos - par->GetY() * phiSin;
44
45 return (ru * ru) / (duu - phiCosSq * C0 - phi2SinCos * C1 - phiSinSq * C5);
46 }
47
49 {
50 litfloat dxx = hit->GetDx() * hit->GetDx();
51 litfloat dxy = hit->GetDxy();
52 litfloat dyy = hit->GetDy() * hit->GetDy();
53 litfloat dtt = hit->GetDt() * hit->GetDt();
54 litfloat xmx = hit->GetX() - par->GetX();
55 litfloat ymy = hit->GetY() - par->GetY();
56 litfloat tmt = hit->GetT() - par->GetTime();
57 litfloat C0 = par->GetCovariance(0);
58 litfloat C1 = par->GetCovariance(1);
59 litfloat C5 = par->GetCovariance(5);
60 litfloat C6 = par->GetCovariance(6);
61 litfloat C10 = par->GetCovariance(10);
62 litfloat C20 = par->GetCovariance(20);
63
64 /*litfloat norm = dxx * dyy - dxx * C5 - dyy * C0 + C0 * C5
65 - dxy * dxy + 2 * dxy * C1 - C1 * C1;
66 if (norm == 0.) { norm = 1e-10; }
67 return ((xmx * (dyy - C5) - ymy * (dxy - C1)) * xmx
68 +(-xmx * (dxy - C1) + ymy * (dxx - C0)) * ymy) / norm;*/
69 litfloat norm = (dxx - C0) * ((dyy - C6) * (dtt - C20) - C10 * C10)
70 + (dxy - C1) * (C5 * C10 - (dxy - C1) * (dtt - C20)) + C5 * ((dxy - C1) * C10 - (dyy - C6) * C5);
71
72 if (norm == 0.) {
73 norm = 1e-10;
74 }
75
76 // Mij is the (symmetric) inverse of the residual matrix
77 litfloat M00 = ((dyy - C6) * (dtt - C20) - C10 * C10) / norm;
78 litfloat M01 = ((dxy - C1) * (dtt - C20) - C5 * C10) / norm;
79 litfloat M02 = ((dxy - C1) * C10 - (dyy - C6) * C5) / norm;
80 litfloat M11 = ((dxx - C0) * (dtt - C20) - C5 * C5) / norm;
81 litfloat M12 = ((dxx - C0) * C10 - (dxy - C1) * C5) / norm;
82 litfloat M22 = ((dxx - C0) * (dyy - C6) - (dxy - C1) * (dxy - C1)) / norm;
83
84 return xmx * (xmx * M00 + ymy * M01 + tmt * M02) + ymy * (xmx * M01 + ymy * M11 + tmt * M12)
85 + tmt * (xmx * M02 + ymy * M12 + tmt * M22);
86 }
87
88 Int_t NDF(const CbmLitTrack* track)
89 {
90 Int_t ndf = 0;
91 for (Int_t i = 0; i < track->GetNofHits(); i++) {
92 if (track->GetHit(i)->GetType() == kLITPIXELHIT) {
93 ndf += 2;
94 }
95 else if (track->GetHit(i)->GetType() == kLITSTRIPHIT) {
96 ndf++;
97 }
98 }
99 ndf -= 5;
100 if (ndf > 0) {
101 return ndf;
102 }
103 else {
104 return 1;
105 }
106 }
107
108} // namespace lit
@ kLITPIXELHIT
Definition CbmLitEnums.h:21
@ kLITSTRIPHIT
Definition CbmLitEnums.h:20
double litfloat
Definition CbmLitFloat.h:19
Base data class for hits.
Base data class for pixel hits.
Base data class for strip hits.
Data class for track parameters.
Base data class for track.
Base data class for hits.
Definition CbmLitHit.h:29
LitHitType GetType() const
Definition CbmLitHit.h:43
litfloat GetT() const
Definition CbmLitHit.h:46
litfloat GetDt() const
Definition CbmLitHit.h:47
Base data class for pixel hits.
litfloat GetDxy() const
litfloat GetDy() const
litfloat GetX() const
litfloat GetY() const
litfloat GetDx() const
Base data class for strip hits.
litfloat GetU() const
litfloat GetSinPhi() const
litfloat GetCosPhi() const
litfloat GetDu() const
Data class for track parameters.
litfloat GetX() const
litfloat GetY() const
litfloat GetTime() const
litfloat GetCovariance(int index) const
Base data class for track.
Definition CbmLitTrack.h:34
const CbmLitHit * GetHit(Int_t index) const
Definition CbmLitTrack.h:71
Int_t GetNofHits() const
Definition CbmLitTrack.h:62
Int_t NDF(const CbmLitTrack *track)
litfloat ChiSq(const CbmLitTrackParam *par, const CbmLitHit *hit)