LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
lar_content::ClearShowersTool Class Reference

ClearShowersTool class. More...

#include "ClearShowersTool.h"

Inheritance diagram for lar_content::ClearShowersTool:
lar_content::ShowerTensorTool

Public Types

typedef ThreeDShowersAlgorithm::TensorType TensorType
 
typedef std::vector< TensorType::ElementList::const_iteratorIteratorList
 

Public Member Functions

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

Static Public Member Functions

static bool HasLargeDirectConnections (IteratorList::const_iterator iIter, const IteratorList &iteratorList)
 Whether a large shower-like element shares clusters with any other long elements. More...
 
static bool IsLargerThanDirectConnections (IteratorList::const_iterator iIter, const TensorType::ElementList &elementList, const unsigned int minMatchedSamplingPointRatio, const float minXOverlapSpanRatio, const pandora::ClusterSet &usedClusters)
 Whether a large shower-like element is significantly larger that other elements with which it shares a cluster. More...
 

Private Member Functions

pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
void FindClearShowers (const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector) const
 Find clear shower matches, hidden by simple ambiguities in the tensor. More...
 
void SelectLargeShowerElements (const TensorType::ElementList &elementList, const pandora::ClusterSet &usedClusters, IteratorList &iteratorList) const
 Select a list of large shower-like elements from a set of connected tensor elements. More...
 

Private Attributes

float m_minMatchedFraction
 The min matched sampling point fraction for particle creation. More...
 
unsigned int m_minMatchedSamplingPoints
 The min number of matched sampling points for particle creation. More...
 
float m_minXOverlapFraction
 The min x overlap fraction (in each view) for particle creation. More...
 
unsigned int m_minMatchedSamplingPointRatio
 The min ratio between 1st and 2nd highest msps for simple ambiguity resolution. More...
 
float m_minXOverlapSpanRatio
 The min ratio between 1st and 2nd highest x-overlap spans for simple ambiguity resolution. More...
 

Detailed Description

ClearShowersTool class.

Definition at line 19 of file ClearShowersTool.h.

Member Typedef Documentation

Constructor & Destructor Documentation

lar_content::ClearShowersTool::ClearShowersTool ( )

Default constructor.

Definition at line 18 of file ClearShowersTool.cc.

18  :
24 {
25 }
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
float m_minXOverlapSpanRatio
The min ratio between 1st and 2nd highest x-overlap spans for simple ambiguity resolution.
TFile f
Definition: plotHisto.C:6
unsigned int m_minMatchedSamplingPoints
The min number of matched sampling points for particle creation.
float m_minXOverlapFraction
The min x overlap fraction (in each view) for particle creation.
unsigned int m_minMatchedSamplingPointRatio
The min ratio between 1st and 2nd highest msps for simple ambiguity resolution.

Member Function Documentation

void lar_content::ClearShowersTool::FindClearShowers ( const TensorType overlapTensor,
ProtoParticleVector protoParticleVector 
) const
private

Find clear shower matches, hidden by simple ambiguities in the tensor.

Parameters
overlapTensorthe overlap tensor
protoParticleVectorto receive the list of proto particles

Definition at line 88 of file ClearShowersTool.cc.

References lar_content::OverlapTensor< T >::GetConnectedElements(), lar_content::OverlapTensor< T >::GetSortedKeyClusters(), HasLargeDirectConnections(), IsLargerThanDirectConnections(), lar_content::ProtoParticle::m_clusterListU, lar_content::ProtoParticle::m_clusterListV, lar_content::ProtoParticle::m_clusterListW, m_minMatchedSamplingPointRatio, m_minXOverlapSpanRatio, and SelectLargeShowerElements().

Referenced by Run().

