Calculation of several variables related to sliding linear fit.
364 const TwoDSlidingFitResult slidingFitResultLarge(
367 if (slidingFitResult.GetLayerFitResultMap().empty())
368 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
370 straightLineLengthLarge =
371 (slidingFitResultLarge.GetGlobalMaxLayerPosition() - slidingFitResultLarge.GetGlobalMinLayerPosition()).GetMagnitude();
372 rmsSlidingLinearFit = 0.f;
376 CartesianVector previousFitPosition(slidingFitResult.GetGlobalMinLayerPosition());
379 for (
const auto &mapEntry : slidingFitResult.GetLayerFitResultMap())
381 const LayerFitResult &layerFitResult(mapEntry.second);
382 rmsSlidingLinearFit += layerFitResult.GetRms();
384 CartesianVector thisFitPosition(0.
f, 0.
f, 0.
f);
385 slidingFitResult.GetGlobalPosition(layerFitResult.GetL(), layerFitResult.GetFitT(), thisFitPosition);
388 slidingFitResultLarge.GetLayerFitResultMap().find(slidingFitResultLarge.GetLayer(layerFitResult.GetL()));
390 if (slidingFitResultLarge.GetLayerFitResultMap().end() == iterLarge)
391 throw StatusCodeException(STATUS_CODE_FAILURE);
393 diffWithStraightLineVector.push_back(static_cast<float>(std::fabs(layerFitResult.GetFitT() - iterLarge->second.GetFitT())));
395 const float thisGapLength((thisFitPosition - previousFitPosition).GetMagnitude());
396 const float minZ(
std::min(thisFitPosition.GetZ(), previousFitPosition.GetZ()));
397 const float maxZ(
std::max(thisFitPosition.GetZ(), previousFitPosition.GetZ()));
399 if ((maxZ - minZ) > std::numeric_limits<float>::epsilon())
402 const float correctedGapLength(thisGapLength * (1.
f - gapZ / (maxZ - minZ)));
404 if (correctedGapLength > maxFitGapLength)
405 maxFitGapLength = correctedGapLength;
409 maxFitGapLength = 0.f;
412 dTdLMin =
std::min(dTdLMin, static_cast<float>(layerFitResult.GetGradient()));
413 dTdLMax =
std::max(dTdLMax, static_cast<float>(layerFitResult.GetGradient()));
414 previousFitPosition = thisFitPosition;
417 if (diffWithStraightLineVector.empty())
418 throw StatusCodeException(STATUS_CODE_FAILURE);
420 diffWithStraightLineMean = 0.f;
422 for (
const float diffWithStraightLine : diffWithStraightLineVector)
423 diffWithStraightLineMean += diffWithStraightLine;
425 diffWithStraightLineMean /=
static_cast<float>(diffWithStraightLineVector.size());
427 catch (
const StatusCodeException &)
429 straightLineLengthLarge = -1.f;
430 diffWithStraightLineMean = -1.f;
431 maxFitGapLength = -1.f;
432 rmsSlidingLinearFit = -1.f;
static float CalculateGapDeltaZ(const pandora::Pandora &pandora, const float minZ, const float maxZ, const pandora::HitType hitType)
Calculate the total distance within a given 2D region that is composed of detector gaps...
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
unsigned int m_slidingLinearFitWindowLarge
The sliding linear fit window - should be large, providing a simple linear fit.
static int max(int a, int b)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Dft::FloatVector FloatVector
unsigned int m_slidingLinearFitWindow
The sliding linear fit window.