CbmRoot
Loading...
Searching...
No Matches
CbmKFParticleInterface.cxx
Go to the documentation of this file.
1/* Copyright (C) 2014-2015 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Maksym Zyzak [committer] */
4
5//-----------------------------------------------------------
6//-----------------------------------------------------------
7
8// Cbm Headers ----------------------
10
11#include "CbmKFVertex.h"
12#include "CbmL1PFFitter.h"
13#include "CbmStsTrack.h"
14
15//KF Particle headers
16#include "KFPTrackVector.h"
17#include "KFParticle.h"
18#include "KFParticleSIMD.h"
19
20//ROOT headers
21#include "TClonesArray.h" //to get arrays from the FairRootManager
22#include "TMath.h" //to calculate Prob function
23#include "TStopwatch.h" //to measure the time
24
25//c++ and std headers
26#include <cmath>
27#include <iostream>
28#include <vector>
29using std::vector;
30
32
33void CbmKFParticleInterface::SetKFParticleFromStsTrack(CbmStsTrack* track, KFParticle* particle, Int_t pdg,
34 Bool_t firstPoint)
35{
36 vector<CbmStsTrack> vRTracks(1);
37 vRTracks[0] = *track;
38
39 CbmL1PFFitter fitter;
40 vector<float> vChiToPrimVtx;
41 CbmKFVertex kfVertex;
42
43 vector<CbmL1PFFitter::PFFieldRegion> vField;
44 fitter.GetChiToVertex(vRTracks, vField, vChiToPrimVtx, kfVertex, -3);
45
46 KFPTrackVector tracks;
47 tracks.Resize(1);
48 //fill vector with tracks
49 for (Int_t iTr = 0; iTr < 1; iTr++) {
50 const FairTrackParam* parameters;
51
52 if (firstPoint) {
53 parameters = vRTracks[iTr].GetParamFirst();
54 }
55 else {
56 parameters = vRTracks[iTr].GetParamLast();
57 }
58
59 float par[6] = {0.f};
60
61 Double_t V[15] = {0.f};
62
63 for (Int_t i = 0, iCov = 0; i < 5; i++) {
64 for (Int_t j = 0; j <= i; j++, iCov++) {
65 V[iCov] = parameters->GetCovariance(i, j);
66 }
67 }
68
69 float a = parameters->GetTx(), b = parameters->GetTy(), qp = parameters->GetQp();
70
71 Int_t q = 0;
72 if (qp > 0.f) {
73 q = 1;
74 }
75 if (qp < 0.f) {
76 q = -1;
77 }
78 if (TMath::Abs(pdg) == 1000020030 || TMath::Abs(pdg) == 1000020040) {
79 q *= 2;
80 }
81
82 float c2 = 1.f / (1.f + a * a + b * b);
83 float pq = 1.f / qp * TMath::Abs(q);
84 float p2 = pq * pq;
85 float pz = sqrt(p2 * c2);
86 float px = a * pz;
87 float py = b * pz;
88
89 float H[3] = {-px * c2, -py * c2, -pz * pq};
90
91 par[0] = parameters->GetX();
92 par[1] = parameters->GetY();
93 par[2] = parameters->GetZ();
94 par[3] = px;
95 par[4] = py;
96 par[5] = pz;
97
98 float cxpz = H[0] * V[3] + H[1] * V[6] + H[2] * V[10];
99 float cypz = H[0] * V[4] + H[1] * V[7] + H[2] * V[11];
100 float capz = H[0] * V[5] + H[1] * V[8] + H[2] * V[12];
101 float cbpz = H[0] * V[8] + H[1] * V[9] + H[2] * V[13];
102 float cpzpz = H[0] * H[0] * V[5] + H[1] * H[1] * V[9] + H[2] * H[2] * V[14]
103 + 2 * (H[0] * H[1] * V[8] + H[0] * H[2] * V[12] + H[1] * H[2] * V[13]);
104
105 float cov[21];
106 cov[0] = V[0];
107 cov[1] = V[1];
108 cov[2] = V[2];
109 cov[3] = 0.f;
110 cov[4] = 0.f;
111 cov[5] = 0.f;
112 cov[6] = V[3] * pz + a * cxpz;
113 cov[7] = V[4] * pz + a * cypz;
114 cov[8] = 0.f;
115 cov[9] = V[5] * pz * pz + 2.f * a * pz * capz + a * a * cpzpz;
116 cov[10] = V[6] * pz + b * cxpz;
117 cov[11] = V[7] * pz + b * cypz;
118 cov[12] = 0.f;
119 cov[13] = V[8] * pz * pz + a * pz * cbpz + b * pz * capz + a * b * cpzpz;
120 cov[14] = V[9] * pz * pz + 2.f * b * pz * cbpz + b * b * cpzpz;
121 cov[15] = cxpz;
122 cov[16] = cypz;
123 cov[17] = 0.f;
124 cov[18] = capz * pz + a * cpzpz;
125 cov[19] = cbpz * pz + b * cpzpz;
126 cov[20] = cpzpz;
127
128 for (Int_t iP = 0; iP < 6; iP++) {
129 tracks.SetParameter(par[iP], iP, iTr);
130 }
131 for (Int_t iC = 0; iC < 21; iC++) {
132 tracks.SetCovariance(cov[iC], iC, iTr);
133 }
134 for (Int_t iF = 0; iF < 10; iF++) {
135 tracks.SetFieldCoefficient(vField[iTr].fP[iF], iF, iTr);
136 }
137 tracks.SetId(1, iTr);
138 tracks.SetPDG(pdg, iTr);
139 tracks.SetQ(q, iTr);
140 tracks.SetPVIndex(-1, iTr);
141 }
142
143 int_v pdgSIMD(pdg);
144 unsigned int index = 0;
145 uint_v indexSIMD(index);
146
147 KFParticleSIMD particleSIMD(tracks, indexSIMD, pdgSIMD);
148 particleSIMD.GetKFParticle(*particle, 0);
149
150 particle->NDF() = track->GetNDF();
151 particle->Chi2() = track->GetChiSq();
152}
153
154void CbmKFParticleInterface::ExtrapolateTrackToPV(const CbmStsTrack* track, CbmVertex* pv, FairTrackParam* paramAtPV,
155 float& chiPrim)
156{
157 vector<CbmStsTrack> vRTracks(1);
158 vRTracks[0] = *track;
159
160 CbmL1PFFitter fitter;
161 vector<float> vChiToPrimVtx;
162 CbmKFVertex kfVertex;
163 assert(pv);
164 if (pv) {
165 kfVertex = CbmKFVertex(*pv);
166 }
167
168 vector<CbmL1PFFitter::PFFieldRegion> vField;
169 fitter.GetChiToVertex(vRTracks, vField, vChiToPrimVtx, kfVertex, 1000000.f);
170
171 chiPrim = vChiToPrimVtx[0];
172 *paramAtPV = *(vRTracks[0].GetParamFirst());
173}
TClonesArray * tracks
ClassImp(CbmKFParticleInterface)
Data class for STS tracks.
friend fvec sqrt(const fvec &a)
static void SetKFParticleFromStsTrack(CbmStsTrack *track, KFParticle *particle, Int_t pdg=211, Bool_t firstPoint=kTRUE)
static void ExtrapolateTrackToPV(const CbmStsTrack *track, CbmVertex *pv, FairTrackParam *paramAtPV, float &chiPrim)
void GetChiToVertex(std::vector< CbmStsTrack > &Tracks, std::vector< PFFieldRegion > &field, std::vector< float > &chiToVtx, CbmKFVertex &primVtx, float chiPrim=-1)
int32_t GetNDF() const
Definition CbmTrack.h:64
double GetChiSq() const
Definition CbmTrack.h:63