22 #include "TClonesArray.h"
34 #include "FairRootManager.h"
35 #include "TDatabasePDG.h"
38 #include "KFParticleDatabase.h"
87 FairRootManager* fManger = FairRootManager::Instance();
88 TClonesArray* listStsHits = (TClonesArray*) fManger->GetObject(
"StsHit");
90 TClonesArray* listMvdHits = 0;
91 if (NMvdStations > 0.)
92 listMvdHits = (TClonesArray*) fManger->GetObject(
"MvdHit");
111 fvec x_first, y_first, x_last, y_last;
112 fvec fz0, fz1, fz2, dz, z_start, z_end;
116 unsigned short N_vTracks = Tracks.size();
119 for (
unsigned short itrack = 0; itrack < N_vTracks; itrack++) {
120 Tracks[itrack].SetPidHypo(pidHypo[itrack]);
125 for (
unsigned short itrack = 0; itrack < N_vTracks; itrack +=
fvecLen) {
127 if (N_vTracks - itrack <
static_cast<unsigned short>(
fvecLen))
128 nTracks_SIMD = N_vTracks - itrack;
129 for (
i = 0;
i < nTracks_SIMD;
i++) {
130 t[
i] = &Tracks[itrack +
i];
153 int pid = pidHypo[itrack +
i];
154 if (pid == -1) pid = 211;
156 mass[
i] = KFParticleDatabase::Instance()->GetMass(pid);
160 for (
i = 0;
i < nHits;
i++) {
165 for (iVec = 0; iVec < nTracks_SIMD; iVec++) {
168 int nHitsTrack = nHitsTrackMvd + nHitsTrackSts;
169 for (
i = 0;
i < nHitsTrack;
i++) {
170 float posx = 0.f, posy = 0.f, posz = 0.f;
172 if (
i < nHitsTrackMvd) {
173 if (!listMvdHits)
continue;
176 L1_DYNAMIC_CAST<CbmMvdHit*>(listMvdHits->At(hitIndex));
183 if (!listStsHits)
continue;
186 L1_DYNAMIC_CAST<CbmStsHit*>(listStsHits->At(hitIndex));
196 x[ista][iVec] = posx;
197 y[ista][iVec] = posy;
202 z[ista][iVec] = posz;
204 fB[ista].
x[iVec] = fB_temp.x[iVec];
205 fB[ista].
y[iVec] = fB_temp.y[iVec];
206 fB[ista].
z[iVec] = fB_temp.z[iVec];
208 z_start[iVec] = posz;
209 x_first[iVec] =
x[ista][iVec];
210 y_first[iVec] =
y[ista][iVec];
215 if (
i == nHitsTrack - 1) {
217 x_last[iVec] =
x[ista][iVec];
218 y_last[iVec] =
y[ista][iVec];
227 FilterFirst(T, x_first, y_first, staFirst);
235 fB2.Combine(fB[
i + 2], w[
i + 2]);
236 fld.Set(fB2, fz2, fB1, fz1, fB0, fz0);
237 for (++
i;
i < nHits;
i++) {
242 fld.Set(fB0, fz0, fB1, fz1, fB2, fz2);
245 fvec w1 = (w[
i] & (initialised));
246 fvec wIn = (
ONE & (initialised));
249 if (
i == NMvdStations) {
279 for (iVec = 0; iVec < nTracks_SIMD; iVec++) {
283 par.SetTx(T.
tx[iVec]);
284 par.SetTy(T.
ty[iVec]);
285 par.SetQp(T.
qp[iVec]);
288 par.SetCovariance(0, 0, Tout.
C00[iVec]);
289 par.SetCovariance(1, 0, Tout.
C10[iVec]);
290 par.SetCovariance(1, 1, Tout.
C11[iVec]);
291 par.SetCovariance(2, 0, Tout.
C20[iVec]);
292 par.SetCovariance(2, 1, Tout.
C21[iVec]);
293 par.SetCovariance(2, 2, Tout.
C22[iVec]);
294 par.SetCovariance(3, 0, Tout.
C30[iVec]);
295 par.SetCovariance(3, 1, Tout.
C31[iVec]);
296 par.SetCovariance(3, 2, Tout.
C32[iVec]);
297 par.SetCovariance(3, 3, Tout.
C33[iVec]);
298 par.SetCovariance(4, 0, Tout.
C40[iVec]);
299 par.SetCovariance(4, 1, Tout.
C41[iVec]);
300 par.SetCovariance(4, 2, Tout.
C42[iVec]);
301 par.SetCovariance(4, 3, Tout.
C43[iVec]);
302 par.SetCovariance(4, 4, Tout.
C44[iVec]);
311 FilterFirst(T, x_last, y_last, staLast);
320 fB2.Combine(fB[
i - 2], w[
i - 2]);
321 fld.Set(fB2, fz2, fB1, fz1, fB0, fz0);
322 for (--
i;
i >= 0;
i--) {
327 fld.Set(fB0, fz0, fB1, fz1, fB2, fz2);
330 fvec w1 = (w[
i] & (initialised));
331 fvec wIn = (
ONE & (initialised));
334 if (
i == NMvdStations - 1) {
363 for (iVec = 0; iVec < nTracks_SIMD; iVec++) {
367 par.SetTx(T.
tx[iVec]);
368 par.SetTy(T.
ty[iVec]);
369 par.SetQp(T.
qp[iVec]);
372 par.SetCovariance(0, 0, T.
C00[iVec]);
373 par.SetCovariance(1, 0, T.
C10[iVec]);
374 par.SetCovariance(1, 1, T.
C11[iVec]);
375 par.SetCovariance(2, 0, T.
C20[iVec]);
376 par.SetCovariance(2, 1, T.
C21[iVec]);
377 par.SetCovariance(2, 2, T.
C22[iVec]);
378 par.SetCovariance(3, 0, T.
C30[iVec]);
379 par.SetCovariance(3, 1, T.
C31[iVec]);
380 par.SetCovariance(3, 2, T.
C32[iVec]);
381 par.SetCovariance(3, 3, T.
C33[iVec]);
382 par.SetCovariance(4, 0, T.
C40[iVec]);
383 par.SetCovariance(4, 1, T.
C41[iVec]);
384 par.SetCovariance(4, 2, T.
C42[iVec]);
385 par.SetCovariance(4, 3, T.
C43[iVec]);
386 par.SetCovariance(4, 4, T.
C44[iVec]);
390 t[iVec]->
SetNDF(
static_cast<int>(T.
NDF[iVec]));
404 vector<L1FieldRegion>& field,
405 vector<float>& chiToVtx,
408 chiToVtx.reserve(Tracks.size());
419 for (
int iSta = 0; iSta < nStations; iSta++)
420 zSta[iSta] = sta[iSta].z;
422 field.reserve(Tracks.size());
428 FairRootManager* fManger = FairRootManager::Instance();
429 TClonesArray* listStsHits = (TClonesArray*) fManger->GetObject(
"StsHit");
430 TClonesArray* listMvdHits = 0;
431 if (NMvdStations > 0.)
432 listMvdHits = (TClonesArray*) fManger->GetObject(
"MvdHit");
434 unsigned short N_vTracks = Tracks.size();
436 for (
unsigned short itrack = 0; itrack < N_vTracks; itrack +=
fvecLen) {
437 if (N_vTracks - itrack <
static_cast<unsigned short>(
fvecLen))
438 nTracks_SIMD = N_vTracks - itrack;
441 for (
int iVec = 0; iVec < nTracks_SIMD; iVec++) {
442 t[iVec] = &Tracks[itrack + iVec];
466 KFParticleDatabase::Instance()->GetMass(t[iVec]->GetPidHypo());
467 mass2[iVec] = mass * mass;
470 for (
int iH = 0; iH < 2; iH++) {
471 float posx = 0.f, posy = 0.f, posz = 0.f;
473 if (iH < nHitsTrackMvd) {
474 if (!listMvdHits)
continue;
477 L1_DYNAMIC_CAST<CbmMvdHit*>(listMvdHits->At(hitIndex));
484 if (!listStsHits)
continue;
485 int hitIndex = t[iVec]->
GetHitIndex(iH - nHitsTrackMvd);
487 L1_DYNAMIC_CAST<CbmStsHit*>(listStsHits->At(hitIndex));
497 fB[iH + 1].
x[iVec] = fB_temp.x[iVec];
498 fB[iH + 1].
y[iVec] = fB_temp.y[iVec];
499 fB[iH + 1].
z[iVec] = fB_temp.z[iVec];
500 zField[iH + 1][iVec] = posz;
506 fld.Set(fB[2], zField[2], fB[1], zField[1], fB[0], zField[0]);
507 field.push_back(fld);
509 for (
int iSt = nStations - 4; iSt >= 0; iSt--) {
511 fvec initialized =
fvec(T.
z > (zSta[iSt] + 2.5));
512 w =
fvec(w & initialized);
515 if (iSt == NMvdStations - 1) {
533 if (NMvdStations <= 0) {
550 fvec d = c[0] * c[2] - c[1] * c[1];
552 fabs(0.5 * (dx * dx * c[0] - 2 * dx * dy * c[1] + dy * dy * c[2]) /
d));
556 for (
int iVec = 0; iVec < nTracks_SIMD; iVec++)
557 chiToVtx.push_back(chi[iVec]);
560 for (
int iVec = 0; iVec < nTracks_SIMD; iVec++) {
561 if (chi[iVec] < chiPrim) {
565 par.SetTx(T.
tx[iVec]);
566 par.SetTy(T.
ty[iVec]);
567 par.SetQp(T.
qp[iVec]);
570 par.SetCovariance(0, 0, T.
C00[iVec]);
571 par.SetCovariance(1, 0, T.
C10[iVec]);
572 par.SetCovariance(1, 1, T.
C11[iVec]);
573 par.SetCovariance(2, 0, T.
C20[iVec]);
574 par.SetCovariance(2, 1, T.
C21[iVec]);
575 par.SetCovariance(2, 2, T.
C22[iVec]);
576 par.SetCovariance(3, 0, T.
C30[iVec]);
577 par.SetCovariance(3, 1, T.
C31[iVec]);
578 par.SetCovariance(3, 2, T.
C32[iVec]);
579 par.SetCovariance(3, 3, T.
C33[iVec]);
580 par.SetCovariance(4, 0, T.
C40[iVec]);
581 par.SetCovariance(4, 1, T.
C41[iVec]);
582 par.SetCovariance(4, 2, T.
C42[iVec]);
583 par.SetCovariance(4, 3, T.
C43[iVec]);
584 par.SetCovariance(4, 4, T.
C44[iVec]);
594 vector<L1FieldRegion>& field) {
595 field.reserve(Tracks.size());
599 FairRootManager* fManger = FairRootManager::Instance();
600 TClonesArray* listStsHits = (TClonesArray*) fManger->GetObject(
"StsHit");
601 TClonesArray* listMvdHits = 0;
603 if (NMvdStations > 0.)
604 listMvdHits = (TClonesArray*) fManger->GetObject(
"MvdHit");
616 unsigned short N_vTracks = Tracks.size();
618 for (
unsigned short itrack = 0; itrack < N_vTracks; itrack +=
fvecLen) {
619 if (N_vTracks - itrack <
static_cast<unsigned short>(
fvecLen))
620 nTracks_SIMD = N_vTracks - itrack;
622 for (
int i = 0;
i < nTracks_SIMD;
i++)
623 t[
i] = &Tracks[itrack +
i];
625 for (
int iVec = 0; iVec < nTracks_SIMD; iVec++) {
627 for (
int iH = 0; iH < 2; iH++) {
628 float posx = 0.f, posy = 0.f, posz = 0.f;
630 if (iH < nHitsTrackMvd) {
631 if (!listMvdHits)
continue;
634 L1_DYNAMIC_CAST<CbmMvdHit*>(listMvdHits->At(hitIndex));
641 if (!listStsHits)
continue;
642 int hitIndex = t[iVec]->
GetHitIndex(iH - nHitsTrackMvd);
644 L1_DYNAMIC_CAST<CbmStsHit*>(listStsHits->At(hitIndex));
654 fB[iH + 1].
x[iVec] = fB_temp.x[iVec];
655 fB[iH + 1].
y[iVec] = fB_temp.y[iVec];
656 fB[iH + 1].
z[iVec] = fB_temp.z[iVec];
657 zField[iH + 1][iVec] = posz;
663 fld.Set(fB[2], zField[2], fB[1], zField[1], fB[0], zField[0]);
664 field.push_back(fld);
669 vector<CbmStsTrack>& Tracks,
670 vector<L1FieldRegion>& field) {
671 field.reserve(Tracks.size());
675 FairRootManager* fManger = FairRootManager::Instance();
676 TClonesArray* listStsHits = (TClonesArray*) fManger->GetObject(
"StsHit");
677 TClonesArray* listMvdHits = 0;
679 if (NMvdStations > 0.)
680 listMvdHits = (TClonesArray*) fManger->GetObject(
"MvdHit");
692 unsigned short N_vTracks = Tracks.size();
694 for (
unsigned short itrack = 0; itrack < N_vTracks; itrack +=
fvecLen) {
695 if (N_vTracks - itrack <
static_cast<unsigned short>(
fvecLen))
696 nTracks_SIMD = N_vTracks - itrack;
698 for (
int i = 0;
i < nTracks_SIMD;
i++)
699 t[
i] = &Tracks[itrack +
i];
701 for (
int iVec = 0; iVec < nTracks_SIMD; iVec++) {
704 for (
int iH = 0; iH < 3; iH++) {
705 float posx = 0.f, posy = 0.f, posz = 0.f;
707 int hitNumber = nHits - iH - 1;
708 if (hitNumber < nHitsTrackMvd) {
709 if (!listMvdHits)
continue;
712 L1_DYNAMIC_CAST<CbmMvdHit*>(listMvdHits->At(hitIndex));
719 if (!listStsHits)
continue;
720 int hitIndex = t[iVec]->
GetHitIndex(hitNumber - nHitsTrackMvd);
722 L1_DYNAMIC_CAST<CbmStsHit*>(listStsHits->At(hitIndex));
733 fB[iH].
x[iVec] = fB_temp.x[iVec];
734 fB[iH].
y[iVec] = fB_temp.y[iVec];
735 fB[iH].
z[iVec] = fB_temp.z[iVec];
736 zField[iH][iVec] = posz;
740 fld.Set(fB[0], zField[0], fB[1], zField[1], fB[2], zField[2]);
741 field.push_back(fld);