9 #include "Pandora/AlgorithmHeaders.h" 18 TransverseMatrixVisualizationTool::TransverseMatrixVisualizationTool() :
19 m_minClusterConnections(1),
20 m_ignoreUnavailableClusters(true),
21 m_showEachIndividualElement(false),
22 m_showOnlyTrueMatchIndividualElements(false)
30 if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
31 std::cout <<
"----> Running Algorithm Tool: " << this->GetInstanceName() <<
", " << this->GetType() <<
std::endl;
33 ClusterSet usedKeyClusters;
37 for (
const Cluster *
const pKeyCluster : sortedKeyClusters)
42 if (usedKeyClusters.count(pKeyCluster))
45 unsigned int n1(0), n2(0);
56 ClusterList allClusterList1, allClusterList2;
57 std::cout <<
" Connections: n1 " << n1 <<
", n2 " << n2 <<
", nElements " << elementList.size() <<
std::endl;
61 if (allClusterList1.end() == std::find(allClusterList1.begin(), allClusterList1.end(), eIter->GetCluster1()))
62 allClusterList1.push_back(eIter->GetCluster1());
63 if (allClusterList2.end() == std::find(allClusterList2.begin(), allClusterList2.end(), eIter->GetCluster2()))
64 allClusterList2.push_back(eIter->GetCluster2());
65 usedKeyClusters.insert(eIter->GetCluster1());
72 bool isPrimary0(
false);
73 bool isPrimary1(
false);
74 bool sameParticle(
false);
77 const MCParticle *particle0(MCParticleHelper::GetMainMCParticle(eIter->GetCluster1()));
78 const MCParticle *particle1(MCParticleHelper::GetMainMCParticle(eIter->GetCluster2()));
79 pdg0 = (particle0->GetParticleId());
80 isPrimary0 = (particle0->IsRootParticle());
81 pdg1 = (particle1->GetParticleId());
82 isPrimary1 = (particle1->IsRootParticle());
83 sameParticle = (particle0->GetUid() == particle1->GetUid());
85 catch (
const StatusCodeException &)
92 std::cout <<
" Element " << counter++ <<
std::endl;
93 std::cout <<
" ---True PDG 0: " << pdg0 <<
std::endl;
94 std::cout <<
" ---True PDG 1: " << pdg1 <<
std::endl;
95 std::cout <<
" ---True is primary 0: " << isPrimary0 <<
std::endl;
96 std::cout <<
" ---True is primary 1: " << isPrimary1 <<
std::endl;
97 std::cout <<
" ---True is same particle: " << sameParticle <<
std::endl;
98 std::cout <<
" ---Is cluster 0 available: " << eIter->GetCluster1()->IsAvailable() <<
std::endl;
99 std::cout <<
" ---Is cluster 1 available: " << eIter->GetCluster2()->IsAvailable() <<
std::endl;
100 std::cout <<
" ---XOverlap: " << eIter->GetOverlapResult().GetTwoViewXOverlap().GetTwoViewXOverlapSpan() <<
std::endl;
101 std::cout <<
" ---XOverlap fraction view0: " << eIter->GetOverlapResult().GetTwoViewXOverlap().GetXOverlapFraction0() <<
std::endl;
102 std::cout <<
" ---XOverlap fraction view1: " << eIter->GetOverlapResult().GetTwoViewXOverlap().GetXOverlapFraction1() <<
std::endl;
103 std::cout <<
" ---Matching score: " << eIter->GetOverlapResult().GetMatchingScore() <<
std::endl;
104 std::cout <<
" ---N. sampling points: " << eIter->GetOverlapResult().GetNSamplingPoints() <<
std::endl;
105 std::cout <<
" ---N. matched sampling points: " << eIter->GetOverlapResult().GetNMatchedSamplingPoints() <<
std::endl;
106 std::cout <<
" ---N. (re-)upsampled sampling points: " << eIter->GetOverlapResult().GetNReUpsampledSamplingPoints() <<
std::endl;
107 std::cout <<
" ---N. (re-)upsampled matched sampling points: " << eIter->GetOverlapResult().GetNMatchedReUpsampledSamplingPoints()
109 std::cout <<
" ---Correlation coeff.: " << eIter->GetOverlapResult().GetCorrelationCoefficient() <<
std::endl;
110 std::cout <<
" ---Locally matched fraction: " << eIter->GetOverlapResult().GetLocallyMatchedFraction() <<
std::endl;
114 const ClusterList clusterList1(1, eIter->GetCluster1()), clusterList2(1, eIter->GetCluster2());
115 PANDORA_MONITORING_API(SetEveDisplayParameters(this->GetPandora(),
false, DETECTOR_VIEW_XZ, -1.
f, -1.
f, 1.
f));
116 PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &allClusterList1,
"AllClusters1", LIGHTORANGE));
117 PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &allClusterList2,
"AllClusters2", LIGHTYELLOW));
118 PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &clusterList1,
"Cluster1", RED));
119 PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &clusterList2,
"Cluster2", GREEN));
120 PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
124 std::cout <<
" All Connected Clusters " <<
std::endl;
125 PANDORA_MONITORING_API(SetEveDisplayParameters(this->GetPandora(),
false, DETECTOR_VIEW_XZ, -1.
f, -1.
f, 1.
f));
126 PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &allClusterList1,
"AllClusters1", RED));
127 PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &allClusterList2,
"AllClusters2", GREEN));
129 PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
139 PANDORA_RETURN_RESULT_IF_AND_IF(
140 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MinClusterConnections",
m_minClusterConnections));
142 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
145 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
148 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
151 return STATUS_CODE_SUCCESS;
bool m_ignoreUnavailableClusters
Whether to ignore (skip-over) unavailable clusters in the matrix.
unsigned int m_minClusterConnections
The minimum number of cluster connections for display.
bool m_showOnlyTrueMatchIndividualElements
Whether to draw only truly matching individual matrix elements.
TwoViewTransverseTracksAlgorithm class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::vector< Element > ElementList
void GetSortedKeyClusters(pandora::ClusterVector &sortedKeyClusters) const
Get a sorted vector of key clusters (view 1 clusters with current implementation) ...
bool Run(TwoViewTransverseTracksAlgorithm *const pAlgorithm, MatrixType &overlapMatrix)
Run the algorithm tool.
bool m_showEachIndividualElement
Whether to draw each individual matrix element.
TheMatrix::const_iterator const_iterator
void GetConnectedElements(const pandora::Cluster *const pCluster, const bool ignoreUnavailable, ElementList &elementList) const
Get a list of elements connected to a specified cluster.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
QTextStream & endl(QTextStream &s)