9 #include "Pandora/AlgorithmHeaders.h" 18 ClearShowersTool::ClearShowersTool() :
19 m_minMatchedFraction(0.2
f),
20 m_minMatchedSamplingPoints(40),
21 m_minXOverlapFraction(0.5
f),
22 m_minMatchedSamplingPointRatio(3),
23 m_minXOverlapSpanRatio(3.
f),
37 if (((*iIter)->GetClusterU() == (*iIter2)->GetClusterU()) || ((*iIter)->GetClusterV() == (*iIter2)->GetClusterV()) ||
38 ((*iIter)->GetClusterW() == (*iIter2)->GetClusterW()))
48 const unsigned int minMatchedSamplingPointRatio,
const float minXOverlapSpanRatio,
const ClusterSet &usedClusters)
50 const unsigned int nMatchedSamplingPoints((*iIter)->GetOverlapResult().GetNMatchedSamplingPoints());
51 const unsigned int xOverlapSpan((*iIter)->GetOverlapResult().GetXOverlap().GetXOverlapSpan());
55 if ((*iIter) == eIter)
58 if (usedClusters.count(eIter->GetClusterU()) || usedClusters.count(eIter->GetClusterV()) || usedClusters.count(eIter->GetClusterW()))
61 if (((*iIter)->GetClusterU() != eIter->GetClusterU()) && ((*iIter)->GetClusterV() != eIter->GetClusterV()) &&
62 ((*iIter)->GetClusterW() != eIter->GetClusterW()))
65 if (nMatchedSamplingPoints < minMatchedSamplingPointRatio * eIter->GetOverlapResult().GetNMatchedSamplingPoints())
68 if (xOverlapSpan < minXOverlapSpanRatio * eIter->GetOverlapResult().GetXOverlap().GetXOverlapSpan())
79 if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
80 std::cout <<
"----> Running Algorithm Tool: " << this->GetInstanceName() <<
", " << this->GetType() <<
std::endl;
93 ClusterSet usedClusters;
97 for (
const Cluster *
const pKeyCluster : sortedKeyClusters)
99 if (!pKeyCluster->IsAvailable())
102 unsigned int nU(0), nV(0), nW(0);
120 ClusterList clusterList{(*iIter)->GetClusterU(), (*iIter)->GetClusterV(), (*iIter)->GetClusterW()};
121 PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &clusterList,
"Selected",
BLUE));
122 PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
126 protoParticle.
m_clusterList.push_back((*iIter)->GetClusterU());
127 protoParticle.
m_clusterList.push_back((*iIter)->GetClusterV());
128 protoParticle.
m_clusterList.push_back((*iIter)->GetClusterW());
129 protoParticleVector.push_back(protoParticle);
131 usedClusters.insert((*iIter)->GetClusterU());
132 usedClusters.insert((*iIter)->GetClusterV());
133 usedClusters.insert((*iIter)->GetClusterW());
147 ClusterList clusterList{eIter->GetClusterU(), eIter->GetClusterV(), eIter->GetClusterW()};
148 PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &clusterList,
"Considered", RED));
149 PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
152 if (usedClusters.count(eIter->GetClusterU()) || usedClusters.count(eIter->GetClusterV()) || usedClusters.count(eIter->GetClusterW()))
161 const XOverlap &xOverlap(eIter->GetOverlapResult().GetXOverlap());
163 if ((xOverlap.GetXSpanU() > std::numeric_limits<float>::epsilon()) && (xOverlap.GetXOverlapSpan() / xOverlap.GetXSpanU() >
m_minXOverlapFraction) &&
164 (xOverlap.GetXSpanV() > std::numeric_limits<float>::epsilon()) && (xOverlap.GetXOverlapSpan() / xOverlap.GetXSpanV() >
m_minXOverlapFraction) &&
165 (xOverlap.GetXSpanW() > std::numeric_limits<float>::epsilon()) && (xOverlap.GetXOverlapSpan() / xOverlap.GetXSpanW() >
m_minXOverlapFraction))
167 iteratorList.push_back(eIter);
170 ClusterList clusterList{eIter->GetClusterU(), eIter->GetClusterV(), eIter->GetClusterW()};
171 PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &clusterList,
"Large", GREEN));
172 PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
182 PANDORA_RETURN_RESULT_IF_AND_IF(
183 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MinMatchedFraction",
m_minMatchedFraction));
185 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
188 PANDORA_RETURN_RESULT_IF_AND_IF(
189 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MinXOverlapFraction",
m_minXOverlapFraction));
191 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
194 PANDORA_RETURN_RESULT_IF_AND_IF(
195 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MinXOverlapSpanRatio",
m_minXOverlapSpanRatio));
197 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"Visualize",
m_visualize));
199 return STATUS_CODE_SUCCESS;
std::vector< ProtoParticle > ProtoParticleVector
void FindClearShowers(const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector) const
Find clear shower matches, hidden by simple ambiguities in the tensor.
static bool IsLargerThanDirectConnections(IteratorList::const_iterator iIter, const TensorType::ElementList &elementList, const unsigned int minMatchedSamplingPointRatio, const float minXOverlapSpanRatio, const pandora::ClusterSet &usedClusters)
Whether a large shower-like element is significantly larger that other elements with which it shares ...
void SelectLargeShowerElements(const TensorType::ElementList &elementList, const pandora::ClusterSet &usedClusters, IteratorList &iteratorList) const
Select a list of large shower-like elements from a set of connected tensor elements.
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
void GetConnectedElements(const pandora::Cluster *const pCluster, const bool ignoreUnavailable, ElementList &elementList) const
Get a list of elements connected to a specified cluster.
ThreeViewShowersAlgorithm class.
float m_minXOverlapSpanRatio
The min ratio between 1st and 2nd highest x-overlap spans for simple ambiguity resolution.
std::vector< TensorType::ElementList::const_iterator > IteratorList
std::vector< Element > ElementList
static bool HasLargeDirectConnections(IteratorList::const_iterator iIter, const IteratorList &iteratorList)
Whether a large shower-like element shares clusters with any other long elements. ...
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
pandora::ClusterList m_clusterList
List of 2D clusters in a 3D proto particle.
bool Run(ThreeViewShowersAlgorithm *const pAlgorithm, TensorType &overlapTensor)
Run the algorithm tool.
void GetSortedKeyClusters(pandora::ClusterVector &sortedKeyClusters) const
Get a sorted vector of key clusters (U clusters with current implementation)
unsigned int m_minMatchedSamplingPoints
The min number of matched sampling points for particle creation.
float m_minXOverlapFraction
The min x overlap fraction (in each view) for particle creation.
virtual bool CreateThreeDParticles(const ProtoParticleVector &protoParticleVector)
Create particles using findings from recent algorithm processing.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
bool m_visualize
Visualize cluster split locations.
TheTensor::const_iterator const_iterator
QTextStream & endl(QTextStream &s)
unsigned int m_minMatchedSamplingPointRatio
The min ratio between 1st and 2nd highest msps for simple ambiguity resolution.