All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
lar_content::TwoViewMatchingControl< T > Class Template Reference

TwoViewMatchingControl class. More...

#include <TwoViewMatchingControl.h>

Inheritance diagram for lar_content::TwoViewMatchingControl< T >:
lar_content::NViewMatchingControl

Public Types

typedef OverlapMatrix< T > MatrixType
 

Public Member Functions

 TwoViewMatchingControl (MatchingBaseAlgorithm *const pAlgorithm)
 Constructor. More...
 
virtual ~TwoViewMatchingControl ()
 Destructor. More...
 
MatrixTypeGetOverlapMatrix ()
 Get the overlap matrix. More...
 
unsigned int GetHitTypeIndex (const pandora::HitType hitType)
 Get the index of an input hit type returning 0 if not found in map. More...
 
- Public Member Functions inherited from lar_content::NViewMatchingControl
 NViewMatchingControl (MatchingBaseAlgorithm *const pAlgorithm)
 Constructor. More...
 
virtual ~NViewMatchingControl ()
 Destructor. More...
 

Private Types

typedef std::unordered_map
< pandora::HitType, unsigned
int, std::hash< int > > 
HitTypeToIndexMap
 

Private Member Functions

void UpdateForNewCluster (const pandora::Cluster *const pNewCluster)
 Update to reflect addition of a new cluster to the problem space. More...
 
void UpdateUponDeletion (const pandora::Cluster *const pDeletedCluster)
 Update to reflect cluster deletion. More...
 
const std::string & GetClusterListName (const pandora::HitType hitType) const
 Get the cluster list name corresponding to a specified hit type. More...
 
const pandora::ClusterList & GetInputClusterList (const pandora::HitType hitType) const
 Get the input cluster list corresponding to a specified hit type. More...
 
const pandora::ClusterList & GetSelectedClusterList (const pandora::HitType hitType) const
 Get the selected cluster list corresponding to a specified hit type. More...
 
void SelectAllInputClusters ()
 Select a subset of input clusters for processing in this algorithm. More...
 
void PrepareAllInputClusters ()
 Perform any preparatory steps required on the input clusters, e.g. caching expensive fit results. More...
 
void PerformMainLoop ()
 Main loop over cluster combinations in order to populate the overlap container. Responsible for calling CalculateOverlapResult. More...
 
void TidyUp ()
 Tidy member variables. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 Read settings from xml. More...
 

Private Attributes

const pandora::ClusterList * m_pInputClusterList1
 Address of the input cluster list 1. More...
 
const pandora::ClusterList * m_pInputClusterList2
 Address of the input cluster list 2. More...
 
pandora::ClusterList m_clusterList1
 The selected modified cluster list 1. More...
 
pandora::ClusterList m_clusterList2
 The selected modified cluster list 2. More...
 
MatrixType m_overlapMatrix
 The overlap matrix. More...
 
HitTypeToIndexMap m_hitTypeToIndexMap
 The hit type to index map. More...
 
std::string m_inputClusterListName1
 The name of the view 1 cluster list. More...
 
std::string m_inputClusterListName2
 The name of the view 2 cluster list. More...
 

Friends

template<typename U >
class NViewMatchingAlgorithm
 

Additional Inherited Members

- Protected Attributes inherited from lar_content::NViewMatchingControl
MatchingBaseAlgorithmm_pAlgorithm
 The address of the matching base algorithm. More...
 

Detailed Description

template<typename T>
class lar_content::TwoViewMatchingControl< T >

TwoViewMatchingControl class.

Definition at line 24 of file TwoViewMatchingControl.h.

Member Typedef Documentation

template<typename T>
typedef std::unordered_map<pandora::HitType, unsigned int, std::hash<int> > lar_content::TwoViewMatchingControl< T >::HitTypeToIndexMap
private

Definition at line 75 of file TwoViewMatchingControl.h.

template<typename T>
typedef OverlapMatrix<T> lar_content::TwoViewMatchingControl< T >::MatrixType

Definition at line 27 of file TwoViewMatchingControl.h.

Constructor & Destructor Documentation

template<typename T >
lar_content::TwoViewMatchingControl< T >::TwoViewMatchingControl ( MatchingBaseAlgorithm *const  pAlgorithm)

