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