26 #include "AliHLTTPCCAGBTracker.h"
49 #ifdef HomogeneousField
50 void KFParticleTopoReconstructor::SetField(
double b)
53 KFParticle::SetField(b);
54 KFParticleSIMD::SetField(
float(b));
77 KFParticle::SetField( tracker->Slice(0).Param().Bz() );
78 KFParticleSIMD::SetField( tracker->Slice(0).Param().Bz() );
81 const int nTracks = tracker->NTracks();
87 float_v
alpha(Vc::Zero);
90 for (
int iTr = 0; iTr < nTracks; iTr++ ) {
94 const int q = -(tracker->Tracks()[ iTr ].InnerParam().QPt()>=0 ? 1 : -1);
96 for(
int iParamSet=0; iParamSet<2; iParamSet++)
98 AliHLTTPCCATrackParam trParam;
103 trParam = tracker->Tracks()[ iTr ].InnerParam();
108 trParam = tracker->Tracks()[ iTr ].OuterParam();
112 trParam.TransportToXWithMaterial( x0, tracker->Slice(0).Param().cBz( ) );
119 const float pt = CAMath::Abs( 1.
f / trParam.QPt() );
122 ok = ok && !( trParam.NDF() < 10+5);
123 ok = ok && !( trParam.Chi2() > 10*trParam.NDF() );
126 const float cosL = trParam.DzDs();
134 for (
int i = 0;
i < 6;
i++)
135 for (
int j = 0;
j < 6;
j++)
140 J[3][3] = -pt * trParam.SinPhi() / trParam.GetCosPhi();
141 J[3][5] = -q * pt * pt * trParam.GetCosPhi();
143 J[4][5] = -q* pt * pt * trParam.SinPhi();
145 J[5][5] = -q* pt * pt * cosL;
149 CovIn[0][0] = .001f*.001f;
150 for (
int i = 1;
i < 6;
i++) {
155 for (
int i = 1;
i < 6;
i++) {
156 for (
int j = 1;
j <=
i;
j++, k++) {
157 CovIn[
i][
j] = trParam.Cov()[
k];
158 CovIn[
j][
i] = trParam.Cov()[
k];
164 for (
int i = 0;
i < 6;
i++)
165 for (
int j = 0;
j < 6;
j++) {
167 for (
int k = 0; k < 6; k++) {
168 CovInJ[
i][
j] += CovIn[
i][
k] * J[
j][
k];
173 for (
int i = 0;
i < 6;
i++)
174 for (
int j = 0;
j < 6;
j++) {
176 for (
int k = 0; k < 6; k++) {
177 CovOut[
i][
j] += J[
i][
k] * CovInJ[
k][
j];
184 for (
int i = 0;
i < 6;
i++) {
185 for (
int j = 0;
j <=
i;
j++, k++) {
186 KFPCov[
k] = CovOut[
i][
j];
187 ASSERT( !CAMath::Finite(CovOut[
i][
j]) || CovOut[
i][j] == 0 || fabs( 1. - CovOut[j][
i]/CovOut[
i][j] ) <= 0.05,
188 "CovOut[" <<
i <<
"][" << j <<
"] == CovOut[" << j <<
"][" <<
i <<
"] : " << CovOut[
i][j] <<
" == " << CovOut[j][
i]);
196 for (
int i = 0;
i < 6;
i++) {
197 for (
int j = 0;
j <=
i;
j++, k++) {
198 ok &= CAMath::Finite( KFPCov[k] );
200 ok &= ( KFPCov[k-1] > 0 );
208 trackPDG = (*pdg)[iTr];
210 for(
int iC=0; iC<21; iC++)
223 alpha[nElements] = tracker->Tracks()[ iTr ].Alpha();
247 fStatTime[0] = timer.RealTime();
264 int nTracks = particles.size();
274 for(
int iTr=0; iTr<nTracks; iTr++)
278 trackPDG = (*pdg)[iTr];
282 npixelhits = nPixelHits->at(iTr);
284 for(
int iP=0; iP<6; iP++)
286 for(
int iC=0; iC<21; iC++)
300 fStatTime[0] = timer.RealTime();
316 int nTracks = tracks.
Size();
331 fStatTime[0] = timer.RealTime();
346 fPV.resize(pv.size());
348 for(
unsigned int iPV=0; iPV<
fPV.size(); iPV++)
353 fStatTime[0] = timer.RealTime();
385 fPV.resize(nPrimVtx);
390 fPV.resize(nPrimVtx);
391 for(
int iPV=0; iPV<nPrimVtx; iPV++)
401 if(iPV != nPV)
continue;
406 for(
unsigned int iTr=0; iTr<tracks.size(); iTr++)
420 fStatTime[1] = timer.RealTime();
450 for(
int iSet=nSets-1; iSet>=0; iSet--)
454 vector<KFPTrackIndex> sortedTracks(Size);
456 for(
int iTV=0; iTV<4; iTV++)
457 trackIndex[iTV].resize(Size);
458 int nTracks[4] = {0,0,0,0};
460 for(
int iTr=0; iTr<
Size; iTr++)
462 sortedTracks[iTr].fIndex = iTr;
463 sortedTracks[iTr].fPdg =
fTracks[0].
PDG()[iTr];
468 for(
int iTr=0; iTr<
Size; iTr++)
470 int iTrSorted = sortedTracks[iTr].fIndex;
479 trackIndex[1][nTracks[1]] = iTrSorted;
484 trackIndex[0][nTracks[0]] = iTrSorted;
492 trackIndex[3][nTracks[3]] = iTrSorted;
497 trackIndex[2][nTracks[2]] = iTrSorted;
503 for(
int iTV=1; iTV<4; iTV++)
509 fTracks[offset[iSet]].
Set(positive,nTracks[0],0);
511 for(
int iTV=0; iTV<4; iTV++)
517 vector<int> newIndex(Size);
519 for(
int iTC=0; iTC<4; iTC++)
521 for(
int iTrackIndex=0; iTrackIndex<
fTracks[iTC].
Size(); iTrackIndex++)
523 newIndex[trackIndex[iTC][iTrackIndex]] = iCurrentTrack;
539 fStatTime[2] = timer.RealTime();
552 for(
int iTV=2; iTV<4; iTV++)
555 for(
unsigned int iTr=0; iTr < NTr; iTr +=
float_vLen)
557 const int_v& pdg =
reinterpret_cast<const int_v&
>(
fTracks[iTV].
PDG()[iTr]);
558 const int_v& pvIndex =
reinterpret_cast<const int_v&
>(
fTracks[iTV].
PVIndex()[iTr]);
562 for(
unsigned int iV=0; iV < (
unsigned int)
float_vLen; iV++)
564 if(iV+iTr >= NTr)
continue;
566 int iPV = pvIndex[iV];
567 point[0][iV] =
fPV[iPV].X()[0];
568 point[1][iV] =
fPV[iPV].Y()[0];
569 point[2][iV] =
fPV[iPV].Z()[0];
574 for(
int iP=0; iP<6; iP++)
576 for(
int iC=0; iC<21; iC++)
591 for(
int iTV=0; iTV<2; iTV++)
594 for(
unsigned int iTr=0; iTr < NTr; iTr +=
float_vLen)
596 uint_v trackIndex = iTr + uint_v::IndexesFromZero();
597 const int_v& pdg =
reinterpret_cast<const int_v&
>(
fTracks[iTV].
PDG()[iTr]);
600 float_v& chi2 =
reinterpret_cast<float_v&
>(
fChiToPrimVtx[iTV][iTr]);
601 chi2(simd_cast<float_m>(trackIndex<NTr)) = 10000.f;
603 for(
int iPV=0; iPV<nPV; iPV++)
605 const float_v
point[3] = {pv[iPV].
X(), pv[iPV].
Y(), pv[iPV].
Z()};
608 chi2( (chi2>chiVec) && simd_cast<float_m>(trackIndex<NTr) ) = chiVec;
643 bool use = (PDG == 310) ||
646 (abs(PDG) == 3122) ||
647 (abs(PDG) == 3312) ||
648 (abs(PDG) == 3334) ||
649 (abs(PDG) == 3003) ||
650 (abs(PDG) == 3103) ||
651 (abs(PDG) == 3004) ||
652 (abs(PDG) == 3005) ||
653 (abs(PDG) == 3006) ||
654 (abs(PDG) == 3007) ||
655 (abs(PDG) == 3203) ||
656 (abs(PDG) == 3008) ||
657 (abs(PDG) == 3009) ||
658 (abs(PDG) == 3010) ||
674 std::vector<ParticleInfo> particleInfo;
676 std::vector<bool> deleteCandidate(
fParticles.size());
677 std::vector<int> bestMother(
fParticles.size());
679 for(
unsigned int iParticle=0; iParticle<
fParticles.size(); iParticle++)
681 isUsed[iParticle] =
false;
682 deleteCandidate[iParticle] =
false;
683 bestMother[iParticle] = -1;
686 for(
unsigned int iParticle=0; iParticle<
fParticles.size(); iParticle++)
690 bool isSecondary = 1;
699 deleteCandidate[iParticle] =
true;
742 for(
unsigned int iParticle=0; iParticle<
fParticles.size(); iParticle++)
744 if(deleteCandidate[iParticle])
continue;
747 float mass, massSigma;
748 fParticles[iParticle].GetMass(mass, massSigma);
750 float massPDG, massPDGSigma;
753 float dm1 = fabs(mass - massPDG)/massPDGSigma;
756 for(
unsigned int jParticle=iParticle+1; jParticle<
fParticles.size(); jParticle++)
758 if(deleteCandidate[jParticle])
continue;
761 fParticles[jParticle].GetMass(mass, massSigma);
764 float dm2 = fabs(mass - massPDG)/massPDGSigma;
770 if(dm1 < 3.
f || dm2 < 3.
f)
790 deleteCandidate[jParticle] =
true;
791 bestMother[
fParticles[iParticle].DaughterIds()[0]] = iParticle;
792 bestMother[
fParticles[iParticle].DaughterIds()[1]] = iParticle;
796 deleteCandidate[iParticle] =
true;
797 bestMother[
fParticles[iParticle].DaughterIds()[0]] = jParticle;
798 bestMother[
fParticles[iParticle].DaughterIds()[1]] = jParticle;
823 for(
unsigned int iParticle=0; iParticle<
fParticles.size(); iParticle++)
825 if(deleteCandidate[iParticle])
continue;
836 float mass, massSigma;
837 fParticles[iParticle].GetMass(mass, massSigma);
838 float massPDG, massPDGSigma;
840 float dm = fabs(mass - massPDG)/massPDGSigma;
848 for(
unsigned int iPI=0; iPI<particleInfo.size(); iPI++)
850 const int index = particleInfo[iPI].fParticleIndex;
851 if(deleteCandidate[index])
continue;
854 for(
int iDaughter=0; iDaughter<
fParticles[
index].NDaughters(); iDaughter++)
859 for(
int iDaughter=0; iDaughter<
fParticles[
index].NDaughters(); iDaughter++)
863 deleteCandidate[
index] =
true;
866 for(
unsigned int iParticle=0; iParticle<
fParticles.size(); iParticle++)
868 if(deleteCandidate[iParticle])
continue;
871 bool bothDaughtersElectrons = 1;
872 for(
int iDaughter=0; iDaughter<
fParticles[iParticle].NDaughters(); iDaughter++)
874 const int daughterIndex =
fParticles[iParticle].DaughterIds()[iDaughter];
878 float mass, massSigma;
879 fParticles[iParticle].GetMass(mass, massSigma);
880 float massPDG, massPDGSigma;
882 float dm = fabs(mass - massPDG)/massPDGSigma;
888 for(
int iDaughter=0; iDaughter<
fParticles[iParticle].NDaughters(); iDaughter++)
892 deleteCandidate[iParticle] =
true;
898 for(
unsigned int iParticle=0; iParticle<
fParticles.size(); iParticle++)
902 bool bothDaughtersElectrons = 1;
903 for(
int iDaughter=0; iDaughter<
fParticles[iParticle].NDaughters(); iDaughter++)
905 const int daughterIndex =
fParticles[iParticle].DaughterIds()[iDaughter];
908 if(!bothDaughtersElectrons)
910 deleteCandidate[iParticle] =
true;
915 for(
int iDaughter=0; iDaughter<
fParticles[iParticle].NDaughters(); iDaughter++)
919 deleteCandidate[iParticle] =
true;
962 for(
int iParticle=0; iParticle<int(
fParticles.size()); iParticle++)
964 if(deleteCandidate[iParticle])
continue;
966 for(
int iDaughter=0; iDaughter<
fParticles[iParticle].NDaughters(); iDaughter++)
969 deleteCandidate[iParticle] =
true;
974 for(
unsigned int iParticle=0; iParticle<
fParticles.size(); iParticle++)
975 if(deleteCandidate[iParticle])
987 vector<int> daughters;
989 std::sort(daughters.begin(), daughters.end());
991 for(
unsigned int iDaughter=1; iDaughter<daughters.size(); iDaughter++)
993 if(daughters[iDaughter] == daughters[iDaughter-1])
1012 for(
int iDaughter=0; iDaughter<particle.
NDaughters(); iDaughter++)
1027 #endif // USE_TIMERS
1031 if(
fPV.size() < 1)
return;
1049 fStatTime[3] = timer.RealTime();
1050 #endif // USE_TIMERS
1054 void KFParticleTopoReconstructor::SendDataToXeonPhi(
int iHLT, scif_epd_t& endpoint,
void*
buffer, off_t& offsetServer, off_t& offsetSender,
float Bz)
1057 int*
data =
reinterpret_cast<int*
>(buffer);
1061 dataSize +=
fPV.size() * 9;
1067 float&
field =
reinterpret_cast<float&
>(data[NInputSets+1]);
1070 int offset = NInputSets+2;
1075 for(
int iP=0; iP<3; iP++)
1077 for(
unsigned int iPV=0; iPV<
fPV.size(); iPV++)
1079 float& tmpFloat =
reinterpret_cast<float&
>(data[offset + iPV]);
1080 tmpFloat =
fPV[iPV].Parameter(iP)[0];
1082 offset +=
fPV.size();
1085 for(
int iC=0; iC<6; iC++)
1087 for(
unsigned int iPV=0; iPV<
fPV.size(); iPV++)
1089 float& tmpFloat =
reinterpret_cast<float&
>(data[offset + iPV]);
1090 tmpFloat =
fPV[iPV].Covariance(iC)[0];
1092 offset +=
fPV.size();
1096 int msgSize =
sizeof(int) * dataSize;
1098 const uint16_t portSenderId = 2000 + iHLT;
1100 int controlSignal = portSenderId;
1101 scif_send(endpoint, &msgSize,
sizeof(
int), SCIF_SEND_BLOCK);
1102 scif_recv(endpoint, &controlSignal,
sizeof(controlSignal), 1);
1103 if(controlSignal != portSenderId) { std::cout << controlSignal <<
" " << portSenderId << std::endl;
return; }
1105 int ret = scif_writeto(endpoint, offsetServer, msgSize, offsetSender, 0);
1106 if ( ret == -1 ) std::cout <<
"Fail sending array to the server. Error: " << errno << std::endl;
1108 scif_send(endpoint, &controlSignal,
sizeof(
int), SCIF_SEND_BLOCK);
1125 sprintf ( Result,
"%d", nEvents );
1126 outFileName +=
string(Result);
1127 outFileName +=
"_KFPTracks.data";
1129 ofstream
out((prefix+outFileName).
data());
1137 float B[3] = {0.f},
r[3] = {0.f};
1140 out << B[2] << std::endl;
1141 out << nSets << std::endl;
1142 for(
int iSet=0; iSet<nSets; iSet++)
1145 for(
int iP=0; iP<6; iP++)
1152 for(
int iC=0; iC<21; iC++)
1168 out <<
fTracks[iSet].
Q()[iTr] <<
" ";
1183 out <<
fPV.size() << std::endl;
1184 for(
unsigned int iPV=0; iPV <
fPV.size(); iPV++)
1186 out <<
fPV[iPV].X()[0] <<
" " <<
fPV[iPV].Y()[0] <<
" " <<
fPV[iPV].Z()[0] <<
" " << std::endl;
1188 for(
int iC=0; iC<6; iC++)