BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
KFParticleSIMD.cxx
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// Implementation of the KFParticleSIMD class
3// .
4// @author S.Gorbunov, I.Kisel, I.Kulakov, M.Zyzak
5// @version 1.0
6// @since 13.05.07
7//
8// Class to reconstruct and store the decayed particle parameters.
9// The method is described in CBM-SOFT note 2007-003,
10// ``Reconstruction of decayed particles based on the Kalman filter'',
11// http://www.gsi.de/documents/DOC-2007-May-14-1.pdf
12//
13// This class is ALICE interface to general mathematics in KFParticleSIMDCore
14//
15// -= Copyright &copy ALICE HLT and CBM L1 Groups =-
16//____________________________________________________________________________
17
18#include "KFParticleSIMD.h"
19
20#include "KFParticle.h"
21#include "TDatabasePDG.h"
22#include "TParticlePDG.h"
23
24#ifdef HomogeneousField
25#include "AliVTrack.h"
26#include "AliVVertex.h"
27#endif
28
29#ifdef NonhomogeneousField
30#include "CbmKFParticleDatabase.h"
31#include "CbmKFTrack.h"
32#include "CbmKFVertex.h"
33#endif
34
35#ifdef HomogeneousField
36fvec KFParticleSIMD::fgBz = -5.; //* Bz compoment of the magnetic field
37#endif
38
39static const fvec Zero = 0;
40static const fvec One = 1;
41
43#ifdef NonhomogeneousField
44 : fField()
45#endif
46{
47 if (!gamma) {
48 KFParticleSIMD mother;
49 mother += d1;
50 mother += d2;
51 *this = mother;
52 } else
53 ConstructGamma(d1, d2);
54}
55
56void KFParticleSIMD::Create(const fvec Param[], const fvec Cov[], Int_t Charge, fvec mass /*Int_t PID*/)
57{
58 // Constructor from "cartesian" track, PID hypothesis should be provided
59 //
60 // Param[6] = { X, Y, Z, Px, Py, Pz } - position and momentum
61 // Cov [21] = lower-triangular part of the covariance matrix:
62 //
63 // ( 0 . . . . . )
64 // ( 1 2 . . . . )
65 // Cov. matrix = ( 3 4 5 . . . ) - numbering of covariance elements in Cov[]
66 // ( 6 7 8 9 . . )
67 // ( 10 11 12 13 14 . )
68 // ( 15 16 17 18 19 20 )
69 fvec C[21];
70 for (int i = 0; i < 21; i++)
71 C[i] = Cov[i];
72
73 // TParticlePDG* particlePDG = TDatabasePDG::Instance()->GetParticle(PID);
74 // fvec mass = (particlePDG) ? particlePDG->Mass() :0.13957;
75
76 KFParticleBaseSIMD::Initialize(Param, C, Charge, mass);
77}
78
79#ifdef NonhomogeneousField
80KFParticleSIMD::KFParticleSIMD(CbmKFTrackInterface* Track[], int NTracks, Int_t* qHypo, const Int_t* pdg)
81 : fField()
82{
83 Create(Track, NTracks, qHypo, pdg);
84}
85
86void KFParticleSIMD::Create(CbmKFTrackInterface* Track[], int NTracks, Int_t* qHypo, const Int_t* pdg)
87{
88 fvec m[6];
89 fvec V[15];
90 fvec TrMass;
91
92 fDaughterIds.push_back(fvec(-1));
93 for (int j = 0; j < NTracks; j++) {
94 fDaughterIds.back()[j] = Track[j]->Id();
95
96 // TrMass[j] = pdg ? TDatabasePDG::Instance()->GetParticle(*pdg)->Mass() : Track[j]->GetMass();
97 TrMass[j] = pdg ? CbmKFParticleDatabase::Instance()->GetMass(*pdg) : Track[j]->GetMass();
98
99 fNDF[j] = Track[j]->GetRefNDF();
100 fChi2[j] = Track[j]->GetRefChi2();
101
102 for (int i = 0; i < 6; i++)
103 m[i][j] = Track[j]->GetTrack()[i];
104 for (int i = 0; i < 15; i++)
105 V[i][j] = Track[j]->GetCovMatrix()[i];
106 }
107
108 fvec a = m[2], b = m[3], qp = m[4];
109
110 //* convert the track to (x,y,px,py,pz,e,t/p) parameterization
111
112 fvec c2 = 1. / (1. + a * a + b * b);
113 fvec pq = 1. / qp;
114 fvec p2 = pq * pq;
115 fvec pz = sqrt(p2 * c2);
116 fvec px = a * pz;
117 fvec py = b * pz;
118 fvec eE = sqrt(TrMass * TrMass + p2);
119
120 fvec H[3] = {-px * c2, -py * c2, -pz * pq};
121 fvec HE = -pq * p2 / eE;
122
123 fP[0] = m[0];
124 fP[1] = m[1];
125 fP[2] = m[5];
126 fP[3] = px;
127 fP[4] = py;
128 fP[5] = pz;
129 fP[6] = eE;
130 fP[7] = 0;
131
132 fvec cxpz = H[0] * V[3] + H[1] * V[6] + H[2] * V[10];
133 fvec cypz = H[0] * V[4] + H[1] * V[7] + H[2] * V[11];
134 fvec capz = H[0] * V[5] + H[1] * V[8] + H[2] * V[12];
135 fvec cbpz = H[0] * V[8] + H[1] * V[9] + H[2] * V[13];
136 fvec cqpz = H[0] * V[12] + H[1] * V[13] + H[2] * V[14];
137 fvec cpzpz = H[0] * H[0] * V[5] + H[1] * H[1] * V[9] + H[2] * H[2] * V[14]
138 + 2 * (H[0] * H[1] * V[8] + H[0] * H[2] * V[12] + H[1] * H[2] * V[13]);
139
140 fC[0] = V[0];
141 fC[1] = V[1];
142 fC[2] = V[2];
143 fC[3] = 0.f;
144 fC[4] = 0.f;
145 fC[5] = 0.f;
146 fC[6] = V[3] * pz + a * cxpz;
147 fC[7] = V[4] * pz + a * cypz;
148 fC[8] = 0.f;
149 fC[9] = V[5] * pz * pz + 2 * a * pz * capz + a * a * cpzpz;
150 fC[10] = V[6] * pz + b * cxpz;
151 fC[11] = V[7] * pz + b * cypz;
152 fC[12] = 0.f;
153 fC[13] = V[8] * pz * pz + a * pz * cbpz + b * pz * capz + a * b * cpzpz;
154 fC[14] = V[9] * pz * pz + 2 * b * pz * cbpz + b * b * cpzpz;
155 fC[15] = cxpz;
156 fC[16] = cypz;
157 fC[17] = 0.f;
158 fC[18] = capz * pz + a * cpzpz;
159 fC[19] = cbpz * pz + b * cpzpz;
160 fC[20] = cpzpz;
161 fC[21] = HE * V[10];
162 fC[22] = HE * V[11];
163 fC[23] = 0.f;
164 fC[24] = HE * (V[12] * pz + a * cqpz);
165 fC[25] = HE * (V[13] * pz + b * cqpz);
166 fC[26] = HE * cqpz;
167 fC[27] = HE * HE * V[14];
168 fC[28] = fC[29] = fC[30] = fC[31] = fC[32] = fC[33] = fC[34] = 0;
169 fC[35] = 1.f;
170
171 for (int j = 0; j < fvecLen; j++)
172 fQ[j] = (qp[j] > 0.) ? 1 : ((qp[j] < 0) ? -1 : 0);
174 fIsVtxGuess = false;
175 fIsVtxErrGuess = false;
176 fIsLinearized = false;
177
178 fMassHypo = TrMass;
179}
180
182 : fField()
183{
184 fDaughterIds.push_back(Track.Id());
185
186 fvec m[6];
187 fvec V[15];
188 fvec TrMass;
189
190 CbmKFTrack Tr(Track);
191 for (unsigned int i = 0; i < 6; i++)
192 m[i] = Tr.GetTrack()[i];
193 for (unsigned int i = 0; i < 15; i++)
194 V[i] = Tr.GetCovMatrix()[i];
195 // TrMass = pdg ? TDatabasePDG::Instance()->GetParticle(*pdg)->Mass() :Tr.GetMass();
196 TrMass = pdg ? CbmKFParticleDatabase::Instance()->GetMass(*pdg) : Tr.GetMass();
197
198 fNDF = Tr.GetRefNDF();
199 fChi2 = Tr.GetRefChi2();
200
201 fvec a = m[2], b = m[3], qp = m[4];
202
203 //* convert the track to (x,y,px,py,pz,e,t/p) parameterization
204
205 fvec c2 = 1. / (1. + a * a + b * b);
206 fvec pq = 1. / qp;
207 fvec p2 = pq * pq;
208 fvec pz = sqrt(p2 * c2);
209 fvec px = a * pz;
210 fvec py = b * pz;
211 fvec eE = sqrt(TrMass * TrMass + p2);
212
213 fvec H[3] = {-px * c2, -py * c2, -pz * pq};
214 fvec HE = -pq * p2 / eE;
215
216 fP[0] = m[0];
217 fP[1] = m[1];
218 fP[2] = m[5];
219 fP[3] = px;
220 fP[4] = py;
221 fP[5] = pz;
222 fP[6] = eE;
223 fP[7] = 0;
224
225 fvec cxpz = H[0] * V[3] + H[1] * V[6] + H[2] * V[10];
226 fvec cypz = H[0] * V[4] + H[1] * V[7] + H[2] * V[11];
227 fvec capz = H[0] * V[5] + H[1] * V[8] + H[2] * V[12];
228 fvec cbpz = H[0] * V[8] + H[1] * V[9] + H[2] * V[13];
229 fvec cqpz = H[0] * V[12] + H[1] * V[13] + H[2] * V[14];
230 fvec cpzpz = H[0] * H[0] * V[5] + H[1] * H[1] * V[9] + H[2] * H[2] * V[14]
231 + 2 * (H[0] * H[1] * V[8] + H[0] * H[2] * V[12] + H[1] * H[2] * V[13]);
232
233 fC[0] = V[0];
234 fC[1] = V[1];
235 fC[2] = V[2];
236 fC[3] = 0.f;
237 fC[4] = 0.f;
238 fC[5] = 0.f;
239 fC[6] = V[3] * pz + a * cxpz;
240 fC[7] = V[4] * pz + a * cypz;
241 fC[8] = 0.f;
242 fC[9] = V[5] * pz * pz + 2 * a * pz * capz + a * a * cpzpz;
243 fC[10] = V[6] * pz + b * cxpz;
244 fC[11] = V[7] * pz + b * cypz;
245 fC[12] = 0.f;
246 fC[13] = V[8] * pz * pz + a * pz * cbpz + b * pz * capz + a * b * cpzpz;
247 fC[14] = V[9] * pz * pz + 2 * b * pz * cbpz + b * b * cpzpz;
248 fC[15] = cxpz;
249 fC[16] = cypz;
250 fC[17] = 0.f;
251 fC[18] = capz * pz + a * cpzpz;
252 fC[19] = cbpz * pz + b * cpzpz;
253 fC[20] = cpzpz;
254 fC[21] = HE * V[10];
255 fC[22] = HE * V[11];
256 fC[23] = 0.f;
257 fC[24] = HE * (V[12] * pz + a * cqpz);
258 fC[25] = HE * (V[13] * pz + b * cqpz);
259 fC[26] = HE * cqpz;
260 fC[27] = HE * HE * V[14];
261 fC[28] = fC[29] = fC[30] = fC[31] = fC[32] = fC[33] = fC[34] = 0;
262 fC[35] = 1.f;
263
264 for (int j = 0; j < fvecLen; j++)
265 fQ[j] = (qp[j] > 0.) ? 1 : ((qp[j] < 0) ? -1 : 0);
267 fIsVtxGuess = false;
268 fIsVtxErrGuess = false;
269 fIsLinearized = false;
270
271 fMassHypo = TrMass;
272}
273
275 : fField()
276{
277 // Constructor from CBM KF vertex
278 fP[0] = vertex.GetRefX();
279 fP[1] = vertex.GetRefY();
280 fP[2] = vertex.GetRefZ();
281 for (Int_t i = 0; i < 6; i++)
282 fC[i] = vertex.GetCovMatrix()[i];
283 fChi2 = vertex.GetRefChi2();
284 fNDF = vertex.GetRefNDF(); // 2*vertex.GetNContributors() - 3;
285 fQ = 0;
287 fIsLinearized = 0;
288 fSFromDecay = 0;
289}
290
291#endif
292
293#ifdef HomogeneousField
294KFParticleSIMD::KFParticleSIMD(const AliVTrack* track, Int_t PID)
295{
296 // Constructor from ALICE track, PID hypothesis should be provided
297
298 Double_t r[3];
299 Double_t C[21];
300
301 for (Int_t iPart = 0; iPart < fvecLen; iPart++) {
302 track[iPart].XvYvZv(r);
303 for (Int_t i = 0; i < 3; i++)
304 fP[i][iPart] = r[i];
305 track[iPart].PxPyPz(r);
306 for (Int_t i = 0; i < 3; i++)
307 fP[i + 3][iPart] = r[i];
308 fQ[iPart] = track[iPart].Charge();
309 track[iPart].GetCovarianceXYZPxPyPz(C);
310 for (Int_t i = 0; i < 21; i++)
311 fC[i][iPart] = C[i];
312 }
313 Create(fP, fC, fQ, PID);
314}
315
316KFParticleSIMD::KFParticleSIMD(const AliVVertex& vertex)
317{
318 // Constructor from ALICE vertex
319
320 Double_t r[3];
321 Double_t C[21];
322
323 vertex.GetXYZ(r);
324 for (Int_t i = 0; i < 3; i++)
325 fP[i] = r[i];
326 vertex.GetCovarianceMatrix(C);
327 for (Int_t i = 0; i < 21; i++)
328 fC[i] = C[i];
329 fChi2 = vertex.GetChi2();
330 fNDF = 2 * vertex.GetNContributors() - 3;
331 fQ = Zero;
333 fIsLinearized = 0;
334 fSFromDecay = 0;
335}
336
338 Double_t X[fvecLen],
339 Double_t Alpha[fvecLen],
340 Double_t P[5][fvecLen])
341{
342 // Conversion to AliExternalTrackParam parameterization
343
344 fvec cosA = p.GetPx(), sinA = p.GetPy();
345 fvec pt = sqrt(cosA * cosA + sinA * sinA);
346 fvec pti = Zero;
347 fvec mask = fvec(pt < fvec(1.e-4));
348 pti = (!mask) & (One / pt);
349 cosA = if3(mask, One, cosA * pti);
350 sinA = if3(mask, One, sinA * pti);
351
352 fvec AlphaSIMD = atan2SIMD(sinA, cosA);
353 fvec XSIMD = p.GetX() * cosA + p.GetY() * sinA;
354 fvec PSIMD[5];
355 PSIMD[0] = p.GetY() * cosA - p.GetX() * sinA;
356 PSIMD[1] = p.GetZ();
357 PSIMD[2] = Zero;
358 PSIMD[3] = p.GetPz() * pti;
359 PSIMD[4] = p.GetQ() * pti;
360
361 for (int iPart = 0; iPart < fvecLen; iPart++) {
362 X[iPart] = XSIMD[iPart];
363 Alpha[iPart] = AlphaSIMD[iPart];
364 P[0][iPart] = PSIMD[0][iPart];
365 P[1][iPart] = PSIMD[1][iPart];
366 P[2][iPart] = PSIMD[2][iPart];
367 P[3][iPart] = PSIMD[3][iPart];
368 P[4][iPart] = PSIMD[4][iPart];
369 }
370}
371
372#endif
373
375#ifdef NonhomogeneousField
376 : fField()
377#endif
378{
379 { // check
380 bool ok = 1;
381 const int nD = (parts[0])->NDaughters();
382 for (int ie = 1; ie < nPart; ie++) {
383 const KFParticle& part = *(parts[ie]);
384 ok &= part.NDaughters() == nD;
385 }
386 // assert(ok);
387 if (!ok) {
388 std::cout << " void CbmKFParticle_simd::Create(CbmKFParticle *parts[], int N) " << std::endl;
389 exit(1);
390 }
391 }
392
393 fDaughterIds.resize((parts[0])->NDaughters(), fvec(-1));
394
395 for (int ie = 0; ie < nPart; ie++) {
396 KFParticle& part = *(parts[ie]);
397
398 fId[ie] = part.Id();
399 for (int iD = 0; iD < (parts[0])->NDaughters(); iD++)
400 fDaughterIds[iD][ie] = part.DaughterIds()[iD];
401
402 fPDG = part.GetPDG();
403
404 for (int i = 0; i < 8; ++i)
405 fP[i][ie] = part.Parameters()[i];
406 for (int i = 0; i < 36; ++i)
407 fC[i][ie] = part.CovarianceMatrix()[i];
408
409 fNDF = part.GetNDF();
410 fChi2[ie] = part.GetChi2();
411 fQ[ie] = part.GetQ();
412 fAtProductionVertex = part.GetAtProductionVertex(); // CHECKME
413
414 fMassHypo[ie] = part.GetMassHypo();
415
416 L1FieldRegion field(part.GetFieldCoeff());
417 fField.SetOneEntry(ie, field, 0);
418 }
419}
420
422#ifdef NonhomogeneousField
423 : fField()
424#endif
425{
426
427 fId = part.Id();
428 fNDF = part.GetNDF();
429 fChi2 = part.GetChi2();
430 fQ = part.GetQ();
431 fPDG = part.GetPDG();
433 fIsVtxGuess = 0;
434 fIsVtxErrGuess = 0;
435
437 for (int i = 0; i < part.NDaughters(); ++i) {
438 fDaughterIds.push_back(part.DaughterIds()[i]);
439 }
440
441 for (int i = 0; i < 8; ++i)
442 fP[i] = part.Parameters()[i];
443 for (int i = 0; i < 36; ++i)
444 fC[i] = part.CovarianceMatrix()[i];
445
446 fMassHypo = part.GetMassHypo();
447
449}
450
451fvec KFParticleSIMD::GetDistanceFromVertexXY(const fvec vtx[], const fvec Cv[], fvec& val, fvec& err) const
452{
453 //* Calculate DCA distance from vertex (transverse impact parameter) in XY
454 //* v = [xy], Cv=[Cxx,Cxy,Cyy ]-covariance matrix
455
456 fvec ret = Zero;
457
458 fvec mP[8];
459 fvec mC[36];
460
461 Transport(GetDStoPoint(vtx), mP, mC);
462
463 fvec dx = mP[0] - vtx[0];
464 fvec dy = mP[1] - vtx[1];
465 fvec px = mP[3];
466 fvec py = mP[4];
467 fvec pt = sqrt(px * px + py * py);
468 fvec ex = Zero, ey = Zero;
469 fvec mask = fvec(pt < fvec(1.e-4));
470 ret = mask;
471 pt = if3(mask, One, pt);
472 ex = (!mask) & (px / pt);
473 ey = (!mask) & (py / pt);
474 val = if3(mask, fvec(1.e4), dy * ex - dx * ey);
475
476 fvec h0 = -ey;
477 fvec h1 = ex;
478 fvec h3 = (dy * ey + dx * ex) * ey / pt;
479 fvec h4 = -(dy * ey + dx * ex) * ex / pt;
480
481 err =
482 h0 * (h0 * GetCovariance(0, 0) + h1 * GetCovariance(0, 1) + h3 * GetCovariance(0, 3) + h4 * GetCovariance(0, 4))
483 + h1
484 * (h0 * GetCovariance(1, 0) + h1 * GetCovariance(1, 1) + h3 * GetCovariance(1, 3)
485 + h4 * GetCovariance(1, 4))
486 + h3
487 * (h0 * GetCovariance(3, 0) + h1 * GetCovariance(3, 1) + h3 * GetCovariance(3, 3)
488 + h4 * GetCovariance(3, 4))
489 + h4
490 * (h0 * GetCovariance(4, 0) + h1 * GetCovariance(4, 1) + h3 * GetCovariance(4, 3)
491 + h4 * GetCovariance(4, 4));
492
493 if (Cv) {
494 err += h0 * (h0 * Cv[0] + h1 * Cv[1]) + h1 * (h0 * Cv[1] + h1 * Cv[2]);
495 }
496
497 err = sqrt(fabs(err));
498
499 return ret;
500}
501
503{
504 return GetDistanceFromVertexXY(vtx, 0, val, err);
505}
506
508{
509 //* Calculate distance from vertex [cm] in XY-plane
510
511 return GetDistanceFromVertexXY(Vtx.fP, Vtx.fC, val, err);
512}
513
514#ifdef HomogeneousField
515fvec KFParticleSIMD::GetDistanceFromVertexXY(const AliVVertex& Vtx, fvec& val, fvec& err) const
516{
517 //* Calculate distance from vertex [cm] in XY-plane
518
519 return GetDistanceFromVertexXY(KFParticleSIMD(Vtx), val, err);
520}
521#endif
522
524{
525 //* Calculate distance from vertex [cm] in XY-plane
526 fvec val, err;
527 GetDistanceFromVertexXY(vtx, 0, val, err);
528 return val;
529}
530
532{
533 //* Calculate distance from vertex [cm] in XY-plane
534
535 return GetDistanceFromVertexXY(Vtx.fP);
536}
537
538#ifdef HomogeneousField
539fvec KFParticleSIMD::GetDistanceFromVertexXY(const AliVVertex& Vtx) const
540{
541 //* Calculate distance from vertex [cm] in XY-plane
542
544}
545#endif
546
548{
549 //* Calculate distance to other particle [cm]
550
551 fvec dS, dS1;
552 GetDStoParticleXY(p, dS, dS1);
553 fvec mP[8], mC[36], mP1[8], mC1[36];
554 Transport(dS, mP, mC);
555 p.Transport(dS1, mP1, mC1);
556 fvec dx = mP[0] - mP1[0];
557 fvec dy = mP[1] - mP1[1];
558 return sqrt(dx * dx + dy * dy);
559}
560
562{
563 //* Calculate sqrt(Chi2/ndf) deviation from other particle
564
565 fvec dS, dS1;
566 GetDStoParticleXY(p, dS, dS1);
567 fvec mP1[8], mC1[36];
568 p.Transport(dS1, mP1, mC1);
569
570 fvec d[2] = {fP[0] - mP1[0], fP[1] - mP1[1]};
571
572 fvec sigmaS = .1 + 10. * sqrt((d[0] * d[0] + d[1] * d[1]) / (mP1[3] * mP1[3] + mP1[4] * mP1[4]));
573
574 fvec h[2] = {mP1[3] * sigmaS, mP1[4] * sigmaS};
575
576 mC1[0] += h[0] * h[0];
577 mC1[1] += h[1] * h[0];
578 mC1[2] += h[1] * h[1];
579
580 return GetDeviationFromVertexXY(mP1, mC1) * sqrt(2. / 1.);
581}
582
584{
585 //* Calculate sqrt(Chi2/ndf) deviation from vertex
586 //* v = [xyz], Cv=[Cxx,Cxy,Cyy,Cxz,Cyz,Czz]-covariance matrix
587
588 fvec val, err;
589 fvec problem = GetDistanceFromVertexXY(vtx, Cv, val, err);
590 fvec ret = fvec(1.e4);
591 fvec mask = fvec(problem | fvec(err < fvec(1.e-20)));
592 ret = if3(mask, ret, val / err);
593 return ret;
594}
595
597{
598 //* Calculate sqrt(Chi2/ndf) deviation from vertex
599 //* v = [xyz], Cv=[Cxx,Cxy,Cyy,Cxz,Cyz,Czz]-covariance matrix
600
601 return GetDeviationFromVertexXY(Vtx.fP, Vtx.fC);
602}
603
604#ifdef HomogeneousField
605fvec KFParticleSIMD::GetDeviationFromVertexXY(const AliVVertex& Vtx) const
606{
607 //* Calculate sqrt(Chi2/ndf) deviation from vertex
608 //* v = [xyz], Cv=[Cxx,Cxy,Cyy,Cxz,Cyz,Czz]-covariance matrix
609
610 KFParticleSIMD v(Vtx);
611 return GetDeviationFromVertexXY(v.fP, v.fC);
612}
613#endif
614
616{
617 //* Calculate the opening angle between two particles
618
619 fvec dS, dS1;
620 GetDStoParticle(p, dS, dS1);
621 fvec mP[8], mC[36], mP1[8], mC1[36];
622 Transport(dS, mP, mC);
623 p.Transport(dS1, mP1, mC1);
624 fvec n = sqrt(mP[3] * mP[3] + mP[4] * mP[4] + mP[5] * mP[5]);
625 fvec n1 = sqrt(mP1[3] * mP1[3] + mP1[4] * mP1[4] + mP1[5] * mP1[5]);
626 n *= n1;
627 fvec a = Zero;
628 fvec mask = fvec(n > fvec(1.e-8));
629 a = (mP[3] * mP1[3] + mP[4] * mP1[4] + mP[5] * mP1[5]) / n;
630 a = mask & a;
631 mask = fvec(fabs(a) < One);
632 fvec aPos = fvec(a >= Zero);
633 a = if3(mask, acos(a), if3(aPos, Zero, fvec(3.1415926535)));
634 return a;
635}
636
638{
639 //* Calculate the opening angle between two particles in XY plane
640
641 fvec dS, dS1;
642 GetDStoParticleXY(p, dS, dS1);
643 fvec mP[8], mC[36], mP1[8], mC1[36];
644 Transport(dS, mP, mC);
645 p.Transport(dS1, mP1, mC1);
646 fvec n = sqrt(mP[3] * mP[3] + mP[4] * mP[4]);
647 fvec n1 = sqrt(mP1[3] * mP1[3] + mP1[4] * mP1[4]);
648 n *= n1;
649 fvec a = Zero;
650 fvec mask = fvec(n > fvec(1.e-8));
651 a = (mP[3] * mP1[3] + mP[4] * mP1[4]) / n;
652 a = mask & a;
653 mask = fvec(fabs(a) < One);
654 fvec aPos = fvec(a >= Zero);
655 a = if3(mask, acos(a), if3(aPos, Zero, fvec(3.1415926535)));
656 return a;
657}
658
660{
661 //* Calculate the opening angle between two particles in RZ plane
662
663 fvec dS, dS1;
664 GetDStoParticle(p, dS, dS1);
665 fvec mP[8], mC[36], mP1[8], mC1[36];
666 Transport(dS, mP, mC);
667 p.Transport(dS1, mP1, mC1);
668 fvec nr = sqrt(mP[3] * mP[3] + mP[4] * mP[4]);
669 fvec n1r = sqrt(mP1[3] * mP1[3] + mP1[4] * mP1[4]);
670 fvec n = sqrt(nr * nr + mP[5] * mP[5]);
671 fvec n1 = sqrt(n1r * n1r + mP1[5] * mP1[5]);
672 n *= n1;
673 fvec a = Zero;
674 fvec mask = fvec(n > fvec(1.e-8));
675 a = (nr * n1r + mP[5] * mP1[5]) / n;
676 a = mask & a;
677 mask = fvec(fabs(a) < One);
678 fvec aPos = fvec(a >= Zero);
679 a = if3(mask, acos(a), if3(aPos, Zero, fvec(3.1415926535)));
680 return a;
681}
682
683/*
684
685#include "AliExternalTrackParam.h"
686
687void KFParticleSIMD::GetDStoParticleALICE( const KFParticleSIMDBaseSIMD &p,
688 fvec &DS, fvec &DS1 )
689 const
690{
691 DS = DS1 = 0;
692 fvec x1, a1, x2, a2;
693 fvec par1[5], par2[5], cov[15];
694 for(int i=0; i<15; i++) cov[i] = 0;
695 cov[0] = cov[2] = cov[5] = cov[9] = cov[14] = .001;
696
697 GetExternalTrackParam( *this, x1, a1, par1 );
698 GetExternalTrackParam( p, x2, a2, par2 );
699
700 AliExternalTrackParam t1(x1,a1, par1, cov);
701 AliExternalTrackParam t2(x2,a2, par2, cov);
702
703 fvec xe1=0, xe2=0;
704 t1.GetDCA( &t2, -GetFieldAlice(), xe1, xe2 );
705 t1.PropagateTo( xe1, -GetFieldAlice() );
706 t2.PropagateTo( xe2, -GetFieldAlice() );
707
708 fvec xyz1[3], xyz2[3];
709 t1.GetXYZ( xyz1 );
710 t2.GetXYZ( xyz2 );
711
712 DS = GetDStoPoint( xyz1 );
713 DS1 = p.GetDStoPoint( xyz2 );
714
715 return;
716}
717*/
718
719// * Pseudo Proper Time of decay = (r*pt) / |pt| * M/|pt|
721{ // TODO optimize with respect to time and stability
722 const fvec ipt2 = 1 / (Px() * Px() + Py() * Py());
723 const fvec mipt2 = mass * ipt2;
724 const fvec dx = X() - pV.X();
725 const fvec dy = Y() - pV.Y();
726
727 if (timeErr2) {
728 // -- calculate error = sigma(f(r)) = f'Cf'
729 // r = {x,y,px,py,x_pV,y_pV}
730 // df/dr = { px*m/pt^2,
731 // py*m/pt^2,
732 // ( x - x_pV )*m*(1/pt^2 - 2(px/pt^2)^2),
733 // ( y - y_pV )*m*(1/pt^2 - 2(py/pt^2)^2),
734 // -px*m/pt^2,
735 // -py*m/pt^2 }
736 const fvec f0 = Px() * mipt2;
737 const fvec f1 = Py() * mipt2;
738 const fvec mipt2derivative = mipt2 * (1 - 2 * Px() * Px() * ipt2);
739 const fvec f2 = dx * mipt2derivative;
740 const fvec f3 = -dy * mipt2derivative;
741 const fvec f4 = -f0;
742 const fvec f5 = -f1;
743
744 const fvec& mC00 = GetCovariance(0, 0);
745 const fvec& mC10 = GetCovariance(0, 1);
746 const fvec& mC11 = GetCovariance(1, 1);
747 const fvec& mC20 = GetCovariance(3, 0);
748 const fvec& mC21 = GetCovariance(3, 1);
749 const fvec& mC22 = GetCovariance(3, 3);
750 const fvec& mC30 = GetCovariance(4, 0);
751 const fvec& mC31 = GetCovariance(4, 1);
752 const fvec& mC32 = GetCovariance(4, 3);
753 const fvec& mC33 = GetCovariance(4, 4);
754 const fvec& mC44 = pV.GetCovariance(0, 0);
755 const fvec& mC54 = pV.GetCovariance(1, 0);
756 const fvec& mC55 = pV.GetCovariance(1, 1);
757
758 *timeErr2 = f5 * mC55 * f5 + f5 * mC54 * f4 + f4 * mC44 * f4 + f3 * mC33 * f3 + f3 * mC32 * f2 + f3 * mC31 * f1
759 + f3 * mC30 * f0 + f2 * mC22 * f2 + f2 * mC21 * f1 + f2 * mC20 * f0 + f1 * mC11 * f1
760 + f1 * mC10 * f0 + f0 * mC00 * f0;
761 }
762 return (dx * Px() + dy * Py()) * mipt2;
763}
764
766{
767 Part.SetId(static_cast<int>(Id()[iPart]));
768
769 Part.CleanDaughtersId();
770 Part.SetNDaughters(DaughterIds().size());
771 for (unsigned int i = 0; i < DaughterIds().size(); i++)
772 Part.AddDaughter(static_cast<int>(DaughterIds()[i][iPart]));
773
774 Part.SetPDG(static_cast<int>(GetPDG()));
775
776 for (int iP = 0; iP < 8; iP++)
777 Part.Parameters()[iP] = Parameters()[iP][iPart];
778 for (int iC = 0; iC < 36; iC++)
779 Part.CovarianceMatrix()[iC] = CovarianceMatrix()[iC][iPart];
780
781 Part.NDF() = static_cast<int>(GetNDF()[iPart]);
782 Part.Chi2() = GetChi2()[iPart];
783 Part.Q() = GetQ()[iPart];
785
786 Part.SetFieldCoeff(fField.cx0[iPart], 0);
787 Part.SetFieldCoeff(fField.cx1[iPart], 1);
788 Part.SetFieldCoeff(fField.cx2[iPart], 2);
789 Part.SetFieldCoeff(fField.cy0[iPart], 3);
790 Part.SetFieldCoeff(fField.cy1[iPart], 4);
791 Part.SetFieldCoeff(fField.cy2[iPart], 5);
792 Part.SetFieldCoeff(fField.cz0[iPart], 6);
793 Part.SetFieldCoeff(fField.cz1[iPart], 7);
794 Part.SetFieldCoeff(fField.cz2[iPart], 8);
795 Part.SetFieldCoeff(fField.z0[iPart], 9);
796}
797
799{
800 for (int i = 0; i < nPart; i++)
801 GetKFParticle(Part[i], i);
802}
static const fvec One
static const fvec Zero
friend F32vec4 fabs(const F32vec4 &a)
Definition P4_F32vec4.h:52
__m128 v
Definition P4_F32vec4.h:1
const int fvecLen
Definition P4_F32vec4.h:233
int i
Definition P4_F32vec4.h:22
__m128 m
Definition P4_F32vec4.h:27
#define if3(a, b, c)
Definition P4_F32vec4.h:148
F32vec4 fvec
Definition P4_F32vec4.h:231
bool Bool_t
int Int_t
double Double_t
static CbmKFParticleDatabase * Instance()
virtual Int_t & GetRefNDF()
Chi^2 after fit.
virtual Double_t GetMass()
Information not to be changed.
virtual Double_t & GetRefChi2()
array[15] of covariance matrix
virtual Double_t & GetRefY()
virtual Double_t & GetRefX()
I/O parameters for vertex fit routines.
virtual Double_t & GetRefZ()
virtual Double_t & GetRefChi2()
Array[6] of covariance matrix.
virtual Int_t & GetRefNDF()
Chi^2 after fit.
virtual Double_t * GetCovMatrix()
const int & GetPDG() const
std::vector< fvec > fDaughterIds
std::vector< fvec > & DaughterIds()
void SetPDG(int pdg)
const Double_t & GetMassHypo() const
const std::vector< int > & DaughterIds() const
int GetPDG() const
void SetId(int id)
int NDaughters() const
fvec GetDistanceFromParticleXY(const KFParticleSIMD &p) const
fvec GetQ() const
fvec GetCovariance(int i) const
fvec GetNDF() const
fvec GetAngle(const KFParticleSIMD &p) const
fvec GetChi2() const
fvec GetDeviationFromVertexXY(const fvec v[], const fvec Cv[]=0) const
void GetDStoParticle(const KFParticleSIMD &p, fvec &DS, fvec &DSp) const
fvec GetDStoPoint(const fvec xyz[]) const
void Create(const fvec Param[], const fvec Cov[], Int_t Charge, fvec mass)
static void GetExternalTrackParam(const KFParticleBaseSIMD &p, fvec &X, fvec &Alpha, fvec P[5])
const fvec & Px() const
const fvec & Y() const
void Transport(fvec dS, fvec P[], fvec C[]) const
fvec GetDeviationFromParticleXY(const KFParticleSIMD &p) const
fvec GetAngleRZ(const KFParticleSIMD &p) const
fvec GetAngleXY(const KFParticleSIMD &p) const
const fvec & X() const
fvec GetPseudoProperDecayTime(const KFParticleSIMD &primVertex, const fvec &mass, fvec *timeErr2=0) const
L1FieldRegion fField
fvec * CovarianceMatrix()
const fvec & Py() const
void GetKFParticle(KFParticle &Part, int iPart=0)
fvec GetDistanceFromVertexXY(const fvec vtx[], fvec &val, fvec &err) const
void ConstructGamma(const KFParticleSIMD &daughter1, const KFParticleSIMD &daughter2)
void GetDStoParticleXY(const KFParticleBaseSIMD &p, fvec &DS, fvec &DSp) const
float * GetFieldCoeff()
Definition KFParticle.h:124
Double_t * CovarianceMatrix()
Definition KFParticle.h:847
Double_t * Parameters()
Definition KFParticle.h:842
void SetAtProductionVertex(Bool_t b)
Definition KFParticle.h:121
void CleanDaughtersId()
Definition KFParticle.h:90
const Int_t & NDF() const
Definition KFParticle.h:138
Int_t GetNDF() const
Definition KFParticle.h:482
const Int_t & Q() const
Definition KFParticle.h:136
void AddDaughter(int id)
Definition KFParticle.h:92
Double_t GetChi2() const
Definition KFParticle.h:477
Bool_t GetAtProductionVertex() const
Definition KFParticle.h:120
void SetFieldCoeff(float c, int i)
Definition KFParticle.h:125
void SetNDaughters(int n)
Definition KFParticle.h:91
Int_t GetQ() const
Definition KFParticle.h:472
const Double_t & Chi2() const
Definition KFParticle.h:137
RVec< PromoteType< T > > sqrt(const RVec< T > &v)
RVec< PromoteType< T > > acos(const RVec< T > &v)
*brief user defined string literal for JSON values *sa std::size_t n
Definition json.hpp:20362
RooConstVar & C(double value)