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

ThreeDTrackFragmentsAlgorithm class. More...

#include "ThreeDTrackFragmentsAlgorithm.h"

Inheritance diagram for lar_content::ThreeDTrackFragmentsAlgorithm:
lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult > lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >

Public Types

typedef OverlapTensor< FragmentOverlapResultTensorType
 

Public Member Functions

 ThreeDTrackFragmentsAlgorithm ()
 Default constructor. More...
 
void UpdateForNewCluster (const pandora::Cluster *const pNewCluster)
 Update to reflect addition of a new cluster to the problem space. More...
 
void RebuildClusters (const pandora::ClusterList &rebuildList, pandora::ClusterList &newClusters) const
 Rebuild clusters after fragmentation. 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 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 SetPfoParameters (const ProtoParticle &protoParticle, PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
 Calculate Pfo properties from proto particle. More...
 
virtual bool CreateThreeDParticles (const ProtoParticleVector &protoParticleVector)
 Create particles using findings from recent algorithm processing. More...
 
virtual bool MakeClusterMerges (const ClusterMergeMap &clusterMergeMap)
 Merge clusters together. More...
 
virtual void RemoveUnavailableTensorElements ()
 Update tensor to remove all elements that have been added to pfos and so are unavailable. More...
 
const pandora::ClusterList & GetInputClusterListU () const
 Get the input u cluster list. More...
 
const pandora::ClusterList & GetInputClusterListV () const
 Get the input v cluster list. More...
 
const pandora::ClusterList & GetInputClusterListW () const
 Get the input w cluster list. More...
 
const pandora::ClusterList & GetSelectedClusterListU () const
 Get the selected u cluster list. More...
 
const pandora::ClusterList & GetSelectedClusterListV () const
 Get the selected v cluster list. More...
 
const pandora::ClusterList & GetSelectedClusterListW () const
 Get the selected w cluster list. More...
 
const std::string & GetClusterListNameU () const
 Get the name of the u cluster list. More...
 
const std::string & GetClusterListNameV () const
 Get the name of the v cluster list. More...
 
const std::string & GetClusterListNameW () const
 Get the name of the w cluster list. More...
 

Static Public Member Functions

static bool SortSplitPositions (const pandora::CartesianVector &lhs, const pandora::CartesianVector &rhs)
 Sort split position cartesian vectors by increasing x coordinate. More...
 

Protected Types

typedef std::unordered_map< const pandora::CaloHit *, const pandora::Cluster * > HitToClusterMap
 
typedef std::unordered_map< const pandora::Cluster *, unsigned int > ClusterToMatchedHitsMap
 
typedef std::vector< FragmentTensorTool * > TensorToolVector
 

Protected Member Functions

void PerformMainLoop ()
 Main loop over cluster combinations in order to populate the tensor. Responsible for calling CalculateOverlapResult. More...
 
void CalculateOverlapResult (const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW)
 Calculate cluster overlap result and store in tensor. More...
 
pandora::StatusCode CalculateOverlapResult (const TwoDSlidingFitResult &fitResult1, const TwoDSlidingFitResult &fitResult2, const pandora::ClusterList &inputClusterList, const pandora::Cluster *&pBestMatchedCluster, FragmentOverlapResult &fragmentOverlapResult) const
 Calculate overlap result for track fragment candidate consisting of two sliding fit results and a list of available clusters. More...
 
pandora::StatusCode GetProjectedPositions (const TwoDSlidingFitResult &fitResult1, const TwoDSlidingFitResult &fitResult2, pandora::CartesianPointVector &projectedPositions) const
 Get the list of projected positions, in the third view, corresponding to a pair of sliding fit results. More...
 
pandora::StatusCode GetMatchedHits (const pandora::ClusterList &inputClusterList, const pandora::CartesianPointVector &projectedPositions, HitToClusterMap &hitToClusterMap, pandora::CaloHitList &matchedCaloHits) const
 Get the list of hits associated with the projected positions and a useful hit to cluster map. More...
 
pandora::StatusCode GetMatchedClusters (const pandora::CaloHitList &matchedHits, const HitToClusterMap &hitToClusterMap, pandora::ClusterList &matchedClusters, const pandora::Cluster *&pBestMatchedCluster) const
 Get the list of the relevant clusters and the address of the single best matched cluster. More...
 
void GetFragmentOverlapResult (const pandora::CartesianPointVector &projectedPositions, const pandora::CaloHitList &matchedHits, const pandora::ClusterList &matchedClusters, FragmentOverlapResult &fragmentOverlapResult) const
 Get the populated fragment overlap result. More...
 
bool CheckMatchedClusters (const pandora::CartesianPointVector &projectedPositions, const pandora::ClusterList &matchedClusters) const
 Whether the matched clusters are consistent with the projected positions. More...
 
bool CheckOverlapResult (const FragmentOverlapResult &overlapResult) const
 Whether the matched clusters and hits pass the algorithm quality cuts. More...
 
void ExamineTensor ()
 Examine contents of tensor, collect together best-matching 2D particles and modify clusters as required. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
virtual void PreparationStep ()
 Perform any preparatory steps required, e.g. caching expensive fit results for clusters. More...
 
virtual void PreparationStep (pandora::ClusterList &clusterList)
 Preparation step for a specific cluster list. More...
 
virtual void TidyUp ()
 Tidy member variables in derived class. More...
 
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 SelectAllInputClusters ()
 Select a subset of input clusters for processing in this algorithm. More...
 

Protected Attributes

std::string m_reclusteringAlgorithmName
 Name of daughter algorithm to use for cluster re-building. More...
 
TensorToolVector m_algorithmToolVector
 The algorithm tool list. More...
 
unsigned int m_nMaxTensorToolRepeats
 The maximum number of repeat loops over tensor tools. More...
 
float m_minXOverlap
 requirement on minimum X overlap for associated clusters More...
 
float m_minXOverlapFraction
 requirement on minimum X overlap fraction for associated clusters More...
 
float m_maxPointDisplacementSquared
 maximum allowed distance (squared) between projected points and associated hits More...
 
float m_minMatchedSamplingPointFraction
 minimum fraction of matched sampling points More...
 
unsigned int m_minMatchedHits
 minimum number of matched calo hits More...
 
unsigned int m_slidingFitWindow
 The layer window for the sliding linear fits. More...
 
TwoDSlidingFitResultMap m_slidingFitResultMap
 The sliding fit result map. More...
 
unsigned int m_minClusterCaloHits
 The min number of hits in base cluster selection method. More...
 
float m_minClusterLengthSquared
 The min length (squared) in base cluster selection method. More...
 
const pandora::ClusterList * m_pInputClusterListU
 Address of the input cluster list U. More...
 
const pandora::ClusterList * m_pInputClusterListV
 Address of the input cluster list V. More...
 
const pandora::ClusterList * m_pInputClusterListW
 Address of the input cluster list W. More...
 
pandora::ClusterList m_clusterListU
 The selected modified cluster list U. More...
 
pandora::ClusterList m_clusterListV
 The selected modified cluster list V. More...
 
pandora::ClusterList m_clusterListW
 The selected modified cluster list W. More...
 
TensorType m_overlapTensor
 The overlap tensor. More...
 

Detailed Description

Member Typedef Documentation

typedef std::unordered_map<const pandora::Cluster*, unsigned int> lar_content::ThreeDTrackFragmentsAlgorithm::ClusterToMatchedHitsMap
protected

Definition at line 139 of file ThreeDTrackFragmentsAlgorithm.h.

typedef std::unordered_map<const pandora::CaloHit*, const pandora::Cluster*> lar_content::ThreeDTrackFragmentsAlgorithm::HitToClusterMap
protected

Definition at line 66 of file ThreeDTrackFragmentsAlgorithm.h.

Constructor & Destructor Documentation

lar_content::ThreeDTrackFragmentsAlgorithm::ThreeDTrackFragmentsAlgorithm ( )

Default constructor.

Definition at line 21 of file ThreeDTrackFragmentsAlgorithm.cc.

21  :
23  m_minXOverlap(3.f),
28 {
29 }
float m_minMatchedSamplingPointFraction
minimum fraction of matched sampling points
TFile f
Definition: plotHisto.C:6
unsigned int m_nMaxTensorToolRepeats
The maximum number of repeat loops over tensor tools.
unsigned int m_minMatchedHits
minimum number of matched calo hits
float m_minXOverlapFraction
requirement on minimum X overlap fraction for associated clusters
float m_minXOverlap
requirement on minimum X overlap for associated clusters
float m_maxPointDisplacementSquared
maximum allowed distance (squared) between projected points and associated hits

Member Function Documentation

void lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::AddToSlidingFitCache ( const pandora::Cluster *const  pCluster)
protectedinherited

Add a new sliding fit result, for the specified cluster, to the algorithm cache.

Parameters
pClusteraddress of the relevant cluster

Referenced by UpdateForNewCluster().

void lar_content::ThreeDTrackFragmentsAlgorithm::CalculateOverlapResult ( const pandora::Cluster *const  pClusterU,
const pandora::Cluster *const  pClusterV,
const pandora::Cluster *const  pClusterW 
)
protectedvirtual

Calculate cluster overlap result and store in tensor.

Parameters
pClusterUaddress of U view cluster
pClusterVaddress of V view cluster
pClusterWaddress of W view cluster

Implements lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >.

Referenced by PerformMainLoop(), and UpdateForNewCluster().

pandora::StatusCode lar_content::ThreeDTrackFragmentsAlgorithm::CalculateOverlapResult ( const TwoDSlidingFitResult fitResult1,
const TwoDSlidingFitResult fitResult2,
const pandora::ClusterList &  inputClusterList,
const pandora::Cluster *&  pBestMatchedCluster,
FragmentOverlapResult fragmentOverlapResult 
) const
protected

Calculate overlap result for track fragment candidate consisting of two sliding fit results and a list of available clusters.

Parameters
fitResult1the first sliding fit result
fitResult2the second sliding fit result
inputClusterListthe input cluster list
pBestMatchedClusterto receive the address of the best matched cluster
fragmentOverlapResultto receive the populated fragment overlap result
Returns
statusCode, faster than throwing in regular use-cases
bool lar_content::ThreeDTrackFragmentsAlgorithm::CheckMatchedClusters ( const pandora::CartesianPointVector &  projectedPositions,
const pandora::ClusterList &  matchedClusters 
) const
protected

Whether the matched clusters are consistent with the projected positions.

Parameters
projectedPositionsthe list of projected positions
matchedClustersthe list of matched clusters
Returns
boolean

Definition at line 543 of file ThreeDTrackFragmentsAlgorithm.cc.

References f, lar_content::LArClusterHelper::GetClusterBoundingBox(), max, and min.

Referenced by PerformMainLoop().

544 {
545  if (projectedPositions.empty() || matchedClusters.empty())
546  return false;
547 
548  // Calculate X and Z span of projected positions
549  float minXproj(+std::numeric_limits<float>::max());
550  float maxXproj(-std::numeric_limits<float>::max());
551  float minZproj(+std::numeric_limits<float>::max());
552  float maxZproj(-std::numeric_limits<float>::max());
553 
554  for (const CartesianVector &projectedPosition : projectedPositions)
555  {
556  minXproj = std::min(minXproj, projectedPosition.GetX());
557  maxXproj = std::max(maxXproj, projectedPosition.GetX());
558  minZproj = std::min(minZproj, projectedPosition.GetZ());
559  maxZproj = std::max(maxZproj, projectedPosition.GetZ());
560  }
561 
562  const float dXproj(maxXproj - minXproj);
563  const float dZproj(maxZproj - minZproj);
564  const float projectedLengthSquared(dXproj * dXproj + dZproj * dZproj);
565 
566  // Calculate X and Z span of matched clusters
567  float minXcluster(+std::numeric_limits<float>::max());
568  float maxXcluster(-std::numeric_limits<float>::max());
569  float minZcluster(+std::numeric_limits<float>::max());
570  float maxZcluster(-std::numeric_limits<float>::max());
571 
572  for (const Cluster *const pCluster : matchedClusters)
573  {
574  CartesianVector minPosition(0.f,0.f,0.f);
575  CartesianVector maxPosition(0.f,0.f,0.f);
576 
577  LArClusterHelper::GetClusterBoundingBox(pCluster, minPosition, maxPosition);
578 
579  minXcluster = std::min(minXcluster, minPosition.GetX());
580  maxXcluster = std::max(maxXcluster, maxPosition.GetX());
581  minZcluster = std::min(minZcluster, minPosition.GetZ());
582  maxZcluster = std::max(maxZcluster, maxPosition.GetZ());
583  }
584 
585  const float dXcluster(maxXcluster - minXcluster);
586  const float dZcluster(maxZcluster - minZcluster);
587  const float clusterLengthSquared(dXcluster * dXcluster + dZcluster * dZcluster);
588 
589  // Require that the span of the matched clusters is no larger than twice the span of the projected positions
590  if (clusterLengthSquared > 4.f * projectedLengthSquared)
591  return false;
592 
593  return true;
594 }
TFile f
Definition: plotHisto.C:6
static void GetClusterBoundingBox(const pandora::Cluster *const pCluster, pandora::CartesianVector &minimumCoordinate, pandora::CartesianVector &maximumCoordinate)
Get minimum and maximum X, Y and Z positions of the calo hits in a cluster.
Int_t max
Definition: plot.C:27
Int_t min
Definition: plot.C:26
bool lar_content::ThreeDTrackFragmentsAlgorithm::CheckOverlapResult ( const FragmentOverlapResult overlapResult) const
protected

Whether the matched clusters and hits pass the algorithm quality cuts.

Parameters
fragmentOverlapResultthe fragment overlap result
Returns
boolean

Definition at line 598 of file ThreeDTrackFragmentsAlgorithm.cc.

References lar_content::FragmentOverlapResult::GetFragmentCaloHitList(), lar_content::TrackOverlapResult::GetMatchedFraction(), m_minMatchedHits, and m_minMatchedSamplingPointFraction.

Referenced by PerformMainLoop().

599 {
600  // ATTN This method is currently mirrored in ClearTrackFragments tool
601  if (overlapResult.GetMatchedFraction() < m_minMatchedSamplingPointFraction)
602  return false;
603 
604  if (overlapResult.GetFragmentCaloHitList().size() < m_minMatchedHits)
605  return false;
606 
607  return true;
608 }
float m_minMatchedSamplingPointFraction
minimum fraction of matched sampling points
unsigned int m_minMatchedHits
minimum number of matched calo hits
virtual bool lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::CreateThreeDParticles ( const ProtoParticleVector protoParticleVector)
virtualinherited

Create particles using findings from recent algorithm processing.

Parameters
protoParticleVectorthe proto particle vector
whetherparticles were created
void lar_content::ThreeDTrackFragmentsAlgorithm::ExamineTensor ( )
protectedvirtual

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

Implements lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >.

Definition at line 612 of file ThreeDTrackFragmentsAlgorithm.cc.

References m_algorithmToolVector, m_nMaxTensorToolRepeats, and lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::m_overlapTensor.

613 {
614  unsigned int repeatCounter(0);
615 
616  for (TensorToolVector::const_iterator iter = m_algorithmToolVector.begin(), iterEnd = m_algorithmToolVector.end(); iter != iterEnd; )
617  {
618  if ((*iter)->Run(this, m_overlapTensor))
619  {
620  iter = m_algorithmToolVector.begin();
621 
622  if (++repeatCounter > m_nMaxTensorToolRepeats)
623  break;
624  }
625  else
626  {
627  ++iter;
628  }
629  }
630 }
unsigned int m_nMaxTensorToolRepeats
The maximum number of repeat loops over tensor tools.
intermediate_table::const_iterator const_iterator
TensorToolVector m_algorithmToolVector
The algorithm tool list.
const TwoDSlidingFitResult& lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::GetCachedSlidingFitResult ( const pandora::Cluster *const  pCluster) const
inherited

Get a sliding fit result from the algorithm cache.

Parameters
pClusteraddress of the relevant cluster

Referenced by PerformMainLoop().

const std::string& lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::GetClusterListNameU ( ) const
inherited

Get the name of the u cluster list.

const std::string& lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::GetClusterListNameV ( ) const
inherited

Get the name of the v cluster list.

const std::string& lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::GetClusterListNameW ( ) const
inherited

Get the name of the w cluster list.

void lar_content::ThreeDTrackFragmentsAlgorithm::GetFragmentOverlapResult ( const pandora::CartesianPointVector &  projectedPositions,
const pandora::CaloHitList &  matchedHits,
const pandora::ClusterList &  matchedClusters,
FragmentOverlapResult fragmentOverlapResult 
) const
protected

Get the populated fragment overlap result.

Parameters
projectedPositionsthe list of projected positions
matchedHitsthe list of matched hits
matchedClustersthe list of matched clusters
fragmentOverlapResultto receive the populated fragment overlap result

Definition at line 510 of file ThreeDTrackFragmentsAlgorithm.cc.

References f, m_maxPointDisplacementSquared, max, and lar_content::LArClusterHelper::SortHitsByPosition().

Referenced by PerformMainLoop().

512 {
513  float chi2Sum(0.f);
514  unsigned int nMatchedSamplingPoints(0);
515 
516  CaloHitVector sortedMatchedHits(matchedHits.begin(), matchedHits.end());
517  std::sort(sortedMatchedHits.begin(), sortedMatchedHits.end(), LArClusterHelper::SortHitsByPosition);
518 
519  for (const CartesianVector &projectedPosition : projectedPositions)
520  {
521  float closestDistanceSquared(std::numeric_limits<float>::max());
522 
523  for (const CaloHit *const pCaloHit : matchedHits)
524  {
525  const float distanceSquared((pCaloHit->GetPositionVector() - projectedPosition).GetMagnitudeSquared());
526 
527  if (distanceSquared < closestDistanceSquared)
528  closestDistanceSquared = distanceSquared;
529  }
530 
531  if (closestDistanceSquared < m_maxPointDisplacementSquared)
532  {
533  ++nMatchedSamplingPoints;
534  chi2Sum += closestDistanceSquared;
535  }
536  }
537 
538  fragmentOverlapResult = FragmentOverlapResult(nMatchedSamplingPoints, projectedPositions.size(), chi2Sum, matchedHits, matchedClusters);
539 }
TFile f
Definition: plotHisto.C:6
Int_t max
Definition: plot.C:27
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
float m_maxPointDisplacementSquared
maximum allowed distance (squared) between projected points and associated hits
const pandora::ClusterList& lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::GetInputClusterListU ( ) const
inherited

Get the input u cluster list.

Referenced by PerformMainLoop().

const pandora::ClusterList& lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::GetInputClusterListV ( ) const
inherited

Get the input v cluster list.

Referenced by PerformMainLoop().

const pandora::ClusterList& lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::GetInputClusterListW ( ) const
inherited

Get the input w cluster list.

Referenced by PerformMainLoop().

StatusCode lar_content::ThreeDTrackFragmentsAlgorithm::GetMatchedClusters ( const pandora::CaloHitList &  matchedHits,
const HitToClusterMap hitToClusterMap,
pandora::ClusterList &  matchedClusters,
const pandora::Cluster *&  pBestMatchedCluster 
) const
protected

Get the list of the relevant clusters and the address of the single best matched cluster.

Parameters
matchedHitsthe list of matched calo hits
hitToClusterMapthe hit to cluster map
matchedClustersto receive the list of matched clusters
pBestMatchedClusterto receive the address of the single best matched cluster
Returns
statusCode, faster than throwing in regular use-cases

Definition at line 460 of file ThreeDTrackFragmentsAlgorithm.cc.

References f, and lar_content::LArClusterHelper::SortByNHits().

Referenced by PerformMainLoop().

462 {
463  ClusterToMatchedHitsMap clusterToMatchedHitsMap;
464 
465  for (CaloHitList::const_iterator iter = matchedHits.begin(), iterEnd = matchedHits.end(); iter != iterEnd; ++iter)
466  {
467  const CaloHit *const pCaloHit = *iter;
468  HitToClusterMap::const_iterator cIter = hitToClusterMap.find(pCaloHit);
469 
470  if (hitToClusterMap.end() == cIter)
471  throw StatusCodeException(STATUS_CODE_FAILURE);
472 
473  ++clusterToMatchedHitsMap[cIter->second];
474 
475  if (matchedClusters.end() == std::find(matchedClusters.begin(), matchedClusters.end(), cIter->second))
476  matchedClusters.push_back(cIter->second);
477  }
478 
479  if (matchedClusters.empty())
480  return STATUS_CODE_NOT_FOUND;
481 
482  pBestMatchedCluster = NULL;
483  unsigned int bestClusterMatchedHits(0);
484  float tieBreakerBestEnergy(0.f);
485 
486  ClusterVector sortedClusters;
487  for (const auto &mapEntry : clusterToMatchedHitsMap) sortedClusters.push_back(mapEntry.first);
488  std::sort(sortedClusters.begin(), sortedClusters.end(), LArClusterHelper::SortByNHits);
489 
490  for (const Cluster *const pCluster : sortedClusters)
491  {
492  const unsigned int nMatchedHits(clusterToMatchedHitsMap.at(pCluster));
493 
494  if ((nMatchedHits > bestClusterMatchedHits) || ((nMatchedHits == bestClusterMatchedHits) && (pCluster->GetHadronicEnergy() > tieBreakerBestEnergy)))
495  {
496  pBestMatchedCluster = pCluster;
497  bestClusterMatchedHits = nMatchedHits;
498  tieBreakerBestEnergy = pCluster->GetHadronicEnergy();
499  }
500  }
501 
502  if (NULL == pBestMatchedCluster)
503  return STATUS_CODE_NOT_FOUND;
504 
505  return STATUS_CODE_SUCCESS;
506 }
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.
std::unordered_map< const pandora::Cluster *, unsigned int > ClusterToMatchedHitsMap
TFile f
Definition: plotHisto.C:6
intermediate_table::const_iterator const_iterator
std::vector< art::Ptr< recob::Cluster > > ClusterVector
StatusCode lar_content::ThreeDTrackFragmentsAlgorithm::GetMatchedHits ( const pandora::ClusterList &  inputClusterList,
const pandora::CartesianPointVector &  projectedPositions,
HitToClusterMap hitToClusterMap,
pandora::CaloHitList &  matchedCaloHits 
) const
protected

Get the list of hits associated with the projected positions and a useful hit to cluster map.

Parameters
inputClusterListthe input cluster list
projectedPositionsthe list of projected positions
hitToClusterMapto receive the hit to cluster map
matchedCaloHitsto receive the list of associated calo hits
Returns
statusCode, faster than throwing in regular use-cases

Definition at line 409 of file ThreeDTrackFragmentsAlgorithm.cc.

References f, m_maxPointDisplacementSquared, max, and lar_content::LArClusterHelper::SortHitsByPosition().

Referenced by PerformMainLoop().

411 {
412  CaloHitVector availableCaloHits;
413 
414  for (ClusterList::const_iterator iter = inputClusterList.begin(), iterEnd = inputClusterList.end(); iter != iterEnd; ++iter)
415  {
416  const Cluster *const pCluster = *iter;
417 
418  if (!pCluster->IsAvailable())
419  continue;
420 
421  CaloHitList caloHitList;
422  pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
423  availableCaloHits.insert(availableCaloHits.end(), caloHitList.begin(), caloHitList.end());
424 
425  for (CaloHitList::const_iterator hIter = caloHitList.begin(), hIterEnd = caloHitList.end(); hIter != hIterEnd; ++hIter)
426  hitToClusterMap.insert(HitToClusterMap::value_type(*hIter, pCluster));
427  }
428 
429  std::sort(availableCaloHits.begin(), availableCaloHits.end(), LArClusterHelper::SortHitsByPosition);
430 
431  for (const CartesianVector &projectedPosition : projectedPositions)
432  {
433  const CaloHit *pClosestCaloHit(NULL);
434  float closestDistanceSquared(std::numeric_limits<float>::max()), tieBreakerBestEnergy(0.f);
435 
436  for (const CaloHit *const pCaloHit : availableCaloHits)
437  {
438  const float distanceSquared((pCaloHit->GetPositionVector() - projectedPosition).GetMagnitudeSquared());
439 
440  if ((distanceSquared < closestDistanceSquared) || ((std::fabs(distanceSquared - closestDistanceSquared) < std::numeric_limits<float>::epsilon()) && (pCaloHit->GetHadronicEnergy() > tieBreakerBestEnergy)))
441  {
442  pClosestCaloHit = pCaloHit;
443  closestDistanceSquared = distanceSquared;
444  tieBreakerBestEnergy = pCaloHit->GetHadronicEnergy();
445  }
446  }
447 
448  if ((closestDistanceSquared < m_maxPointDisplacementSquared) && (NULL != pClosestCaloHit) && (matchedHits.end() == std::find(matchedHits.begin(), matchedHits.end(), pClosestCaloHit)))
449  matchedHits.push_back(pClosestCaloHit);
450  }
451 
452  if (matchedHits.empty())
453  return STATUS_CODE_NOT_FOUND;
454 
455  return STATUS_CODE_SUCCESS;
456 }
TFile f
Definition: plotHisto.C:6
Int_t max
Definition: plot.C:27
intermediate_table::const_iterator const_iterator
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
float m_maxPointDisplacementSquared
maximum allowed distance (squared) between projected points and associated hits
StatusCode lar_content::ThreeDTrackFragmentsAlgorithm::GetProjectedPositions ( const TwoDSlidingFitResult fitResult1,
const TwoDSlidingFitResult fitResult2,
pandora::CartesianPointVector &  projectedPositions 
) const
protected

Get the list of projected positions, in the third view, corresponding to a pair of sliding fit results.

Parameters
fitResult1the first sliding fit result
fitResult2the second sliding fit result
projectedPositionsto receive the list of projected positions
Returns
statusCode, faster than throwing in regular use-cases

Definition at line 268 of file ThreeDTrackFragmentsAlgorithm.cc.

References f, lar_content::TwoDSlidingFitResult::GetCluster(), lar_content::LArClusterHelper::GetClusterHitType(), lar_content::LArClusterHelper::GetClusterSpanX(), lar_content::TwoDSlidingFitResult::GetFitSegment(), lar_content::TwoDSlidingFitResult::GetGlobalFitProjection(), lar_content::TwoDSlidingFitResult::GetGlobalMaxLayerPosition(), lar_content::TwoDSlidingFitResult::GetGlobalMinLayerPosition(), lar_content::TwoDSlidingFitResult::GetLocalPosition(), lar_content::TwoDSlidingFitResult::GetTransverseProjection(), lar_content::LArGeometryHelper::GetWireZPitch(), m_minXOverlap, m_minXOverlapFraction, max, lar_content::LArGeometryHelper::MergeTwoPositions(), lar_content::LArGeometryHelper::MergeTwoPositions3D(), min, lar_content::LArGeometryHelper::ProjectPosition(), and x.

Referenced by PerformMainLoop().

270 {
271  const Cluster *const pCluster1(fitResult1.GetCluster());
272  const Cluster *const pCluster2(fitResult2.GetCluster());
273 
274  // Check hit types
275  const HitType hitType1(LArClusterHelper::GetClusterHitType(pCluster1));
276  const HitType hitType2(LArClusterHelper::GetClusterHitType(pCluster2));
277  const HitType hitType3((TPC_VIEW_U != hitType1 && TPC_VIEW_U != hitType2) ? TPC_VIEW_U :
278  (TPC_VIEW_V != hitType1 && TPC_VIEW_V != hitType2) ? TPC_VIEW_V :
279  (TPC_VIEW_W != hitType1 && TPC_VIEW_W != hitType2) ? TPC_VIEW_W : HIT_CUSTOM);
280 
281  if (HIT_CUSTOM == hitType3)
282  return STATUS_CODE_INVALID_PARAMETER;
283 
284  // Check absolute and fractional overlap in x coordinate
285  float xMin1(0.f), xMax1(0.f), xMin2(0.f), xMax2(0.f);
286  LArClusterHelper::GetClusterSpanX(pCluster1, xMin1, xMax1);
287  LArClusterHelper::GetClusterSpanX(pCluster2, xMin2, xMax2);
288 
289  const float xOverlap(std::min(xMax1, xMax2) - std::max(xMin1, xMin2));
290  const float xSpan(std::max(xMax1, xMax2) - std::min(xMin1, xMin2));
291 
292  if ((xOverlap < m_minXOverlap) || (xSpan < std::numeric_limits<float>::epsilon()) || ((xOverlap / xSpan) < m_minXOverlapFraction))
293  return STATUS_CODE_NOT_FOUND;
294 
295  // Identify vertex and end positions (2D)
296  const CartesianVector minPosition1(fitResult1.GetGlobalMinLayerPosition());
297  const CartesianVector maxPosition1(fitResult1.GetGlobalMaxLayerPosition());
298  const CartesianVector minPosition2(fitResult2.GetGlobalMinLayerPosition());
299  const CartesianVector maxPosition2(fitResult2.GetGlobalMaxLayerPosition());
300 
301  const float dx_A(std::fabs(minPosition2.GetX() - minPosition1.GetX()));
302  const float dx_B(std::fabs(maxPosition2.GetX() - maxPosition1.GetX()));
303  const float dx_C(std::fabs(maxPosition2.GetX() - minPosition1.GetX()));
304  const float dx_D(std::fabs(minPosition2.GetX() - maxPosition1.GetX()));
305 
306  if (std::min(dx_C,dx_D) > std::max(dx_A,dx_B) && std::min(dx_A,dx_B) > std::max(dx_C,dx_D))
307  return STATUS_CODE_NOT_FOUND;
308 
309  const CartesianVector &vtxPosition1(minPosition1);
310  const CartesianVector &endPosition1(maxPosition1);
311  const CartesianVector &vtxPosition2((dx_A < dx_C) ? minPosition2 : maxPosition2);
312  const CartesianVector &endPosition2((dx_A < dx_C) ? maxPosition2 : minPosition2);
313 
314  // Calculate vertex and end positions (3D)
315  float vtxChi2(0.f);
316  CartesianVector vtxPosition3D(0.f, 0.f, 0.f);
317  LArGeometryHelper::MergeTwoPositions3D(this->GetPandora(), hitType1, hitType2, vtxPosition1, vtxPosition2, vtxPosition3D, vtxChi2);
318 
319  float endChi2(0.f);
320  CartesianVector endPosition3D(0.f, 0.f, 0.f);
321  LArGeometryHelper::MergeTwoPositions3D(this->GetPandora(), hitType1, hitType2, endPosition1, endPosition2, endPosition3D, endChi2);
322 
323  const CartesianVector vtxProjection3(LArGeometryHelper::ProjectPosition(this->GetPandora(), vtxPosition3D, hitType3));
324  const CartesianVector endProjection3(LArGeometryHelper::ProjectPosition(this->GetPandora(), endPosition3D, hitType3));
325 
326  const float samplingPitch(0.5f * LArGeometryHelper::GetWireZPitch(this->GetPandora()));
327  const float nSamplingPoints((endProjection3 - vtxProjection3).GetMagnitude() / samplingPitch);
328 
329  if (nSamplingPoints < 1.f)
330  return STATUS_CODE_NOT_FOUND;
331 
332  // Loop over trajectory points
333  bool foundLastPosition(false);
334  CartesianVector lastPosition(0.f,0.f,0.f);
335 
336  for (float iSample = 0.5f; iSample < nSamplingPoints; iSample += 1.f)
337  {
338  const CartesianVector linearPosition3D(vtxPosition3D + (endPosition3D - vtxPosition3D) * (iSample / nSamplingPoints));
339  const CartesianVector linearPosition1(LArGeometryHelper::ProjectPosition(this->GetPandora(), linearPosition3D, hitType1));
340  const CartesianVector linearPosition2(LArGeometryHelper::ProjectPosition(this->GetPandora(), linearPosition3D, hitType2));
341 
342  float chi2(0.f);
343  CartesianVector fitPosition1(0.f, 0.f, 0.f), fitPosition2(0.f, 0.f, 0.f);
344 
345  if ((STATUS_CODE_SUCCESS != fitResult1.GetGlobalFitProjection(linearPosition1, fitPosition1)) ||
346  (STATUS_CODE_SUCCESS != fitResult2.GetGlobalFitProjection(linearPosition2, fitPosition2)))
347  {
348  continue;
349  }
350 
351  float rL1(0.f), rL2(0.f), rT1(0.f), rT2(0.f);
352  fitResult1.GetLocalPosition(fitPosition1, rL1, rT1);
353  fitResult2.GetLocalPosition(fitPosition2, rL2, rT2);
354 
355  const float x(0.5 * (fitPosition1.GetX() + fitPosition2.GetX()));
356  CartesianVector position1(0.f, 0.f, 0.f), position2(0.f, 0.f, 0.f), position3(0.f, 0.f, 0.f);
357 
358  try
359  {
360  const FitSegment &fitSegment1 = fitResult1.GetFitSegment(rL1);
361  const FitSegment &fitSegment2 = fitResult2.GetFitSegment(rL2);
362 
363  if ((STATUS_CODE_SUCCESS != fitResult1.GetTransverseProjection(x, fitSegment1, position1)) ||
364  (STATUS_CODE_SUCCESS != fitResult2.GetTransverseProjection(x, fitSegment2, position2)))
365  {
366  continue;
367  }
368  }
369  catch (StatusCodeException &statusCodeException)
370  {
371  if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
372  throw statusCodeException;
373 
374  continue;
375  }
376 
377  LArGeometryHelper::MergeTwoPositions(this->GetPandora(), hitType1, hitType2, position1, position2, position3, chi2);
378 
379  // TODO For highly multi-valued x, projected positions can be unreliable. Need to make interpolation more robust for these cases.
380  if (foundLastPosition)
381  {
382  const float thisDisplacement((lastPosition - position3).GetMagnitude());
383  if (thisDisplacement > 2.f * samplingPitch)
384  {
385  const float nExtraPoints(thisDisplacement / samplingPitch);
386  for (float iExtra = 0.5f; iExtra < nExtraPoints; iExtra += 1.f)
387  {
388  const CartesianVector extraPosition(position3 + (lastPosition - position3) * (iExtra / nExtraPoints));
389  projectedPositions.push_back(extraPosition);
390  }
391  }
392  }
393 
394  projectedPositions.push_back(position3);
395 
396  lastPosition = position3;
397  foundLastPosition = true;
398  }
399 
400  // Bail out if list of projected positions is empty
401  if (projectedPositions.empty())
402  return STATUS_CODE_NOT_FOUND;
403 
404  return STATUS_CODE_SUCCESS;
405 }
Float_t x
Definition: compare.C:6
static void MergeTwoPositions3D(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const pandora::CartesianVector &position1, const pandora::CartesianVector &position2, pandora::CartesianVector &position3D, float &chiSquared)
Merge 2D positions from two views to give unified 3D position.
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
TFile f
Definition: plotHisto.C:6
Int_t max
Definition: plot.C:27
static float MergeTwoPositions(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const float position1, const float position2)
Merge two views (U,V) to give a third view (Z).
float m_minXOverlapFraction
requirement on minimum X overlap fraction for associated clusters
Int_t min
Definition: plot.C:26
static void GetClusterSpanX(const pandora::Cluster *const pCluster, float &xmin, float &xmax)
Get minimum and maximum X positions of the calo hits in a cluster.
float m_minXOverlap
requirement on minimum X overlap for associated clusters
const pandora::ClusterList& lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::GetSelectedClusterListU ( ) const
inherited

Get the selected u cluster list.

const pandora::ClusterList& lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::GetSelectedClusterListV ( ) const
inherited

Get the selected v cluster list.

const pandora::ClusterList& lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::GetSelectedClusterListW ( ) const
inherited

Get the selected w cluster list.

unsigned int lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::GetSlidingFitWindow ( ) const
inherited

Get the layer window for the sliding linear fits.

Returns
the layer window for the sliding linear fits
virtual bool lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::MakeClusterMerges ( const ClusterMergeMap clusterMergeMap)
virtualinherited

Merge clusters together.

Parameters
clusterMergeMapthe cluster merge map
Returns
whether changes to the tensor have been made
virtual bool lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::MakeClusterSplit ( const pandora::CartesianVector &  splitPosition,
const pandora::Cluster *&  pCurrentCluster,
const pandora::Cluster *&  pLowXCluster,
const pandora::Cluster *&  pHighXCluster 
) const
virtualinherited

Make a cluster split.

Parameters
splitPositionthe split position
pCurrentClusterthe cluster to split
pLowXClusterto receive the low x cluster
pHighXClusterto receive the high x cluster
Returns
whether a cluster split occurred
virtual bool lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::MakeClusterSplits ( const SplitPositionMap splitPositionMap)
virtualinherited

Make cluster splits.

Parameters
splitPositionMapthe split position map
Returns
whether changes to the tensor have been made
void lar_content::ThreeDTrackFragmentsAlgorithm::PerformMainLoop ( )
protectedvirtual

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

Reimplemented from lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >.

Definition at line 118 of file ThreeDTrackFragmentsAlgorithm.cc.

References CalculateOverlapResult(), CheckMatchedClusters(), CheckOverlapResult(), f, lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::GetCachedSlidingFitResult(), lar_content::TwoDSlidingFitResult::GetCluster(), lar_content::LArClusterHelper::GetClusterSpanX(), lar_content::FragmentOverlapResult::GetFragmentCaloHitList(), GetFragmentOverlapResult(), lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::GetInputClusterListU(), lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::GetInputClusterListV(), lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::GetInputClusterListW(), GetMatchedClusters(), GetMatchedHits(), lar_content::OverlapTensor< T >::GetOverlapResult(), GetProjectedPositions(), lar_content::TrackOverlapResult::IsInitialized(), lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::m_clusterListU, lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::m_clusterListV, lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::m_clusterListW, lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::m_overlapTensor, max, min, lar_content::OverlapTensor< T >::ReplaceOverlapResult(), lar_content::OverlapTensor< T >::SetOverlapResult(), and lar_content::LArClusterHelper::SortByNHits().

119 {
120  ClusterVector clusterVectorU(m_clusterListU.begin(), m_clusterListU.end());
121  ClusterVector clusterVectorV(m_clusterListV.begin(), m_clusterListV.end());
122  ClusterVector clusterVectorW(m_clusterListW.begin(), m_clusterListW.end());
123  std::sort(clusterVectorU.begin(), clusterVectorU.end(), LArClusterHelper::SortByNHits);
124  std::sort(clusterVectorV.begin(), clusterVectorV.end(), LArClusterHelper::SortByNHits);
125  std::sort(clusterVectorW.begin(), clusterVectorW.end(), LArClusterHelper::SortByNHits);
126 
127  for (const Cluster *const pClusterU : clusterVectorU)
128  {
129  for (const Cluster *const pClusterV : clusterVectorV)
130  this->CalculateOverlapResult(pClusterU, pClusterV, NULL);
131  }
132 
133  for (const Cluster *const pClusterU : clusterVectorU)
134  {
135  for (const Cluster *const pClusterW : clusterVectorW)
136  this->CalculateOverlapResult(pClusterU, NULL, pClusterW);
137  }
138 
139  for (const Cluster *const pClusterV : clusterVectorV)
140  {
141  for (const Cluster *const pClusterW : clusterVectorW)
142  this->CalculateOverlapResult(NULL, pClusterV, pClusterW);
143  }
144 }
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.
pandora::ClusterList m_clusterListW
The selected modified cluster list W.
void CalculateOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW)
Calculate cluster overlap result and store in tensor.
pandora::ClusterList m_clusterListV
The selected modified cluster list V.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
pandora::ClusterList m_clusterListU
The selected modified cluster list U.
virtual void lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::PreparationStep ( )
protectedvirtualinherited

Perform any preparatory steps required, e.g. caching expensive fit results for clusters.

Reimplemented from lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >.

virtual void lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::PreparationStep ( pandora::ClusterList &  clusterList)
protectedvirtualinherited

Preparation step for a specific cluster list.

Parameters
clusterListthe cluster list
StatusCode lar_content::ThreeDTrackFragmentsAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
protectedvirtual

Reimplemented from lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >.

Definition at line 634 of file ThreeDTrackFragmentsAlgorithm.cc.

References m_algorithmToolVector, m_maxPointDisplacementSquared, m_minMatchedHits, m_minMatchedSamplingPointFraction, m_minXOverlap, m_minXOverlapFraction, m_nMaxTensorToolRepeats, m_reclusteringAlgorithmName, and lar_content::ThreeDTracksBaseAlgorithm< T >::ReadSettings().

635 {
636  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithm(*this, xmlHandle,
637  "ClusterRebuilding", m_reclusteringAlgorithmName));
638 
639  AlgorithmToolVector algorithmToolVector;
640  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle,
641  "TrackTools", algorithmToolVector));
642 
643  for (AlgorithmToolVector::const_iterator iter = algorithmToolVector.begin(), iterEnd = algorithmToolVector.end(); iter != iterEnd; ++iter)
644  {
645  FragmentTensorTool *const pFragmentTensorTool(dynamic_cast<FragmentTensorTool*>(*iter));
646 
647  if (NULL == pFragmentTensorTool)
648  return STATUS_CODE_INVALID_PARAMETER;
649 
650  m_algorithmToolVector.push_back(pFragmentTensorTool);
651  }
652 
653  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
654  "NMaxTensorToolRepeats", m_nMaxTensorToolRepeats));
655 
656  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
657  "MinXOverlap", m_minXOverlap));
658 
659  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
660  "MinXOverlapFraction", m_minXOverlapFraction));
661 
662  float maxPointDisplacement = std::sqrt(m_maxPointDisplacementSquared);
663  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
664  "MaxPointDisplacement", maxPointDisplacement));
665  m_maxPointDisplacementSquared = maxPointDisplacement * maxPointDisplacement;
666 
667  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
668  "MinMatchedSamplingPointFraction", m_minMatchedSamplingPointFraction));
669 
670  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
671  "MinMatchedHits", m_minMatchedHits));
672 
674 }
float m_minMatchedSamplingPointFraction
minimum fraction of matched sampling points
unsigned int m_nMaxTensorToolRepeats
The maximum number of repeat loops over tensor tools.
intermediate_table::const_iterator const_iterator
std::string m_reclusteringAlgorithmName
Name of daughter algorithm to use for cluster re-building.
unsigned int m_minMatchedHits
minimum number of matched calo hits
TensorToolVector m_algorithmToolVector
The algorithm tool list.
float m_minXOverlapFraction
requirement on minimum X overlap fraction for associated clusters
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
float m_minXOverlap
requirement on minimum X overlap for associated clusters
float m_maxPointDisplacementSquared
maximum allowed distance (squared) between projected points and associated hits
void lar_content::ThreeDTrackFragmentsAlgorithm::RebuildClusters ( const pandora::ClusterList &  rebuildList,
pandora::ClusterList &  newClusters 
) const

Rebuild clusters after fragmentation.

Parameters
rebuildListthe list of clusters containing hits to be rebuilt
newClustersthe output list of clusters

Definition at line 102 of file ThreeDTrackFragmentsAlgorithm.cc.

References m_reclusteringAlgorithmName.

Referenced by lar_content::ClearTrackFragmentsTool::RebuildClusters().

103 {
104  const ClusterList *pNewClusterList = NULL;
105  std::string oldClusterListName, newClusterListName;
106 
107  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::InitializeReclustering(*this, TrackList(), rebuildList,
108  oldClusterListName));
109  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RunClusteringAlgorithm(*this, m_reclusteringAlgorithmName,
110  pNewClusterList, newClusterListName));
111 
112  newClusters.insert(newClusters.end(), pNewClusterList->begin(), pNewClusterList->end());
113  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::EndReclustering(*this, newClusterListName));
114 }
std::string m_reclusteringAlgorithmName
Name of daughter algorithm to use for cluster re-building.
void lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::RemoveFromSlidingFitCache ( const pandora::Cluster *const  pCluster)
protectedinherited

Remova an existing sliding fit result, for the specified cluster, from the algorithm cache.

Parameters
pClusteraddress of the relevant cluster
virtual void lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::RemoveUnavailableTensorElements ( )
virtualinherited

Update tensor to remove all elements that have been added to pfos and so are unavailable.

virtual void lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::SelectAllInputClusters ( )
protectedvirtualinherited

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

virtual void lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::SelectInputClusters ( const pandora::ClusterList *const  pInputClusterList,
pandora::ClusterList &  selectedClusterList 
) const
virtualinherited

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

Parameters
pInputClusterListaddress of an input cluster list
selectedClusterListto receive the selected cluster list

Implements lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >.

virtual void lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::SetPfoParameters ( const ProtoParticle protoParticle,
PandoraContentApi::ParticleFlowObject::Parameters &  pfoParameters 
) const
virtualinherited

Calculate Pfo properties from proto particle.

Parameters
protoParticlethe input proto particle
pfoParametersthe output pfo parameters

Implements lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >.

static bool lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::SortSplitPositions ( const pandora::CartesianVector &  lhs,
const pandora::CartesianVector &  rhs 
)
staticinherited

Sort split position cartesian vectors by increasing x coordinate.

Parameters
lhsthe first cartesian vector
rhsthe second cartesian vector
virtual void lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::TidyUp ( )
protectedvirtualinherited

Tidy member variables in derived class.

Reimplemented from lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >.

void lar_content::ThreeDTrackFragmentsAlgorithm::UpdateForNewCluster ( const pandora::Cluster *const  pNewCluster)
virtual

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

Parameters
pNewClusteraddress of the new cluster

Reimplemented from lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >.

Definition at line 33 of file ThreeDTrackFragmentsAlgorithm.cc.

References lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::AddToSlidingFitCache(), CalculateOverlapResult(), lar_content::LArClusterHelper::GetClusterHitType(), lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::m_clusterListU, lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::m_clusterListV, lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::m_clusterListW, and lar_content::LArClusterHelper::SortByNHits().

Referenced by lar_content::ClearTrackFragmentsTool::UpdateTensor().

34 {
35  try
36  {
37  this->AddToSlidingFitCache(pNewCluster);
38  }
39  catch (StatusCodeException &statusCodeException)
40  {
41  if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
42  throw statusCodeException;
43 
44  return;
45  }
46 
47  const HitType hitType(LArClusterHelper::GetClusterHitType(pNewCluster));
48 
49  if (!((TPC_VIEW_U == hitType) || (TPC_VIEW_V == hitType) || (TPC_VIEW_W == hitType)))
50  throw StatusCodeException(STATUS_CODE_FAILURE);
51 
52  ClusterList &clusterList((TPC_VIEW_U == hitType) ? m_clusterListU : (TPC_VIEW_V == hitType) ? m_clusterListV : m_clusterListW);
53 
54  if (clusterList.end() != std::find(clusterList.begin(), clusterList.end(), pNewCluster))
55  throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
56 
57  clusterList.push_back(pNewCluster);
58 
59  const ClusterList &clusterList1((TPC_VIEW_U == hitType) ? m_clusterListV : m_clusterListU);
60  const ClusterList &clusterList2((TPC_VIEW_W == hitType) ? m_clusterListV : m_clusterListW);
61 
62  ClusterVector clusterVector1(clusterList1.begin(), clusterList1.end());
63  ClusterVector clusterVector2(clusterList2.begin(), clusterList2.end());
64  std::sort(clusterVector1.begin(), clusterVector1.end(), LArClusterHelper::SortByNHits);
65  std::sort(clusterVector2.begin(), clusterVector2.end(), LArClusterHelper::SortByNHits);
66 
67  for (const Cluster *const pCluster1 : clusterVector1)
68  {
69  if (TPC_VIEW_U == hitType)
70  {
71  this->CalculateOverlapResult(pNewCluster, pCluster1, NULL);
72  }
73  else if (TPC_VIEW_V == hitType)
74  {
75  this->CalculateOverlapResult(pCluster1, pNewCluster, NULL);
76  }
77  else
78  {
79  this->CalculateOverlapResult(pCluster1, NULL, pNewCluster);
80  }
81  }
82 
83  for (const Cluster *const pCluster2 : clusterVector2)
84  {
85  if (TPC_VIEW_U == hitType)
86  {
87  this->CalculateOverlapResult(pNewCluster, NULL, pCluster2);
88  }
89  else if (TPC_VIEW_V == hitType)
90  {
91  this->CalculateOverlapResult(NULL, pNewCluster, pCluster2);
92  }
93  else
94  {
95  this->CalculateOverlapResult(NULL, pCluster2, pNewCluster);
96  }
97  }
98 }
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.
pandora::ClusterList m_clusterListW
The selected modified cluster list W.
void CalculateOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW)
Calculate cluster overlap result and store in tensor.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
void AddToSlidingFitCache(const pandora::Cluster *const pCluster)
Add a new sliding fit result, for the specified cluster, to the algorithm cache.
pandora::ClusterList m_clusterListV
The selected modified cluster list V.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
pandora::ClusterList m_clusterListU
The selected modified cluster list U.
virtual void lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::UpdateUponDeletion ( const pandora::Cluster *const  pDeletedCluster)
virtualinherited

Update to reflect cluster deletion.

Parameters
pDeletedClusteraddress of the deleted cluster

Reimplemented from lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >.

Member Data Documentation

TensorToolVector lar_content::ThreeDTrackFragmentsAlgorithm::m_algorithmToolVector
protected

The algorithm tool list.

Definition at line 144 of file ThreeDTrackFragmentsAlgorithm.h.

Referenced by ExamineTensor(), and ReadSettings().

pandora::ClusterList lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::m_clusterListU
protectedinherited

The selected modified cluster list U.

Definition at line 196 of file ThreeDBaseAlgorithm.h.

Referenced by PerformMainLoop(), and UpdateForNewCluster().

pandora::ClusterList lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::m_clusterListV
protectedinherited

The selected modified cluster list V.

Definition at line 197 of file ThreeDBaseAlgorithm.h.

Referenced by PerformMainLoop(), and UpdateForNewCluster().

pandora::ClusterList lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::m_clusterListW
protectedinherited

The selected modified cluster list W.

Definition at line 198 of file ThreeDBaseAlgorithm.h.

Referenced by PerformMainLoop(), and UpdateForNewCluster().

float lar_content::ThreeDTrackFragmentsAlgorithm::m_maxPointDisplacementSquared
protected

maximum allowed distance (squared) between projected points and associated hits

Definition at line 150 of file ThreeDTrackFragmentsAlgorithm.h.

Referenced by GetFragmentOverlapResult(), GetMatchedHits(), and ReadSettings().

unsigned int lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::m_minClusterCaloHits
protectedinherited

The min number of hits in base cluster selection method.

Definition at line 121 of file ThreeDTracksBaseAlgorithm.h.

float lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::m_minClusterLengthSquared
protectedinherited

The min length (squared) in base cluster selection method.

Definition at line 122 of file ThreeDTracksBaseAlgorithm.h.

unsigned int lar_content::ThreeDTrackFragmentsAlgorithm::m_minMatchedHits
protected

minimum number of matched calo hits

Definition at line 152 of file ThreeDTrackFragmentsAlgorithm.h.

Referenced by CheckOverlapResult(), and ReadSettings().

float lar_content::ThreeDTrackFragmentsAlgorithm::m_minMatchedSamplingPointFraction
protected

minimum fraction of matched sampling points

Definition at line 151 of file ThreeDTrackFragmentsAlgorithm.h.

Referenced by CheckOverlapResult(), and ReadSettings().

float lar_content::ThreeDTrackFragmentsAlgorithm::m_minXOverlap
protected

requirement on minimum X overlap for associated clusters

Definition at line 148 of file ThreeDTrackFragmentsAlgorithm.h.

Referenced by GetProjectedPositions(), and ReadSettings().

float lar_content::ThreeDTrackFragmentsAlgorithm::m_minXOverlapFraction
protected

requirement on minimum X overlap fraction for associated clusters

Definition at line 149 of file ThreeDTrackFragmentsAlgorithm.h.

Referenced by GetProjectedPositions(), and ReadSettings().

unsigned int lar_content::ThreeDTrackFragmentsAlgorithm::m_nMaxTensorToolRepeats
protected

The maximum number of repeat loops over tensor tools.

Definition at line 146 of file ThreeDTrackFragmentsAlgorithm.h.

Referenced by ExamineTensor(), and ReadSettings().

TensorType lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::m_overlapTensor
protectedinherited

The overlap tensor.

Definition at line 200 of file ThreeDBaseAlgorithm.h.

Referenced by ExamineTensor(), and PerformMainLoop().

const pandora::ClusterList* lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::m_pInputClusterListU
protectedinherited

Address of the input cluster list U.

Definition at line 192 of file ThreeDBaseAlgorithm.h.

const pandora::ClusterList* lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::m_pInputClusterListV
protectedinherited

Address of the input cluster list V.

Definition at line 193 of file ThreeDBaseAlgorithm.h.

const pandora::ClusterList* lar_content::ThreeDBaseAlgorithm< FragmentOverlapResult >::m_pInputClusterListW
protectedinherited

Address of the input cluster list W.

Definition at line 194 of file ThreeDBaseAlgorithm.h.

std::string lar_content::ThreeDTrackFragmentsAlgorithm::m_reclusteringAlgorithmName
protected

Name of daughter algorithm to use for cluster re-building.

Definition at line 141 of file ThreeDTrackFragmentsAlgorithm.h.

Referenced by ReadSettings(), and RebuildClusters().

The sliding fit result map.

Definition at line 119 of file ThreeDTracksBaseAlgorithm.h.

unsigned int lar_content::ThreeDTracksBaseAlgorithm< FragmentOverlapResult >::m_slidingFitWindow
protectedinherited

The layer window for the sliding linear fits.

Definition at line 118 of file ThreeDTracksBaseAlgorithm.h.


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