9 #include "Objects/Cluster.h" 25 TwoDSlidingShowerFitResult::TwoDSlidingShowerFitResult(
const T *
const pT,
const unsigned int slidingFitWindow,
const float slidingFitLayerPitch,
26 const float showerEdgeMultiplier) :
37 edgePositions.clear();
38 CartesianPointVector fitPositionVector;
39 PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, this->
GetNegativeEdgeFitResult().GetGlobalFitPositionListAtX(x, fitPositionVector));
40 PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, this->
GetPositiveEdgeFitResult().GetGlobalFitPositionListAtX(x, fitPositionVector));
42 if (fitPositionVector.size() < 2)
44 float minXn(0.
f), maxXn(0.
f), minXp(0.
f), maxXp(0.
f);
49 if ((x < minX) || (x > maxX))
52 float minZn(0.
f), maxZn(0.
f), minZp(0.
f), maxZp(0.
f);
57 if (!widenIfAmbiguity)
61 else if (fitPositionVector.empty())
63 fitPositionVector.push_back(CartesianVector(x, 0.
f, minZ));
64 fitPositionVector.push_back(CartesianVector(x, 0.
f, maxZ));
66 else if (1 == fitPositionVector.size())
69 const float existingEdge(fitPositionVector.front().GetZ());
70 const float secondEdge((std::fabs(existingEdge - minZ) < std::fabs(existingEdge - maxZ)) ? minZ : maxZ);
71 fitPositionVector.push_back(CartesianVector(x, 0.
f, secondEdge));
75 FloatVector localEdgePositions;
76 for (
const CartesianVector &fitPosition : fitPositionVector)
77 localEdgePositions.push_back(fitPosition.GetZ());
79 if (localEdgePositions.size() < 2)
80 throw StatusCodeException(STATUS_CODE_FAILURE);
82 std::sort(localEdgePositions.begin(), localEdgePositions.end());
83 edgePositions.push_back(localEdgePositions.front());
84 edgePositions.push_back(localEdgePositions.back());
90 const ShowerEdge showerEdge,
const float showerEdgeMultiplier)
92 CartesianPointVector pointVector;
105 for (
const CartesianVector &hitPosition : *pPointVector)
107 float rL(0.
f), rT(0.
f);
109 rT *= showerEdgeMultiplier;
111 CartesianVector fullShowerFitPosition(0.
f, 0.
f, 0.
f);
115 float rLFit(0.
f), rTFit(0.
f);
118 const float rTDiff(rT - rTFit);
122 const int layer(fullShowerFit.
GetLayer(rL));
129 for (
const FitCoordinateMap::value_type &mapEntry : fitCoordinateMap)
132 bool bestFitCoordinateFound(
false);
139 if (((
POSITIVE_SHOWER_EDGE == showerEdge) && (fitCoordinate.second > bestFitCoordinate.second)) ||
142 bestFitCoordinate = fitCoordinate;
143 bestFitCoordinateFound =
true;
147 if (bestFitCoordinateFound)
148 layerFitContributionMap[mapEntry.first].AddPoint(bestFitCoordinate.first, bestFitCoordinate.second);
unsigned int GetLayerFitHalfWindow() const
Get the layer fit half window.
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.
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. ...
const pandora::CartesianVector & GetAxisDirection() const
Get the axis direction vector.
std::map< int, LayerFitContribution > LayerFitContributionMap
const pandora::CartesianVector & GetAxisIntercept() const
Get the axis intercept position.
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.
pandora::StatusCode GetGlobalFitPosition(const float rL, pandora::CartesianVector &position) const
Get global fit position for a given longitudinal coordinate.
std::pair< float, float > FitCoordinate
const pandora::CartesianVector & GetOrthoDirection() const
Get the orthogonal direction vector.
float GetLayerPitch() const
Get the layer pitch, units cm.
const TwoDSlidingFitResult & GetPositiveEdgeFitResult() const
Get the sliding fit result for the positive shower edge.
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.
void GetLocalPosition(const pandora::CartesianVector &position, float &rL, float &rT) const
Get local sliding fit coordinates for a given global position.
TwoDSlidingFitResult class.
int GetLayer(const float rL) const
Get layer number for given sliding linear fit longitudinal coordinate.
void GetShowerEdges(const float x, const bool widenIfAmbiguity, pandora::FloatVector &edgePositions) const
Get the most appropriate shower edges at a given x coordinate.