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

ConnectedRemnantsTool class. More...

#include <ConnectedRemnantsTool.h>

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

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
 

Additional Inherited Members

- Public Types inherited from lar_content::RemnantTensorTool
typedef ThreeViewRemnantsAlgorithm::MatchingType::TensorType TensorType
 
typedef std::vector< TensorType::ElementList::const_iteratorIteratorList
 

Detailed Description

ConnectedRemnantsTool class.

Definition at line 19 of file ConnectedRemnantsTool.h.

Constructor & Destructor Documentation

lar_content::ConnectedRemnantsTool::ConnectedRemnantsTool ( )

Default constructor.

Definition at line 20 of file ConnectedRemnantsTool.cc.

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 105 of file ConnectedRemnantsTool.cc.

106 {
107  if (clusterVector.empty())
108  throw StatusCodeException(STATUS_CODE_FAILURE);
109 
110  for (const Cluster *const pSecondCluster : clusterVector)
111  {
112  if (pFirstCluster == pSecondCluster)
113  continue;
114 
115  ClusterList &clusterList(clusterMergeMap[pFirstCluster]);
116 
117  if (clusterList.end() == std::find(clusterList.begin(), clusterList.end(), pSecondCluster))
118  clusterList.push_back(pSecondCluster);
119  }
120 }
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 43 of file ConnectedRemnantsTool.cc.

45 {
46  ClusterSet usedClusters;
47  ClusterVector sortedKeyClusters;
48  overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
49 
50  for (const Cluster *const pKeyCluster : sortedKeyClusters)
51  {
52  if (!pKeyCluster->IsAvailable())
53  continue;
54 
55  TensorType::ElementList connectedElements;
56  overlapTensor.GetConnectedElements(pKeyCluster, true, connectedElements);
57 
58  ClusterVector clusterVectorU, clusterVectorV, clusterVectorW;
59  this->GetClusters(connectedElements, usedClusters, clusterVectorU, clusterVectorV, clusterVectorW);
60 
61  if (clusterVectorU.empty() || clusterVectorV.empty() || clusterVectorW.empty())
62  continue;
63 
64  usedClusters.insert(clusterVectorU.begin(), clusterVectorU.end());
65  usedClusters.insert(clusterVectorV.begin(), clusterVectorV.end());
66  usedClusters.insert(clusterVectorW.begin(), clusterVectorW.end());
67 
68  if (!(this->IsConnected(clusterVectorU) && this->IsConnected(clusterVectorV) && this->IsConnected(clusterVectorW)))
69  continue;
70 
71  const Cluster *const pClusterU = clusterVectorU.front();
72  const Cluster *const pClusterV = clusterVectorV.front();
73  const Cluster *const pClusterW = clusterVectorW.front();
74 
75  ProtoParticle protoParticle;
76  protoParticle.m_clusterList.push_back(pClusterU);
77  protoParticle.m_clusterList.push_back(pClusterV);
78  protoParticle.m_clusterList.push_back(pClusterW);
79  protoParticleVector.push_back(protoParticle);
80 
81  this->FillMergeMap(pClusterU, clusterVectorU, clusterMergeMap);
82  this->FillMergeMap(pClusterV, clusterVectorV, clusterMergeMap);
83  this->FillMergeMap(pClusterW, clusterVectorW, clusterMergeMap);
84  }
85 }
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 89 of file ConnectedRemnantsTool.cc.

91 {
92  for (const TensorType::Element &element : elementList)
93  {
94  if (usedClusters.count(element.GetClusterU()) || usedClusters.count(element.GetClusterV()) || usedClusters.count(element.GetClusterW()))
95  continue;
96 
97  clusterVectorU.push_back(element.GetClusterU());
98  clusterVectorV.push_back(element.GetClusterV());
99  clusterVectorW.push_back(element.GetClusterW());
100  }
101 }
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 124 of file ConnectedRemnantsTool.cc.

125 {
126  for (const Cluster *const pCluster1 : clusterVector)
127  {
128  for (const Cluster *const pCluster2 : clusterVector)
129  {
130  if (pCluster1 == pCluster2)
131  continue;
132 
134  return false;
135  }
136  }
137 
138  return true;
139 }
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 143 of file ConnectedRemnantsTool.cc.

144 {
145  PANDORA_RETURN_RESULT_IF_AND_IF(
146  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxClusterSeparation", m_maxClusterSeparation));
147 
148  return STATUS_CODE_SUCCESS;
149 }
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 26 of file ConnectedRemnantsTool.cc.

27 {
28  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
29  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
30 
31  ProtoParticleVector protoParticleVector;
32  ClusterMergeMap clusterMergeMap;
33  this->FindConnectedShowers(overlapTensor, protoParticleVector, clusterMergeMap);
34 
35  const bool particlesMade(pAlgorithm->CreateThreeDParticles(protoParticleVector));
36  const bool mergesMade(pAlgorithm->MakeClusterMerges(clusterMergeMap));
37 
38  return (particlesMade || mergesMade);
39 }
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
QTextStream & endl(QTextStream &s)

Member Data Documentation

float lar_content::ConnectedRemnantsTool::m_maxClusterSeparation
private

Definition at line 68 of file ConnectedRemnantsTool.h.


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