LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::ConnectedRemnantsTool Class Reference

ConnectedRemnantsTool class. More...

#include "ConnectedRemnantsTool.h"

Inheritance diagram for lar_content::ConnectedRemnantsTool:
lar_content::RemnantTensorTool

Public Types

typedef ThreeViewRemnantsAlgorithm::MatchingType::TensorType TensorType
 
typedef std::vector< TensorType::ElementList::const_iteratorIteratorList
 

Public Member Functions

 ConnectedRemnantsTool ()
 Default constructor. More...
 
bool Run (ThreeViewRemnantsAlgorithm *const pAlgorithm, TensorType &overlapTensor)
 Run the algorithm tool. More...
 

Private Member Functions

pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
void FindConnectedShowers (const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector, ClusterMergeMap &clusterMergeMap) const
 Identify candidate particles. More...
 
void GetClusters (const TensorType::ElementList &connectedElements, const pandora::ClusterSet &usedClusters, pandora::ClusterVector &clusterVectorU, pandora::ClusterVector &clusterVectorV, pandora::ClusterVector &clusterVectorW) const
 Separate connected clusters into cluster lists by view. More...
 
void FillMergeMap (const pandora::Cluster *const pCluster, const pandora::ClusterVector &clusterVector, ClusterMergeMap &clusterMergeMap) const
 Fill map of clusters to be merged. More...
 
bool IsConnected (const pandora::ClusterVector &clusterVector) const
 Check whether all clusters in a list are spatially connected. More...
 

Private Attributes

float m_maxClusterSeparation
 

Detailed Description

ConnectedRemnantsTool class.

Definition at line 19 of file ConnectedRemnantsTool.h.

Member Typedef Documentation

Constructor & Destructor Documentation

lar_content::ConnectedRemnantsTool::ConnectedRemnantsTool ( )

Default constructor.

Definition at line 20 of file ConnectedRemnantsTool.cc.

20  :
22 {
23 }
TFile f
Definition: plotHisto.C:6

Member Function Documentation

void lar_content::ConnectedRemnantsTool::FillMergeMap ( const pandora::Cluster *const  pCluster,
const pandora::ClusterVector &  clusterVector,
ClusterMergeMap clusterMergeMap 
) const
private

Fill map of clusters to be merged.

Parameters
clusterVectorthe input vector of clusters
clusterMergeMapthe output map of cluster merges

Definition at line 106 of file ConnectedRemnantsTool.cc.

Referenced by FindConnectedShowers().

107 {
108  if (clusterVector.empty())
109  throw StatusCodeException(STATUS_CODE_FAILURE);
110 
111  for (const Cluster *const pSecondCluster : clusterVector)
112  {
113  if (pFirstCluster == pSecondCluster)
114  continue;
115 
116  ClusterList &clusterList(clusterMergeMap[pFirstCluster]);
117 
118  if (clusterList.end() == std::find(clusterList.begin(), clusterList.end(), pSecondCluster))
119  clusterList.push_back(pSecondCluster);
120  }
121 }
void lar_content::ConnectedRemnantsTool::FindConnectedShowers ( const TensorType overlapTensor,
ProtoParticleVector protoParticleVector,
ClusterMergeMap clusterMergeMap 
) const
private

Identify candidate particles.

Parameters
overlapTensorthe input overlap tensor
protoParticleVectorthe output vector of candidate particles
clusterMergeMapthe output map of clusters to be merged

Definition at line 44 of file ConnectedRemnantsTool.cc.

References FillMergeMap(), GetClusters(), lar_content::OverlapTensor< T >::GetConnectedElements(), lar_content::OverlapTensor< T >::GetSortedKeyClusters(), IsConnected(), and lar_content::ProtoParticle::m_clusterList.

Referenced by Run().

