Match a seed cluster with a list of target clusters and populate the cluster association map.
178 TwoDSlidingFitResultMap::const_iterator fsIter = slidingFitResultMap.find(pSeedCluster);
180 if (slidingFitResultMap.end() == fsIter)
181 throw StatusCodeException(STATUS_CODE_FAILURE);
183 const TwoDSlidingFitResult &slidingFitResult1(fsIter->second);
184 const CartesianVector &innerVertex1(slidingFitResult1.GetGlobalMinLayerPosition());
185 const CartesianVector &outerVertex1(slidingFitResult1.GetGlobalMaxLayerPosition());
186 const float xSpan1(std::fabs(outerVertex1.GetX() - innerVertex1.GetX()));
188 const Cluster *pBestClusterInner(NULL);
189 const Cluster *pBestClusterOuter(NULL);
190 const Cluster *pBestCluster(NULL);
196 for (ClusterVector::const_iterator tIter = targetClusters.begin(), tIterEnd = targetClusters.end(); tIter != tIterEnd; ++tIter)
198 const Cluster *
const pTargetCluster = *tIter;
200 UIntSet daughterVolumeIntersection;
203 if (daughterVolumeIntersection.empty())
207 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
209 TwoDSlidingFitResultMap::const_iterator ftIter = slidingFitResultMap.find(*tIter);
211 if (slidingFitResultMap.end() == ftIter)
212 throw StatusCodeException(STATUS_CODE_FAILURE);
214 const TwoDSlidingFitResult &slidingFitResult2(ftIter->second);
215 const CartesianVector &innerVertex2(slidingFitResult2.GetGlobalMinLayerPosition());
216 const CartesianVector &outerVertex2(slidingFitResult2.GetGlobalMaxLayerPosition());
217 const float xSpan2(std::fabs(outerVertex2.GetX() - innerVertex2.GetX()));
219 if (xSpan2 > 1.5f * xSpan1)
222 const float xMin1(std::min(innerVertex1.GetX(), outerVertex1.GetX()));
223 const float xMax1(std::max(innerVertex1.GetX(), outerVertex1.GetX()));
224 const float xMin2(std::min(innerVertex2.GetX(), outerVertex2.GetX()));
225 const float xMax2(std::max(innerVertex2.GetX(), outerVertex2.GetX()));
226 const float xOverlap(std::min(xMax1, xMax2) - std::max(xMin1, xMin2));
231 const float dxMin(std::fabs(xMin2 - xMin1));
232 const float dxMax(std::fabs(xMax2 - xMax1));
234 if (dxMin < bestDisplacementInner)
236 pBestClusterInner = pTargetCluster;
237 bestDisplacementInner = dxMin;
240 if (dxMax < bestDisplacementOuter)
242 pBestClusterOuter = pTargetCluster;
243 bestDisplacementOuter = dxMax;
246 if (dxMin + dxMax < bestDisplacement)
248 pBestCluster = pTargetCluster;
249 bestDisplacement = dxMin + dxMax;
255 ClusterList &seedList(clusterAssociationMap[pSeedCluster]);
257 if (seedList.end() == std::find(seedList.begin(), seedList.end(), pBestCluster))
258 seedList.push_back(pBestCluster);
260 ClusterList &bestList(clusterAssociationMap[pBestCluster]);
262 if (bestList.end() == std::find(bestList.begin(), bestList.end(), pSeedCluster))
263 bestList.push_back(pSeedCluster);
265 else if (pBestClusterInner && pBestClusterOuter)
267 TwoDSlidingFitResultMap::const_iterator iterInner = slidingFitResultMap.find(pBestClusterInner);
268 TwoDSlidingFitResultMap::const_iterator iterOuter = slidingFitResultMap.find(pBestClusterOuter);
270 if (slidingFitResultMap.end() == iterInner || slidingFitResultMap.end() == iterOuter)
271 throw StatusCodeException(STATUS_CODE_FAILURE);
273 const LArPointingCluster pointingClusterInner(iterInner->second);
274 const LArPointingCluster pointingClusterOuter(iterOuter->second);
276 LArPointingCluster::Vertex pointingVertexInner, pointingVertexOuter;
282 catch (StatusCodeException &)
287 const LArPointingCluster::Vertex pointingEndInner(
288 pointingVertexInner.IsInnerVertex() ? pointingClusterInner.GetOuterVertex() : pointingClusterInner.GetInnerVertex());
289 const LArPointingCluster::Vertex pointingEndOuter(
290 pointingVertexOuter.IsInnerVertex() ? pointingClusterOuter.GetOuterVertex() : pointingClusterOuter.GetInnerVertex());
292 const float rSpan((pointingEndInner.GetPosition() - pointingEndOuter.GetPosition()).GetMagnitude());
297 ClusterList &bestInnerList(clusterAssociationMap[pBestClusterInner]);
299 if (bestInnerList.end() == std::find(bestInnerList.begin(), bestInnerList.end(), pSeedCluster))
300 bestInnerList.push_back(pSeedCluster);
302 ClusterList &bestOuterList(clusterAssociationMap[pBestClusterOuter]);
304 if (bestOuterList.end() == std::find(bestOuterList.begin(), bestOuterList.end(), pSeedCluster))
305 bestOuterList.push_back(pSeedCluster);
static bool IsEmission(const pandora::CartesianVector &parentVertex, const LArPointingCluster::Vertex &daughterVertex, const float minLongitudinalDistance, const float maxLongitudinalDistance, const float maxTransverseDistance, const float angularAllowance)
Whether pointing vertex is emitted from a given position.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static void GetClosestVertices(const bool useX, const bool useY, const bool useZ, const LArPointingCluster &pointingClusterI, const LArPointingCluster &pointingClusterJ, LArPointingCluster::Vertex &closestVertexI, LArPointingCluster::Vertex &closestVertexJ)
Given a pair of pointing clusters, receive the closest or farthest pair of vertices.
std::set< unsigned int > UIntSet
float m_clusterMinOverlapX
static void GetCommonDaughterVolumes(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, UIntSet &intersect)
Return the set of common daughter volumes between two 2D clusters.