Cluster mop up for a single view. This function is responsible for instructing pandora to make cluster alterations.
40 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*
this, pVertexList));
42 if ((pVertexList->size() != 1) || (VERTEX_3D != (*(pVertexList->begin()))->GetVertexType()))
45 const Vertex *
const pVertex(*(pVertexList->begin()));
47 ClusterVector sortedPfoClusters(pfoClusters.begin(), pfoClusters.end());
50 ClusterVector sortedRemnantClusters(remnantClusters.begin(), remnantClusters.end());
53 for (
const Cluster *
const pPfoCluster : sortedPfoClusters)
59 const LayerFitResultMap &layerFitResultMapS(showerFitResult.GetShowerFitResult().GetLayerFitResultMap());
60 const LayerFitResultMap &layerFitResultMapP(showerFitResult.GetPositiveEdgeFitResult().GetLayerFitResultMap());
61 const LayerFitResultMap &layerFitResultMapN(showerFitResult.GetNegativeEdgeFitResult().GetLayerFitResultMap());
63 if (layerFitResultMapS.size() < 2)
67 CartesianVector minLayerPositionOnAxis(0.
f, 0.
f, 0.
f), maxLayerPositionOnAxis(0.
f, 0.
f, 0.
f);
68 showerFitResult.GetShowerFitResult().GetGlobalPosition(layerFitResultMapS.begin()->second.GetL(), 0.f, minLayerPositionOnAxis);
69 showerFitResult.GetShowerFitResult().GetGlobalPosition(layerFitResultMapS.rbegin()->second.GetL(), 0.f, maxLayerPositionOnAxis);
73 const bool vertexAtMinL((vertexPosition2D - minLayerPositionOnAxis).GetMagnitudeSquared() <
74 (vertexPosition2D - maxLayerPositionOnAxis).GetMagnitudeSquared());
84 if (layerFitResultMapP.end() != iterP)
85 coordinateListP.push_back(
Coordinate(iterP->second.GetL(), iterP->second.GetFitT()));
87 if (layerFitResultMapN.end() != iterN)
88 coordinateListN.push_back(
Coordinate(iterN->second.GetL(), iterN->second.GetFitT()));
91 if (coordinateListP.empty() || coordinateListN.empty())
99 ?
Coordinate(layerFitResultMapP.begin()->second.GetL(), layerFitResultMapP.begin()->second.GetFitT())
100 :
Coordinate(layerFitResultMapP.rbegin()->second.GetL(), layerFitResultMapP.rbegin()->second.GetFitT()));
104 ?
Coordinate(layerFitResultMapN.begin()->second.GetL(), layerFitResultMapN.begin()->second.GetFitT())
105 :
Coordinate(layerFitResultMapN.rbegin()->second.GetL(), layerFitResultMapN.rbegin()->second.GetFitT()));
107 const float minL(layerFitResultMapS.begin()->second.GetL());
110 if ((std::fabs(maxP.first - minP.first) < std::numeric_limits<float>::epsilon()) ||
111 (std::fabs(maxN.first - minN.first) < std::numeric_limits<float>::epsilon()) ||
112 (std::fabs(maxL - minL) < std::numeric_limits<float>::epsilon()))
118 for (
const Cluster *
const pRemnantCluster : sortedRemnantClusters)
120 const unsigned int nHits(pRemnantCluster->GetNCaloHits());
122 unsigned int nMatchedHits(0);
123 const OrderedCaloHitList &orderedCaloHitList(pRemnantCluster->GetOrderedCaloHitList());
129 float rL(0.
f), rT(0.
f);
130 showerFitResult.GetShowerFitResult().GetLocalPosition((*hIter)->GetPositionVector(), rL, rT);
132 if ((rL < minL) || (rL > maxL))
135 const float rTP(minP.second + (rL - minP.first) * ((maxP.second - minP.second) / (maxP.first - minP.first)));
136 const float rTN(minN.second + (rL - minN.first) * ((maxN.second - minN.second) / (maxN.first - minN.first)));
138 if ((rT > rTP) || (rT < rTN))
145 const float boundedFraction((nHits > 0) ? static_cast<float>(nMatchedHits) / static_cast<float>(nHits) : 0.
f);
152 if (!associationDetails.insert(AssociationDetails::value_type(pPfoCluster, boundedFraction)).second)
153 throw StatusCodeException(STATUS_CODE_FAILURE);
156 catch (StatusCodeException &statusCodeException)
158 if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
159 throw statusCodeException;
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 ...
static bool SortCoordinates(const Coordinate &lhs, const Coordinate &rhs)
Sort coordinates by increasing transverse displacement.
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
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.
std::unordered_map< const pandora::Cluster *, AssociationDetails > ClusterAssociationMap
float m_maxConeLengthMultiplier
Consider hits as bound if inside cone, with projected distance less than N times cone length...
float m_minBoundedFraction
The minimum cluster bounded fraction for merging.
std::pair< float, float > Coordinate
float m_showerEdgeMultiplier
Artificially tune width of shower envelope so as to make it more/less inclusive.
std::map< int, LayerFitResult > LayerFitResultMap
std::unordered_map< const pandora::Cluster *, float > AssociationDetails
std::vector< Coordinate > CoordinateList
float m_coneAngleCentile
Cluster cone angle is defined using specified centile of distribution of hit half angles...
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
std::vector< art::Ptr< recob::Cluster > > ClusterVector
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
std::list< Vertex > VertexList