89 {
90  ClusterSet usedClusters;
91  ClusterVector sortedKeyClusters;
92  overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
93 
94  for (const Cluster *const pKeyCluster : sortedKeyClusters)
95  {
96  if (!pKeyCluster->IsAvailable())
97  continue;
98 
99  unsigned int nU(0), nV(0), nW(0);
100  TensorType::ElementList elementList;
101  overlapTensor.GetConnectedElements(pKeyCluster, true, elementList, nU, nV, nW);
102 
103  IteratorList iteratorList;
104  this->SelectLargeShowerElements(elementList, usedClusters, iteratorList);
105 
106  // Check that elements are not directly connected and are significantly longer than any other directly connected elements
107  for (IteratorList::const_iterator iIter = iteratorList.begin(), iIterEnd = iteratorList.end(); iIter != iIterEnd; ++iIter)
108  {
109  if (ClearShowersTool::HasLargeDirectConnections(iIter, iteratorList))
110  continue;
111 
113  continue;
114 
115  ProtoParticle protoParticle;
116  protoParticle.m_clusterListU.push_back((*iIter)->GetClusterU());
117  protoParticle.m_clusterListV.push_back((*iIter)->GetClusterV());
118  protoParticle.m_clusterListW.push_back((*iIter)->GetClusterW());
119  protoParticleVector.push_back(protoParticle);
120 
121  usedClusters.insert((*iIter)->GetClusterU());
122  usedClusters.insert((*iIter)->GetClusterV());
123  usedClusters.insert((*iIter)->GetClusterW());
124  }
125  }
126 }
static bool IsLargerThanDirectConnections(IteratorList::const_iterator iIter, const TensorType::ElementList &elementList, const unsigned int minMatchedSamplingPointRatio, const float minXOverlapSpanRatio, const pandora::ClusterSet &usedClusters)
Whether a large shower-like element is significantly larger that other elements with which it shares ...
void SelectLargeShowerElements(const TensorType::ElementList &elementList, const pandora::ClusterSet &usedClusters, IteratorList &iteratorList) const
Select a list of large shower-like elements from a set of connected tensor elements.
float m_minXOverlapSpanRatio
The min ratio between 1st and 2nd highest x-overlap spans for simple ambiguity resolution.
std::vector< TensorType::ElementList::const_iterator > IteratorList
intermediate_table::const_iterator const_iterator
static bool HasLargeDirectConnections(IteratorList::const_iterator iIter, const IteratorList &iteratorList)
Whether a large shower-like element shares clusters with any other long elements. ...
std::vector< art::Ptr< recob::Cluster > > ClusterVector
unsigned int m_minMatchedSamplingPointRatio
The min ratio between 1st and 2nd highest msps for simple ambiguity resolution.
bool lar_content::ClearShowersTool::HasLargeDirectConnections ( IteratorList::const_iterator  iIter,
const IteratorList iteratorList 
)
static

Whether a large shower-like element shares clusters with any other long elements.

Parameters
iIterspecifies the large element under consideration
iteratorListlist of iterators to other large elements
Returns
boolean

Definition at line 29 of file ClearShowersTool.cc.

Referenced by FindClearShowers().

30 {
31  for (IteratorList::const_iterator iIter2 = iteratorList.begin(), iIter2End = iteratorList.end(); iIter2 != iIter2End; ++iIter2)
32  {
33  if (iIter == iIter2)
34  continue;
35 
36  if (((*iIter)->GetClusterU() == (*iIter2)->GetClusterU()) || ((*iIter)->GetClusterV() == (*iIter2)->GetClusterV()) || ((*iIter)->GetClusterW() == (*iIter2)->GetClusterW()) )
37  return true;
38  }
39 
40  return false;
41 }
intermediate_table::const_iterator const_iterator
bool lar_content::ClearShowersTool::IsLargerThanDirectConnections ( IteratorList::const_iterator  iIter,
const TensorType::ElementList elementList,
const unsigned int  minMatchedSamplingPointRatio,
const float  minXOverlapSpanRatio,
const pandora::ClusterSet &  usedClusters 
)
static

