21 HitType LArClusterHelper::GetClusterHitType(
const Cluster *
const pCluster)
23 if (0 == pCluster->GetNCaloHits())
24 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
30 return (*(pCluster->GetOrderedCaloHitList().begin()->second->begin()))->GetHitType();
35 void LArClusterHelper::GetClustersUVW(
const ClusterList &inputClusters, ClusterList &clusterListU, ClusterList &clusterListV, ClusterList &clusterListW)
39 const HitType hitType(LArClusterHelper::GetClusterHitType(*iter));
41 if (TPC_VIEW_U == hitType)
42 clusterListU.push_back(*iter);
43 else if (TPC_VIEW_V == hitType)
44 clusterListV.push_back(*iter);
45 else if (TPC_VIEW_W == hitType)
46 clusterListW.push_back(*iter);
48 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
54 void LArClusterHelper::GetClustersByHitType(
const ClusterList &inputClusters,
const HitType hitType, ClusterList &clusterList)
58 if (hitType == LArClusterHelper::GetClusterHitType(*iter))
59 clusterList.push_back(*iter);
65 float LArClusterHelper::GetLengthSquared(
const Cluster *
const pCluster)
67 const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
69 if (orderedCaloHitList.empty())
70 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
73 float minX(std::numeric_limits<float>::max()), maxX(-std::numeric_limits<float>::max());
74 float minY(std::numeric_limits<float>::max()),
maxY(-std::numeric_limits<float>::max());
75 float minZ(std::numeric_limits<float>::max()), maxZ(-std::numeric_limits<float>::max());
79 for (
CaloHitList::const_iterator hitIter = iter->second->begin(), hitIterEnd = iter->second->end(); hitIter != hitIterEnd; ++hitIter)
81 const CartesianVector &hitPosition((*hitIter)->GetPositionVector());
82 minX = std::min(hitPosition.GetX(), minX);
83 maxX = std::max(hitPosition.GetX(), maxX);
84 minY = std::min(hitPosition.GetY(),
minY);
85 maxY = std::max(hitPosition.GetY(),
maxY);
86 minZ = std::min(hitPosition.GetZ(), minZ);
87 maxZ = std::max(hitPosition.GetZ(), maxZ);
91 const float deltaX(maxX - minX), deltaY(maxY -
minY), deltaZ(maxZ - minZ);
92 return (deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);
97 float LArClusterHelper::GetLength(
const Cluster *
const pCluster)
99 return std::sqrt(LArClusterHelper::GetLengthSquared(pCluster));
104 float LArClusterHelper::GetEnergyFromLength(
const Cluster *
const pCluster)
106 const float dEdX(0.002
f);
107 return (dEdX * LArClusterHelper::GetLength(pCluster));
112 unsigned int LArClusterHelper::GetLayerSpan(
const Cluster *
const pCluster)
114 return (1 + pCluster->GetOuterPseudoLayer() - pCluster->GetInnerPseudoLayer());
119 float LArClusterHelper::GetLayerOccupancy(
const Cluster *
const pCluster)
121 const unsigned int nOccupiedLayers(pCluster->GetOrderedCaloHitList().size());
122 const unsigned int nLayers(1 + pCluster->GetOuterPseudoLayer() - pCluster->GetInnerPseudoLayer());
125 return (static_cast<float>(nOccupiedLayers) /
static_cast<float>(nLayers));
132 float LArClusterHelper::GetLayerOccupancy(
const Cluster *
const pCluster1,
const Cluster *
const pCluster2)
134 const unsigned int nOccupiedLayers(pCluster1->GetOrderedCaloHitList().size() + pCluster2->GetOrderedCaloHitList().size());
135 const unsigned int nLayers(1 + std::max(pCluster1->GetOuterPseudoLayer(), pCluster2->GetOuterPseudoLayer()) -
136 std::min(pCluster1->GetInnerPseudoLayer(), pCluster2->GetInnerPseudoLayer()));
139 return (static_cast<float>(nOccupiedLayers) / static_cast<float>(nLayers));
146 float LArClusterHelper::GetClosestDistance(
const ClusterList &clusterList1,
const ClusterList &clusterList2)
148 if (clusterList1.empty() || clusterList2.empty())
149 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
151 float closestDistance(std::numeric_limits<float>::max());
155 const Cluster *
const pCluster1 = *iter1;
156 const float thisDistance(LArClusterHelper::GetClosestDistance(pCluster1, clusterList2));
158 if (thisDistance < closestDistance)
159 closestDistance = thisDistance;
162 return closestDistance;
167 float LArClusterHelper::GetClosestDistance(
const Cluster *
const pCluster,
const ClusterList &clusterList)
169 if (clusterList.empty())
170 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
172 float closestDistance(std::numeric_limits<float>::max());
176 const Cluster *
const pTestCluster = *iter;
177 const float thisDistance(LArClusterHelper::GetClosestDistance(pCluster, pTestCluster));
179 if (thisDistance < closestDistance)
180 closestDistance = thisDistance;
183 return closestDistance;
188 float LArClusterHelper::GetClosestDistance(
const Cluster *
const pCluster1,
const Cluster *
const pCluster2)
190 CartesianVector closestPosition1(0.
f, 0.
f, 0.
f);
191 CartesianVector closestPosition2(0.
f, 0.
f, 0.
f);
193 LArClusterHelper::GetClosestPositions(pCluster1, pCluster2, closestPosition1, closestPosition2);
195 return (closestPosition1 - closestPosition2).GetMagnitude();
200 float LArClusterHelper::GetClosestDistance(
const CartesianVector &position,
const ClusterList &clusterList)
202 return (position - LArClusterHelper::GetClosestPosition(position, clusterList)).GetMagnitude();
207 float LArClusterHelper::GetClosestDistance(
const CartesianVector &position,
const Cluster *
const pCluster)
209 return (position - LArClusterHelper::GetClosestPosition(position, pCluster)).GetMagnitude();
214 float LArClusterHelper::GetClosestDistance(
const CartesianVector &position,
const CaloHitList &caloHitList)
216 return (position - LArClusterHelper::GetClosestPosition(position, caloHitList)).GetMagnitude();
221 CartesianVector LArClusterHelper::GetClosestPosition(
const CartesianVector &position,
const ClusterList &clusterList)
223 bool distanceFound(
false);
224 float closestDistanceSquared(std::numeric_limits<float>::max());
225 CartesianVector closestPosition(0.
f, 0.
f, 0.
f);
229 const Cluster *
const pTestCluster = *iter;
230 const CartesianVector thisPosition(LArClusterHelper::GetClosestPosition(position, pTestCluster));
231 const float thisDistanceSquared((position - thisPosition).GetMagnitudeSquared());
233 if (thisDistanceSquared < closestDistanceSquared)
235 distanceFound =
true;
236 closestDistanceSquared = thisDistanceSquared;
237 closestPosition = thisPosition;
242 return closestPosition;
244 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
249 CartesianVector LArClusterHelper::GetClosestPosition(
const CartesianVector &position,
const Cluster *
const pCluster)
251 return LArClusterHelper::GetClosestPosition(position, pCluster->GetOrderedCaloHitList());
256 CartesianVector LArClusterHelper::GetClosestPosition(
const CartesianVector &position,
const OrderedCaloHitList &caloHitList)
258 const CaloHit *pClosestCaloHit(
nullptr);
259 float closestDistanceSquared(std::numeric_limits<float>::max());
261 for (
const auto &entry : caloHitList)
263 for (
const CaloHit *
const pCaloHit : *entry.second)
265 const float distanceSquared((pCaloHit->GetPositionVector() - position).GetMagnitudeSquared());
267 if (distanceSquared < closestDistanceSquared)
269 closestDistanceSquared = distanceSquared;
270 pClosestCaloHit = pCaloHit;
276 return pClosestCaloHit->GetPositionVector();
278 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
283 CartesianVector LArClusterHelper::GetClosestPosition(
const CartesianVector &position,
const CaloHitList &caloHitList)
285 const CaloHit *pClosestCaloHit(
nullptr);
286 float closestDistanceSquared(std::numeric_limits<float>::max());
288 for (
const CaloHit *
const pCaloHit : caloHitList)
290 const float distanceSquared((pCaloHit->GetPositionVector() - position).GetMagnitudeSquared());
292 if (distanceSquared < closestDistanceSquared)
294 closestDistanceSquared = distanceSquared;
295 pClosestCaloHit = pCaloHit;
300 return pClosestCaloHit->GetPositionVector();
302 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
307 void LArClusterHelper::GetClosestPositions(
308 const Cluster *
const pCluster1,
const Cluster *
const pCluster2, CartesianVector &outputPosition1, CartesianVector &outputPosition2)
310 bool distanceFound(
false);
311 float minDistanceSquared(std::numeric_limits<float>::max());
313 CartesianVector closestPosition1(0.
f, 0.
f, 0.
f);
314 CartesianVector closestPosition2(0.
f, 0.
f, 0.
f);
316 const OrderedCaloHitList &orderedCaloHitList1(pCluster1->GetOrderedCaloHitList());
317 const OrderedCaloHitList &orderedCaloHitList2(pCluster2->GetOrderedCaloHitList());
322 for (
CaloHitList::const_iterator hitIter1 = iter1->second->begin(), hitIter1End = iter1->second->end(); hitIter1 != hitIter1End; ++hitIter1)
324 const CartesianVector &positionVector1((*hitIter1)->GetPositionVector());
329 for (
CaloHitList::const_iterator hitIter2 = iter2->second->begin(), hitIter2End = iter2->second->end(); hitIter2 != hitIter2End; ++hitIter2)
331 const CartesianVector &positionVector2((*hitIter2)->GetPositionVector());
333 const float distanceSquared((positionVector1 - positionVector2).GetMagnitudeSquared());
335 if (distanceSquared < minDistanceSquared)
337 minDistanceSquared = distanceSquared;
338 closestPosition1 = positionVector1;
339 closestPosition2 = positionVector2;
340 distanceFound =
true;
348 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
350 outputPosition1 = closestPosition1;
351 outputPosition2 = closestPosition2;
356 void LArClusterHelper::GetClusterBoundingBox(
const Cluster *
const pCluster, CartesianVector &minimumCoordinate, CartesianVector &maximumCoordinate)
358 const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
360 float xmin(std::numeric_limits<float>::max());
361 float ymin(std::numeric_limits<float>::max());
362 float zmin(std::numeric_limits<float>::max());
363 float xmax(-std::numeric_limits<float>::max());
364 float ymax(-std::numeric_limits<float>::max());
365 float zmax(-std::numeric_limits<float>::max());
371 const CaloHit *
const pCaloHit = *hIter;
372 const CartesianVector &
hit(pCaloHit->GetPositionVector());
373 xmin = std::min(
hit.GetX(), xmin);
374 xmax = std::max(
hit.GetX(), xmax);
375 ymin = std::min(
hit.GetY(), ymin);
376 ymax = std::max(
hit.GetY(), ymax);
377 zmin = std::min(
hit.GetZ(), zmin);
378 zmax = std::max(
hit.GetZ(), zmax);
382 minimumCoordinate.SetValues(xmin, ymin, zmin);
383 maximumCoordinate.SetValues(xmax, ymax, zmax);
388 StatusCode LArClusterHelper::GetAverageZ(
const Cluster *
const pCluster,
const float xmin,
const float xmax,
float &averageZ)
390 averageZ = std::numeric_limits<float>::max();
393 return STATUS_CODE_INVALID_PARAMETER;
395 const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
404 const CaloHit *
const pCaloHit = *hIter;
405 const CartesianVector &
hit(pCaloHit->GetPositionVector());
407 if (
hit.GetX() < xmin ||
hit.GetX() > xmax)
416 return STATUS_CODE_NOT_FOUND;
418 averageZ = zsum /
static_cast<float>(count);
419 return STATUS_CODE_SUCCESS;
424 void LArClusterHelper::GetExtremalCoordinates(
const ClusterList &clusterList, CartesianVector &innerCoordinate, CartesianVector &outerCoordinate)
426 OrderedCaloHitList orderedCaloHitList;
430 const Cluster *
const pCluster = *cIter;
431 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, orderedCaloHitList.Add(pCluster->GetOrderedCaloHitList()));
434 return LArClusterHelper::GetExtremalCoordinates(orderedCaloHitList, innerCoordinate, outerCoordinate);
439 void LArClusterHelper::GetExtremalCoordinates(
const Cluster *
const pCluster, CartesianVector &innerCoordinate, CartesianVector &outerCoordinate)
441 return LArClusterHelper::GetExtremalCoordinates(pCluster->GetOrderedCaloHitList(), innerCoordinate, outerCoordinate);
446 void LArClusterHelper::GetExtremalCoordinates(
const OrderedCaloHitList &orderedCaloHitList, CartesianVector &innerCoordinate, CartesianVector &outerCoordinate)
448 if (orderedCaloHitList.empty())
449 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
451 CartesianPointVector coordinateVector;
455 for (
CaloHitList::const_iterator hitIter = iter->second->begin(), hitIterEnd = iter->second->end(); hitIter != hitIterEnd; ++hitIter)
457 const CaloHit *
const pCaloHit = *hitIter;
458 coordinateVector.push_back(pCaloHit->GetPositionVector());
462 std::sort(coordinateVector.begin(), coordinateVector.end(), LArClusterHelper::SortCoordinatesByPosition);
463 return LArClusterHelper::GetExtremalCoordinates(coordinateVector, innerCoordinate, outerCoordinate);
468 void LArClusterHelper::GetExtremalCoordinates(
const CartesianPointVector &coordinateVector, CartesianVector &innerCoordinate, CartesianVector &outerCoordinate)
470 if (coordinateVector.empty())
471 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
474 float xMin(+std::numeric_limits<float>::max());
475 float yMin(+std::numeric_limits<float>::max());
476 float zMin(+std::numeric_limits<float>::max());
477 float xMax(-std::numeric_limits<float>::max());
478 float yMax(-std::numeric_limits<float>::max());
479 float zMax(-std::numeric_limits<float>::max());
483 const CartesianVector &pos = *pIter;
484 xMin = std::min(pos.GetX(), xMin);
485 xMax = std::max(pos.GetX(), xMax);
486 yMin = std::min(pos.GetY(), yMin);
487 yMax = std::max(pos.GetY(), yMax);
488 zMin = std::min(pos.GetZ(), zMin);
489 zMax = std::max(pos.GetZ(), zMax);
493 const float xAve(0.5
f * (xMin + xMax));
494 const float yAve(0.5
f * (yMin + yMax));
495 const float zAve(0.5
f * (zMin + zMax));
497 const float xSpan(xMax - xMin);
498 const float ySpan(yMax - yMin);
499 const float zSpan(zMax - zMin);
501 const bool useX((xSpan > std::numeric_limits<float>::epsilon()) && (xSpan + std::numeric_limits<float>::epsilon() > std::max(ySpan, zSpan)));
502 const bool useY((ySpan > std::numeric_limits<float>::epsilon()) && (ySpan + std::numeric_limits<float>::epsilon() > std::max(zSpan, xSpan)));
503 const bool useZ((zSpan > std::numeric_limits<float>::epsilon()) && (zSpan + std::numeric_limits<float>::epsilon() > std::max(xSpan, ySpan)));
506 CartesianPointVector candidateVector;
510 const CartesianVector &pos = *pIter;
514 if (((pos.GetX() - xMin) < std::numeric_limits<float>::epsilon()) || ((pos.GetX() - xMax) > -std::numeric_limits<float>::epsilon()))
515 candidateVector.push_back(pos);
520 if (((pos.GetY() - yMin) < std::numeric_limits<float>::epsilon()) || ((pos.GetY() - yMax) > -std::numeric_limits<float>::epsilon()))
521 candidateVector.push_back(pos);
526 if (((pos.GetZ() - zMin) < std::numeric_limits<float>::epsilon()) || ((pos.GetZ() - zMax) > -std::numeric_limits<float>::epsilon()))
527 candidateVector.push_back(pos);
532 CartesianVector firstCoordinate(xAve, yAve, zAve);
533 CartesianVector secondCoordinate(xAve, yAve, zAve);
534 float maxDistanceSquared(+std::numeric_limits<float>::epsilon());
538 const CartesianVector &posI = *iterI;
542 const CartesianVector &posJ = *iterJ;
544 const float distanceSquared((posI - posJ).GetMagnitudeSquared());
546 if (distanceSquared > maxDistanceSquared)
548 maxDistanceSquared = distanceSquared;
549 firstCoordinate = posI;
550 secondCoordinate = posJ;
556 const float deltaZ(secondCoordinate.GetZ() - firstCoordinate.GetZ());
557 const float deltaX(secondCoordinate.GetX() - firstCoordinate.GetX());
559 if ((deltaZ > 0.
f) || ((std::fabs(deltaZ) < std::numeric_limits<float>::epsilon()) && (deltaX > 0.
f)))
561 innerCoordinate = firstCoordinate;
562 outerCoordinate = secondCoordinate;
566 innerCoordinate = secondCoordinate;
567 outerCoordinate = firstCoordinate;
573 void LArClusterHelper::GetCoordinateVector(
const Cluster *
const pCluster, CartesianPointVector &coordinateVector)
575 for (
const OrderedCaloHitList::value_type &layerEntry : pCluster->GetOrderedCaloHitList())
577 for (
const CaloHit *
const pCaloHit : *layerEntry.second)
578 coordinateVector.push_back(pCaloHit->GetPositionVector());
581 std::sort(coordinateVector.begin(), coordinateVector.end(), LArClusterHelper::SortCoordinatesByPosition);
586 void LArClusterHelper::GetCaloHitListInBoundingBox(
const pandora::Cluster *
const pCluster,
const pandora::CartesianVector &lowerBound,
587 const pandora::CartesianVector &upperBound, pandora::CaloHitList &caloHitList)
589 const bool useX(std::fabs(upperBound.GetX() - lowerBound.GetX()) > std::numeric_limits<float>::epsilon());
590 const bool useY(std::fabs(upperBound.GetY() - lowerBound.GetY()) > std::numeric_limits<float>::epsilon());
591 const bool useZ(std::fabs(upperBound.GetZ() - lowerBound.GetZ()) > std::numeric_limits<float>::epsilon());
592 if (!useX && !useY && !useZ)
593 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
595 const float minX(std::min(lowerBound.GetX(), upperBound.GetX()));
596 const float maxX(std::max(lowerBound.GetX(), upperBound.GetX()));
597 const float minY(std::min(lowerBound.GetY(), upperBound.GetY()));
598 const float maxY(std::max(lowerBound.GetY(), upperBound.GetY()));
599 const float minZ(std::min(lowerBound.GetZ(), upperBound.GetZ()));
600 const float maxZ(std::max(lowerBound.GetZ(), upperBound.GetZ()));
602 for (
const OrderedCaloHitList::value_type &layerEntry : pCluster->GetOrderedCaloHitList())
604 for (
const CaloHit *
const pCaloHit : *layerEntry.second)
606 const CartesianVector &hitPosition = pCaloHit->GetPositionVector();
608 (hitPosition.GetX() < minX - std::numeric_limits<float>::epsilon() || hitPosition.GetX() > maxX + std::numeric_limits<float>::epsilon()))
611 (hitPosition.GetY() < minY - std::numeric_limits<float>::epsilon() || hitPosition.GetY() > maxY + std::numeric_limits<float>::epsilon()))
614 (hitPosition.GetZ() < minZ - std::numeric_limits<float>::epsilon() || hitPosition.GetZ() > maxZ + std::numeric_limits<float>::epsilon()))
617 caloHitList.push_back(pCaloHit);
620 caloHitList.sort(LArClusterHelper::SortHitsByPosition);
625 void LArClusterHelper::GetDaughterVolumeIDs(
const Cluster *
const pCluster,
UIntSet &daughterVolumeIds)
627 const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
633 const CaloHit *
const pCaloHit(*hIter);
634 const LArCaloHit *
const pLArCaloHit(dynamic_cast<const LArCaloHit *>(pCaloHit));
643 bool LArClusterHelper::SortByNOccupiedLayers(
const Cluster *
const pLhs,
const Cluster *
const pRhs)
645 const unsigned int nOccupiedLayersLhs(pLhs->GetOrderedCaloHitList().size());
646 const unsigned int nOccupiedLayersRhs(pRhs->GetOrderedCaloHitList().size());
648 if (nOccupiedLayersLhs != nOccupiedLayersRhs)
649 return (nOccupiedLayersLhs > nOccupiedLayersRhs);
651 return SortByNHits(pLhs, pRhs);
656 bool LArClusterHelper::SortByNHits(
const Cluster *
const pLhs,
const Cluster *
const pRhs)
658 const unsigned int nHitsLhs(pLhs->GetNCaloHits());
659 const unsigned int nHitsRhs(pRhs->GetNCaloHits());
661 if (nHitsLhs != nHitsRhs)
662 return (nHitsLhs > nHitsRhs);
664 return SortByLayerSpan(pLhs, pRhs);
669 bool LArClusterHelper::SortByLayerSpan(
const Cluster *
const pLhs,
const Cluster *
const pRhs)
671 const unsigned int layerSpanLhs(pLhs->GetOuterPseudoLayer() - pLhs->GetInnerPseudoLayer());
672 const unsigned int layerSpanRhs(pRhs->GetOuterPseudoLayer() - pRhs->GetInnerPseudoLayer());
674 if (layerSpanLhs != layerSpanRhs)
675 return (layerSpanLhs > layerSpanRhs);
677 return SortByInnerLayer(pLhs, pRhs);
682 bool LArClusterHelper::SortByInnerLayer(
const Cluster *
const pLhs,
const Cluster *
const pRhs)
684 const unsigned int innerLayerLhs(pLhs->GetInnerPseudoLayer());
685 const unsigned int innerLayerRhs(pRhs->GetInnerPseudoLayer());
687 if (innerLayerLhs != innerLayerRhs)
688 return (innerLayerLhs < innerLayerRhs);
690 return SortByPosition(pLhs, pRhs);
695 bool LArClusterHelper::SortByPosition(
const Cluster *
const pLhs,
const Cluster *
const pRhs)
697 const CartesianVector deltaPositionIL(pRhs->GetCentroid(pRhs->GetInnerPseudoLayer()) - pLhs->GetCentroid(pLhs->GetInnerPseudoLayer()));
699 if (std::fabs(deltaPositionIL.GetZ()) > std::numeric_limits<float>::epsilon())
700 return (deltaPositionIL.GetZ() > std::numeric_limits<float>::epsilon());
702 if (std::fabs(deltaPositionIL.GetX()) > std::numeric_limits<float>::epsilon())
703 return (deltaPositionIL.GetX() > std::numeric_limits<float>::epsilon());
705 if (std::fabs(deltaPositionIL.GetY()) > std::numeric_limits<float>::epsilon())
706 return (deltaPositionIL.GetY() > std::numeric_limits<float>::epsilon());
708 const CartesianVector deltaPositionOL(pRhs->GetCentroid(pRhs->GetOuterPseudoLayer()) - pLhs->GetCentroid(pLhs->GetOuterPseudoLayer()));
710 if (std::fabs(deltaPositionOL.GetZ()) > std::numeric_limits<float>::epsilon())
711 return (deltaPositionOL.GetZ() > std::numeric_limits<float>::epsilon());
713 if (std::fabs(deltaPositionOL.GetX()) > std::numeric_limits<float>::epsilon())
714 return (deltaPositionOL.GetX() > std::numeric_limits<float>::epsilon());
716 if (std::fabs(deltaPositionOL.GetY()) > std::numeric_limits<float>::epsilon())
717 return (deltaPositionOL.GetY() > std::numeric_limits<float>::epsilon());
720 return SortByPulseHeight(pLhs, pRhs);
725 bool LArClusterHelper::SortByPulseHeight(
const Cluster *
const pLhs,
const Cluster *
const pRhs)
727 return (pLhs->GetHadronicEnergy() > pRhs->GetHadronicEnergy());
732 bool LArClusterHelper::SortHitsByPosition(
const CaloHit *
const pLhs,
const CaloHit *
const pRhs)
734 const CartesianVector deltaPosition(pRhs->GetPositionVector() - pLhs->GetPositionVector());
736 if (std::fabs(deltaPosition.GetZ()) > std::numeric_limits<float>::epsilon())
737 return (deltaPosition.GetZ() > std::numeric_limits<float>::epsilon());
739 if (std::fabs(deltaPosition.GetX()) > std::numeric_limits<float>::epsilon())
740 return (deltaPosition.GetX() > std::numeric_limits<float>::epsilon());
742 if (std::fabs(deltaPosition.GetY()) > std::numeric_limits<float>::epsilon())
743 return (deltaPosition.GetY() > std::numeric_limits<float>::epsilon());
746 return SortHitsByPulseHeight(pLhs, pRhs);
751 bool LArClusterHelper::SortHitsByPositionInX(
const pandora::CaloHit *
const pLhs,
const pandora::CaloHit *
const pRhs)
753 const CartesianVector deltaPosition(pRhs->GetPositionVector() - pLhs->GetPositionVector());
755 if (std::fabs(deltaPosition.GetX()) > std::numeric_limits<float>::epsilon())
756 return (deltaPosition.GetX() > std::numeric_limits<float>::epsilon());
758 return SortHitsByPosition(pLhs, pRhs);
763 bool LArClusterHelper::SortHitsByPulseHeight(
const CaloHit *
const pLhs,
const CaloHit *
const pRhs)
766 return (pLhs->GetHadronicEnergy() > pRhs->GetHadronicEnergy());
771 bool LArClusterHelper::SortCoordinatesByPosition(
const CartesianVector &lhs,
const CartesianVector &rhs)
773 const CartesianVector deltaPosition(rhs - lhs);
775 if (std::fabs(deltaPosition.GetZ()) > std::numeric_limits<float>::epsilon())
776 return (deltaPosition.GetZ() > std::numeric_limits<float>::epsilon());
778 if (std::fabs(deltaPosition.GetX()) > std::numeric_limits<float>::epsilon())
779 return (deltaPosition.GetX() > std::numeric_limits<float>::epsilon());
781 return (deltaPosition.GetY() > std::numeric_limits<float>::epsilon());
Header file for the lar calo hit class.
Header file for the cluster helper class.
std::set< unsigned int > UIntSet
Detector simulation of raw signals on wires.
unsigned int GetDaughterVolumeId() const
Get the daughter volume id.