9 #include "Objects/Cluster.h"
25 TwoDSlidingShowerFitResult::TwoDSlidingShowerFitResult(
26 const T *
const pT,
const unsigned int slidingFitWindow,
const float slidingFitLayerPitch,
const float showerEdgeMultiplier) :
37 edgePositions.clear();
38 CartesianPointVector fitPositionVector;
39 PANDORA_THROW_RESULT_IF_AND_IF(
40 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, this->
GetNegativeEdgeFitResult().GetGlobalFitPositionListAtX(x, fitPositionVector));
41 PANDORA_THROW_RESULT_IF_AND_IF(
42 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, this->
GetPositiveEdgeFitResult().GetGlobalFitPositionListAtX(x, fitPositionVector));
44 if (fitPositionVector.size() < 2)
46 float minXn(0.f), maxXn(0.f), minXp(0.f), maxXp(0.f);
49 const float minX(std::min(minXn, minXp)), maxX(std::max(maxXn, maxXp));
51 if ((x < minX) || (x > maxX))
54 float minZn(0.f), maxZn(0.f), minZp(0.f), maxZp(0.f);
57 const float minZ(std::min(minZn, minZp)), maxZ(std::max(maxZn, maxZp));
59 if (!widenIfAmbiguity)
63 else if (fitPositionVector.empty())
65 fitPositionVector.push_back(CartesianVector(x, 0.f, minZ));
66 fitPositionVector.push_back(CartesianVector(x, 0.f, maxZ));
68 else if (1 == fitPositionVector.size())
71 const float existingEdge(fitPositionVector.front().GetZ());
72 const float secondEdge((std::fabs(existingEdge - minZ) < std::fabs(existingEdge - maxZ)) ? minZ : maxZ);
73 fitPositionVector.push_back(CartesianVector(x, 0.f, secondEdge));
77 FloatVector localEdgePositions;
78 for (
const CartesianVector &fitPosition : fitPositionVector)
79 localEdgePositions.push_back(fitPosition.GetZ());
81 if (localEdgePositions.size() < 2)
82 throw StatusCodeException(STATUS_CODE_FAILURE);
84 std::sort(localEdgePositions.begin(), localEdgePositions.end());
85 edgePositions.push_back(localEdgePositions.front());
86 edgePositions.push_back(localEdgePositions.back());
94 CartesianPointVector pointVector;
102 const TwoDSlidingFitResult &fullShowerFit,
const ShowerEdge showerEdge,
const float showerEdgeMultiplier)
107 for (
const CartesianVector &hitPosition : *pPointVector)
109 float rL(0.f), rT(0.f);
110 fullShowerFit.GetLocalPosition(hitPosition, rL, rT);
111 rT *= showerEdgeMultiplier;
113 CartesianVector fullShowerFitPosition(0.f, 0.f, 0.f);
114 if (STATUS_CODE_SUCCESS != fullShowerFit.GetGlobalFitPosition(rL, fullShowerFitPosition))
117 float rLFit(0.f), rTFit(0.f);
118 fullShowerFit.GetLocalPosition(fullShowerFitPosition, rLFit, rTFit);
120 const float rTDiff(rT - rTFit);
124 const int layer(fullShowerFit.GetLayer(rL));
131 for (
const FitCoordinateMap::value_type &mapEntry : fitCoordinateMap)
134 bool bestFitCoordinateFound(
false);
140 if (((
POSITIVE_SHOWER_EDGE == showerEdge) && (fitCoordinate.second > bestFitCoordinate.second)) ||
143 bestFitCoordinate = fitCoordinate;
144 bestFitCoordinateFound =
true;
148 if (bestFitCoordinateFound)
149 layerFitContributionMap[mapEntry.first].AddPoint(bestFitCoordinate.first, bestFitCoordinate.second);
152 return TwoDSlidingFitResult(fullShowerFit.GetLayerFitHalfWindow(), fullShowerFit.GetLayerPitch(), fullShowerFit.GetAxisIntercept(),
153 fullShowerFit.GetAxisDirection(), fullShowerFit.GetOrthoDirection(), layerFitContributionMap);
Header file for the lar two dimensional sliding shower fit result class.
ShowerEdge
ShowerEdge enum.
void GetMinAndMaxX(float &minX, float &maxX) const
Get the minimum and maximum x coordinates associated with the sliding fit.
process_name opflash particleana ie x
std::map< int, FitCoordinateList > FitCoordinateMap
static TwoDSlidingFitResult LArTwoDShowerEdgeFit(const pandora::Cluster *const pCluster, const TwoDSlidingFitResult &fullShowerFit, const ShowerEdge showerEdge, const float showerEdgeMultiplier)
Perform two dimensional sliding fit to shower edge, using specified primary axis. ...
std::map< int, LayerFitContribution > LayerFitContributionMap
TwoDSlidingShowerFitResult class.
void GetMinAndMaxZ(float &minZ, float &maxZ) const
Get the minimum and maximum z coordinates associated with the sliding fit.
Header file for the cluster helper class.
std::pair< float, float > FitCoordinate
const TwoDSlidingFitResult & GetPositiveEdgeFitResult() const
Get the sliding fit result for the positive shower edge.
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
const TwoDSlidingFitResult & GetNegativeEdgeFitResult() const
Get the sliding fit result for the negative shower edge.
static void GetCoordinateVector(const pandora::Cluster *const pCluster, pandora::CartesianPointVector &coordinateVector)
Get vector of hit coordinates from an input cluster.
TwoDSlidingShowerFitResult(const T *const pT, const unsigned int slidingFitWindow, const float slidingFitLayerPitch, const float showerEdgeMultiplier=1.f)
Constructor.
TwoDSlidingFitResult class.
void GetShowerEdges(const float x, const bool widenIfAmbiguity, pandora::FloatVector &edgePositions) const
Get the most appropriate shower edges at a given x coordinate.