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

AmbiguousDeltaRayTool class. More...

#include "AmbiguousDeltaRayTool.h"

Inheritance diagram for lar_content::AmbiguousDeltaRayTool:
lar_content::DeltaRayTensorTool

Public Types

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

Public Member Functions

 AmbiguousDeltaRayTool ()
 Default constructor. More...
 

Public Attributes

ThreeViewDeltaRayMatchingAlgorithmm_pParentAlgorithm
 Address of the parent matching algorithm. More...
 

Private Member Functions

bool Run (ThreeViewDeltaRayMatchingAlgorithm *const pAlgorithm, TensorType &overlapTensor)
 Run the algorithm tool. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
void ExamineConnectedElements (TensorType &overlapTensor) const
 Identify ambiguous matches (e.g. 3:2:1) and, if possible, create pfos out of the best 1:1:1 cluster match. More...
 
void PickOutGoodMatches (const TensorType::ElementList &elementList, pandora::ClusterSet &usedClusters, ProtoParticleVector &protoParticleVector) const
 Identify the best 1:1:1 match in a group of connected elements and from it create a pfo. More...
 

Private Attributes

float m_maxGoodMatchReducedChiSquared
 The maximum reduced chi squared value of a good 1:1:1 match. More...
 

Detailed Description

AmbiguousDeltaRayTool class.

Definition at line 18 of file AmbiguousDeltaRayTool.h.

Member Typedef Documentation

Constructor & Destructor Documentation

lar_content::AmbiguousDeltaRayTool::AmbiguousDeltaRayTool ( )

Default constructor.

Definition at line 18 of file AmbiguousDeltaRayTool.cc.

18  :
20 {
21 }
TFile f
Definition: plotHisto.C:6
float m_maxGoodMatchReducedChiSquared
The maximum reduced chi squared value of a good 1:1:1 match.

Member Function Documentation

void lar_content::AmbiguousDeltaRayTool::ExamineConnectedElements ( TensorType overlapTensor) const
private

Identify ambiguous matches (e.g. 3:2:1) and, if possible, create pfos out of the best 1:1:1 cluster match.

Parameters
overlapTensorthe overlap tensor

Definition at line 40 of file AmbiguousDeltaRayTool.cc.

References lar_content::NViewDeltaRayMatchingAlgorithm< T >::CreatePfos(), lar_content::OverlapTensor< T >::GetConnectedElements(), lar_content::OverlapTensor< T >::GetSortedKeyClusters(), lar_content::DeltaRayTensorTool::m_pParentAlgorithm, and PickOutGoodMatches().

Referenced by Run().

41 {
42  ClusterVector sortedKeyClusters;
43  overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
44 
45  ClusterSet usedClusters;
46  ClusterSet usedKeyClusters;
47  ProtoParticleVector protoParticleVector;
48 
49  for (const Cluster *const pKeyCluster : sortedKeyClusters)
50  {
51  if (usedKeyClusters.count(pKeyCluster))
52  continue;
53 
54  TensorType::ElementList elementList;
55  overlapTensor.GetConnectedElements(pKeyCluster, true, elementList);
56 
57  for (const TensorType::Element &element : elementList)
58  usedKeyClusters.insert(element.GetClusterU());
59 
60  if (elementList.size() < 2)
61  continue;
62 
63  this->PickOutGoodMatches(elementList, usedClusters, protoParticleVector);
64  }
65 
66  if (!protoParticleVector.empty())
67  m_pParentAlgorithm->CreatePfos(protoParticleVector);
68 }
std::vector< ProtoParticle > ProtoParticleVector
ThreeViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
bool CreatePfos(ProtoParticleVector &protoParticleVector)
Create delta ray pfos maxmising completeness by searching for and merging in any stray clusters...
void PickOutGoodMatches(const TensorType::ElementList &elementList, pandora::ClusterSet &usedClusters, ProtoParticleVector &protoParticleVector) const
Identify the best 1:1:1 match in a group of connected elements and from it create a pfo...
void lar_content::AmbiguousDeltaRayTool::PickOutGoodMatches ( const TensorType::ElementList elementList,
pandora::ClusterSet &  usedClusters,
ProtoParticleVector protoParticleVector 
) const
private

Identify the best 1:1:1 match in a group of connected elements and from it create a pfo.

