All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ShowerTensorVisualizationTool.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArMonitoring/ShowerTensorVisualizationTool.cc
3  *
4  * @brief Implementation of the shower tensor visualization tool class.
5  *
6  * $Log: $
7  */
8 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
13 using namespace pandora;
14 
15 namespace lar_content
16 {
17 
18 ShowerTensorVisualizationTool::ShowerTensorVisualizationTool() :
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()))
62  allClusterListU.push_back(eIter->GetClusterU());
63  if (allClusterListV.end() == std::find(allClusterListV.begin(), allClusterListV.end(), eIter->GetClusterV()))
64  allClusterListV.push_back(eIter->GetClusterV());
65  if (allClusterListW.end() == std::find(allClusterListW.begin(), allClusterListW.end(), eIter->GetClusterW()))
66  allClusterListW.push_back(eIter->GetClusterW());
67  usedKeyClusters.insert(eIter->GetClusterU());
68 
69  std::cout << " Element " << counter++ << ": MatchedFraction " << eIter->GetOverlapResult().GetMatchedFraction()
70  << ", MatchedSamplingPoints " << eIter->GetOverlapResult().GetNMatchedSamplingPoints() << ", xSpanU "
71  << eIter->GetOverlapResult().GetXOverlap().GetXSpanU() << ", xSpanV " << eIter->GetOverlapResult().GetXOverlap().GetXSpanV()
72  << ", xSpanW " << eIter->GetOverlapResult().GetXOverlap().GetXSpanW() << ", xOverlapSpan "
73  << eIter->GetOverlapResult().GetXOverlap().GetXOverlapSpan() << ", Availability (" << eIter->GetClusterU()->IsAvailable()
74  << eIter->GetClusterV()->IsAvailable() << eIter->GetClusterW()->IsAvailable() << ") "
75  << ", TrackFlags (" << (MU_MINUS == std::abs(eIter->GetClusterU()->GetParticleId()))
76  << (MU_MINUS == std::abs(eIter->GetClusterV()->GetParticleId()))
77  << (MU_MINUS == std::abs(eIter->GetClusterW()->GetParticleId())) << ") " << std::endl;
78 
80  {
81  const ClusterList clusterListU(1, eIter->GetClusterU()), clusterListV(1, eIter->GetClusterV()),
82  clusterListW(1, eIter->GetClusterW());
83  PANDORA_MONITORING_API(SetEveDisplayParameters(this->GetPandora(), false, DETECTOR_VIEW_XZ, -1.f, -1.f, 1.f));
84  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &clusterListU, "UCluster", RED));
85  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &clusterListV, "VCluster", GREEN));
86  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &clusterListW, "WCluster", BLUE));
87  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
88  }
89  }
90 
91  std::cout << " All Connected Clusters " << std::endl;
92  PANDORA_MONITORING_API(SetEveDisplayParameters(this->GetPandora(), false, DETECTOR_VIEW_XZ, -1.f, -1.f, 1.f));
93  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &allClusterListU, "AllUClusters", RED));
94  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &allClusterListV, "AllVClusters", GREEN));
95  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &allClusterListW, "AllWClusters", BLUE));
96 
97  if (m_showContext)
98  {
99  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &(pAlgorithm->GetInputClusterList(TPC_VIEW_U)), "InputClusterListU", GRAY));
100  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &(pAlgorithm->GetInputClusterList(TPC_VIEW_V)), "InputClusterListV", GRAY));
101  PANDORA_MONITORING_API(VisualizeClusters(this->GetPandora(), &(pAlgorithm->GetInputClusterList(TPC_VIEW_W)), "InputClusterListW", GRAY));
102  }
103 
104  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
105  }
106 
107  return false;
108 }
109 
110 //------------------------------------------------------------------------------------------------------------------------------------------
111 
112 StatusCode ShowerTensorVisualizationTool::ReadSettings(const TiXmlHandle xmlHandle)
113 {
114  PANDORA_RETURN_RESULT_IF_AND_IF(
115  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterConnections", m_minClusterConnections));
116 
117  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
118  XmlHelper::ReadValue(xmlHandle, "IgnoreUnavailableClusters", m_ignoreUnavailableClusters));
119 
120  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
121  XmlHelper::ReadValue(xmlHandle, "ShowEachIndividualElement", m_showEachIndividualElement));
122 
123  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ShowContext", m_showContext));
124 
125  return STATUS_CODE_SUCCESS;
126 }
127 
128 } // namespace lar_content
unsigned int m_minClusterConnections
The minimum number of cluster connections for display.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
void GetConnectedElements(const pandora::Cluster *const pCluster, const bool ignoreUnavailable, ElementList &elementList) const
Get a list of elements connected to a specified cluster.
T abs(T value)
bool m_ignoreUnavailableClusters
Whether to ignore (skip-over) unavailable clusters in the tensor.
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:285
const pandora::ClusterList & GetInputClusterList(const pandora::HitType hitType) const
Get the input cluster list corresponding to a specified hit type.
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)
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
Definition: reco_sbnd.fcl:182
bool m_showEachIndividualElement
Whether to draw each individual tensor element.
Header file for the shower tensor visualization tool class.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
bool m_showContext
Whether to show input cluster lists to add context to tensor elements.
BEGIN_PROLOG don t mess with this pandoraTrackGausCryoW true
BEGIN_PROLOG could also be cout