9 #include "Pandora/AlgorithmHeaders.h" 23 TrackSplittingTool::TrackSplittingTool() :
24 m_minMatchedFraction(0.75
f),
25 m_minMatchedSamplingPoints(10),
26 m_minXOverlapFraction(0.75
f),
27 m_minMatchedSamplingPointRatio(2),
28 m_maxShortDeltaXFraction(0.2
f),
29 m_maxAbsoluteShortDeltaX(5.
f),
30 m_minLongDeltaXFraction(0.2
f),
31 m_minAbsoluteLongDeltaX(1.
f),
32 m_minSplitToVertexProjection(1.
f),
33 m_maxSplitVsFitPositionDistance(1.5
f)
41 if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
42 std::cout <<
"----> Running Algorithm Tool: " << this->GetInstanceName() <<
", " << this->GetType() << std::endl;
45 this->
FindTracks(pAlgorithm, overlapTensor, splitPositionMap);
55 ClusterSet usedClusters;
59 for (
const Cluster *
const pKeyCluster : sortedKeyClusters)
61 if (!pKeyCluster->IsAvailable())
64 unsigned int nU(0), nV(0), nW(0);
79 if (!this->
PassesChecks(pAlgorithm, *(*iIter),
true, usedClusters, splitPositionMap) &&
80 !this->
PassesChecks(pAlgorithm, *(*iIter),
false, usedClusters, splitPositionMap))
85 usedClusters.insert((*iIter)->GetClusterU());
86 usedClusters.insert((*iIter)->GetClusterV());
87 usedClusters.insert((*iIter)->GetClusterW());
98 if (usedClusters.count(eIter->GetClusterU()) || usedClusters.count(eIter->GetClusterV()) || usedClusters.count(eIter->GetClusterW()))
107 const XOverlap &xOverlap(eIter->GetOverlapResult().GetXOverlap());
108 const float longSpan(
std::max(xOverlap.GetXSpanU(),
std::max(xOverlap.GetXSpanV(), xOverlap.GetXSpanW())));
109 const float shortSpan1(
std::min(xOverlap.GetXSpanU(),
std::min(xOverlap.GetXSpanV(), xOverlap.GetXSpanW())));
110 const float shortSpan2(((xOverlap.GetXSpanU() > shortSpan1) && (xOverlap.GetXSpanU() < longSpan)) ? xOverlap.GetXSpanU() :
111 ((xOverlap.GetXSpanV() > shortSpan1) && (xOverlap.GetXSpanV() < longSpan)) ? xOverlap.GetXSpanV() : xOverlap.GetXSpanW());
113 if ((shortSpan1 < std::numeric_limits<float>::epsilon()) || (longSpan < std::numeric_limits<float>::epsilon()))
125 iteratorList.push_back(eIter);
143 if (longXSpan < std::numeric_limits<float>::epsilon())
148 const float longDeltaX(isMinX ? (splitX - particle.
m_longMinX) : (particle.
m_longMaxX - splitX));
160 const CartesianVector &position1(pointingCluster1.GetInnerVertex().GetPosition().GetX() < pointingCluster1.GetOuterVertex().GetPosition().GetX() ? pointingCluster1.GetInnerVertex().GetPosition() : pointingCluster1.GetOuterVertex().GetPosition());
161 const CartesianVector &position2(pointingCluster2.GetInnerVertex().GetPosition().GetX() < pointingCluster2.GetOuterVertex().GetPosition().GetX() ? pointingCluster2.GetInnerVertex().GetPosition() : pointingCluster2.GetOuterVertex().GetPosition());
163 CartesianVector splitPosition(0.
f, 0.
f, 0.
f);
171 const CartesianVector splitToInnerVertex(splitPosition - longPointingCluster.GetInnerVertex().GetPosition());
172 const CartesianVector outerVertexToSplit(longPointingCluster.GetOuterVertex().GetPosition() - splitPosition);
173 const CartesianVector outerToInnerUnitVector((longPointingCluster.GetOuterVertex().GetPosition() - longPointingCluster.GetInnerVertex().GetPosition()).GetUnitVector());
178 splitPositionMap[particle.
m_pLongCluster].push_back(splitPosition);
182 catch (StatusCodeException &)
193 CartesianPointVector fitPositionList;
211 const XOverlap &xOverlap(element.GetOverlapResult().GetXOverlap());
213 const HitType longHitType = ((xOverlap.GetXSpanU() > xOverlap.GetXSpanV()) && (xOverlap.GetXSpanU() > xOverlap.GetXSpanW())) ? TPC_VIEW_U :
214 ((xOverlap.GetXSpanV() > xOverlap.GetXSpanU()) && (xOverlap.GetXSpanV() > xOverlap.GetXSpanW())) ? TPC_VIEW_V :
215 ((xOverlap.GetXSpanW() > xOverlap.GetXSpanU()) && (xOverlap.GetXSpanW() > xOverlap.GetXSpanV())) ? TPC_VIEW_W : HIT_CUSTOM;
217 if (HIT_CUSTOM == longHitType)
218 throw StatusCodeException(STATUS_CODE_FAILURE);
220 m_pLongCluster = (TPC_VIEW_U == longHitType) ? element.GetClusterU() : (TPC_VIEW_V == longHitType) ? element.GetClusterV() : element.GetClusterW();
221 m_pCluster1 = (TPC_VIEW_U == longHitType) ? element.GetClusterV() : element.GetClusterU();
222 m_pCluster2 = (TPC_VIEW_W == longHitType) ? element.GetClusterV() : element.GetClusterW();
223 m_longMinX = (TPC_VIEW_U == longHitType) ? xOverlap.GetUMinX() : (TPC_VIEW_V == longHitType) ? xOverlap.GetVMinX() : xOverlap.GetWMinX();
224 m_longMaxX = (TPC_VIEW_U == longHitType) ? xOverlap.GetUMaxX() : (TPC_VIEW_V == longHitType) ? xOverlap.GetVMaxX() : xOverlap.GetWMaxX();
225 m_short1MinX = (TPC_VIEW_U == longHitType) ? xOverlap.GetVMinX() : xOverlap.GetUMinX();
226 m_short1MaxX = (TPC_VIEW_U == longHitType) ? xOverlap.GetVMaxX() : xOverlap.GetUMaxX();
227 m_short2MinX = (TPC_VIEW_W == longHitType) ? xOverlap.GetVMinX() : xOverlap.GetWMinX();
228 m_short2MaxX = (TPC_VIEW_W == longHitType) ? xOverlap.GetVMaxX() : xOverlap.GetWMaxX();
236 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
239 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
242 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
245 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
248 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
251 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
254 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
257 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
260 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
263 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
266 return STATUS_CODE_SUCCESS;
unsigned int m_minMatchedSamplingPoints
The min number of matched sampling points for particle creation.
std::unordered_map< const pandora::Cluster *, pandora::CartesianPointVector > SplitPositionMap
Header file for the lar pointing cluster class.
virtual bool MakeClusterSplits(const SplitPositionMap &splitPositionMap)
Make cluster splits.
bool PassesChecks(ThreeDTransverseTracksAlgorithm *const pAlgorithm, const TensorType::Element &element, const bool isMinX, pandora::ClusterSet &usedClusters, SplitPositionMap &splitPositionMap) const
Whether a provided tensor element can be used to construct a pfo.
bool CheckSplitPosition(const pandora::CartesianVector &splitPosition, const float splitX, const TwoDSlidingFitResult &longFitResult) const
Check a candidate split position for consistency with the associated track cluster sliding linear fit...
std::vector< TensorType::ElementList::const_iterator > IteratorList
static bool IsLongerThanDirectConnections(IteratorList::const_iterator iIter, const TensorType::ElementList &elementList, const unsigned int minMatchedSamplingPointRatio, const pandora::ClusterSet &usedClusters)
Whether a long element is significantly longer that other elements with which it shares a cluster...
float m_minSplitToVertexProjection
Min projected distance between split position and either inner or outer vertex of long cluster...
void GetConnectedElements(const pandora::Cluster *const pCluster, const bool ignoreUnavailable, ElementList &elementList) const
Get a list of elements connected to a specified cluster.
const pandora::Cluster * m_pCluster2
Address of short cluster in view 2.
float m_short2MinX
The min x coordinate of short cluster 2.
LArPointingCluster class.
void SelectElements(const TensorType::ElementList &elementList, const pandora::ClusterSet &usedClusters, IteratorList &iteratorList) const
Select a list of the relevant elements from a set of connected tensor elements.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
const TwoDSlidingFitResult & GetCachedSlidingFitResult(const pandora::Cluster *const pCluster) const
Get a sliding fit result from the algorithm cache.
float m_maxAbsoluteShortDeltaX
Max x distance between ends of two short clusters (measured as an absolute distance) ...
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
Header file for the geometry helper class.
float m_longMinX
The min x coordinate of the long cluster.
std::vector< Element > ElementList
float m_minAbsoluteLongDeltaX
Min x distance between ends of short and long clusters (measured as an absolute distance) ...
float m_maxShortDeltaXFraction
Max x distance between ends of two short clusters (measured as fraction of long cluster x length) ...
Header file for the cluster helper class.
float m_minLongDeltaXFraction
Min x distance between ends of short and long clusters (measured as fraction of long cluster x length...
bool Run(ThreeDTransverseTracksAlgorithm *const pAlgorithm, TensorType &overlapTensor)
Run the algorithm tool.
static float MergeTwoPositions(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const float position1, const float position2)
Merge two views (U,V) to give a third view (Z).
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
void GetSortedKeyClusters(pandora::ClusterVector &sortedKeyClusters) const
Get a sorted vector of key clusters (U clusters with current implementation)
float m_longMaxX
The max x coordinate of the long cluster.
float m_short2MaxX
The max x coordinate of short cluster 2.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
const pandora::Cluster * m_pCluster1
Address of short cluster in view 1.
float m_short1MaxX
The max x coordinate of short cluster 1.
float m_minXOverlapFraction
The min x overlap fraction (between long clusters and short cluster vs. shared overlap) ...
unsigned int m_minMatchedSamplingPointRatio
The min ratio between 1st and 2nd highest msps for simple ambiguity resolution.
float m_short1MinX
The min x coordinate of short cluster 1.
static bool HasLongDirectConnections(IteratorList::const_iterator iIter, const IteratorList &iteratorList)
Whether a long element shares clusters with any other long elements.
float m_maxSplitVsFitPositionDistance
Max allowed distance between split position and sliding linear fit position at the split x coordinate...
pandora::StatusCode GetGlobalFitPositionListAtX(const float x, pandora::CartesianPointVector &positionList) const
Get a list of projected positions for a given input x coordinate.
const pandora::Cluster * m_pLongCluster
Address of the long cluster.
void FindTracks(ThreeDTransverseTracksAlgorithm *const pAlgorithm, const TensorType &overlapTensor, SplitPositionMap &splitPositionMap) const
Find remaining tracks, hidden by spurious track segments (and maybe other ambiguities) in the tensor...
TwoDSlidingFitResult class.
ThreeDTransverseTracksAlgorithm class.
Particle(const TensorType::Element &element)
Constructor.
TheTensor::const_iterator const_iterator