Constructor.

Parameters
pAlgorithmaddress of the matching base algorithm

Definition at line 24 of file TwoViewMatchingControl.cc.

24  :
25  NViewMatchingControl(pAlgorithm),
26  m_pInputClusterList1(nullptr),
27  m_pInputClusterList2(nullptr)
28 {
29 }
NViewMatchingControl(MatchingBaseAlgorithm *const pAlgorithm)
Constructor.
const pandora::ClusterList * m_pInputClusterList1
Address of the input cluster list 1.
const pandora::ClusterList * m_pInputClusterList2
Address of the input cluster list 2.
template<typename T >
lar_content::TwoViewMatchingControl< T >::~TwoViewMatchingControl ( )
virtual

Destructor.

Definition at line 34 of file TwoViewMatchingControl.cc.

35 {
36 }

Member Function Documentation

template<typename T>
const std::string & lar_content::TwoViewMatchingControl< T >::GetClusterListName ( const pandora::HitType  hitType) const
privatevirtual

Get the cluster list name corresponding to a specified hit type.

Parameters
hitTypethe hit type
Returns
the cluster list name

Implements lar_content::NViewMatchingControl.

Definition at line 115 of file TwoViewMatchingControl.cc.

116 {
117  HitTypeToIndexMap::const_iterator iter = m_hitTypeToIndexMap.find(hitType);
118  if (m_hitTypeToIndexMap.end() == iter)
119  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
120 
121  if ((1 != iter->second) && (2 != iter->second))
122  throw StatusCodeException(STATUS_CODE_FAILURE);
123 
124  return ((1 == iter->second) ? m_inputClusterListName1 : m_inputClusterListName2);
125 }
std::string m_inputClusterListName2
The name of the view 2 cluster list.
HitTypeToIndexMap m_hitTypeToIndexMap
The hit type to index map.
std::string m_inputClusterListName1
The name of the view 1 cluster list.
template<typename T >
unsigned int lar_content::TwoViewMatchingControl< T >::GetHitTypeIndex ( const pandora::HitType  hitType)

Get the index of an input hit type returning 0 if not found in map.

Returns
the hit type index

Definition at line 49 of file TwoViewMatchingControl.cc.

50 {
51  HitTypeToIndexMap::const_iterator iter = m_hitTypeToIndexMap.find(hitType);
52 
53  if ((iter != m_hitTypeToIndexMap.end()) && (iter->second != 1) && (iter->second != 2))
54  throw StatusCodeException(STATUS_CODE_FAILURE);
55 
56  return iter == m_hitTypeToIndexMap.end() ? 0 : iter->second;
57 }
HitTypeToIndexMap m_hitTypeToIndexMap
The hit type to index map.
template<typename T>
const pandora::ClusterList & lar_content::TwoViewMatchingControl< T >::GetInputClusterList ( const pandora::HitType  hitType) const
privatevirtual

Get the input cluster list corresponding to a specified hit type.

Parameters
hitTypethe hit type
Returns
the input cluster list

Implements lar_content::NViewMatchingControl.

Definition at line 130 of file TwoViewMatchingControl.cc.

131 {
132  HitTypeToIndexMap::const_iterator iter = m_hitTypeToIndexMap.find(hitType);
133  if (m_hitTypeToIndexMap.end() == iter)
134  throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
135 
136  if ((1 == iter->second) && m_pInputClusterList1)
137  return (*m_pInputClusterList1);
138 
139  if ((2 == iter->second) && m_pInputClusterList2)
140  return (*m_pInputClusterList2);
141 
142  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
143 }
const pandora::ClusterList * m_pInputClusterList1
Address of the input cluster list 1.
HitTypeToIndexMap m_hitTypeToIndexMap
The hit type to index map.
const pandora::ClusterList * m_pInputClusterList2
Address of the input cluster list 2.
template<typename T >
TwoViewMatchingControl< T >::MatrixType & lar_content::TwoViewMatchingControl< T >::GetOverlapMatrix ( )

Get the overlap matrix.

Returns
the overlap matrix

Definition at line 41 of file TwoViewMatchingControl.cc.

