9 #include "Pandora/AlgorithmHeaders.h"
20 RemovalBaseTool::RemovalBaseTool() : m_minSeparation(1.f), m_distanceToLine(0.5f)
28 const Cluster *pMuonCluster(
nullptr), *
const pDeltaRayCluster(element.GetCluster(hitType));
42 for (
const HitType hitType : {TPC_VIEW_U, TPC_VIEW_V, TPC_VIEW_W})
44 if (ignoreHitType && (hitType == hitTypeToIgnore))
47 const Cluster *pMuonCluster(
nullptr), *
const pDeltaRayCluster(element.GetCluster(hitType));
52 float xMinDR(-std::numeric_limits<float>::max()), xMaxDR(+std::numeric_limits<float>::max());
53 pDeltaRayCluster->GetClusterSpanX(xMinDR, xMaxDR);
55 float xMinCR(-std::numeric_limits<float>::max()), xMaxCR(+std::numeric_limits<float>::max());
56 pMuonCluster->GetClusterSpanX(xMinCR, xMaxCR);
58 if ((xMinDR < xMinCR) || (xMaxDR > xMaxCR))
61 float zMinDR(-std::numeric_limits<float>::max()), zMaxDR(+std::numeric_limits<float>::max());
62 pDeltaRayCluster->GetClusterSpanZ(xMinDR, xMaxDR, zMinDR, zMaxDR);
64 float zMinCR(-std::numeric_limits<float>::max()), zMaxCR(+std::numeric_limits<float>::max());
65 pMuonCluster->GetClusterSpanZ(xMinCR, xMaxCR, zMinCR, zMaxCR);
67 if ((zMinDR < zMinCR) || (zMaxDR > zMaxCR))
77 const ClusterSet &modifiedClusters)
const
79 const float chiSquared(element.GetOverlapResult().GetReducedChi2());
80 const unsigned int hitSum(element.GetClusterU()->GetNCaloHits() + element.GetClusterV()->GetNCaloHits() + element.GetClusterW()->GetNCaloHits());
82 for (
const TensorType::Element &testElement : elementList)
84 if (modifiedClusters.count(testElement.GetClusterU()) || modifiedClusters.count(testElement.GetClusterV()) ||
85 modifiedClusters.count(testElement.GetClusterW()))
88 if (testElement.GetCluster(hitType) != element.GetCluster(hitType))
91 if ((testElement.GetClusterU() == element.GetClusterU()) && (testElement.GetClusterV() == element.GetClusterV()) &&
92 (testElement.GetClusterW() == element.GetClusterW()))
95 const unsigned int testHitSum(
96 testElement.GetClusterU()->GetNCaloHits() + testElement.GetClusterV()->GetNCaloHits() + testElement.GetClusterW()->GetNCaloHits());
97 const float testChiSquared(testElement.GetOverlapResult().GetReducedChi2());
99 if ((testHitSum < hitSum) || ((testHitSum == hitSum) && (testChiSquared > chiSquared)))
112 const CartesianVector &hitPosition,
const CartesianVector &lineStart,
const CartesianVector &lineEnd,
const float distanceToLine)
const
114 CartesianVector lineDirection(lineStart - lineEnd);
115 lineDirection = lineDirection.GetUnitVector();
117 const float transverseDistanceFromLine(lineDirection.GetCrossProduct(hitPosition - lineStart).GetMagnitude());
119 if (transverseDistanceFromLine > distanceToLine)
129 const float segmentBoundaryGradient = (-1.f) * (upperBoundary.GetX() - lowerBoundary.GetX()) / (upperBoundary.GetZ() - lowerBoundary.GetZ());
130 const float xPointOnUpperLine((point.GetZ() - upperBoundary.GetZ()) / segmentBoundaryGradient + upperBoundary.GetX());
131 const float xPointOnLowerLine((point.GetZ() - lowerBoundary.GetZ()) / segmentBoundaryGradient + lowerBoundary.GetX());
133 if (std::fabs(xPointOnUpperLine - point.GetX()) < std::numeric_limits<float>::epsilon())
136 if (std::fabs(xPointOnLowerLine - point.GetX()) < std::numeric_limits<float>::epsilon())
139 if ((point.GetX() > xPointOnUpperLine) && (point.GetX() > xPointOnLowerLine))
142 if ((point.GetX() < xPointOnUpperLine) && (point.GetX() < xPointOnLowerLine))
151 const CartesianVector &upperBoundary, CaloHitList &collectedHits)
const
153 CaloHitList caloHitList;
154 pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
156 for (
const CaloHit *
const pCaloHit : caloHitList)
158 if (!this->
IsInLineSegment(lowerBoundary, upperBoundary, pCaloHit->GetPositionVector()))
164 collectedHits.push_back(pCaloHit);
172 HitTypeVector hitTypes({TPC_VIEW_U, TPC_VIEW_V, TPC_VIEW_W});
174 hitTypes.erase(std::find(hitTypes.begin(), hitTypes.end(), hitType));
176 const Cluster *
const pCluster1(element.GetCluster(hitTypes[0]));
177 const Cluster *
const pCluster2(element.GetCluster(hitTypes[1]));
186 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MinSeparation",
m_minSeparation));
188 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"DistanceToLine",
m_distanceToLine));
190 return STATUS_CODE_SUCCESS;
float m_minSeparation
The minimum delta ray - parent muon cluster separation required to investigate a delta/cosmic ray clu...
pandora::StatusCode GetProjectedPositions(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, pandora::CartesianPointVector &projectedPositions) const
Use two clusters from different views to calculate projected positions in the remaining third view...
float m_distanceToLine
The maximum perpendicular distance of a position to a line for it to be considered close...
ThreeViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
std::vector< Element > ElementList
bool IsBestElement(const TensorType::Element &element, const pandora::HitType hitType, const TensorType::ElementList &elementList, const pandora::ClusterSet &modifiedClusters) const
Determine whether the input element is the best to use to modify the contaminated cluster (best is de...
bool IsInLineSegment(const pandora::CartesianVector &lowerBoundary, const pandora::CartesianVector &upperBoundary, const pandora::CartesianVector &point) const
Whether the projection of a given position lies on a defined line.
Header file for the cluster helper class.
void FindExtrapolatedHits(const pandora::Cluster *const pCluster, const pandora::CartesianVector &lowerBoundary, const pandora::CartesianVector &upperBoundary, pandora::CaloHitList &collectedHits) const
Collect the hits that are closest to and can be projected onto a defined line.
bool IsCloseToLine(const pandora::CartesianVector &hitPosition, const pandora::CartesianVector &lineStart, const pandora::CartesianVector &lineEnd, const float distanceToLine) const
Whether a given position is close to a defined line.
pandora::StatusCode ProjectDeltaRayPositions(const TensorType::Element &element, const pandora::HitType hitType, pandora::CartesianPointVector &projectedPositions) const
Use two views of a delta ray pfo to calculate projected positions in a given third view...
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
virtual bool PassElementChecks(const TensorType::Element &element, const pandora::HitType hitType) const =0
Determine whether element satifies simple checks.
std::vector< pandora::HitType > HitTypeVector
bool IsMuonEndpoint(const TensorType::Element &element, const bool ignoreHitType, const pandora::HitType hitTypeToIgnore=pandora::TPC_VIEW_U) const
Determine whether the matched clusters suggest that the delta ray is at the endpoint of the cosmic ra...
pandora::StatusCode GetMuonCluster(const pandora::PfoList &commonMuonPfoList, const pandora::HitType hitType, const pandora::Cluster *&pMuonCluster) const
Return the cluster of the common cosmic ray pfo in a given view (function demands there to be only on...
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)=0