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

ThreeViewTrackFragmentsAlgorithm class. More...

#include "ThreeViewTrackFragmentsAlgorithm.h"

Inheritance diagram for lar_content::ThreeViewTrackFragmentsAlgorithm:
lar_content::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > > lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > > lar_content::MatchingBaseAlgorithm

Public Types

typedef NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > > BaseAlgorithm
 
typedef ThreeViewMatchingControl< FragmentOverlapResultMatchingType
 

Public Member Functions

 ThreeViewTrackFragmentsAlgorithm ()
 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 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...
 
const std::string & GetClusterListName (const pandora::HitType hitType) const
 Get the cluster list name corresponding to a specified hit type. More...
 
const pandora::ClusterList & GetInputClusterList (const pandora::HitType hitType) const
 Get the input cluster list corresponding to a specified hit type. More...
 
const pandora::ClusterList & GetSelectedClusterList (const pandora::HitType hitType) const
 Get the selected cluster list corresponding to a specified hit type. More...
 
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...
 

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 overlap container. 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 container. 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 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)
 
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...
 
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...
 

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...
 
MatchingType m_matchingControl
 The matching control. More...
 

Detailed Description

Member Typedef Documentation

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

Definition at line 142 of file ThreeViewTrackFragmentsAlgorithm.h.

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

Definition at line 69 of file ThreeViewTrackFragmentsAlgorithm.h.

Constructor & Destructor Documentation

lar_content::ThreeViewTrackFragmentsAlgorithm::ThreeViewTrackFragmentsAlgorithm ( )

Default constructor.

Definition at line 21 of file ThreeViewTrackFragmentsAlgorithm.cc.

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

Member Function Documentation

void lar_content::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< 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::ThreeViewTrackFragmentsAlgorithm::CalculateOverlapResult ( const pandora::Cluster *const  pCluster1,
const pandora::Cluster *const  pCluster2,
const pandora::Cluster *const  pCluster3 
)
protectedvirtual

Calculate cluster overlap result and store in container.

Parameters
pCluster1address of cluster1
pCluster2address of cluster2
pCluster3address of cluster3

Implements lar_content::MatchingBaseAlgorithm.

Referenced by PerformMainLoop(), and UpdateForNewCluster().

pandora::StatusCode lar_content::ThreeViewTrackFragmentsAlgorithm::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::ThreeViewTrackFragmentsAlgorithm::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 556 of file ThreeViewTrackFragmentsAlgorithm.cc.

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

Referenced by PerformMainLoop().

557 {
558  if (projectedPositions.empty() || matchedClusters.empty())
559  return false;
560 
561  // Calculate X and Z span of projected positions
562  float minXproj(+std::numeric_limits<float>::max());
563  float maxXproj(-std::numeric_limits<float>::max());
564  float minZproj(+std::numeric_limits<float>::max());
565  float maxZproj(-std::numeric_limits<float>::max());
566 
567  for (const CartesianVector &projectedPosition : projectedPositions)
568  {
569  minXproj = std::min(minXproj, projectedPosition.GetX());
570  maxXproj = std::max(maxXproj, projectedPosition.GetX());
571  minZproj = std::min(minZproj, projectedPosition.GetZ());
572  maxZproj = std::max(maxZproj, projectedPosition.GetZ());
573  }
574 
575  const float dXproj(maxXproj - minXproj);
576  const float dZproj(maxZproj - minZproj);
577  const float projectedLengthSquared(dXproj * dXproj + dZproj * dZproj);
578 
579  // Calculate X and Z span of matched clusters
580  float minXcluster(+std::numeric_limits<float>::max());
581  float maxXcluster(-std::numeric_limits<float>::max());
582  float minZcluster(+std::numeric_limits<float>::max());
583  float maxZcluster(-std::numeric_limits<float>::max());
584 
585  for (const Cluster *const pCluster : matchedClusters)
586  {
587  CartesianVector minPosition(0.f, 0.f, 0.f);
588  CartesianVector maxPosition(0.f, 0.f, 0.f);
589 
590  LArClusterHelper::GetClusterBoundingBox(pCluster, minPosition, maxPosition);
591 
592  minXcluster = std::min(minXcluster, minPosition.GetX());
593  maxXcluster = std::max(maxXcluster, maxPosition.GetX());
594  minZcluster = std::min(minZcluster, minPosition.GetZ());
595  maxZcluster = std::max(maxZcluster, maxPosition.GetZ());
596  }
597 
598  const float dXcluster(maxXcluster - minXcluster);
599  const float dZcluster(maxZcluster - minZcluster);
600  const float clusterLengthSquared(dXcluster * dXcluster + dZcluster * dZcluster);
601 
602  // Require that the span of the matched clusters is no larger than twice the span of the projected positions
603  if (clusterLengthSquared > 4.f * projectedLengthSquared)
604  return false;
605 
606  return true;
607 }
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.
bool lar_content::ThreeViewTrackFragmentsAlgorithm::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 611 of file ThreeViewTrackFragmentsAlgorithm.cc.

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