42 {
43  return m_overlapMatrix;
44 }
MatrixType m_overlapMatrix
The overlap matrix.
template<typename T>
const pandora::ClusterList & lar_content::TwoViewMatchingControl< T >::GetSelectedClusterList ( const pandora::HitType  hitType) const
privatevirtual

Get the selected cluster list corresponding to a specified hit type.

Parameters
hitTypethe hit type
Returns
the selected cluster list

Implements lar_content::NViewMatchingControl.

Definition at line 148 of file TwoViewMatchingControl.cc.

149 {
150  HitTypeToIndexMap::const_iterator iter = m_hitTypeToIndexMap.find(hitType);
151  if (m_hitTypeToIndexMap.end() == iter)
152  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
153 
154  if ((1 != iter->second) && (2 != iter->second))
155  throw StatusCodeException(STATUS_CODE_FAILURE);
156 
157  return ((1 == iter->second) ? m_clusterList1 : m_clusterList2);
158 }
pandora::ClusterList m_clusterList1
The selected modified cluster list 1.
pandora::ClusterList m_clusterList2
The selected modified cluster list 2.
HitTypeToIndexMap m_hitTypeToIndexMap
The hit type to index map.
template<typename T >
void lar_content::TwoViewMatchingControl< T >::PerformMainLoop ( )
privatevirtual

Main loop over cluster combinations in order to populate the overlap container. Responsible for calling CalculateOverlapResult.

Implements lar_content::NViewMatchingControl.

Definition at line 215 of file TwoViewMatchingControl.cc.

216 {
217  ClusterVector clusterVector1(m_clusterList1.begin(), m_clusterList1.end());
218  ClusterVector clusterVector2(m_clusterList2.begin(), m_clusterList2.end());
219  std::sort(clusterVector1.begin(), clusterVector1.end(), LArClusterHelper::SortByNHits);
220  std::sort(clusterVector2.begin(), clusterVector2.end(), LArClusterHelper::SortByNHits);
221 
222  for (const Cluster *const pCluster1 : clusterVector1)
223  {
224  for (const Cluster *const pCluster2 : clusterVector2)
225  m_pAlgorithm->CalculateOverlapResult(pCluster1, pCluster2);
226  }
227 }
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
MatchingBaseAlgorithm * m_pAlgorithm
The address of the matching base algorithm.
virtual void CalculateOverlapResult(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3=nullptr)=0
Calculate cluster overlap result and store in container.
pandora::ClusterList m_clusterList1
The selected modified cluster list 1.
pandora::ClusterList m_clusterList2
The selected modified cluster list 2.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
template<typename T >
void lar_content::TwoViewMatchingControl< T >::PrepareAllInputClusters ( )
privatevirtual

Perform any preparatory steps required on the input clusters, e.g. caching expensive fit results.

Implements lar_content::NViewMatchingControl.

Definition at line 191 of file TwoViewMatchingControl.cc.

192 {
195 }
MatchingBaseAlgorithm * m_pAlgorithm
The address of the matching base algorithm.
pandora::ClusterList m_clusterList1
The selected modified cluster list 1.
pandora::ClusterList m_clusterList2
The selected modified cluster list 2.
virtual void PrepareInputClusters(pandora::ClusterList &preparedClusterList)
Perform any preparatory steps required on the input clusters, e.g. caching expensive fit results...
template<typename T>
StatusCode lar_content::TwoViewMatchingControl< T >::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Read settings from xml.

Parameters
xmlHandlethe xml handle

Implements lar_content::NViewMatchingControl.

Definition at line 232 of file TwoViewMatchingControl.cc.

233 {
234  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListName1", m_inputClusterListName1));
235  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListName2", m_inputClusterListName2));
236 
237  return STATUS_CODE_SUCCESS;
238 }
std::string m_inputClusterListName2
The name of the view 2 cluster list.
std::string m_inputClusterListName1
The name of the view 1 cluster list.
template<typename T >
void lar_content::TwoViewMatchingControl< T >::SelectAllInputClusters ( )
privatevirtual

Select a subset of input clusters for processing in this algorithm.

Implements lar_content::NViewMatchingControl.

Definition at line 163 of file TwoViewMatchingControl.cc.

