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

TwoViewTransverseTracksAlgorithm class. More...

#include <TwoViewTransverseTracksAlgorithm.h>

Inheritance diagram for lar_content::TwoViewTransverseTracksAlgorithm:
lar_content::NViewTrackMatchingAlgorithm< TwoViewMatchingControl< TwoViewTransverseOverlapResult > > lar_content::NViewMatchingAlgorithm< TwoViewMatchingControl< TwoViewTransverseOverlapResult > > lar_content::MatchingBaseAlgorithm

Public Types

typedef NViewTrackMatchingAlgorithm< TwoViewMatchingControl< TwoViewTransverseOverlapResult > > BaseAlgorithm
 
typedef std::set< unsigned int > UIntSet
 
- Public Types inherited from lar_content::NViewMatchingAlgorithm< TwoViewMatchingControl< TwoViewTransverseOverlapResult > >
typedef TwoViewMatchingControl< TwoViewTransverseOverlapResultMatchingType
 

Public Member Functions

 TwoViewTransverseTracksAlgorithm ()
 Default constructor. More...
 
- Public Member Functions inherited from lar_content::NViewTrackMatchingAlgorithm< TwoViewMatchingControl< TwoViewTransverseOverlapResult > >
 NViewTrackMatchingAlgorithm ()
 Default constructor. More...
 
virtual ~NViewTrackMatchingAlgorithm ()
 Destructor. More...
 
const TwoDSlidingFitResultGetCachedSlidingFitResult (const pandora::Cluster *const pCluster) const
 Get a sliding fit result from the algorithm cache. More...
 
unsigned int GetSlidingFitWindow () const
 Get the layer window for the sliding linear fits. More...
 
virtual bool MakeClusterSplits (const SplitPositionMap &splitPositionMap)
 Make cluster splits. More...
 
virtual bool MakeClusterSplit (const pandora::CartesianVector &splitPosition, const pandora::Cluster *&pCurrentCluster, const pandora::Cluster *&pLowXCluster, const pandora::Cluster *&pHighXCluster) const
 Make a cluster split. More...
 
virtual void UpdateForNewCluster (const pandora::Cluster *const pNewCluster)
 Update to reflect addition of a new cluster to the problem space. More...
 
virtual void UpdateUponDeletion (const pandora::Cluster *const pDeletedCluster)
 Update to reflect cluster deletion. More...
 
virtual void SelectInputClusters (const pandora::ClusterList *const pInputClusterList, pandora::ClusterList &selectedClusterList) const
 Select a subset of input clusters for processing in this algorithm. More...
 
virtual void PrepareInputClusters (pandora::ClusterList &preparedClusterList)
 Perform any preparatory steps required on the input clusters, e.g. caching expensive fit results. More...
 
