9 #include "Pandora/AlgorithmHeaders.h" 21 BoundedClusterMopUpAlgorithm::BoundedClusterMopUpAlgorithm() :
22 m_slidingFitWindow(20),
23 m_showerEdgeMultiplier(1.5
f),
24 m_minBoundedFraction(0.5
f)
34 ClusterVector sortedPfoClusters(pfoClusters.begin(), pfoClusters.end());
37 ClusterVector sortedRemnantClusters(remnantClusters.begin(), remnantClusters.end());
40 for (
const Cluster *
const pPfoCluster : sortedPfoClusters)
42 CaloHitList clusterHitList;
43 pPfoCluster->GetOrderedCaloHitList().FillCaloHitList(clusterHitList);
44 if (clusterHitList.size() <= 3)
54 for (
const Cluster *
const pRemnantCluster : sortedRemnantClusters)
56 const float boundedFraction(this->
GetBoundedFraction(pRemnantCluster, xSampling, showerPositionMap));
63 if (!associationDetails.insert(AssociationDetails::value_type(pPfoCluster, boundedFraction)).second)
64 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
67 catch (
const StatusCodeException &
e)
69 if (e.GetStatusCode() != STATUS_CODE_NOT_INITIALIZED)
86 FloatVector edgePositions;
89 if (edgePositions.size() < 2)
92 std::sort(edgePositions.begin(), edgePositions.end());
96 const int xBin(xSampling.
GetBin(x));
97 showerPositionMap.insert(ShowerPositionMap::value_type(xBin,
ShowerExtent(x, edgePositions.front(), edgePositions.back())));
99 catch (StatusCodeException &)
110 if (((xSampling.
m_maxX - xSampling.
m_minX) < std::numeric_limits<float>::epsilon()) || (0 >= xSampling.
m_nPoints) || (0 == pCluster->GetNCaloHits()))
112 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
115 unsigned int nMatchedHits(0);
116 const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
122 const CaloHit *
const pCaloHit = *hIter;
123 const float x(pCaloHit->GetPositionVector().GetX());
124 const float z(pCaloHit->GetPositionVector().GetZ());
128 const int xBin(xSampling.
GetBin(
x));
132 if ((showerPositionMap.end() != positionIter) && (
z > positionIter->second.GetLowEdgeZ()) && (z < positionIter->
second.GetHighEdgeZ()))
135 catch (StatusCodeException &)
141 return (static_cast<float>(nMatchedHits) /
static_cast<float>(pCluster->GetNCaloHits()));
153 if (((m_maxX - m_minX) < std::numeric_limits<float>::epsilon()) || (0 >= m_nPoints))
154 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
161 if (((x - m_minX) < -std::numeric_limits<float>::epsilon()) || ((x - m_maxX) > +std::numeric_limits<float>::epsilon()))
162 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
164 return static_cast<int>(0.5f +
static_cast<float>(m_nPoints) * (x - m_minX) / (m_maxX - m_minX));
172 PANDORA_RETURN_RESULT_IF_AND_IF(
173 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"SlidingFitWindow",
m_slidingFitWindow));
175 PANDORA_RETURN_RESULT_IF_AND_IF(
176 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"ShowerEdgeMultiplier",
m_showerEdgeMultiplier));
178 PANDORA_RETURN_RESULT_IF_AND_IF(
179 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MinBoundedFraction",
m_minBoundedFraction));
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
virtual void MakeClusterMerges(const ClusterAssociationMap &clusterAssociationMap) const
Make the cluster merges specified in the cluster association map, using list name information in the ...
void GetMinAndMaxX(float &minX, float &maxX) const
Get the minimum and maximum x coordinates associated with the sliding fit.
XSampling(const TwoDSlidingFitResult &fitResult)
Constructor.
const TwoDSlidingFitResult & GetShowerFitResult() const
Get the sliding fit result for the full shower cluster.
Header file for the bounded cluster mop up algorithm class.
void ClusterMopUp(const pandora::ClusterList &pfoClusters, const pandora::ClusterList &remnantClusters) const
Cluster mop up for a single view. This function is responsible for instructing pandora to make cluste...
float m_minBoundedFraction
The minimum cluster bounded fraction for merging.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
void GetShowerPositionMap(const TwoDSlidingShowerFitResult &fitResult, const XSampling &xSampling, ShowerPositionMap &showerPositionMap) const
Get the shower position map containing high and low edge z positions in bins of x.
std::unordered_map< const pandora::Cluster *, AssociationDetails > ClusterAssociationMap
TwoDSlidingShowerFitResult class.
Header file for the geometry helper class.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::map< int, ShowerExtent > ShowerPositionMap
int GetBin(const float x) const
Convert an x position into a sampling bin.
int GetMaxLayer() const
Get the maximum occupied layer in the sliding fit.
int GetMinLayer() const
Get the minimum occupied layer in the sliding fit.
Header file for the cluster helper class.
float m_showerEdgeMultiplier
Artificially tune width of shower envelope so as to make it more/less inclusive.
float GetBoundedFraction(const pandora::Cluster *const pCluster, const XSampling &xSampling, const ShowerPositionMap &showerPositionMap) const
Get the fraction of hits in a cluster bounded by a specified shower position map. ...
static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
std::unordered_map< const pandora::Cluster *, float > AssociationDetails
int m_nPoints
The number of sampling points to be used.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
float m_minX
The min x value.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
second_as<> second
Type of time stored in seconds, in double precision.
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.
float m_maxX
The max x value.