164 {
165  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=,
166  PandoraContentApi::GetList(*m_pAlgorithm, m_inputClusterListName1, m_pInputClusterList1));
167  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=,
168  PandoraContentApi::GetList(*m_pAlgorithm, m_inputClusterListName2, m_pInputClusterList2));
169 
171  {
172  if (PandoraContentApi::GetSettings(*m_pAlgorithm)->ShouldDisplayAlgorithmInfo())
173  std::cout << "TwoViewMatchingControl: one or more input cluster lists unavailable." << std::endl;
174 
175  throw StatusCodeException(STATUS_CODE_SUCCESS);
176  }
177 
178  if (!m_pInputClusterList1->empty())
179  m_hitTypeToIndexMap.insert(HitTypeToIndexMap::value_type(LArClusterHelper::GetClusterHitType(m_pInputClusterList1->front()), 1));
180 
181  if (!m_pInputClusterList2->empty())
182  m_hitTypeToIndexMap.insert(HitTypeToIndexMap::value_type(LArClusterHelper::GetClusterHitType(m_pInputClusterList2->front()), 2));
183 
186 }
MatchingBaseAlgorithm * m_pAlgorithm
The address of the matching base algorithm.
pandora::ClusterList m_clusterList1
The selected modified cluster list 1.
virtual void SelectInputClusters(const pandora::ClusterList *const pInputClusterList, pandora::ClusterList &selectedClusterList) const
Select a subset of input clusters for processing in this algorithm.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
std::string m_inputClusterListName2
The name of the view 2 cluster list.
const pandora::ClusterList * m_pInputClusterList1
Address of the input cluster list 1.
pandora::ClusterList m_clusterList2
The selected modified cluster list 2.
HitTypeToIndexMap m_hitTypeToIndexMap
The hit type to index map.
std::string m_inputClusterListName1
The name of the view 1 cluster list.
const pandora::ClusterList * m_pInputClusterList2
Address of the input cluster list 2.
BEGIN_PROLOG could also be cout
template<typename T >
void lar_content::TwoViewMatchingControl< T >::TidyUp ( )
privatevirtual

Tidy member variables.

Implements lar_content::NViewMatchingControl.

Definition at line 200 of file TwoViewMatchingControl.cc.

201 {
203  m_hitTypeToIndexMap.clear();
204 
205  m_pInputClusterList1 = nullptr;
206  m_pInputClusterList2 = nullptr;
207 
208  m_clusterList1.clear();
209  m_clusterList2.clear();
210 }
void Clear()
Clear overlap matrix.
pandora::ClusterList m_clusterList1
The selected modified cluster list 1.
MatrixType m_overlapMatrix
The overlap matrix.
const pandora::ClusterList * m_pInputClusterList1
Address of the input cluster list 1.
pandora::ClusterList m_clusterList2
The selected modified cluster list 2.
HitTypeToIndexMap m_hitTypeToIndexMap
The hit type to index map.
const pandora::ClusterList * m_pInputClusterList2
Address of the input cluster list 2.
template<typename T>
void lar_content::TwoViewMatchingControl< T >::UpdateForNewCluster ( const pandora::Cluster *const  pNewCluster)
privatevirtual

Update to reflect addition of a new cluster to the problem space.

Parameters
pNewClusteraddress of the new cluster

Implements lar_content::NViewMatchingControl.

Definition at line 62 of file TwoViewMatchingControl.cc.