virtual void SetPfoParticleId (PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
 Set pfo particle id. More...
 
- Public Member Functions inherited from lar_content::NViewMatchingAlgorithm< TwoViewMatchingControl< TwoViewTransverseOverlapResult > >
 NViewMatchingAlgorithm ()
 Default constructor. More...
 
virtual ~NViewMatchingAlgorithm ()
 Destructor. More...
 
const std::stringGetClusterListName (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...
 
- Public Member Functions inherited from lar_content::MatchingBaseAlgorithm
 MatchingBaseAlgorithm ()
 Default constructor. More...
 
virtual ~MatchingBaseAlgorithm ()
 Destructor. More...
 
virtual bool MakeClusterMerges (const ClusterMergeMap &clusterMergeMap)
 Merge clusters together. More...
 
virtual bool CreateThreeDParticles (const ProtoParticleVector &protoParticleVector)
 Create particles using findings from recent algorithm processing. More...
 
virtual void SetPfoParameters (const ProtoParticle &protoParticle, PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
 Set Pfo properties. More...
 

Private Types

typedef std::vector< TransverseMatrixTool * > MatrixToolVector
 

Private Member Functions

void CalculateOverlapResult (const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const)
 Calculate cluster overlap result and store in container. More...
 
pandora::StatusCode CalculateOverlapResult (const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, TwoViewTransverseOverlapResult &overlapResult)
 Calculates the two view overlap result. More...
 
unsigned int CalculateNumberOfLocallyMatchingSamplingPoints (const DiscreteProbabilityVector &discreteProbabilityVector1, const DiscreteProbabilityVector &discreteProbabilityVector2, std::mt19937 &randomNumberGenerator)
 Calculates the number of the sliding windows that contains charge bins that locally match. More...
 
float GetPrimaryAxisDotDriftAxis (const pandora::Cluster *const pCluster)
 Get the dot product between the cluster's primary axis and the drift axis. More...
 
void ExamineOverlapContainer ()
 Examine contents of overlap container, collect together best-matching 2D particles and modify clusters as required. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

MatrixToolVector m_algorithmToolVector
 The algorithm tool vector. More...
 
unsigned int m_nMaxMatrixToolRepeats
 The maximum number of repeat loops over matrix tools. More...
 
unsigned int m_downsampleFactor
 The downsampling (hit merging) applied to hits in the overlap region. More...
 
unsigned int m_minSamples
 The minimum number of samples needed for comparing charges. More...
 
unsigned int m_nPermutations
 The number of permutations for calculating p-values. More...
 
float m_localMatchingScoreThreshold
 The minimum score to classify a local region as matching. More...
 
float m_maxDotProduct
 
float m_minOverallMatchingScore
 M The maximum allowed cluster primary qxis Dot drift axis to fill the overlap result. More...
 
float m_minOverallLocallyMatchedFraction
 The minimum required lcoally matched fraction to fill the overlap result. More...
 
std::mt19937 m_randomNumberGenerator
 The random number generator. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from lar_content::NViewTrackMatchingAlgorithm< TwoViewMatchingControl< TwoViewTransverseOverlapResult > >
static bool SortSplitPositions (const pandora::CartesianVector &lhs, const pandora::CartesianVector &rhs)
 Sort split position cartesian vectors by increasing x coordinate. More...
 
- Protected Member Functions inherited from lar_content::NViewTrackMatchingAlgorithm< TwoViewMatchingControl< TwoViewTransverseOverlapResult > >
void AddToSlidingFitCache (const pandora::Cluster *const pCluster)
 Add a new sliding fit result, for the specified cluster, to the algorithm cache. More...
 
void RemoveFromSlidingFitCache (const pandora::Cluster *const pCluster)
 Remova an existing sliding fit result, for the specified cluster, from the algorithm cache. More...
 
virtual void TidyUp ()
 Tidy member variables in derived class. More...
 
- Protected Member Functions inherited from lar_content::NViewMatchingAlgorithm< TwoViewMatchingControl< TwoViewTransverseOverlapResult > >
MatchingTypeGetMatchingControl ()
 Get the matching control. More...
 
virtual void SelectAllInputClusters ()
 Select a subset of input clusters for processing in this algorithm. More...
 
virtual void PrepareAllInputClusters ()
 Perform any preparatory steps required, e.g. caching expensive fit results for clusters. More...
 
virtual void PerformMainLoop ()
 Main loop over cluster combinations in order to populate the overlap container. Responsible for calling CalculateOverlapResult. More...
 
- Protected Attributes inherited from lar_content::NViewMatchingAlgorithm< TwoViewMatchingControl< TwoViewTransverseOverlapResult > >
MatchingType m_matchingControl
 The matching control. More...
 

Detailed Description

TwoViewTransverseTracksAlgorithm class.

Definition at line 32 of file TwoViewTransverseTracksAlgorithm.h.

Member Typedef Documentation

Definition at line 35 of file TwoViewTransverseTracksAlgorithm.h.

Definition at line 80 of file TwoViewTransverseTracksAlgorithm.h.

Definition at line 36 of file TwoViewTransverseTracksAlgorithm.h.

Constructor & Destructor Documentation

lar_content::TwoViewTransverseTracksAlgorithm::TwoViewTransverseTracksAlgorithm ( )

Default constructor.

Definition at line 23 of file TwoViewTransverseTracksAlgorithm.cc.

23  :
26  m_minSamples(11),
27  m_nPermutations(1000),
29  m_maxDotProduct(0.998f),
32  m_randomNumberGenerator(static_cast<std::mt19937::result_type>(0))
33 {
34 }
std::mt19937 m_randomNumberGenerator
The random number generator.
float m_localMatchingScoreThreshold
The minimum score to classify a local region as matching.
unsigned int m_nPermutations
The number of permutations for calculating p-values.
unsigned int m_minSamples
The minimum number of samples needed for comparing charges.
float m_minOverallMatchingScore
M The maximum allowed cluster primary qxis Dot drift axis to fill the overlap result.
float m_minOverallLocallyMatchedFraction
The minimum required lcoally matched fraction to fill the overlap result.
unsigned int m_downsampleFactor
The downsampling (hit merging) applied to hits in the overlap region.
unsigned int m_nMaxMatrixToolRepeats
The maximum number of repeat loops over matrix tools.

Member Function Documentation

unsigned int lar_content::TwoViewTransverseTracksAlgorithm::CalculateNumberOfLocallyMatchingSamplingPoints ( const DiscreteProbabilityVector discreteProbabilityVector1,
const DiscreteProbabilityVector discreteProbabilityVector2,
std::mt19937 &  randomNumberGenerator 
)
private

Calculates the number of the sliding windows that contains charge bins that locally match.

Parameters
discreteProbabilityVector1the view 0 discrete probability vector containing the charge information
pCluster2the view 1 discrete probability vector containing the charge information
randomNumberGeneratora seeded random number generator
Returns
the number of locally matching sampling points

Definition at line 145 of file TwoViewTransverseTracksAlgorithm.cc.

147 {
148  if (discreteProbabilityVector1.GetSize() != discreteProbabilityVector2.GetSize() ||
149  0 == discreteProbabilityVector1.GetSize() * discreteProbabilityVector2.GetSize())
150  throw STATUS_CODE_INVALID_PARAMETER;
151 
152  if (m_minSamples > discreteProbabilityVector1.GetSize())
153  throw STATUS_CODE_INVALID_PARAMETER;
154 
155  pandora::FloatVector localValues1, localValues2;
156  unsigned int nMatchedComparisons(0);
157 
158  for (unsigned int iValue = 0; iValue < discreteProbabilityVector1.GetSize(); ++iValue)
159  {
160  localValues1.emplace_back(discreteProbabilityVector1.GetProbability(iValue));
161  localValues2.emplace_back(discreteProbabilityVector2.GetProbability(iValue));
162  if (localValues1.size() == m_minSamples)
163  {
164  float localPValue(0);
165  try
166  {
168  localValues1, localValues2, randomNumberGenerator, m_nPermutations);
169  }
170  catch (const StatusCodeException &)
171  {
172  std::cout << "TwoViewTransverseTracksAlgorithm: failed to calculate correlation coefficient p-value for these numbers" << std::endl;
173  ;
174  std::cout << "----view 0: ";
175  for (unsigned int iElement = 0; iElement < localValues1.size(); ++iElement)
176  std::cout << localValues1.at(iElement) << " ";
177  std::cout << std::endl;
178  std::cout << "----view 1: ";
179  for (unsigned int iElement = 0; iElement < localValues2.size(); ++iElement)
180  std::cout << localValues2.at(iElement) << " ";
181  std::cout << std::endl;
182  }
183 
184  if ((1.f - localPValue) - m_localMatchingScoreThreshold > std::numeric_limits<float>::epsilon())
185  nMatchedComparisons++;
186 
187  localValues1.erase(localValues1.begin());
188  localValues2.erase(localValues2.begin());
189  }
190  }
191  return nMatchedComparisons;
192 }
static float CalculateCorrelationCoefficientPValueFromPermutationTest(const T &t1, const T &t2, std::mt19937 &randomNumberGenerator, const unsigned int nPermutations)
Calculate P value for measured correlation coefficient between two datasets via a permutation test...
float m_localMatchingScoreThreshold
The minimum score to classify a local region as matching.
unsigned int m_nPermutations
The number of permutations for calculating p-values.
unsigned int m_minSamples
The minimum number of samples needed for comparing charges.
Dft::FloatVector FloatVector
QTextStream & endl(QTextStream &s)
void lar_content::TwoViewTransverseTracksAlgorithm::CalculateOverlapResult ( const pandora::Cluster *const  pCluster1,
const pandora::Cluster *const  pCluster2,
const pandora::Cluster *  pCluster3 
)
privatevirtual

Calculate cluster overlap result and store in container.

Parameters
pCluster1address of cluster1
pCluster2address of cluster2
pCluster3address of cluster3

Implements lar_content::MatchingBaseAlgorithm.

pandora::StatusCode lar_content::TwoViewTransverseTracksAlgorithm::CalculateOverlapResult ( const pandora::Cluster *const  pCluster1,
const pandora::Cluster *const  pCluster2,
TwoViewTransverseOverlapResult overlapResult 
)
private

Calculates the two view overlap result.

Parameters
pCluster1the view 0 cluster
pCluster2the view 1 cluster
overlapResultthe two view overlap result
void lar_content::TwoViewTransverseTracksAlgorithm::ExamineOverlapContainer ( )
privatevirtual

Examine contents of overlap container, collect together best-matching 2D particles and modify clusters as required.

Implements lar_content::MatchingBaseAlgorithm.

Definition at line 213 of file TwoViewTransverseTracksAlgorithm.cc.

214 {
215  unsigned int repeatCounter(0);
216  for (MatrixToolVector::const_iterator iter = m_algorithmToolVector.begin(), iterEnd = m_algorithmToolVector.end(); iter != iterEnd;)
217  {
218  if ((*iter)->Run(this, this->GetMatchingControl().GetOverlapMatrix()))
219  {
220  iter = m_algorithmToolVector.begin();
221 
222  if (++repeatCounter > m_nMaxMatrixToolRepeats)
223  break;
224  }
225  else
226  {
227  ++iter;
228  }
229  }
230 }
intermediate_table::const_iterator const_iterator
MatrixToolVector m_algorithmToolVector
The algorithm tool vector.
unsigned int m_nMaxMatrixToolRepeats
The maximum number of repeat loops over matrix tools.
float lar_content::TwoViewTransverseTracksAlgorithm::GetPrimaryAxisDotDriftAxis ( const pandora::Cluster *const  pCluster)
private

Get the dot product between the cluster's primary axis and the drift axis.

Parameters
pClusterthe cluster
Returns
dot product

Definition at line 196 of file TwoViewTransverseTracksAlgorithm.cc.

197 {
198  pandora::CartesianPointVector pointVector;
199  LArClusterHelper::GetCoordinateVector(pCluster, pointVector);
200 
201  pandora::CartesianVector centroid(0.f, 0.f, 0.f);
202  LArPcaHelper::EigenVectors eigenVecs;
203  LArPcaHelper::EigenValues eigenValues(0.f, 0.f, 0.f);
204  LArPcaHelper::RunPca(pointVector, centroid, eigenValues, eigenVecs);
205 
206  const pandora::CartesianVector primaryAxis(eigenVecs.at(0));
207  const pandora::CartesianVector driftAxis(1.f, 0.f, 0.f);
208  return primaryAxis.GetDotProduct(driftAxis);
209 }
pandora::CartesianVector EigenValues
Definition: LArPcaHelper.h:24
static void RunPca(const T &t, pandora::CartesianVector &centroid, EigenValues &outputEigenValues, EigenVectors &outputEigenVectors)
Run principal component analysis using input calo hits (TPC_VIEW_U,V,W or TPC_3D; all treated as 3D p...
std::vector< pandora::CartesianVector > EigenVectors
Definition: LArPcaHelper.h:25
static void GetCoordinateVector(const pandora::Cluster *const pCluster, pandora::CartesianPointVector &coordinateVector)
Get vector of hit coordinates from an input cluster.
StatusCode lar_content::TwoViewTransverseTracksAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Reimplemented from lar_content::NViewTrackMatchingAlgorithm< TwoViewMatchingControl< TwoViewTransverseOverlapResult > >.

Definition at line 234 of file TwoViewTransverseTracksAlgorithm.cc.

235 {
236  AlgorithmToolVector algorithmToolVector;
237  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "TrackTools", algorithmToolVector));
238 
239  for (AlgorithmToolVector::const_iterator iter = algorithmToolVector.begin(), iterEnd = algorithmToolVector.end(); iter != iterEnd; ++iter)
240  {
241  TransverseMatrixTool *const pTransverseMatrixTool(dynamic_cast<TransverseMatrixTool *>(*iter));
242 
243  if (!pTransverseMatrixTool)
244  return STATUS_CODE_INVALID_PARAMETER;
245 
246  m_algorithmToolVector.push_back(pTransverseMatrixTool);
247  }
248 
249  PANDORA_RETURN_RESULT_IF_AND_IF(
250  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NMaxMatrixToolRepeats", m_nMaxMatrixToolRepeats));
251 
252  PANDORA_RETURN_RESULT_IF_AND_IF(
253  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DownsampleFactor", m_downsampleFactor));
254 
255  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinSamples", m_minSamples));
256 
257  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NPermutations", m_nPermutations));
258 
259  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
260  XmlHelper::ReadValue(xmlHandle, "LocalMatchingScoreThreshold", m_localMatchingScoreThreshold));
261 
262  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxDotProduct", m_maxDotProduct));
263 
264  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
265  XmlHelper::ReadValue(xmlHandle, "MinOverallMatchingScore", m_minOverallMatchingScore));
266 
267  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
268  XmlHelper::ReadValue(xmlHandle, "MinOverallLocallyMatchedFraction", m_minOverallLocallyMatchedFraction));
269 
270  return BaseAlgorithm::ReadSettings(xmlHandle);
271 }
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
intermediate_table::const_iterator const_iterator
float m_localMatchingScoreThreshold
The minimum score to classify a local region as matching.
MatrixToolVector m_algorithmToolVector
The algorithm tool vector.
unsigned int m_nPermutations
The number of permutations for calculating p-values.
unsigned int m_minSamples
The minimum number of samples needed for comparing charges.
float m_minOverallMatchingScore
M The maximum allowed cluster primary qxis Dot drift axis to fill the overlap result.
float m_minOverallLocallyMatchedFraction
The minimum required lcoally matched fraction to fill the overlap result.
unsigned int m_downsampleFactor
The downsampling (hit merging) applied to hits in the overlap region.
unsigned int m_nMaxMatrixToolRepeats
The maximum number of repeat loops over matrix tools.

