Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
TransverseMatrixVisualizationTool.cc
Go to the documentation of this file.
1
10
12
13using namespace pandora;
14
15namespace lar_content
16{
17
19 m_minClusterConnections(1),
20 m_ignoreUnavailableClusters(true),
21 m_showEachIndividualElement(false),
22 m_showOnlyTrueMatchIndividualElements(false)
23{
24}
25
26//------------------------------------------------------------------------------------------------------------------------------------------
27
29{
31 std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
32
33 ClusterSet usedKeyClusters;
34 ClusterVector sortedKeyClusters;
35 overlapMatrix.GetSortedKeyClusters(sortedKeyClusters);
36
37 for (const Cluster *const pKeyCluster : sortedKeyClusters)
38 {
39 if (m_ignoreUnavailableClusters && !pKeyCluster->IsAvailable())
40 continue;
41
42 if (usedKeyClusters.count(pKeyCluster))
43 continue;
44
45 unsigned int n1(0), n2(0);
46 MatrixType::ElementList elementList;
47 overlapMatrix.GetConnectedElements(pKeyCluster, m_ignoreUnavailableClusters, elementList, n1, n2);
48
50 continue;
51
52 if (n1 * n2 == 0)
53 continue;
54
55 int counter(0);
56 ClusterList allClusterList1, allClusterList2;
57 std::cout << " Connections: n1 " << n1 << ", n2 " << n2 << ", nElements " << elementList.size() << std::endl;
58
59 for (MatrixType::ElementList::const_iterator eIter = elementList.begin(); eIter != elementList.end(); ++eIter)
60 {
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());
66 }
67
68 for (MatrixType::ElementList::const_iterator eIter = elementList.begin(); eIter != elementList.end(); ++eIter)
69 {
70 int pdg0(0);
71 int pdg1(0);
72 bool isPrimary0(false);
73 bool isPrimary1(false);
74 bool sameParticle(false);
75 try
76 {
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());
84 }
85 catch (const StatusCodeException &)
86 {
87 };
88
89 if (m_showOnlyTrueMatchIndividualElements && !sameParticle)
90 continue;
91
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()
108 << std::endl;
109 std::cout << " ---Correlation coeff.: " << eIter->GetOverlapResult().GetCorrelationCoefficient() << std::endl;
110 std::cout << " ---Locally matched fraction: " << eIter->GetOverlapResult().GetLocallyMatchedFraction() << std::endl;
111
113 {
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()));
121 }
122 }
123
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));
128
129 PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
130 }
131
132 return false;
133}
134
135//------------------------------------------------------------------------------------------------------------------------------------------
136
138{
140 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterConnections", m_minClusterConnections));
141
142 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
143 XmlHelper::ReadValue(xmlHandle, "IgnoreUnavailableClusters", m_ignoreUnavailableClusters));
144
145 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
146 XmlHelper::ReadValue(xmlHandle, "ShowEachIndividualElement", m_showEachIndividualElement));
147
148 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
149 XmlHelper::ReadValue(xmlHandle, "ShowOnlyTrueMatchIndividualElements", m_showOnlyTrueMatchIndividualElements));
150
151 return STATUS_CODE_SUCCESS;
152}
153
154} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
#define PANDORA_MONITORING_API(command)
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
Header file for the transverse matrix visualization tool class.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
TwoViewTransverseTracksAlgorithm::MatchingType::MatrixType MatrixType
bool Run(TwoViewTransverseTracksAlgorithm *const pAlgorithm, MatrixType &overlapMatrix)
Run the algorithm tool.
bool m_showEachIndividualElement
Whether to draw each individual matrix element.
bool m_ignoreUnavailableClusters
Whether to ignore (skip-over) unavailable clusters in the matrix.
bool m_showOnlyTrueMatchIndividualElements
Whether to draw only truly matching individual matrix elements.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
unsigned int m_minClusterConnections
The minimum number of cluster connections for display.
Cluster class.
Definition Cluster.h:31
static const MCParticle * GetMainMCParticle(const T *const pT)
Find the mc particle making the largest contribution to a specified calo hit, track or cluster.
MCParticle class.
Definition MCParticle.h:26
Uid GetUid() const
Get the mc particle unique identifier.
Definition MCParticle.h:236
bool IsRootParticle() const
Whether the mc particle is a root particle.
Definition MCParticle.h:215
int GetParticleId() const
Get the PDG code of the mc particle.
Definition MCParticle.h:285
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
const std::string & GetType() const
Get the type.
Definition Process.h:102
const Pandora & GetPandora() const
Get the associated pandora instance.
Definition Process.h:116
const std::string & GetInstanceName() const
Get the instance name.
Definition Process.h:109
StatusCodeException class.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
std::vector< const Cluster * > ClusterVector
MANAGED_CONTAINER< const Cluster * > ClusterList
std::unordered_set< const Cluster * > ClusterSet
StatusCode
The StatusCode enum.