Use sliding linear fit to identify the best split position.
27 const LayerFitResultMap &layerFitResultMap(slidingFitResult.GetLayerFitResultMap());
28 const int minLayer(layerFitResultMap.begin()->first), maxLayer(layerFitResultMap.rbegin()->first);
30 const int nLayersHalfWindow(slidingFitResult.GetLayerFitHalfWindow());
31 const int nLayersSpanned(1 + maxLayer - minLayer);
33 if (nLayersSpanned <= 2 * nLayersHalfWindow)
34 return STATUS_CODE_NOT_FOUND;
36 bool foundSplit(
false);
38 float bestCosTheta(1.
f);
42 const int iLayer(iter->first);
44 const float rL(slidingFitResult.GetL(iLayer));
45 const float rL1(slidingFitResult.GetL(iLayer - nLayersHalfWindow));
46 const float rL2(slidingFitResult.GetL(iLayer + nLayersHalfWindow));
48 CartesianVector centralPosition(0.
f, 0.
f, 0.
f), firstDirection(0.
f, 0.
f, 0.
f), secondDirection(0.
f, 0.
f, 0.
f);
50 if ((STATUS_CODE_SUCCESS != slidingFitResult.GetGlobalFitPosition(rL, centralPosition)) ||
51 (STATUS_CODE_SUCCESS != slidingFitResult.GetGlobalFitDirection(rL1, firstDirection)) ||
52 (STATUS_CODE_SUCCESS != slidingFitResult.GetGlobalFitDirection(rL2, secondDirection)))
57 const float cosTheta(firstDirection.GetDotProduct(secondDirection));
58 const float rms1(slidingFitResult.GetFitRms(rL1));
59 const float rms2(slidingFitResult.GetFitRms(rL2));
69 if (
rms < rmsCut && cosTheta < bestCosTheta)
71 bestCosTheta = cosTheta;
72 splitPosition = centralPosition;
78 return STATUS_CODE_NOT_FOUND;
80 return STATUS_CODE_SUCCESS;
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
float m_maxSlidingCosTheta
std::map< int, LayerFitResult > LayerFitResultMap
float m_maxScatterCosTheta
static int max(int a, int b)