26 m_minMatchedFraction(0.9f),
27 m_minMatchedSamplingPoints(10),
28 m_minMatchedSamplingPointRatio(2),
29 m_minInitialXOverlapFraction(0.75f),
30 m_minFinalXOverlapFraction(0.75f),
31 m_minCaloHitsInCandidateCluster(5),
33 m_makePfoMinSamplingPoints(5),
34 m_makePfoMinMatchedSamplingPoints(5),
35 m_makePfoMinMatchedFraction(0.8f),
36 m_makePfoMaxImpactParameter(3.f),
37 m_mergeMaxChi2PerSamplingPoint(0.25f),
38 m_mergeXContainmentTolerance(1.f)
47 std::cout <<
"----> Running Algorithm Tool: " << this->
GetInstanceName() <<
", " << this->
GetType() << std::endl;
51 this->
FindTracks(pAlgorithm, overlapTensor, protoParticleVector, clusterMergeMap);
56 return (particlesMade || mergesMade);
66 overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
68 for (
const Cluster *
const pKeyCluster : sortedKeyClusters)
70 if (!pKeyCluster->IsAvailable())
73 unsigned int nU(0), nV(0), nW(0);
74 TensorType::ElementList elementList;
75 overlapTensor.GetConnectedElements(pKeyCluster,
true, elementList, nU, nV, nW);
80 for (IteratorList::const_iterator iIter = iteratorList.begin(), iIterEnd = iteratorList.end(); iIter != iIterEnd; ++iIter)
92 protoParticle.
m_clusterList.push_back((*iIter)->GetClusterU());
93 protoParticle.
m_clusterList.push_back((*iIter)->GetClusterV());
94 protoParticle.
m_clusterList.push_back((*iIter)->GetClusterW());
95 protoParticleVector.push_back(protoParticle);
97 usedClusters.insert((*iIter)->GetClusterU());
98 usedClusters.insert((*iIter)->GetClusterV());
99 usedClusters.insert((*iIter)->GetClusterW());
109 for (TensorType::ElementList::const_iterator eIter = elementList.begin(); eIter != elementList.end(); ++eIter)
111 if (usedClusters.count(eIter->GetClusterU()) || usedClusters.count(eIter->GetClusterV()) || usedClusters.count(eIter->GetClusterW()))
120 const XOverlap &xOverlap(eIter->GetOverlapResult().GetXOverlap());
123 const float longSpan2(
128 if ((xOverlap.
GetXOverlapSpan() < std::numeric_limits<float>::epsilon()) || (longSpan1 < std::numeric_limits<float>::epsilon()))
134 iteratorList.push_back(eIter);
150 if (candidateClusters.empty())
156 if (slidingFitResultMap.empty())
162 if (segmentOverlapMap.empty())
165 return this->
MakeDecisions(particle, slidingFitResultMap, segmentOverlapMap, usedClusters, clusterMergeMap);
180 for (ClusterList::const_iterator iter = clusterList.begin(), iterEnd = clusterList.end(); iter != iterEnd; ++iter)
182 const Cluster *
const pCluster(*iter);
190 candidateClusters.push_back(pCluster);
201 for (ClusterList::const_iterator iter = candidateClusterList.begin(), iterEnd = candidateClusterList.end(); iter != iterEnd; ++iter)
203 const Cluster *
const pCluster(*iter);
208 (void)slidingFitResultMap.insert(TwoDSlidingFitResultMap::value_type(pCluster, slidingFitResult));
218 (void)slidingFitResultMap.insert(TwoDSlidingFitResultMap::value_type(pCluster, slidingFitResult));
238 const unsigned int nPoints(
static_cast<unsigned int>(1.f + (nPoints1 + nPoints2) / 2.f));
241 for (
const auto &mapEntry : slidingFitResultMap)
242 clusterList.push_back(mapEntry.first);
245 for (
unsigned n = 0; n <= nPoints; ++n)
263 for (
const Cluster *
const pCluster : clusterList)
274 const float delta((prediction - fitVector.GetZ()) * fitDirection.
GetX());
275 const float pseudoChi2(delta * delta);
298 bool matchesACluster(
false);
301 for (
const auto &mapEntry : segmentOverlapMap)
302 sortedClusters.push_back(mapEntry.first);
305 for (
const Cluster *
const pCluster : sortedClusters)
307 const SegmentOverlap &segmentOverlap(segmentOverlapMap.at(pCluster));
314 matchesACluster =
true;
317 if (!usedClusters.insert(pCluster).second || !pCluster->IsAvailable())
320 if (!this->
IsPossibleMerge(pCluster, particle, segmentOverlap, slidingFitResultMap))
323 possibleMerges.push_back(pCluster);
326 if (std::fabs(particle.
m_longMaxX - particle.
m_longMinX) < std::numeric_limits<float>::epsilon())
329 if (!matchesACluster || possibleMerges.empty())
336 clusterList.insert(clusterList.end(), possibleMerges.begin(), possibleMerges.end());
364 TwoDSlidingFitResultMap::const_iterator fitIter = slidingFitResultMap.find(pCluster);
366 if (slidingFitResultMap.end() == fitIter)
369 float mergeMinX(std::numeric_limits<float>::max()), mergeMaxX(-std::numeric_limits<float>::max());
370 fitIter->second.GetMinAndMaxX(mergeMinX, mergeMaxX);
388 const XOverlap &xOverlap(element.GetOverlapResult().GetXOverlap());
459 return STATUS_CODE_SUCCESS;
Header file for the cluster helper class.
Header file for the geometry helper class.
Header file for the lar pointing cluster class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
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,...
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).
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
static bool HasLongDirectConnections(IteratorList::const_iterator iIter, const IteratorList &iteratorList)
Whether a long element shares clusters with any other long elements.
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.
virtual bool MakeClusterMerges(const ClusterMergeMap &clusterMergeMap)
Merge clusters together.
virtual bool CreateThreeDParticles(const ProtoParticleVector &protoParticleVector)
Create particles using findings from recent algorithm processing.
const pandora::Cluster * m_pCluster1
Address of long cluster in view 1.
pandora::HitType m_hitType2
The hit type of the long cluster in view 2.
float m_longMinX
The min x coordinate of the long clusters.
pandora::HitType m_hitType1
The hit type of the long cluster in view 1.
const pandora::Cluster * m_pShortCluster
Address of the short cluster.
float m_longMaxX
The max x coordinate of the long clusters.
pandora::HitType m_shortHitType
The hit type of the short cluster.
float m_shortMaxX
The max x coordinate of the short cluster.
float m_shortMinX
The min x coordinate of the short cluster.
Particle(const TensorType::Element &element)
Constructor.
const pandora::Cluster * m_pCluster2
Address of long cluster in view 2.
unsigned int m_nMatchedSamplingPoints
The number of matched sampling points.
float m_matchedSamplingMinX
The min matched sampling point x coordinate.
float m_matchedSamplingMaxX
The max matched sampling point x coordinate.
unsigned int m_nSamplingPoints
The number of sampling points.
float m_pseudoChi2Sum
The pseudo chi2 sum.
float m_pseudoChi2Cut
The pseudo chi2 cut to determine whether a sampling point is matched.
std::unordered_map< const pandora::Cluster *, SegmentOverlap > SegmentOverlapMap
void GetCandidateClusters(ThreeViewTransverseTracksAlgorithm *const pAlgorithm, const Particle &particle, pandora::ClusterList &candidateClusters) const
Get a list of candidate clusters, which may represent missing track segments for a provided particle.
bool PassesSamplingCuts(const SegmentOverlap &segmentOverlap) const
Whether the segment overlap object passes cuts on matched sampling points, etc.
void GetSegmentOverlapMap(ThreeViewTransverseTracksAlgorithm *const pAlgorithm, const Particle &particle, const TwoDSlidingFitResultMap &slidingFitResultMap, SegmentOverlapMap &segmentOverlapMap) const
Get a segment overlap map, describing overlap between a provided particle and all clusters in a slidi...
unsigned int m_makePfoMinMatchedSamplingPoints
The min number of matched sampling points in order to be able to make pfo.
unsigned int m_minMatchedSamplingPointRatio
The min ratio between 1st and 2nd highest msps for simple ambiguity resolution.
bool IsPossibleMerge(const pandora::Cluster *const pCluster, const Particle &particle, const SegmentOverlap &segmentOverlap, const TwoDSlidingFitResultMap &slidingFitResultMap) const
Whether the cluster could be merged with the candidate particle.
unsigned int m_minMatchedSamplingPoints
The min number of matched sampling points for particle creation.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
bool PassesParticleChecks(ThreeViewTransverseTracksAlgorithm *const pAlgorithm, const TensorType::Element &element, pandora::ClusterSet &usedClusters, ClusterMergeMap &clusterMergeMap) const
Whether a provided tensor element can be used to construct a pfo.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
unsigned int m_minCaloHitsInCandidateCluster
The min no. of calo hits in a candidate cluster, for matching with long clusters.
float m_minInitialXOverlapFraction
The min x overlap fraction (between long clusters and short cluster vs. shared overlap)
float m_mergeMaxChi2PerSamplingPoint
The max value of chi2 per sampling point in order to merge cluster with parent.
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
float m_minFinalXOverlapFraction
The min x overlap fraction between extended short cluster and the long clusters.
void FindTracks(ThreeViewTransverseTracksAlgorithm *const pAlgorithm, const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector, ClusterMergeMap &clusterMergeMap) const
Find remaining tracks, hidden by missing track segments (and maybe other ambiguities) in the tensor.
float m_makePfoMinMatchedFraction
The min matched sampling point fraction in order to be able to make pfo.
MissingTrackSegmentTool()
Default constructor.
bool MakeDecisions(const Particle &particle, const TwoDSlidingFitResultMap &slidingFitResultMap, const SegmentOverlapMap &segmentOverlapMap, pandora::ClusterSet &usedClusters, ClusterMergeMap &clusterMergeMap) const
Make decisions about whether to create a pfo for a provided particle and whether to make cluster merg...
void GetSlidingFitResultMap(ThreeViewTransverseTracksAlgorithm *const pAlgorithm, const pandora::ClusterList &candidateClusterList, TwoDSlidingFitResultMap &slidingFitResultMap) const
Get a sliding fit result map for the list of candidate clusters.
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.
bool Run(ThreeViewTransverseTracksAlgorithm *const pAlgorithm, TensorType &overlapTensor)
Run the algorithm tool.
unsigned int m_makePfoMinSamplingPoints
The min number of sampling points in order to be able to make pfo.
float m_mergeXContainmentTolerance
The tolerance in determining whether candidate cluster is contained in x window.
float m_makePfoMaxImpactParameter
The max transverse impact parameter in order to be able to make pfo.
const pandora::ClusterList & GetInputClusterList(const pandora::HitType hitType) const
Get the input cluster list corresponding to a specified hit type.
unsigned int GetSlidingFitWindow() const
Get the layer window for the sliding linear fits.
const TwoDSlidingFitResult & GetCachedSlidingFitResult(const pandora::Cluster *const pCluster) const
Get a sliding fit result from the algorithm cache.
ThreeViewTransverseTracksAlgorithm class.
ThreeViewTransverseTracksAlgorithm::MatchingType::TensorType TensorType
std::vector< TensorType::ElementList::const_iterator > IteratorList
TwoDSlidingFitResult class.
int GetMaxLayer() const
Get the maximum occupied layer in the sliding fit.
int GetMinLayer() const
Get the minimum occupied layer in the sliding fit.
pandora::StatusCode GetGlobalFitPositionAtX(const float x, pandora::CartesianVector &position) const
Get global fit position for a given input x coordinate.
pandora::StatusCode GetGlobalFitDirectionAtX(const float x, pandora::CartesianVector &direction) const
Get global fit direction for a given input x coordinate.
float GetUMinX() const
Get the min x value in the u view.
float GetXSpanV() const
Get the x span in the v view.
float GetWMaxX() const
Get the max x value in the w view.
float GetXOverlapSpan() const
Get the x overlap span.
float GetWMinX() const
Get the min x value in the w view.
float GetVMinX() const
Get the min x value in the v view.
float GetXSpanW() const
Get the x span in the w view.
float GetUMaxX() const
Get the max x value in the u view.
float GetVMaxX() const
Get the max x value in the v view.
float GetXSpanU() const
Get the x span in the u view.
float GetX() const
Get the cartesian x coordinate.
float GetZ() const
Get the cartesian z coordinate.
unsigned int GetNCaloHits() const
Get the number of calo hits in the cluster.
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
const std::string & GetType() const
Get the type.
const Pandora & GetPandora() const
Get the associated pandora instance.
const std::string & GetInstanceName() const
Get the instance name.
StatusCodeException class.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
std::vector< ProtoParticle > ProtoParticleVector
pandora::ClusterList m_clusterList
List of 2D clusters in a 3D proto particle.
std::unordered_map< const pandora::Cluster *, TwoDSlidingFitResult > TwoDSlidingFitResultMap
std::vector< const Cluster * > ClusterVector
MANAGED_CONTAINER< const Cluster * > ClusterList
std::unordered_set< const Cluster * > ClusterSet
StatusCode
The StatusCode enum.