46 {
47  ClusterSet usedClusters;
48  ClusterVector sortedKeyClusters;
49  overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
50 
51  for (const Cluster *const pKeyCluster : sortedKeyClusters)
52  {
53  if (!pKeyCluster->IsAvailable())
54  continue;
55 
56  TensorType::ElementList connectedElements;
57  overlapTensor.GetConnectedElements(pKeyCluster, true, connectedElements);
58 
59  ClusterVector clusterVectorU, clusterVectorV, clusterVectorW;
60  this->GetClusters(connectedElements, usedClusters, clusterVectorU, clusterVectorV, clusterVectorW);
61 
62  if (clusterVectorU.empty() || clusterVectorV.empty() || clusterVectorW.empty())
63  continue;
64 
65  usedClusters.insert(clusterVectorU.begin(), clusterVectorU.end());
66  usedClusters.insert(clusterVectorV.begin(), clusterVectorV.end());
67  usedClusters.insert(clusterVectorW.begin(), clusterVectorW.end());
68 
69  if (!(this->IsConnected(clusterVectorU) && this->IsConnected(clusterVectorV) && this->IsConnected(clusterVectorW)))
70  continue;
71 
72  const Cluster *const pClusterU = clusterVectorU.front();
73  const Cluster *const pClusterV = clusterVectorV.front();
74  const Cluster *const pClusterW = clusterVectorW.front();
75 
76  ProtoParticle protoParticle;
77  protoParticle.m_clusterList.push_back(pClusterU);
78  protoParticle.m_clusterList.push_back(pClusterV);
79  protoParticle.m_clusterList.push_back(pClusterW);
80  protoParticleVector.push_back(protoParticle);
81 
82  this->FillMergeMap(pClusterU, clusterVectorU, clusterMergeMap);
83  this->FillMergeMap(pClusterV, clusterVectorV, clusterMergeMap);
84  this->FillMergeMap(pClusterW, clusterVectorW, clusterMergeMap);
85  }
86 }
void FillMergeMap(const pandora::Cluster *const pCluster, const pandora::ClusterVector &clusterVector, ClusterMergeMap &clusterMergeMap) const
Fill map of clusters to be merged.
std::vector< Element > ElementList
void GetClusters(const TensorType::ElementList &connectedElements, const pandora::ClusterSet &usedClusters, pandora::ClusterVector &clusterVectorU, pandora::ClusterVector &clusterVectorV, pandora::ClusterVector &clusterVectorW) const
Separate connected clusters into cluster lists by view.
bool IsConnected(const pandora::ClusterVector &clusterVector) const
Check whether all clusters in a list are spatially connected.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void lar_content::ConnectedRemnantsTool::GetClusters ( const TensorType::ElementList connectedElements,
const pandora::ClusterSet &  usedClusters,
pandora::ClusterVector &  clusterVectorU,
pandora::ClusterVector &  clusterVectorV,
pandora::ClusterVector &  clusterVectorW 
) const
private

Separate connected clusters into cluster lists by view.

Parameters
connectedElementsthe input list of connected elements
usedClustersthe list of clusters already analysed
clusterVectorUthe output vector of clusters for the U view
clusterVectorVthe output vector of clusters for the V view
clusterVectorWthe output vector of clusters for the W view

Definition at line 90 of file ConnectedRemnantsTool.cc.

Referenced by FindConnectedShowers().

92 {
93  for (const TensorType::Element &element : elementList)
94  {
95  if (usedClusters.count(element.GetClusterU()) || usedClusters.count(element.GetClusterV()) || usedClusters.count(element.GetClusterW()))
96  continue;
97 
98  clusterVectorU.push_back(element.GetClusterU());
99  clusterVectorV.push_back(element.GetClusterV());
100  clusterVectorW.push_back(element.GetClusterW());
101  }
102 }
bool lar_content::ConnectedRemnantsTool::IsConnected ( const pandora::ClusterVector &  clusterVector) const
private

Check whether all clusters in a list are spatially connected.

Parameters
clusterVectorthe input cluster vector

Definition at line 125 of file ConnectedRemnantsTool.cc.

References lar_content::LArClusterHelper::GetClosestDistance(), and m_maxClusterSeparation.

Referenced by FindConnectedShowers().

126 {
127  for (const Cluster *const pCluster1 : clusterVector)
128  {
129  for (const Cluster *const pCluster2 : clusterVector)
130  {
131  if (pCluster1 == pCluster2)
132  continue;
133 
135  return false;
136  }
137  }
138 
139  return true;
140 }
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
StatusCode lar_content::ConnectedRemnantsTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 144 of file ConnectedRemnantsTool.cc.

References m_maxClusterSeparation.

145 {
146  PANDORA_RETURN_RESULT_IF_AND_IF(
147  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxClusterSeparation", m_maxClusterSeparation));
148 
149  return STATUS_CODE_SUCCESS;
150 }
bool lar_content::ConnectedRemnantsTool::Run ( ThreeViewRemnantsAlgorithm *const  pAlgorithm,
TensorType overlapTensor 
)
virtual

Run the algorithm tool.

Parameters
pAlgorithmaddress of the calling algorithm
overlapTensorthe overlap tensor
Returns
whether changes have been made by the tool

Implements lar_content::RemnantTensorTool.

Definition at line 27 of file ConnectedRemnantsTool.cc.

References lar_content::MatchingBaseAlgorithm::CreateThreeDParticles(), FindConnectedShowers(), and lar_content::MatchingBaseAlgorithm::MakeClusterMerges().

28 {
29  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
30  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
31 
32  ProtoParticleVector protoParticleVector;
33  ClusterMergeMap clusterMergeMap;
34  this->FindConnectedShowers(overlapTensor, protoParticleVector, clusterMergeMap);
35 
36  const bool particlesMade(pAlgorithm->CreateThreeDParticles(protoParticleVector));
37  const bool mergesMade(pAlgorithm->MakeClusterMerges(clusterMergeMap));
38 
39  return (particlesMade || mergesMade);
40 }
std::vector< ProtoParticle > ProtoParticleVector
void FindConnectedShowers(const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector, ClusterMergeMap &clusterMergeMap) const
Identify candidate particles.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap

Member Data Documentation

float lar_content::ConnectedRemnantsTool::m_maxClusterSeparation
private

Definition at line 68 of file ConnectedRemnantsTool.h.

Referenced by IsConnected(), and ReadSettings().


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