Member Data Documentation

MatrixToolVector lar_content::TwoViewTransverseTracksAlgorithm::m_algorithmToolVector
private

The algorithm tool vector.

Definition at line 81 of file TwoViewTransverseTracksAlgorithm.h.

unsigned int lar_content::TwoViewTransverseTracksAlgorithm::m_downsampleFactor
private

The downsampling (hit merging) applied to hits in the overlap region.

Definition at line 84 of file TwoViewTransverseTracksAlgorithm.h.

float lar_content::TwoViewTransverseTracksAlgorithm::m_localMatchingScoreThreshold
private

The minimum score to classify a local region as matching.

Definition at line 87 of file TwoViewTransverseTracksAlgorithm.h.

float lar_content::TwoViewTransverseTracksAlgorithm::m_maxDotProduct
private

Definition at line 88 of file TwoViewTransverseTracksAlgorithm.h.

float lar_content::TwoViewTransverseTracksAlgorithm::m_minOverallLocallyMatchedFraction
private

The minimum required lcoally matched fraction to fill the overlap result.

Definition at line 90 of file TwoViewTransverseTracksAlgorithm.h.

float lar_content::TwoViewTransverseTracksAlgorithm::m_minOverallMatchingScore
private

M The maximum allowed cluster primary qxis Dot drift axis to fill the overlap result.

The minimum required global matching score to fill the overlap result

Definition at line 89 of file TwoViewTransverseTracksAlgorithm.h.

unsigned int lar_content::TwoViewTransverseTracksAlgorithm::m_minSamples
private

The minimum number of samples needed for comparing charges.

Definition at line 85 of file TwoViewTransverseTracksAlgorithm.h.

unsigned int lar_content::TwoViewTransverseTracksAlgorithm::m_nMaxMatrixToolRepeats
private

The maximum number of repeat loops over matrix tools.

Definition at line 83 of file TwoViewTransverseTracksAlgorithm.h.

unsigned int lar_content::TwoViewTransverseTracksAlgorithm::m_nPermutations
private

The number of permutations for calculating p-values.

Definition at line 86 of file TwoViewTransverseTracksAlgorithm.h.

std::mt19937 lar_content::TwoViewTransverseTracksAlgorithm::m_randomNumberGenerator
private

The random number generator.

Definition at line 91 of file TwoViewTransverseTracksAlgorithm.h.


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