Whether a large shower-like element is significantly larger that other elements with which it shares a cluster.

Parameters
iIterspecifies the large element under consideration
elementListthe full list of connected tensor elements
minMatchedSamplingPointRatiothe min ratio between 1st and 2nd highest msps for simple ambiguity resolution
minMatchedSamplingPointRatiothe min ratio between 1st and 2nd highest x-overlap spans for simple ambiguity resolution
usedClustersthe list of clusters already marked as to be added to a pfo

Definition at line 45 of file ClearShowersTool.cc.

Referenced by FindClearShowers().

47 {
48  const unsigned int nMatchedSamplingPoints((*iIter)->GetOverlapResult().GetNMatchedSamplingPoints());
49  const unsigned int xOverlapSpan((*iIter)->GetOverlapResult().GetXOverlap().GetXOverlapSpan());
50 
51  for (TensorType::ElementList::const_iterator eIter = elementList.begin(); eIter != elementList.end(); ++eIter)
52  {
53  if ((*iIter) == eIter)
54  continue;
55 
56  if (usedClusters.count(eIter->GetClusterU()) || usedClusters.count(eIter->GetClusterV()) || usedClusters.count(eIter->GetClusterW()))
57  continue;
58 
59  if (((*iIter)->GetClusterU() != eIter->GetClusterU()) && ((*iIter)->GetClusterV() != eIter->GetClusterV()) && ((*iIter)->GetClusterW() != eIter->GetClusterW()))
60  continue;
61 
62  if (nMatchedSamplingPoints < minMatchedSamplingPointRatio * eIter->GetOverlapResult().GetNMatchedSamplingPoints())
63  return false;
64 
65  if (xOverlapSpan < minXOverlapSpanRatio * eIter->GetOverlapResult().GetXOverlap().GetXOverlapSpan())
66  return false;
67  }
68 
69  return true;
70 }
intermediate_table::const_iterator const_iterator
StatusCode lar_content::ClearShowersTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 157 of file ClearShowersTool.cc.

References m_minMatchedFraction, m_minMatchedSamplingPointRatio, m_minMatchedSamplingPoints, m_minXOverlapFraction, and m_minXOverlapSpanRatio.