Parameters
elementListthe tensor element list
usedClustersthe output list of clusters contained within to be created pfos
protoParticleVectorthe output vector of ProtoParticles

Definition at line 72 of file AmbiguousDeltaRayTool.cc.

References lar_content::ProtoParticle::m_clusterList, and m_maxGoodMatchReducedChiSquared.

Referenced by ExamineConnectedElements().

74 {
75  bool found(false);
76 
77  do
78  {
79  found = false;
80 
81  unsigned int highestHitCount(0);
82  float bestChiSquared(std::numeric_limits<float>::max());
83  const Cluster *pBestClusterU(nullptr), *pBestClusterV(nullptr), *pBestClusterW(nullptr);
84 
85  for (const TensorType::Element &element : elementList)
86  {
87  const Cluster *const pClusterU(element.GetClusterU()), *const pClusterV(element.GetClusterV()), *const pClusterW(element.GetClusterW());
88 
89  if (usedClusters.count(pClusterU) || usedClusters.count(pClusterV) || usedClusters.count(pClusterW))
90  continue;
91 
92  const float chiSquared(element.GetOverlapResult().GetReducedChi2());
93 
94  if (chiSquared > m_maxGoodMatchReducedChiSquared)
95  continue;
96 
97  const unsigned int hitSum(pClusterU->GetNCaloHits() + pClusterV->GetNCaloHits() + pClusterW->GetNCaloHits());
98 
99  if ((hitSum > highestHitCount) || ((hitSum == highestHitCount) && (chiSquared < bestChiSquared)))
100  {
101  bestChiSquared = chiSquared;
102  highestHitCount = hitSum;
103  pBestClusterU = pClusterU;
104  pBestClusterV = pClusterV;
105  pBestClusterW = pClusterW;
106  }
107  }
108 
109  if (pBestClusterU && pBestClusterV && pBestClusterW)
110  {
111  found = true;
112  usedClusters.insert(pBestClusterU);
113  usedClusters.insert(pBestClusterV);
114  usedClusters.insert(pBestClusterW);
115 
116  ProtoParticle protoParticle;
117  protoParticle.m_clusterList.push_back(pBestClusterU);
118  protoParticle.m_clusterList.push_back(pBestClusterV);
119  protoParticle.m_clusterList.push_back(pBestClusterW);
120  protoParticleVector.push_back(protoParticle);
121  }
122  } while (found);
123 }
float m_maxGoodMatchReducedChiSquared
The maximum reduced chi squared value of a good 1:1:1 match.
StatusCode lar_content::AmbiguousDeltaRayTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 127 of file AmbiguousDeltaRayTool.cc.

References m_maxGoodMatchReducedChiSquared.

128 {
129  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
130  XmlHelper::ReadValue(xmlHandle, "MaxGoodMatchReducedChiSquared", m_maxGoodMatchReducedChiSquared));
131 
132  return STATUS_CODE_SUCCESS;
133 }
float m_maxGoodMatchReducedChiSquared
The maximum reduced chi squared value of a good 1:1:1 match.
bool lar_content::AmbiguousDeltaRayTool::Run ( ThreeViewDeltaRayMatchingAlgorithm *const  pAlgorithm,
TensorType overlapTensor 
)
privatevirtual

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::DeltaRayTensorTool.

Definition at line 25 of file AmbiguousDeltaRayTool.cc.

References ExamineConnectedElements(), and lar_content::DeltaRayTensorTool::m_pParentAlgorithm.

26 {
27  m_pParentAlgorithm = pAlgorithm;
28 
29  if (PandoraContentApi::GetSettings(*m_pParentAlgorithm)->ShouldDisplayAlgorithmInfo())
30  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
31 
32  this->ExamineConnectedElements(overlapTensor);
33 
34  // ATTN: Prevent tensor tool loop running again
35  return false;
36 }
void ExamineConnectedElements(TensorType &overlapTensor) const
Identify ambiguous matches (e.g. 3:2:1) and, if possible, create pfos out of the best 1:1:1 cluster m...
ThreeViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.

Member Data Documentation

float lar_content::AmbiguousDeltaRayTool::m_maxGoodMatchReducedChiSquared
private

The maximum reduced chi squared value of a good 1:1:1 match.

Definition at line 46 of file AmbiguousDeltaRayTool.h.

Referenced by PickOutGoodMatches(), and ReadSettings().


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