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);
51 if ((x < minX) || (x > maxX))
54 float minZn(0.
f), maxZn(0.
f), minZp(0.
f), maxZp(0.
f);
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));
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;
107 for (
const CartesianVector &hitPosition : *pPointVector)
109 float rL(0.
f), rT(0.
f);
111 rT *= showerEdgeMultiplier;
113 CartesianVector fullShowerFitPosition(0.
f, 0.
f, 0.
f);
117 float rLFit(0.
f), rTFit(0.
f);
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);
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.
static int max(int a, int b)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
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.
Dft::FloatVector FloatVector
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.