158 {
159  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
160  "MinMatchedFraction", m_minMatchedFraction));
161 
162  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
163  "MinMatchedSamplingPoints", m_minMatchedSamplingPoints));
164 
165  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
166  "MinXOverlapFraction", m_minXOverlapFraction));
167 
168  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
169  "MinMatchedSamplingPointRatio", m_minMatchedSamplingPointRatio));
170 
171  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
172  "MinXOverlapSpanRatio", m_minXOverlapSpanRatio));
173 
174  return STATUS_CODE_SUCCESS;
175 }
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
float m_minXOverlapSpanRatio
The min ratio between 1st and 2nd highest x-overlap spans for simple ambiguity resolution.
unsigned int m_minMatchedSamplingPoints
The min number of matched sampling points for particle creation.
float m_minXOverlapFraction
The min x overlap fraction (in each view) for particle creation.
unsigned int m_minMatchedSamplingPointRatio
The min ratio between 1st and 2nd highest msps for simple ambiguity resolution.
bool lar_content::ClearShowersTool::Run ( ThreeDShowersAlgorithm *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::ShowerTensorTool.

Definition at line 74 of file ClearShowersTool.cc.

References lar_content::ThreeDBaseAlgorithm< T >::CreateThreeDParticles(), and FindClearShowers().

75 {
76  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
77  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
78 
79  ProtoParticleVector protoParticleVector;
80  this->FindClearShowers(overlapTensor, protoParticleVector);
81 
82  const bool particlesMade(pAlgorithm->CreateThreeDParticles(protoParticleVector));
83  return particlesMade;
84 }
std::vector< ProtoParticle > ProtoParticleVector
void FindClearShowers(const TensorType &overlapTensor, ProtoParticleVector &protoParticleVector) const
Find clear shower matches, hidden by simple ambiguities in the tensor.
void lar_content::ClearShowersTool::SelectLargeShowerElements ( const TensorType::ElementList elementList,
const pandora::ClusterSet &  usedClusters,
IteratorList iteratorList 
) const
private

Select a list of large shower-like elements from a set of connected tensor elements.

Parameters
elementListthe full list of connected tensor elements
usedClustersthe list of clusters already marked as to be added to a pfo
iteratorListto receive a list of iterators to large shower-like elements

Definition at line 130 of file ClearShowersTool.cc.

References m_minMatchedFraction, m_minMatchedSamplingPoints, and m_minXOverlapFraction.

Referenced by FindClearShowers().

132 {
133  for (TensorType::ElementList::const_iterator eIter = elementList.begin(); eIter != elementList.end(); ++eIter)
134  {
135  if (usedClusters.count(eIter->GetClusterU()) || usedClusters.count(eIter->GetClusterV()) || usedClusters.count(eIter->GetClusterW()))
136  continue;
137 
138  if (eIter->GetOverlapResult().GetMatchedFraction() < m_minMatchedFraction)
139  continue;
140 
141  if (eIter->GetOverlapResult().GetNMatchedSamplingPoints() < m_minMatchedSamplingPoints)
142  continue;
143 
144  const XOverlap &xOverlap(eIter->GetOverlapResult().GetXOverlap());
145 
146  if ((xOverlap.GetXSpanU() > std::numeric_limits<float>::epsilon()) && (xOverlap.GetXOverlapSpan() / xOverlap.GetXSpanU() > m_minXOverlapFraction) &&
147  (xOverlap.GetXSpanV() > std::numeric_limits<float>::epsilon()) && (xOverlap.GetXOverlapSpan() / xOverlap.GetXSpanV() > m_minXOverlapFraction) &&
148  (xOverlap.GetXSpanW() > std::numeric_limits<float>::epsilon()) && (xOverlap.GetXOverlapSpan() / xOverlap.GetXSpanW() > m_minXOverlapFraction))
149  {
150  iteratorList.push_back(eIter);
151  }
152  }
153 }
float m_minMatchedFraction
The min matched sampling point fraction for particle creation.
intermediate_table::const_iterator const_iterator
unsigned int m_minMatchedSamplingPoints
The min number of matched sampling points for particle creation.
float m_minXOverlapFraction
The min x overlap fraction (in each view) for particle creation.

Member Data Documentation

float lar_content::ClearShowersTool::m_minMatchedFraction
private

The min matched sampling point fraction for particle creation.

Definition at line 72 of file ClearShowersTool.h.

Referenced by ReadSettings(), and SelectLargeShowerElements().

unsigned int lar_content::ClearShowersTool::m_minMatchedSamplingPointRatio
private

The min ratio between 1st and 2nd highest msps for simple ambiguity resolution.

Definition at line 75 of file ClearShowersTool.h.

Referenced by FindClearShowers(), and ReadSettings().

unsigned int lar_content::ClearShowersTool::m_minMatchedSamplingPoints
private

The min number of matched sampling points for particle creation.

Definition at line 73 of file ClearShowersTool.h.

Referenced by ReadSettings(), and SelectLargeShowerElements().

float lar_content::ClearShowersTool::m_minXOverlapFraction
private

The min x overlap fraction (in each view) for particle creation.

Definition at line 74 of file ClearShowersTool.h.

Referenced by ReadSettings(), and SelectLargeShowerElements().

float lar_content::ClearShowersTool::m_minXOverlapSpanRatio
private

The min ratio between 1st and 2nd highest x-overlap spans for simple ambiguity resolution.

Definition at line 76 of file ClearShowersTool.h.

Referenced by FindClearShowers(), and ReadSettings().


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