Referenced by PerformMainLoop().

612 {
613  // ATTN This method is currently mirrored in ClearTrackFragments tool
614  if (overlapResult.GetMatchedFraction() < m_minMatchedSamplingPointFraction)
615  return false;
616 
617  if (overlapResult.GetFragmentCaloHitList().size() < m_minMatchedHits)
618  return false;
619 
620  return true;
621 }
unsigned int m_minMatchedHits
minimum number of matched calo hits
float m_minMatchedSamplingPointFraction
minimum fraction of matched sampling points
bool lar_content::MatchingBaseAlgorithm::CreateThreeDParticles ( const ProtoParticleVector protoParticleVector)
virtualinherited

Create particles using findings from recent algorithm processing.

Parameters
protoParticleVectorthe proto particle vector
whetherparticles were created

Definition at line 88 of file MatchingBaseAlgorithm.cc.

Referenced by lar_content::NViewDeltaRayMatchingAlgorithm< T >::CreatePfos(), lar_content::ClearRemnantsTool::CreateThreeDParticles(), lar_content::TwoViewClearTracksTool::CreateThreeDParticles(), lar_content::ClearLongitudinalTracksTool::CreateThreeDParticles(), lar_content::ClearTracksTool::CreateThreeDParticles(), lar_content::ClearTrackFragmentsTool::FindTrackFragments(), lar_content::SimpleShowersTool::Run(), lar_content::TwoViewSimpleTracksTool::Run(), lar_content::ConnectedRemnantsTool::Run(), lar_content::MopUpRemnantsTool::Run(), lar_content::MissingTrackTool::Run(), lar_content::MatchedEndPointsTool::Run(), lar_content::TracksCrossingGapsTool::Run(), lar_content::MissingTrackSegmentTool::Run(), lar_content::LongTracksTool::Run(), lar_content::TwoViewLongTracksTool::Run(), and lar_content::ClearShowersTool::Run().