63 {
64  const HitType hitType(LArClusterHelper::GetClusterHitType(pNewCluster));
65  HitTypeToIndexMap::const_iterator iter = m_hitTypeToIndexMap.find(hitType);
66 
67  if ((m_hitTypeToIndexMap.end() == iter) || ((1 != iter->second) && (2 != iter->second)))
68  throw StatusCodeException(STATUS_CODE_FAILURE);
69 
70  ClusterList &clusterList((1 == iter->second) ? m_clusterList1 : m_clusterList2);
71 
72  if (clusterList.end() != std::find(clusterList.begin(), clusterList.end(), pNewCluster))
73  throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
74 
75  clusterList.push_back(pNewCluster);
76 
77  const ClusterList &clusterList2((1 == iter->second) ? m_clusterList2 : m_clusterList1);
78 
79  ClusterVector clusterVector2(clusterList2.begin(), clusterList2.end());
80  std::sort(clusterVector2.begin(), clusterVector2.end(), LArClusterHelper::SortByNHits);
81 
82  for (const Cluster *const pCluster2 : clusterVector2)
83  {
84  if (1 == iter->second)
85  {
86  m_pAlgorithm->CalculateOverlapResult(pNewCluster, pCluster2);
87  }
88  else
89  {
90  m_pAlgorithm->CalculateOverlapResult(pCluster2, pNewCluster);
91  }
92  }
93 }
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
MatchingBaseAlgorithm * m_pAlgorithm
The address of the matching base algorithm.
virtual void CalculateOverlapResult(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3=nullptr)=0
Calculate cluster overlap result and store in container.
pandora::ClusterList m_clusterList1
The selected modified cluster list 1.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
pandora::ClusterList m_clusterList2
The selected modified cluster list 2.
HitTypeToIndexMap m_hitTypeToIndexMap
The hit type to index map.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
template<typename T>
void lar_content::TwoViewMatchingControl< T >::UpdateUponDeletion ( const pandora::Cluster *const  pDeletedCluster)
privatevirtual

Update to reflect cluster deletion.

Parameters
pDeletedClusteraddress of the deleted cluster

Implements lar_content::NViewMatchingControl.

Definition at line 98 of file TwoViewMatchingControl.cc.

99 {
100  ClusterList::iterator iter1 = std::find(m_clusterList1.begin(), m_clusterList1.end(), pDeletedCluster);
101  ClusterList::iterator iter2 = std::find(m_clusterList2.begin(), m_clusterList2.end(), pDeletedCluster);
102 
103  if (m_clusterList1.end() != iter1)
104  m_clusterList1.erase(iter1);
105 
106  if (m_clusterList2.end() != iter2)
107  m_clusterList2.erase(iter2);
108 
109  m_overlapMatrix.RemoveCluster(pDeletedCluster);
110 }
void RemoveCluster(const pandora::Cluster *const pCluster)
Remove entries from matrix corresponding to specified cluster.
pandora::ClusterList m_clusterList1
The selected modified cluster list 1.
MatrixType m_overlapMatrix
The overlap matrix.
pandora::ClusterList m_clusterList2
The selected modified cluster list 2.

Friends And Related Function Documentation

template<typename T>
template<typename U >
friend class NViewMatchingAlgorithm
friend

Definition at line 82 of file TwoViewMatchingControl.h.

Member Data Documentation

template<typename T>
pandora::ClusterList lar_content::TwoViewMatchingControl< T >::m_clusterList1
private

The selected modified cluster list 1.

Definition at line 70 of file TwoViewMatchingControl.h.

template<typename T>
pandora::ClusterList lar_content::TwoViewMatchingControl< T >::m_clusterList2
private

The selected modified cluster list 2.

Definition at line 71 of file TwoViewMatchingControl.h.

template<typename T>
HitTypeToIndexMap lar_content::TwoViewMatchingControl< T >::m_hitTypeToIndexMap
private

The hit type to index map.

Definition at line 76 of file TwoViewMatchingControl.h.

template<typename T>
std::string lar_content::TwoViewMatchingControl< T >::m_inputClusterListName1
private

The name of the view 1 cluster list.

Definition at line 78 of file TwoViewMatchingControl.h.

template<typename T>
std::string lar_content::TwoViewMatchingControl< T >::m_inputClusterListName2
private

The name of the view 2 cluster list.

Definition at line 79 of file TwoViewMatchingControl.h.

template<typename T>
MatrixType lar_content::TwoViewMatchingControl< T >::m_overlapMatrix
private

The overlap matrix.

Definition at line 73 of file TwoViewMatchingControl.h.

template<typename T>
const pandora::ClusterList* lar_content::TwoViewMatchingControl< T >::m_pInputClusterList1
private

Address of the input cluster list 1.

Definition at line 67 of file TwoViewMatchingControl.h.

template<typename T>
const pandora::ClusterList* lar_content::TwoViewMatchingControl< T >::m_pInputClusterList2
private

Address of the input cluster list 2.

Definition at line 68 of file TwoViewMatchingControl.h.


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