LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
TransverseTensorVisualizationTool.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
13 using namespace pandora;
14 
15 namespace lar_content
16 {
17 
18 TransverseTensorVisualizationTool::TransverseTensorVisualizationTool() :
19  m_minClusterConnections(1),
20  m_ignoreUnavailableClusters(true),
21  m_showEachIndividualElement(false),
22  m_showContext(false)
23 {
24 }
25 
26 //------------------------------------------------------------------------------------------------------------------------------------------
27 
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  overlapTensor.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 nU(0), nV(0), nW(0);
46  TensorType::ElementList elementList;
47  overlapTensor.GetConnectedElements(pKeyCluster, m_ignoreUnavailableClusters, elementList, nU, nV, nW);
48 
50  continue;
51 
52  if (nU * nV * nW == 0)
53  continue;
54 
55  int counter(0);
56  ClusterList allClusterListU, allClusterListV, allClusterListW;
57  std::cout << " Connections: nU " << nU << ", nV " << nV << ", nW " << nW << ", nElements " << elementList.size() << std::endl;
58 
59  for (TensorType::ElementList::const_iterator eIter = elementList.begin(); eIter != elementList.end(); ++eIter)
60  {
61  if (allClusterListU.end() == std::find(allClusterListU.begin(), allClusterListU.end(), eIter->GetClusterU())) allClusterListU.push_back(eIter->GetClusterU());
62  if (allClusterListV.end() == std::find(allClusterListV.begin(), allClusterListV.end(), eIter->GetClusterV())) allClusterListV.push_back(eIter->GetClusterV());
63  if (allClusterListW.end() == std::find(allClusterListW.begin(), allClusterListW.end(), eIter->GetClusterW())) allClusterListW.push_back(eIter->GetClusterW());
64  usedKeyClusters.insert(eIter->GetClusterU());
65 
66  std::cout << " Element " << counter++ << ": MatchedFraction " << eIter->GetOverlapResult().GetMatchedFraction()
67  << ", MatchedSamplingPoints " << eIter->GetOverlapResult().GetNMatchedSamplingPoints()
68  << ", xSpanU " << eIter->GetOverlapResult().GetXOverlap().GetXSpanU()
69  << ", xSpanV " << eIter->GetOverlapResult().GetXOverlap().GetXSpanV()
70  << ", xSpanW " << eIter->GetOverlapResult().GetXOverlap().GetXSpanW()
71  << ", xOverlapSpan " << eIter->GetOverlapResult().GetXOverlap().GetXOverlapSpan() << std::endl;
72 
74  {
75  const ClusterList clusterListU(1, eIter->GetClusterU()), clusterListV(1, eIter->GetClusterV()), clusterListW(1, eIter->GetClusterW());
76  PANDORA_MONITORING_API(SetEveDisplayParameters(this->GetPandora(), false, DETECTOR_VIEW_XZ, -1.f, -1.f, 1.f));
77  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &clusterListU, "UCluster", RED));
78  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &clusterListV, "VCluster", GREEN));
79  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &clusterListW, "WCluster", BLUE));
80  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
81  }
82  }
83 
84  std::cout << " All Connected Clusters " << std::endl;
85  PANDORA_MONITORING_API(SetEveDisplayParameters(this->GetPandora(), false, DETECTOR_VIEW_XZ, -1.f, -1.f, 1.f));
86  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &allClusterListU, "AllUClusters", RED));
87  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &allClusterListV, "AllVClusters", GREEN));
88  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &allClusterListW, "AllWClusters", BLUE));
89 
90  if (m_showContext)
91  {
92  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &(pAlgorithm->GetInputClusterListU()), "InputClusterListU", GRAY));
93  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &(pAlgorithm->GetInputClusterListV()), "InputClusterListV", GRAY));
94  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &(pAlgorithm->GetInputClusterListW()), "InputClusterListW", GRAY));
95  }
96 
97  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
98  }
99 
100  return false;
101 }
102 
103 //------------------------------------------------------------------------------------------------------------------------------------------
104 
105 StatusCode TransverseTensorVisualizationTool::ReadSettings(const TiXmlHandle xmlHandle)
106 {
107  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
108  "MinClusterConnections", m_minClusterConnections));
109 
110  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
111  "IgnoreUnavailableClusters", m_ignoreUnavailableClusters));
112 
113  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
114  "ShowEachIndividualElement", m_showEachIndividualElement));
115 
116  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
117  "ShowContext", m_showContext));
118 
119  return STATUS_CODE_SUCCESS;
120 }
121 
122 } // namespace lar_content
const pandora::ClusterList & GetInputClusterListW() const
Get the input w cluster list.
Header file for the transverse tensor visualization tool class.
bool m_showContext
Whether to show input cluster lists to add context to tensor elements.
bool m_ignoreUnavailableClusters
Whether to ignore (skip-over) unavailable clusters in the tensor.
void GetConnectedElements(const pandora::Cluster *const pCluster, const bool ignoreUnavailable, ElementList &elementList) const
Get a list of elements connected to a specified cluster.
bool Run(ThreeDTransverseTracksAlgorithm *const pAlgorithm, TensorType &overlapTensor)
Run the algorithm tool.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
TFile f
Definition: plotHisto.C:6
const pandora::ClusterList & GetInputClusterListV() const
Get the input v cluster list.
const pandora::ClusterList & GetInputClusterListU() const
Get the input u cluster list.
void GetSortedKeyClusters(pandora::ClusterVector &sortedKeyClusters) const
Get a sorted vector of key clusters (U clusters with current implementation)
bool m_showEachIndividualElement
Whether to draw each individual tensor element.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
unsigned int m_minClusterConnections
The minimum number of cluster connections for display.