89 {
90  bool particlesMade(false);
91  const PfoList *pPfoList(nullptr);
92  std::string pfoListName;
93  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pPfoList, pfoListName));
94 
95  for (const ProtoParticle &protoParticle : protoParticleVector)
96  {
97  PandoraContentApi::ParticleFlowObject::Parameters pfoParameters;
98  this->SetPfoParameters(protoParticle, pfoParameters);
99 
100  const ParticleFlowObject *pPfo(nullptr);
101  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, pfoParameters, pPfo));
102  particlesMade = true;
103  }
104 
105  if (!pPfoList->empty())
106  {
107  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Pfo>(*this, m_outputPfoListName));
108  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Pfo>(*this, m_outputPfoListName));
109  }
110 
111  return particlesMade;
112 }
virtual void SetPfoParameters(const ProtoParticle &protoParticle, PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
Set Pfo properties.
std::string m_outputPfoListName
The output pfo list name.
void lar_content::ThreeViewTrackFragmentsAlgorithm::ExamineOverlapContainer ( )
protectedvirtual

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

Implements lar_content::MatchingBaseAlgorithm.

Definition at line 625 of file ThreeViewTrackFragmentsAlgorithm.cc.

References m_algorithmToolVector, and m_nMaxTensorToolRepeats.

626 {
627  unsigned int repeatCounter(0);
628 
629  for (TensorToolVector::const_iterator iter = m_algorithmToolVector.begin(), iterEnd = m_algorithmToolVector.end(); iter != iterEnd;)
630  {
631  if ((*iter)->Run(this, this->GetMatchingControl().GetOverlapTensor()))
632  {
633  iter = m_algorithmToolVector.begin();
634 
635  if (++repeatCounter > m_nMaxTensorToolRepeats)
636  break;
637  }
638  else
639  {
640  ++iter;
641  }
642  }
643 }
intermediate_table::const_iterator const_iterator
TensorToolVector m_algorithmToolVector
The algorithm tool list.
unsigned int m_nMaxTensorToolRepeats
The maximum number of repeat loops over tensor tools.
const TwoDSlidingFitResult& lar_content::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< 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::NViewMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::GetClusterListName ( const pandora::HitType  hitType) const
virtualinherited

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

Parameters
hitTypethe hit type
Returns
the cluster list name

Implements lar_content::MatchingBaseAlgorithm.

void lar_content::ThreeViewTrackFragmentsAlgorithm::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 523 of file ThreeViewTrackFragmentsAlgorithm.cc.

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

Referenced by PerformMainLoop().

525 {
526  float chi2Sum(0.f);
527  unsigned int nMatchedSamplingPoints(0);
528 
529  CaloHitVector sortedMatchedHits(matchedHits.begin(), matchedHits.end());
530  std::sort(sortedMatchedHits.begin(), sortedMatchedHits.end(), LArClusterHelper::SortHitsByPosition);
531 
532  for (const CartesianVector &projectedPosition : projectedPositions)
533  {
534  float closestDistanceSquared(std::numeric_limits<float>::max());
535 
536  for (const CaloHit *const pCaloHit : matchedHits)
537  {
538  const float distanceSquared((pCaloHit->GetPositionVector() - projectedPosition).GetMagnitudeSquared());
539 
540  if (distanceSquared < closestDistanceSquared)
541  closestDistanceSquared = distanceSquared;
542  }
543 
544  if (closestDistanceSquared < m_maxPointDisplacementSquared)
545  {
546  ++nMatchedSamplingPoints;
547  chi2Sum += closestDistanceSquared;
548  }
549  }
550 
551  fragmentOverlapResult = FragmentOverlapResult(nMatchedSamplingPoints, projectedPositions.size(), chi2Sum, matchedHits, matchedClusters);
552 }
TFile f
Definition: plotHisto.C:6
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::NViewMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::GetInputClusterList ( const pandora::HitType  hitType) const
virtualinherited

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

Parameters
hitTypethe hit type
Returns
the input cluster list

Implements lar_content::MatchingBaseAlgorithm.

Referenced by PerformMainLoop().

StatusCode lar_content::ThreeViewTrackFragmentsAlgorithm::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 472 of file ThreeViewTrackFragmentsAlgorithm.cc.

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

Referenced by PerformMainLoop().

474 {
475  ClusterToMatchedHitsMap clusterToMatchedHitsMap;
476 
477  for (CaloHitList::const_iterator iter = matchedHits.begin(), iterEnd = matchedHits.end(); iter != iterEnd; ++iter)
478  {
479  const CaloHit *const pCaloHit = *iter;
480  HitToClusterMap::const_iterator cIter = hitToClusterMap.find(pCaloHit);
481 
482  if (hitToClusterMap.end() == cIter)
483  throw StatusCodeException(STATUS_CODE_FAILURE);
484 
485  ++clusterToMatchedHitsMap[cIter->second];
486 
487  if (matchedClusters.end() == std::find(matchedClusters.begin(), matchedClusters.end(), cIter->second))
488  matchedClusters.push_back(cIter->second);
489  }
490 
491  if (matchedClusters.empty())
492  return STATUS_CODE_NOT_FOUND;
493 
494  pBestMatchedCluster = nullptr;
495  unsigned int bestClusterMatchedHits(0);
496  float tieBreakerBestEnergy(0.f);
497 
498  ClusterVector sortedClusters;
499  for (const auto &mapEntry : clusterToMatchedHitsMap)
500  sortedClusters.push_back(mapEntry.first);
501  std::sort(sortedClusters.begin(), sortedClusters.end(), LArClusterHelper::SortByNHits);
502 
503  for (const Cluster *const pCluster : sortedClusters)
504  {
505  const unsigned int nMatchedHits(clusterToMatchedHitsMap.at(pCluster));
506 
507  if ((nMatchedHits > bestClusterMatchedHits) || ((nMatchedHits == bestClusterMatchedHits) && (pCluster->GetHadronicEnergy() > tieBreakerBestEnergy)))
508  {
509  pBestMatchedCluster = pCluster;
510  bestClusterMatchedHits = nMatchedHits;
511  tieBreakerBestEnergy = pCluster->GetHadronicEnergy();
512  }
513  }
514 
515  if (nullptr == pBestMatchedCluster)
516  return STATUS_CODE_NOT_FOUND;
517 
518  return STATUS_CODE_SUCCESS;
519 }
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
intermediate_table::const_iterator const_iterator
TFile f
Definition: plotHisto.C:6
std::vector< art::Ptr< recob::Cluster > > ClusterVector
StatusCode lar_content::ThreeViewTrackFragmentsAlgorithm::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 418 of file ThreeViewTrackFragmentsAlgorithm.cc.

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

Referenced by PerformMainLoop().

420 {
421  CaloHitVector availableCaloHits;
422 
423  for (ClusterList::const_iterator iter = inputClusterList.begin(), iterEnd = inputClusterList.end(); iter != iterEnd; ++iter)
424  {
425  const Cluster *const pCluster = *iter;
426 
427  if (!pCluster->IsAvailable())
428  continue;
429 
430  CaloHitList caloHitList;
431  pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
432  availableCaloHits.insert(availableCaloHits.end(), caloHitList.begin(), caloHitList.end());
433 
434  for (CaloHitList::const_iterator hIter = caloHitList.begin(), hIterEnd = caloHitList.end(); hIter != hIterEnd; ++hIter)
435  hitToClusterMap.insert(HitToClusterMap::value_type(*hIter, pCluster));
436  }
437 
438  std::sort(availableCaloHits.begin(), availableCaloHits.end(), LArClusterHelper::SortHitsByPosition);
439 
440  for (const CartesianVector &projectedPosition : projectedPositions)
441  {
442  const CaloHit *pClosestCaloHit(nullptr);
443  float closestDistanceSquared(std::numeric_limits<float>::max()), tieBreakerBestEnergy(0.f);
444 
445  for (const CaloHit *const pCaloHit : availableCaloHits)
446  {
447  const float distanceSquared((pCaloHit->GetPositionVector() - projectedPosition).GetMagnitudeSquared());
448 
449  if ((distanceSquared < closestDistanceSquared) ||
450  ((std::fabs(distanceSquared - closestDistanceSquared) < std::numeric_limits<float>::epsilon()) &&
451  (pCaloHit->GetHadronicEnergy() > tieBreakerBestEnergy)))
452  {
453  pClosestCaloHit = pCaloHit;
454  closestDistanceSquared = distanceSquared;
455  tieBreakerBestEnergy = pCaloHit->GetHadronicEnergy();
456  }
457  }
458 
459  if ((closestDistanceSquared < m_maxPointDisplacementSquared) && (nullptr != pClosestCaloHit) &&
460  (matchedHits.end() == std::find(matchedHits.begin(), matchedHits.end(), pClosestCaloHit)))
461  matchedHits.push_back(pClosestCaloHit);
462  }
463 
464  if (matchedHits.empty())
465  return STATUS_CODE_NOT_FOUND;
466 
467  return STATUS_CODE_SUCCESS;
468 }
intermediate_table::const_iterator const_iterator
TFile f
Definition: plotHisto.C:6
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

Get the matching control.

Referenced by PerformMainLoop(), and UpdateForNewCluster().

StatusCode lar_content::ThreeViewTrackFragmentsAlgorithm::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 272 of file ThreeViewTrackFragmentsAlgorithm.cc.

References f, lar_content::TwoDSlidingFitResult::GetCluster(), lar_content::LArClusterHelper::GetClusterHitType(), 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::GetWirePitch(), m_minXOverlap, m_minXOverlapFraction, lar_content::LArGeometryHelper::MergeTwoPositions(), lar_content::LArGeometryHelper::MergeTwoPositions3D(), lar_content::LArGeometryHelper::ProjectPosition(), and x.

Referenced by PerformMainLoop().

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

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

Parameters
hitTypethe hit type
Returns
the selected cluster list

Implements lar_content::MatchingBaseAlgorithm.

Referenced by PerformMainLoop(), and UpdateForNewCluster().

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

Get the layer window for the sliding linear fits.

Returns
the layer window for the sliding linear fits
bool lar_content::MatchingBaseAlgorithm::MakeClusterMerges ( const ClusterMergeMap clusterMergeMap)
virtualinherited

Merge clusters together.

Parameters
clusterMergeMapthe cluster merge map
Returns
whether changes to the overlap container have been made

Definition at line 48 of file MatchingBaseAlgorithm.cc.

Referenced by lar_content::SplitShowersTool::ApplyChanges(), lar_content::ThreeDKinkBaseTool::ApplyChanges(), lar_content::TwoViewThreeDKinkTool::ApplyChanges(), lar_content::ConnectedRemnantsTool::Run(), and lar_content::MissingTrackSegmentTool::Run().

49 {
50  ClusterSet deletedClusters;
51 
52  ClusterList parentClusters;
53  for (const auto &mapEntry : clusterMergeMap)
54  parentClusters.push_back(mapEntry.first);
55  parentClusters.sort(LArClusterHelper::SortByNHits);
56 
57  for (const Cluster *const pParentCluster : parentClusters)
58  {
59  const HitType hitType(LArClusterHelper::GetClusterHitType(pParentCluster));
60  const std::string &clusterListName(this->GetClusterListName(hitType));
61 
62  if (!((TPC_VIEW_U == hitType) || (TPC_VIEW_V == hitType) || (TPC_VIEW_W == hitType)))
63  throw StatusCodeException(STATUS_CODE_FAILURE);
64 
65  ClusterList daughterClusters(clusterMergeMap.at(pParentCluster));
66  daughterClusters.sort(LArClusterHelper::SortByNHits);
67 
68  for (const Cluster *const pDaughterCluster : daughterClusters)
69  {
70  if (deletedClusters.count(pParentCluster) || deletedClusters.count(pDaughterCluster))
71  throw StatusCodeException(STATUS_CODE_FAILURE);
72 
73  this->UpdateUponDeletion(pDaughterCluster);
74  this->UpdateUponDeletion(pParentCluster);
75  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
76  PandoraContentApi::MergeAndDeleteClusters(*this, pParentCluster, pDaughterCluster, clusterListName, clusterListName));
77 
78  this->UpdateForNewCluster(pParentCluster);
79  deletedClusters.insert(pDaughterCluster);
80  }
81  }
82 
83  return !(deletedClusters.empty());
84 }
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.
virtual void UpdateUponDeletion(const pandora::Cluster *const pDeletedCluster)=0
Update to reflect cluster deletion.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
virtual const std::string & GetClusterListName(const pandora::HitType hitType) const =0
Get the cluster list name corresponding to a specified hit type.
virtual void UpdateForNewCluster(const pandora::Cluster *const pNewCluster)=0
Update to reflect addition of a new cluster to the problem space.
HitType
Definition: HitType.h:12
virtual bool lar_content::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< 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::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::MakeClusterSplits ( const SplitPositionMap splitPositionMap)
virtualinherited

