Public Member Functions | Private Member Functions | Private Attributes | List of all members
lar_content::TransverseMatrixVisualizationTool Class Reference

TransverseMatrixVisualizationTool class. More...

#include <TransverseMatrixVisualizationTool.h>

Inheritance diagram for lar_content::TransverseMatrixVisualizationTool:
lar_content::TransverseMatrixTool

Public Member Functions

 TransverseMatrixVisualizationTool ()
 Default constructor. More...
 
bool Run (TwoViewTransverseTracksAlgorithm *const pAlgorithm, MatrixType &overlapMatrix)
 Run the algorithm tool. More...
 

Private Member Functions

pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

unsigned int m_minClusterConnections
 The minimum number of cluster connections for display. More...
 
bool m_ignoreUnavailableClusters
 Whether to ignore (skip-over) unavailable clusters in the matrix. More...
 
bool m_showEachIndividualElement
 Whether to draw each individual matrix element. More...
 
bool m_showOnlyTrueMatchIndividualElements
 Whether to draw only truly matching individual matrix elements. More...
 

Additional Inherited Members

- Public Types inherited from lar_content::TransverseMatrixTool
typedef TwoViewTransverseTracksAlgorithm::MatchingType::MatrixType MatrixType
 
typedef std::vector< MatrixType::ElementList::const_iteratorIteratorList
 

Detailed Description

TransverseMatrixVisualizationTool class.

Definition at line 19 of file TransverseMatrixVisualizationTool.h.

Constructor & Destructor Documentation

lar_content::TransverseMatrixVisualizationTool::TransverseMatrixVisualizationTool ( )

Default constructor.

Definition at line 18 of file TransverseMatrixVisualizationTool.cc.

18  :
23 {
24 }
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.
bool m_showEachIndividualElement
Whether to draw each individual matrix element.

Member Function Documentation

StatusCode lar_content::TransverseMatrixVisualizationTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 137 of file TransverseMatrixVisualizationTool.cc.

138 {
139  PANDORA_RETURN_RESULT_IF_AND_IF(
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 }
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.
bool m_showEachIndividualElement
Whether to draw each individual matrix element.
bool lar_content::TransverseMatrixVisualizationTool::Run ( TwoViewTransverseTracksAlgorithm *const  pAlgorithm,
MatrixType overlapMatrix 
)
virtual

Run the algorithm tool.

Parameters
pAlgorithmaddress of the calling algorithm
overlapMatrixthe overlap matrix
Returns
whether changes have been made by the tool

Implements lar_content::TransverseMatrixTool.

Definition at line 28 of file TransverseMatrixVisualizationTool.cc.

29 {
30  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
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 }
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.
intermediate_table::const_iterator const_iterator
bool m_showEachIndividualElement
Whether to draw each individual matrix element.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
QTextStream & endl(QTextStream &s)

Member Data Documentation

bool lar_content::TransverseMatrixVisualizationTool::m_ignoreUnavailableClusters
private

Whether to ignore (skip-over) unavailable clusters in the matrix.

Definition at line 33 of file TransverseMatrixVisualizationTool.h.

unsigned int lar_content::TransverseMatrixVisualizationTool::m_minClusterConnections
private

The minimum number of cluster connections for display.

Definition at line 32 of file TransverseMatrixVisualizationTool.h.

bool lar_content::TransverseMatrixVisualizationTool::m_showEachIndividualElement
private

Whether to draw each individual matrix element.

Definition at line 34 of file TransverseMatrixVisualizationTool.h.

bool lar_content::TransverseMatrixVisualizationTool::m_showOnlyTrueMatchIndividualElements
private

Whether to draw only truly matching individual matrix elements.

Definition at line 35 of file TransverseMatrixVisualizationTool.h.


The documentation for this class was generated from the following files: