61 float zeroPoint[3]{0,0,0};
64 for(
int iC=0; iC<3; iC++)
78 float pvEstimation[3] = {0.};
79 float pvEstimationTr[3] = {0.};
81 float parTmp[8] = {0.};
82 float covTmp[36] = {0.};
84 for(
int iC=0; iC<3; iC++)
92 for(
int iIter=0; iIter<3; iIter++)
94 C[0]*=100.f; C[1]*=100.f; C[2]*=100.f;
97 float dsdr[6] = {0.f};
99 ds =
fParticles[iTr].GetDStoPoint(pvEstimationTr, dsdr);
100 fParticles[iTr].Transport( ds, dsdr, parTmp, covTmp);
102 float r2 = parTmp[0]*parTmp[0] + parTmp[1]*parTmp[1];
103 if(!(r2==r2))
continue;
104 if(r2 > 25 )
continue;
106 const float V[3] = {covTmp[0], covTmp[2], covTmp[5]};
108 for(
int iComp=0; iComp<3; iComp++)
110 float K = C[iComp]/(C[iComp]+V[iComp]);
111 if (fabs(V[iComp]) < 1.e-8)
continue;
112 if(C[iComp] > 16*V[iComp])
113 K = 1.f - V[iComp]/C[iComp];
114 const float dzeta = parTmp[iComp]-pvEstimation[iComp];
116 if(K<0. || K>0.999)
continue;
117 pvEstimation[iComp] += K*dzeta;
118 C[iComp] -= K*C[iComp];
121 pvEstimationTr[0] = pvEstimation[0];
122 pvEstimationTr[1] = pvEstimation[1];
123 pvEstimationTr[2] = pvEstimation[2];
128 fParticles[iP].TransportToPoint(pvEstimation);
166 vector<unsigned short int> notUsedTracks(
fNParticles);
167 vector<unsigned short int> *notUsedTracksPtr = ¬UsedTracks;
170 vector<unsigned short int> notUsedTracksNew(
fNParticles);
171 vector<unsigned short int> *notUsedTracksNewPtr = ¬UsedTracksNew;
172 int nNotUsedTracksNew = 0;
175 (*notUsedTracksPtr)[iTr] = iTr;
177 while(nNotUsedTracks>0)
179 short int bestTrack = 0;
180 float bestWeight = -1.f;
182 for(
unsigned short int iTr = 0; iTr < nNotUsedTracks; iTr++)
184 unsigned short int &curTrack = (*notUsedTracksPtr)[iTr];
186 if (
fWeight[curTrack] > bestWeight)
188 bestWeight =
fWeight[curTrack];
189 bestTrack = curTrack;
193 if(bestWeight < 0.
f)
break;
196 cluster.
fTracks.reserve(nNotUsedTracks);
198 const float *rBest =
fParticles[bestTrack].Parameters();
199 const float *covBest =
fParticles[bestTrack].CovarianceMatrix();
201 float rVertex[3] = {0.f};
202 float covVertex[6] = {0.f};
203 float weightVertex = 0.f;
205 for(
unsigned short int iTr = 0; iTr < nNotUsedTracks; iTr++)
207 unsigned short int &curTrack = (*notUsedTracksPtr)[iTr];
208 float chi2deviation =
fParticles[curTrack].GetDeviationFromVertex(rBest, covBest);
209 if( ( chi2deviation < fChi2CutPreparation && chi2deviation >= 0 &&
fWeight[curTrack] > -1.
f) || curTrack == bestTrack)
211 for(
int iP=0; iP<3; iP++)
215 for(
int iC=0; iC<6; iC++)
216 covVertex[iC] += weight2 *
fParticles[curTrack].CovarianceMatrix()[iC];
218 weightVertex += fWeight[curTrack];
219 cluster.
fTracks.push_back(curTrack);
223 (*notUsedTracksNewPtr)[nNotUsedTracksNew] = curTrack;
228 vector<unsigned short int> *notUsedTracksPtrSave = notUsedTracksPtr;
229 notUsedTracksPtr = notUsedTracksNewPtr;
230 notUsedTracksNewPtr = notUsedTracksPtrSave;
232 nNotUsedTracks = nNotUsedTracksNew;
233 nNotUsedTracksNew = 0;
235 if(cluster.
fTracks.size() < 2)
continue;
236 if((cluster.
fTracks.size() < 3) && (fNParticles>3))
continue;
238 for(
int iP=0; iP<3; iP++)
239 cluster.
fP[iP] = rVertex[iP]/weightVertex;
241 for(
int iC=0; iC<6; iC++)
242 cluster.
fC[iC] = covVertex[iC]/(weightVertex*weightVertex);
245 int nPrimCand = cluster.
fTracks.size();
246 int nTracks = cluster.
fTracks.size();
250 for (
int iP = 0; iP < nPrimCand; iP++ )
266 bool *vFlags =
new bool[nPrimCand];
267 for(
int iFl=0; iFl<nPrimCand; iFl++)
274 vector<int> clearClusterInd;
275 clearClusterInd.reserve(cluster.
fTracks.size());
276 for (
int iP = 0; iP < nTracks; iP++ ){
277 if(cluster.
fTracks[iP] == bestTrack) {
278 clearClusterInd.push_back(cluster.
fTracks[iP]);
282 clearClusterInd.push_back(cluster.
fTracks[iP]);
285 (*notUsedTracksPtr)[nNotUsedTracks] = cluster.
fTracks[iP];
290 for(
unsigned short int iTr = 0; iTr < nNotUsedTracks; iTr++)
292 unsigned short int &curTrack = (*notUsedTracksPtr)[iTr];
296 clearClusterInd.push_back(curTrack);
300 (*notUsedTracksNewPtr)[nNotUsedTracksNew] = curTrack;
304 cluster.
fTracks = clearClusterInd;
306 notUsedTracksPtrSave = notUsedTracksPtr;
307 notUsedTracksPtr = notUsedTracksNewPtr;
308 notUsedTracksNewPtr = notUsedTracksPtrSave;
310 nNotUsedTracks = nNotUsedTracksNew;
311 nNotUsedTracksNew = 0;
315 if( primVtx.
GetNDF() >= cutNDF && ((cluster.
fTracks.size()>0.1f*fNParticles && fNParticles > 30) || fNParticles<=30 ) )
317 if( primVtx.
GetNDF() >= cutNDF)
324 if(vFlags)
delete [] vFlags;
326 if(pParticles)
delete [] pParticles;