Make cluster splits.

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

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

Reimplemented from lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >.

Definition at line 118 of file ThreeViewTrackFragmentsAlgorithm.cc.

References CalculateOverlapResult(), CheckMatchedClusters(), CheckOverlapResult(), f, lar_content::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::GetCachedSlidingFitResult(), lar_content::TwoDSlidingFitResult::GetCluster(), lar_content::FragmentOverlapResult::GetFragmentCaloHitList(), GetFragmentOverlapResult(), lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::GetInputClusterList(), GetMatchedClusters(), GetMatchedHits(), lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::GetMatchingControl(), lar_content::OverlapTensor< T >::GetOverlapResult(), GetProjectedPositions(), lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::GetSelectedClusterList(), lar_content::TrackOverlapResult::IsInitialized(), lar_content::OverlapTensor< T >::ReplaceOverlapResult(), lar_content::OverlapTensor< T >::SetOverlapResult(), and lar_content::LArClusterHelper::SortByNHits().

119 {
120  ClusterList clusterListU(this->GetSelectedClusterList(TPC_VIEW_U));
121  ClusterList clusterListV(this->GetSelectedClusterList(TPC_VIEW_V));
122  ClusterList clusterListW(this->GetSelectedClusterList(TPC_VIEW_W));
123  clusterListU.sort(LArClusterHelper::SortByNHits);
124  clusterListV.sort(LArClusterHelper::SortByNHits);
125  clusterListW.sort(LArClusterHelper::SortByNHits);
126 
127  for (const Cluster *const pClusterU : clusterListU)
128  {
129  for (const Cluster *const pClusterV : clusterListV)
130  this->CalculateOverlapResult(pClusterU, pClusterV, nullptr);
131  }
132 
133  for (const Cluster *const pClusterU : clusterListU)
134  {
135  for (const Cluster *const pClusterW : clusterListW)
136  this->CalculateOverlapResult(pClusterU, nullptr, pClusterW);
137  }
138 
139  for (const Cluster *const pClusterV : clusterListV)
140  {
141  for (const Cluster *const pClusterW : clusterListW)
142  this->CalculateOverlapResult(nullptr, 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.
void CalculateOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW)
Calculate cluster overlap result and store in container.
const pandora::ClusterList & GetSelectedClusterList(const pandora::HitType hitType) const
virtual void lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::PrepareAllInputClusters ( )
protectedvirtualinherited

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

Implements lar_content::MatchingBaseAlgorithm.

virtual void lar_content::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::PrepareInputClusters ( pandora::ClusterList &  preparedClusterList)
virtualinherited

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

Parameters
preparedClusterListto receive the prepared cluster list, non const so as to be able to modify input selected list

Reimplemented from lar_content::MatchingBaseAlgorithm.

StatusCode lar_content::ThreeViewTrackFragmentsAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
protectedvirtual

Reimplemented from lar_content::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >.

Definition at line 647 of file ThreeViewTrackFragmentsAlgorithm.cc.

References m_algorithmToolVector, m_maxPointDisplacementSquared, m_minMatchedHits, m_minMatchedSamplingPointFraction, m_minXOverlap, m_minXOverlapFraction, m_nMaxTensorToolRepeats, m_reclusteringAlgorithmName, and lar_content::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::ReadSettings().

648 {
649  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithm(*this, xmlHandle, "ClusterRebuilding", m_reclusteringAlgorithmName));
650 
651  AlgorithmToolVector algorithmToolVector;
652  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "TrackTools", algorithmToolVector));
653 
654  for (AlgorithmToolVector::const_iterator iter = algorithmToolVector.begin(), iterEnd = algorithmToolVector.end(); iter != iterEnd; ++iter)
655  {
656  FragmentTensorTool *const pFragmentTensorTool(dynamic_cast<FragmentTensorTool *>(*iter));
657 
658  if (!pFragmentTensorTool)
659  return STATUS_CODE_INVALID_PARAMETER;
660 
661  m_algorithmToolVector.push_back(pFragmentTensorTool);
662  }
663 
664  PANDORA_RETURN_RESULT_IF_AND_IF(
665  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NMaxTensorToolRepeats", m_nMaxTensorToolRepeats));
666 
667  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinXOverlap", m_minXOverlap));
668 
669  PANDORA_RETURN_RESULT_IF_AND_IF(
670  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinXOverlapFraction", m_minXOverlapFraction));
671 
672  float maxPointDisplacement = std::sqrt(m_maxPointDisplacementSquared);
673  PANDORA_RETURN_RESULT_IF_AND_IF(
674  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxPointDisplacement", maxPointDisplacement));
675  m_maxPointDisplacementSquared = maxPointDisplacement * maxPointDisplacement;
676 
677  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
678  XmlHelper::ReadValue(xmlHandle, "MinMatchedSamplingPointFraction", m_minMatchedSamplingPointFraction));
679 
680  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinMatchedHits", m_minMatchedHits));
681 
682  return BaseAlgorithm::ReadSettings(xmlHandle);
683 }
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
unsigned int m_minMatchedHits
minimum number of matched calo hits
intermediate_table::const_iterator const_iterator
std::string m_reclusteringAlgorithmName
Name of daughter algorithm to use for cluster re-building.
TensorToolVector m_algorithmToolVector
The algorithm tool list.
unsigned int m_nMaxTensorToolRepeats
The maximum number of repeat loops over tensor tools.
float m_minXOverlapFraction
requirement on minimum X overlap fraction for associated clusters
float m_maxPointDisplacementSquared
maximum allowed distance (squared) between projected points and associated hits
float m_minXOverlap
requirement on minimum X overlap for associated clusters
float m_minMatchedSamplingPointFraction
minimum fraction of matched sampling points
void lar_content::ThreeViewTrackFragmentsAlgorithm::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 103 of file ThreeViewTrackFragmentsAlgorithm.cc.

References m_reclusteringAlgorithmName.

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

104 {
105  const ClusterList *pNewClusterList = nullptr;
106  std::string oldClusterListName, newClusterListName;
107 
108  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::InitializeReclustering(*this, TrackList(), rebuildList, oldClusterListName));
109  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
110  PandoraContentApi::RunClusteringAlgorithm(*this, m_reclusteringAlgorithmName, 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::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< 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::NViewMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::SelectAllInputClusters ( )
protectedvirtualinherited

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

Implements lar_content::MatchingBaseAlgorithm.

virtual void lar_content::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< 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

Reimplemented from lar_content::MatchingBaseAlgorithm.

void lar_content::MatchingBaseAlgorithm::SetPfoParameters ( const ProtoParticle protoParticle,
PandoraContentApi::ParticleFlowObject::Parameters &  pfoParameters 
) const
virtualinherited

Set Pfo properties.

Parameters
protoParticlethe input proto particle
pfoParametersthe output pfo parameters

Definition at line 116 of file MatchingBaseAlgorithm.cc.

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

117 {
118  this->SetPfoParticleId(pfoParameters);
119  pfoParameters.m_charge = PdgTable::GetParticleCharge(pfoParameters.m_particleId.Get());
120  pfoParameters.m_mass = PdgTable::GetParticleMass(pfoParameters.m_particleId.Get());
121  pfoParameters.m_energy = 0.f;
122  pfoParameters.m_momentum = CartesianVector(0.f, 0.f, 0.f);
123  pfoParameters.m_clusterList = protoParticle.m_clusterList;
124 }
TFile f
Definition: plotHisto.C:6
virtual void SetPfoParticleId(PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
Set pfo particle id.
virtual void lar_content::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::SetPfoParticleId ( PandoraContentApi::ParticleFlowObject::Parameters &  pfoParameters) const
virtualinherited

Set pfo particle id.

Parameters
pfoParametersthe output pfo parameters

Reimplemented from lar_content::MatchingBaseAlgorithm.

static bool lar_content::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< 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::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::TidyUp ( )
protectedvirtualinherited

Tidy member variables in derived class.

Reimplemented from lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >.

void lar_content::ThreeViewTrackFragmentsAlgorithm::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::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >.

Definition at line 33 of file ThreeViewTrackFragmentsAlgorithm.cc.

References lar_content::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::AddToSlidingFitCache(), CalculateOverlapResult(), lar_content::LArClusterHelper::GetClusterHitType(), lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::GetMatchingControl(), lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::GetSelectedClusterList(), lar_content::ThreeViewMatchingControl< T >::m_clusterListU, lar_content::ThreeViewMatchingControl< T >::m_clusterListV, lar_content::ThreeViewMatchingControl< T >::m_clusterListW, and lar_content::LArClusterHelper::SortByNHits().

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

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  // ATTN This is non-standard usage, supported here only (for legacy purposes)
53  MatchingType &matchingControl(this->GetMatchingControl());
54  ClusterList &clusterList((TPC_VIEW_U == hitType) ? matchingControl.m_clusterListU
55  : (TPC_VIEW_V == hitType) ? matchingControl.m_clusterListV
56  : matchingControl.m_clusterListW);
57 
58  if (clusterList.end() != std::find(clusterList.begin(), clusterList.end(), pNewCluster))
59  throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
60 
61  clusterList.push_back(pNewCluster);
62 
63  ClusterList clusterList1(this->GetSelectedClusterList((TPC_VIEW_U == hitType) ? TPC_VIEW_V : TPC_VIEW_U));
64  ClusterList clusterList2(this->GetSelectedClusterList((TPC_VIEW_W == hitType) ? TPC_VIEW_V : TPC_VIEW_W));
65  clusterList1.sort(LArClusterHelper::SortByNHits);
66  clusterList2.sort(LArClusterHelper::SortByNHits);
67 
68  for (const Cluster *const pCluster1 : clusterList1)
69  {
70  if (TPC_VIEW_U == hitType)
71  {
72  this->CalculateOverlapResult(pNewCluster, pCluster1, nullptr);
73  }
74  else if (TPC_VIEW_V == hitType)
75  {
76  this->CalculateOverlapResult(pCluster1, pNewCluster, nullptr);
77  }
78  else
79  {
80  this->CalculateOverlapResult(pCluster1, nullptr, pNewCluster);
81  }
82  }
83 
84  for (const Cluster *const pCluster2 : clusterList2)
85  {
86  if (TPC_VIEW_U == hitType)
87  {
88  this->CalculateOverlapResult(pNewCluster, nullptr, pCluster2);
89  }
90  else if (TPC_VIEW_V == hitType)
91  {
92  this->CalculateOverlapResult(nullptr, pNewCluster, pCluster2);
93  }
94  else
95  {
96  this->CalculateOverlapResult(nullptr, pCluster2, pNewCluster);
97  }
98  }
99 }
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.
void AddToSlidingFitCache(const pandora::Cluster *const pCluster)
Add a new sliding fit result, for the specified cluster, to the algorithm cache.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
void CalculateOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW)
Calculate cluster overlap result and store in container.
const pandora::ClusterList & GetSelectedClusterList(const pandora::HitType hitType) const
HitType
Definition: HitType.h:12
virtual void lar_content::NViewTrackMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >::UpdateUponDeletion ( const pandora::Cluster *const  pDeletedCluster)
virtualinherited

Update to reflect cluster deletion.

Parameters
pDeletedClusteraddress of the deleted cluster

Reimplemented from lar_content::NViewMatchingAlgorithm< ThreeViewMatchingControl< FragmentOverlapResult > >.

Member Data Documentation

TensorToolVector lar_content::ThreeViewTrackFragmentsAlgorithm::m_algorithmToolVector
protected

The algorithm tool list.

Definition at line 147 of file ThreeViewTrackFragmentsAlgorithm.h.

Referenced by ExamineOverlapContainer(), and ReadSettings().

The matching control.

Definition at line 53 of file NViewMatchingAlgorithm.h.

float lar_content::ThreeViewTrackFragmentsAlgorithm::m_maxPointDisplacementSquared
protected

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

Definition at line 153 of file ThreeViewTrackFragmentsAlgorithm.h.

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

unsigned int lar_content::ThreeViewTrackFragmentsAlgorithm::m_minMatchedHits
protected

minimum number of matched calo hits

Definition at line 155 of file ThreeViewTrackFragmentsAlgorithm.h.

Referenced by CheckOverlapResult(), and ReadSettings().

float lar_content::ThreeViewTrackFragmentsAlgorithm::m_minMatchedSamplingPointFraction
protected

minimum fraction of matched sampling points

Definition at line 154 of file ThreeViewTrackFragmentsAlgorithm.h.

Referenced by CheckOverlapResult(), and ReadSettings().

float lar_content::ThreeViewTrackFragmentsAlgorithm::m_minXOverlap
protected

requirement on minimum X overlap for associated clusters

Definition at line 151 of file ThreeViewTrackFragmentsAlgorithm.h.

Referenced by GetProjectedPositions(), and ReadSettings().

float lar_content::ThreeViewTrackFragmentsAlgorithm::m_minXOverlapFraction
protected

requirement on minimum X overlap fraction for associated clusters

Definition at line 152 of file ThreeViewTrackFragmentsAlgorithm.h.

Referenced by GetProjectedPositions(), and ReadSettings().

unsigned int lar_content::ThreeViewTrackFragmentsAlgorithm::m_nMaxTensorToolRepeats
protected

The maximum number of repeat loops over tensor tools.

Definition at line 149 of file ThreeViewTrackFragmentsAlgorithm.h.

Referenced by ExamineOverlapContainer(), and ReadSettings().

std::string lar_content::ThreeViewTrackFragmentsAlgorithm::m_reclusteringAlgorithmName
protected

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

Definition at line 144 of file ThreeViewTrackFragmentsAlgorithm.h.

Referenced by ReadSettings(), and RebuildClusters().


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