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

DeltaRayMatchingAlgorithm class. More...

#include "DeltaRayMatchingAlgorithm.h"

Inheritance diagram for lar_content::DeltaRayMatchingAlgorithm:

Classes

class  Particle
 Particle class. More...
 

Public Member Functions

 DeltaRayMatchingAlgorithm ()
 Default constructor. More...
 

Private Types

typedef std::vector< ParticleParticleList
 
typedef KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
 
typedef KDTreeNodeInfoT< const pandora::CaloHit *, 2 > HitKDNode2D
 
typedef std::vector< HitKDNode2DHitKDNode2DList
 
typedef std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterToClustersMap
 
typedef std::unordered_map< const pandora::CaloHit *, const pandora::Cluster * > HitToClusterMap
 
typedef std::unordered_map< const pandora::Cluster *, float > ClusterLengthMap
 
typedef std::unordered_map< const pandora::ParticleFlowObject *, float > PfoLengthMap
 

Private Member Functions

pandora::StatusCode Run ()
 
void InitializeNearbyClusterMaps ()
 Initialize nearby cluster maps. More...
 
void InitializeNearbyClusterMap (const std::string &clusterListName, ClusterToClustersMap &nearbyClusters)
 Initialize a nearby cluster map with details relating to a specific cluster list. More...
 
void ClearNearbyClusterMaps ()
 Clear nearby cluster maps. More...
 
void GetAllPfos (const std::string &inputPfoListName, pandora::PfoVector &pfoVector) const
 Get a vector of all Pfos in the provided input Pfo lists. More...
 
void GetTrackPfos (const std::string &inputPfoListName, pandora::PfoVector &pfoVector) const
 Get a vector of track-like Pfos in the provided input Pfo lists. More...
 
void GetClusters (const std::string &clusterListName, pandora::ClusterVector &clusterVector) const
 Get a vector containing all available input clusters in the provided cluster list, storing sliding linear fits in the algorithm cache. More...
 
void ThreeViewMatching (ClusterLengthMap &clusterLengthMap) const
 Match clusters using all three views. More...
 
void TwoViewMatching (ClusterLengthMap &clusterLengthMap) const
 Match clusters using pairs of views. More...
 
void OneViewMatching (ClusterLengthMap &clusterLengthMap) const
 Match clusters using single views. More...
 
void ThreeViewMatching (const pandora::ClusterVector &clusters1, const pandora::ClusterVector &clusters2, const pandora::ClusterVector &clusters3, ClusterLengthMap &clusterLengthMap, PfoLengthMap &pfoLengthMap, ParticleList &particleList) const
 Match clusters using all three views. More...
 
void TwoViewMatching (const pandora::ClusterVector &clusters1, const pandora::ClusterVector &clusters2, ClusterLengthMap &clusterLengthMap, PfoLengthMap &pfoLengthMap, ParticleList &particleList) const
 Match clusters using a pair of views. More...
 
void OneViewMatching (const pandora::ClusterVector &clusters, ClusterLengthMap &clusterLengthMap, PfoLengthMap &pfoLengthMap, ParticleList &particleList) const
 Match clusters using a single view. More...
 
void SelectParticles (const ParticleList &inputParticles, ClusterLengthMap &clusterLengthMap, ParticleList &outputParticles) const
 Resolve any ambiguities between candidate particles. More...
 
void CreateParticles (const ParticleList &particleList) const
 Build new particle flow objects. More...
 
void FindBestParentPfo (const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW, ClusterLengthMap &clusterLengthMap, PfoLengthMap &pfoLengthMap, const pandora::ParticleFlowObject *&pBestPfo) const
 Find best Pfo to associate a UVW triplet. More...
 
float GetLengthFromCache (const pandora::Cluster *const pCluster, ClusterLengthMap &clusterLengthMap) const
 Reduce number of length (squared) calculations by caching results when they are first obtained. More...
 
float GetLengthFromCache (const pandora::ParticleFlowObject *const pPfo, PfoLengthMap &pfoLengthMap) const
 Reduce number of length (squared) calculations by caching results when they are first obtained. More...
 
float GetLength (const Particle &particle, ClusterLengthMap &clusterLengthMap) const
 Get the length (squared) of a candidate particle. More...
 
bool AreClustersMatched (const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3) const
 Look at consistency of a combination of clusters. More...
 
float GetDistanceSquaredToPfo (const pandora::Cluster *const pCluster, const pandora::ParticleFlowObject *const pPfo) const
 Get displacementr between cluster and particle flow object. More...
 
void CreateDaughterPfo (const pandora::ClusterList &clusterList, const pandora::ParticleFlowObject *const pParentPfo) const
 Create a new Pfo from an input cluster list and set up a parent/daughter relationship. More...
 
void AddToDaughterPfo (const pandora::ClusterList &clusterList, const pandora::ParticleFlowObject *const pParentPfo) const
 Merge an input cluster list with an existing daughter Pfo. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

std::string m_parentPfoListName
 The parent pfo list name. More...
 
std::string m_daughterPfoListName
 The daughter pfo list name for new daughter particles. More...
 
std::string m_inputClusterListNameU
 The input cluster list name for the u view. More...
 
std::string m_inputClusterListNameV
 The input cluster list name for the v view. More...
 
std::string m_inputClusterListNameW
 The input cluster list name for the w view. More...
 
unsigned int m_minCaloHitsPerCluster
 The min number of calo hits per candidate cluster. More...
 
float m_xOverlapWindow
 The maximum allowed displacement in x position. More...
 
float m_distanceForMatching
 The maximum allowed distance between tracks and delta rays. More...
 
float m_pseudoChi2Cut
 Pseudo chi2 cut for three view matching. More...
 
float m_searchRegion1D
 Search region, applied to each dimension, for look-up from kd-trees. More...
 
ClusterToClustersMap m_nearbyClustersU
 The nearby clusters map for the u view. More...
 
ClusterToClustersMap m_nearbyClustersV
 The nearby clusters map for the v view. More...
 
ClusterToClustersMap m_nearbyClustersW
 The nearby clusters map for the w view. More...
 

Detailed Description

DeltaRayMatchingAlgorithm class.

Definition at line 26 of file DeltaRayMatchingAlgorithm.h.

Member Typedef Documentation

typedef std::unordered_map<const pandora::Cluster*, float> lar_content::DeltaRayMatchingAlgorithm::ClusterLengthMap
private

Definition at line 143 of file DeltaRayMatchingAlgorithm.h.

typedef std::unordered_map<const pandora::Cluster*, pandora::ClusterList> lar_content::DeltaRayMatchingAlgorithm::ClusterToClustersMap
private

Definition at line 97 of file DeltaRayMatchingAlgorithm.h.

typedef KDTreeNodeInfoT<const pandora::CaloHit*, 2> lar_content::DeltaRayMatchingAlgorithm::HitKDNode2D
private

Definition at line 94 of file DeltaRayMatchingAlgorithm.h.

typedef KDTreeLinkerAlgo<const pandora::CaloHit*, 2> lar_content::DeltaRayMatchingAlgorithm::HitKDTree2D
private

Definition at line 93 of file DeltaRayMatchingAlgorithm.h.

typedef std::unordered_map<const pandora::CaloHit*, const pandora::Cluster*> lar_content::DeltaRayMatchingAlgorithm::HitToClusterMap
private

Definition at line 98 of file DeltaRayMatchingAlgorithm.h.

Definition at line 91 of file DeltaRayMatchingAlgorithm.h.

typedef std::unordered_map<const pandora::ParticleFlowObject*, float> lar_content::DeltaRayMatchingAlgorithm::PfoLengthMap
private

Definition at line 144 of file DeltaRayMatchingAlgorithm.h.

Constructor & Destructor Documentation

lar_content::DeltaRayMatchingAlgorithm::DeltaRayMatchingAlgorithm ( )

Default constructor.

Definition at line 24 of file DeltaRayMatchingAlgorithm.cc.

24  :
28  m_pseudoChi2Cut(3.f),
30 {
31 }
float m_xOverlapWindow
The maximum allowed displacement in x position.
float m_pseudoChi2Cut
Pseudo chi2 cut for three view matching.
unsigned int m_minCaloHitsPerCluster
The min number of calo hits per candidate cluster.
TFile f
Definition: plotHisto.C:6
float m_searchRegion1D
Search region, applied to each dimension, for look-up from kd-trees.
float m_distanceForMatching
The maximum allowed distance between tracks and delta rays.

Member Function Documentation

void lar_content::DeltaRayMatchingAlgorithm::AddToDaughterPfo ( const pandora::ClusterList &  clusterList,
const pandora::ParticleFlowObject *const  pParentPfo 
) const
private

Merge an input cluster list with an existing daughter Pfo.

Parameters
clusterListthe list of clusters
pParentPfoaddress of the parent pfo

Definition at line 697 of file DeltaRayMatchingAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), lar_content::LArPfoHelper::GetClusters(), m_inputClusterListNameU, m_inputClusterListNameV, and m_inputClusterListNameW.

Referenced by CreateParticles().

698 {
699  for (const Cluster *const pDaughterCluster : clusterList)
700  {
701  const HitType hitType(LArClusterHelper::GetClusterHitType(pDaughterCluster));
702  const std::string clusterListName((TPC_VIEW_U == hitType) ? m_inputClusterListNameU :
703  (TPC_VIEW_V == hitType) ? m_inputClusterListNameV : m_inputClusterListNameW);
704 
705  ClusterList pfoClusters;
706  LArPfoHelper::GetClusters(pParentPfo, hitType, pfoClusters);
707 
708  if (pfoClusters.empty())
709  throw StatusCodeException(STATUS_CODE_FAILURE);
710 
711  const Cluster *const pParentCluster = *(pfoClusters.begin());
712 
713  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::MergeAndDeleteClusters(*this, pParentCluster, pDaughterCluster,
714  clusterListName, clusterListName));
715  }
716 }
static void GetClusters(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::ClusterList &clusterList)
Get a list of clusters of a particular hit type from a list of pfos.
std::string m_inputClusterListNameV
The input cluster list name for the v view.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
std::string m_inputClusterListNameW
The input cluster list name for the w view.
std::string m_inputClusterListNameU
The input cluster list name for the u view.
bool lar_content::DeltaRayMatchingAlgorithm::AreClustersMatched ( const pandora::Cluster *const  pCluster1,
const pandora::Cluster *const  pCluster2,
const pandora::Cluster *const  pCluster3 
) const
private

Look at consistency of a combination of clusters.

Parameters
pCluster1pointer to first luster
pCluster2pointer to second cluster
pCluster3pointer to third cluster

Definition at line 437 of file DeltaRayMatchingAlgorithm.cc.

References f, lar_content::LArClusterHelper::GetClusterHitType(), lar_content::LArClusterHelper::GetClusterSpanX(), lar_content::LArClusterHelper::GetClusterSpanZ(), lar_content::LArGeometryHelper::GetWireZPitch(), m_pseudoChi2Cut, m_xOverlapWindow, max, lar_content::LArGeometryHelper::MergeTwoPositions(), min, n, and x.

Referenced by OneViewMatching().

439 {
440  if (NULL == pCluster1 && NULL == pCluster2 && NULL == pCluster3)
441  throw StatusCodeException(STATUS_CODE_FAILURE);
442 
443  // First step: Check X overlap
447 
448  if (NULL != pCluster1)
449  LArClusterHelper::GetClusterSpanX(pCluster1, xMin1, xMax1);
450 
451  if (NULL != pCluster2)
452  LArClusterHelper::GetClusterSpanX(pCluster2, xMin2, xMax2);
453 
454  if (NULL != pCluster3)
455  LArClusterHelper::GetClusterSpanX(pCluster3, xMin3, xMax3);
456 
457  const float xPitch(0.5 * m_xOverlapWindow);
458  const float xMin(std::max(xMin1, std::max(xMin2, xMin3)) - xPitch);
459  const float xMax(std::min(xMax1, std::min(xMax2, xMax3)) + xPitch);
460  const float xOverlap(xMax - xMin);
461 
462  if (xOverlap < std::numeric_limits<float>::epsilon())
463  return false;
464 
465  if (NULL == pCluster1 || NULL == pCluster2 || NULL == pCluster3)
466  return true;
467 
468  // Second step: Check 3D matching
469  const HitType hitType1(LArClusterHelper::GetClusterHitType(pCluster1));
470  const HitType hitType2(LArClusterHelper::GetClusterHitType(pCluster2));
471  const HitType hitType3(LArClusterHelper::GetClusterHitType(pCluster3));
472 
473  if (hitType1 == hitType2 || hitType2 == hitType3 || hitType3 == hitType1)
474  throw StatusCodeException(STATUS_CODE_FAILURE);
475 
476  const unsigned int nSamplingPoints(1 + static_cast<unsigned int>(xOverlap / xPitch));
477 
478  for (unsigned int n = 0; n < nSamplingPoints; ++n)
479  {
480  const float x(xMin + (xMax - xMin) * (static_cast<float>(n) + 0.5f) / static_cast<float>(nSamplingPoints));
481  const float xmin(x - xPitch);
482  const float xmax(x + xPitch);
483 
484  try
485  {
486  float zMin1(0.f), zMin2(0.f), zMin3(0.f), zMax1(0.f), zMax2(0.f), zMax3(0.f);
487  LArClusterHelper::GetClusterSpanZ(pCluster1, xmin, xmax, zMin1, zMax1);
488  LArClusterHelper::GetClusterSpanZ(pCluster2, xmin, xmax, zMin2, zMax2);
489  LArClusterHelper::GetClusterSpanZ(pCluster3, xmin, xmax, zMin3, zMax3);
490 
491  const float z1(0.5f * (zMin1 + zMax1));
492  const float z2(0.5f * (zMin2 + zMax2));
493  const float z3(0.5f * (zMin3 + zMax3));
494 
495  const float dz1(zMax1 - zMin1);
496  const float dz2(zMax2 - zMin2);
497  const float dz3(zMax3 - zMin3);
498  const float dz4(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
499 
500  const float zproj1(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), hitType2, hitType3, z2, z3));
501  const float zproj2(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), hitType3, hitType1, z3, z1));
502  const float zproj3(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), hitType1, hitType2, z1, z2));
503 
504  const float deltaSquared(((z1 - zproj1) * (z1 - zproj1) + (z2 - zproj2) * (z2 - zproj2) + (z3 - zproj3) * (z3 - zproj3)) / 3.f);
505  const float sigmaSquared(dz1 * dz1 + dz2 * dz2 + dz3 * dz3 + dz4 * dz4);
506  const float pseudoChi2(deltaSquared / sigmaSquared);
507 
508  if (pseudoChi2 < m_pseudoChi2Cut)
509  return true;
510  }
511  catch(StatusCodeException &statusCodeException)
512  {
513  if (STATUS_CODE_NOT_FOUND != statusCodeException.GetStatusCode())
514  throw statusCodeException;
515  }
516  }
517 
518  return false;
519 }
Float_t x
Definition: compare.C:6
float m_xOverlapWindow
The maximum allowed displacement in x position.
float m_pseudoChi2Cut
Pseudo chi2 cut for three view matching.
static void GetClusterSpanZ(const pandora::Cluster *const pCluster, const float xmin, const float xmax, float &zmin, float &zmax)
Get upper and lower Z positions of the calo hits in a cluster in range xmin to xmax.
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).
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.
Char_t n[5]
void lar_content::DeltaRayMatchingAlgorithm::ClearNearbyClusterMaps ( )
private

Clear nearby cluster maps.

Definition at line 126 of file DeltaRayMatchingAlgorithm.cc.

References m_nearbyClustersU, m_nearbyClustersV, and m_nearbyClustersW.

Referenced by InitializeNearbyClusterMaps(), and Run().

127 {
128  m_nearbyClustersU.clear();
129  m_nearbyClustersV.clear();
130  m_nearbyClustersW.clear();
131 }
ClusterToClustersMap m_nearbyClustersU
The nearby clusters map for the u view.
ClusterToClustersMap m_nearbyClustersV
The nearby clusters map for the v view.
ClusterToClustersMap m_nearbyClustersW
The nearby clusters map for the w view.
void lar_content::DeltaRayMatchingAlgorithm::CreateDaughterPfo ( const pandora::ClusterList &  clusterList,
const pandora::ParticleFlowObject *const  pParentPfo 
) const
private

Create a new Pfo from an input cluster list and set up a parent/daughter relationship.

Parameters
clusterListthe list of clusters
pParentPfoaddress of the parent pfo

Definition at line 671 of file DeltaRayMatchingAlgorithm.cc.

References f, and m_daughterPfoListName.

Referenced by CreateParticles().

672 {
673  const PfoList *pPfoList = NULL; std::string pfoListName;
674  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pPfoList, pfoListName));
675 
676  // TODO Correct these placeholder parameters
677  PandoraContentApi::ParticleFlowObject::Parameters pfoParameters;
678  pfoParameters.m_particleId = E_MINUS; // SHOWER
679  pfoParameters.m_charge = PdgTable::GetParticleCharge(pfoParameters.m_particleId.Get());
680  pfoParameters.m_mass = PdgTable::GetParticleMass(pfoParameters.m_particleId.Get());
681  pfoParameters.m_energy = 0.f;
682  pfoParameters.m_momentum = CartesianVector(0.f, 0.f, 0.f);
683  pfoParameters.m_clusterList = clusterList;
684 
685  const ParticleFlowObject *pDaughterPfo(NULL);
686  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, pfoParameters, pDaughterPfo));
687 
688  if (!pPfoList->empty())
689  {
690  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Pfo>(*this, m_daughterPfoListName));
691  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pParentPfo, pDaughterPfo));
692  }
693 }
TFile f
Definition: plotHisto.C:6
std::string m_daughterPfoListName
The daughter pfo list name for new daughter particles.
void lar_content::DeltaRayMatchingAlgorithm::CreateParticles ( const ParticleList particleList) const
private

Build new particle flow objects.

Parameters
particleListthe list of candidate particles

Definition at line 386 of file DeltaRayMatchingAlgorithm.cc.

References AddToDaughterPfo(), CreateDaughterPfo(), GetAllPfos(), GetTrackPfos(), m_daughterPfoListName, and m_parentPfoListName.

Referenced by OneViewMatching(), ThreeViewMatching(), and TwoViewMatching().

387 {
388  PfoVector parentVector, daughterVector;
389  this->GetTrackPfos(m_parentPfoListName, parentVector);
390  this->GetAllPfos(m_daughterPfoListName, daughterVector);
391 
392  PfoList parentList(parentVector.begin(), parentVector.end());
393  PfoList daughterList(daughterVector.begin(), daughterVector.end());
394 
395  for (const Particle &particle : particleList)
396  {
397  const ParticleFlowObject *const pParentPfo = particle.GetParentPfo();
398 
399  if (NULL == pParentPfo)
400  continue;
401 
402  const Cluster *const pClusterU = particle.GetClusterU();
403  const Cluster *const pClusterV = particle.GetClusterV();
404  const Cluster *const pClusterW = particle.GetClusterW();
405 
406  if (NULL == pClusterU && NULL == pClusterV && NULL == pClusterW)
407  throw StatusCodeException(STATUS_CODE_FAILURE);
408 
409  ClusterList clusterList;
410 
411  if (pClusterU)
412  clusterList.push_back(pClusterU);
413 
414  if (pClusterV)
415  clusterList.push_back(pClusterV);
416 
417  if (pClusterW)
418  clusterList.push_back(pClusterW);
419 
420  if (parentList.end() != std::find(parentList.begin(), parentList.end(), pParentPfo))
421  {
422  this->CreateDaughterPfo(clusterList, pParentPfo);
423  }
424  else if (daughterList.end() != std::find(daughterList.begin(), daughterList.end(), pParentPfo))
425  {
426  this->AddToDaughterPfo(clusterList, pParentPfo);
427  }
428  else
429  {
430  throw StatusCodeException(STATUS_CODE_FAILURE);
431  }
432  }
433 }
void GetTrackPfos(const std::string &inputPfoListName, pandora::PfoVector &pfoVector) const
Get a vector of track-like Pfos in the provided input Pfo lists.
void GetAllPfos(const std::string &inputPfoListName, pandora::PfoVector &pfoVector) const
Get a vector of all Pfos in the provided input Pfo lists.
std::string m_parentPfoListName
The parent pfo list name.
void AddToDaughterPfo(const pandora::ClusterList &clusterList, const pandora::ParticleFlowObject *const pParentPfo) const
Merge an input cluster list with an existing daughter Pfo.
void CreateDaughterPfo(const pandora::ClusterList &clusterList, const pandora::ParticleFlowObject *const pParentPfo) const
Create a new Pfo from an input cluster list and set up a parent/daughter relationship.
std::string m_daughterPfoListName
The daughter pfo list name for new daughter particles.
void lar_content::DeltaRayMatchingAlgorithm::FindBestParentPfo ( const pandora::Cluster *const  pClusterU,
const pandora::Cluster *const  pClusterV,
const pandora::Cluster *const  pClusterW,
ClusterLengthMap clusterLengthMap,
PfoLengthMap pfoLengthMap,
const pandora::ParticleFlowObject *&  pBestPfo 
) const
private

Find best Pfo to associate a UVW triplet.

Parameters
pClusterUpointer to U view cluster
pClusterVpointer to V view cluster
pClusterWpointer to W view cluster
clusterLengthMapthe cluster length map
pfoLengthMapthe pfo length map
pBestPfoto receive the address of the best Pfo

Definition at line 523 of file DeltaRayMatchingAlgorithm.cc.

References f, GetAllPfos(), GetDistanceSquaredToPfo(), GetLengthFromCache(), lar_content::LArClusterHelper::GetLengthSquared(), GetTrackPfos(), m_daughterPfoListName, m_distanceForMatching, and m_parentPfoListName.

Referenced by OneViewMatching().

525 {
526  PfoVector pfoVector;
527  this->GetTrackPfos(m_parentPfoListName, pfoVector);
528  this->GetAllPfos(m_daughterPfoListName, pfoVector);
529 
530  if (pfoVector.empty())
531  throw StatusCodeException(STATUS_CODE_FAILURE);
532 
533  unsigned int numViews(0);
534  float lengthSquared(0.f);
535 
536  if (pCluster1)
537  {
538  lengthSquared += this->GetLengthFromCache(pCluster1, clusterLengthMap);
539  ++numViews;
540  }
541 
542  if (pCluster2)
543  {
544  lengthSquared += this->GetLengthFromCache(pCluster2, clusterLengthMap);
545  ++numViews;
546  }
547 
548  if (pCluster3)
549  {
550  lengthSquared += this->GetLengthFromCache(pCluster3, clusterLengthMap);
551  ++numViews;
552  }
553 
554  float bestDistanceSquared(static_cast<float>(numViews) * m_distanceForMatching * m_distanceForMatching);
555 
556  for (const ParticleFlowObject *const pPfo : pfoVector)
557  {
558  if (lengthSquared > this->GetLengthFromCache(pPfo, pfoLengthMap))
559  continue;
560 
561  try
562  {
563  float distanceSquared(0.f);
564 
565  if (NULL != pCluster1)
566  distanceSquared += this->GetDistanceSquaredToPfo(pCluster1, pPfo);
567 
568  if (NULL != pCluster2)
569  distanceSquared += this->GetDistanceSquaredToPfo(pCluster2, pPfo);
570 
571  if (NULL != pCluster3)
572  distanceSquared += this->GetDistanceSquaredToPfo(pCluster3, pPfo);
573 
574  if (distanceSquared < bestDistanceSquared)
575  {
576  pBestPfo = pPfo;
577  bestDistanceSquared = distanceSquared;
578  }
579  }
580  catch (StatusCodeException &statusCodeException)
581  {
582  if (!(STATUS_CODE_NOT_FOUND == statusCodeException.GetStatusCode()))
583  throw statusCodeException;
584  }
585  }
586 }
void GetTrackPfos(const std::string &inputPfoListName, pandora::PfoVector &pfoVector) const
Get a vector of track-like Pfos in the provided input Pfo lists.
TFile f
Definition: plotHisto.C:6
void GetAllPfos(const std::string &inputPfoListName, pandora::PfoVector &pfoVector) const
Get a vector of all Pfos in the provided input Pfo lists.
std::string m_parentPfoListName
The parent pfo list name.
float GetDistanceSquaredToPfo(const pandora::Cluster *const pCluster, const pandora::ParticleFlowObject *const pPfo) const
Get displacementr between cluster and particle flow object.
float m_distanceForMatching
The maximum allowed distance between tracks and delta rays.
float GetLengthFromCache(const pandora::Cluster *const pCluster, ClusterLengthMap &clusterLengthMap) const
Reduce number of length (squared) calculations by caching results when they are first obtained...
std::string m_daughterPfoListName
The daughter pfo list name for new daughter particles.
void lar_content::DeltaRayMatchingAlgorithm::GetAllPfos ( const std::string &  inputPfoListName,
pandora::PfoVector &  pfoVector 
) const
private

Get a vector of all Pfos in the provided input Pfo lists.

Parameters
inputPfoListNamethe input Pfo list name
pfoVectorthe output vector of Pfos

Definition at line 135 of file DeltaRayMatchingAlgorithm.cc.

References lar_content::LArPfoHelper::SortByNHits().

Referenced by CreateParticles(), FindBestParentPfo(), GetTrackPfos(), and Run().

136 {
137  const PfoList *pPfoList = NULL;
138  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this,
139  inputPfoListName, pPfoList));
140 
141  if (NULL == pPfoList)
142  return;
143 
144  for (PfoList::const_iterator iter = pPfoList->begin(), iterEnd = pPfoList->end(); iter != iterEnd; ++iter)
145  pfoVector.push_back(*iter);
146 
147  std::sort(pfoVector.begin(), pfoVector.end(), LArPfoHelper::SortByNHits);
148 }
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
intermediate_table::const_iterator const_iterator
void lar_content::DeltaRayMatchingAlgorithm::GetClusters ( const std::string &  clusterListName,
pandora::ClusterVector &  clusterVector 
) const
private

Get a vector containing all available input clusters in the provided cluster list, storing sliding linear fits in the algorithm cache.

Parameters
clusterListNamethe vector of cluster list names
clusterVectorto receive the populated cluster vector

Definition at line 172 of file DeltaRayMatchingAlgorithm.cc.

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

Referenced by OneViewMatching(), ThreeViewMatching(), and TwoViewMatching().

173 {
174  const ClusterList *pClusterList = NULL;
175  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this,
176  inputClusterListName, pClusterList))
177 
178  if (NULL == pClusterList)
179  return;
180 
181  for (ClusterList::const_iterator cIter = pClusterList->begin(), cIterEnd = pClusterList->end(); cIter != cIterEnd; ++cIter)
182  {
183  const Cluster *const pCluster = *cIter;
184 
185  if (!pCluster->IsAvailable() || (pCluster->GetNCaloHits() < m_minCaloHitsPerCluster))
186  continue;
187 
188  clusterVector.push_back(pCluster);
189  }
190 
191  std::sort(clusterVector.begin(), clusterVector.end(), LArClusterHelper::SortByNHits);
192 }
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.
unsigned int m_minCaloHitsPerCluster
The min number of calo hits per candidate cluster.
for(int i=0;i< 401;i++)
if(nlines<=0)
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
float lar_content::DeltaRayMatchingAlgorithm::GetDistanceSquaredToPfo ( const pandora::Cluster *const  pCluster,
const pandora::ParticleFlowObject *const  pPfo 
) const
private

Get displacementr between cluster and particle flow object.

Parameters
pClusterpointer to cluster
pPfopointer to particle flow object

Definition at line 636 of file DeltaRayMatchingAlgorithm.cc.

References lar_content::LArClusterHelper::GetClosestDistance(), lar_content::LArClusterHelper::GetClusterHitType(), lar_content::LArPfoHelper::GetClusters(), m_nearbyClustersU, m_nearbyClustersV, m_nearbyClustersW, and max.

Referenced by FindBestParentPfo().

637 {
638  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
639 
640  if ((TPC_VIEW_U != hitType) && (TPC_VIEW_V != hitType) && (TPC_VIEW_W != hitType))
641  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
642 
643  ClusterList comparisonList;
644  const ClusterToClustersMap &nearbyClusters((TPC_VIEW_U == hitType) ? m_nearbyClustersU : (TPC_VIEW_V == hitType) ? m_nearbyClustersV : m_nearbyClustersW);
645 
646  if (!nearbyClusters.count(pCluster))
648 
649  ClusterList pfoClusterList;
650  LArPfoHelper::GetClusters(pPfo, hitType, pfoClusterList);
651 
652  for (const Cluster *const pPfoCluster : pfoClusterList)
653  {
654  const ClusterList &clusterList(nearbyClusters.at(pCluster));
655 
656  if ((clusterList.end() != std::find(clusterList.begin(), clusterList.end(), pPfoCluster)) &&
657  (comparisonList.end() == std::find(comparisonList.begin(), comparisonList.end(), pPfoCluster)))
658  {
659  comparisonList.push_back(pPfoCluster);
660  }
661  }
662 
663  if (comparisonList.empty())
665 
666  return LArClusterHelper::GetClosestDistance(pCluster, comparisonList);
667 }
ClusterToClustersMap m_nearbyClustersU
The nearby clusters map for the u view.
static void GetClusters(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::ClusterList &clusterList)
Get a list of clusters of a particular hit type from a list of pfos.
ClusterToClustersMap m_nearbyClustersV
The nearby clusters map for the v view.
ClusterToClustersMap m_nearbyClustersW
The nearby clusters map for the w view.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterToClustersMap
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
Int_t max
Definition: plot.C:27
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
float lar_content::DeltaRayMatchingAlgorithm::GetLength ( const Particle particle,
ClusterLengthMap clusterLengthMap 
) const
private

Get the length (squared) of a candidate particle.

Parameters
particlethe particle
clusterLengthMapthe cluster length map
Returns
the length (squared)

Definition at line 618 of file DeltaRayMatchingAlgorithm.cc.

References f, lar_content::DeltaRayMatchingAlgorithm::Particle::GetClusterU(), lar_content::DeltaRayMatchingAlgorithm::Particle::GetClusterV(), lar_content::DeltaRayMatchingAlgorithm::Particle::GetClusterW(), and GetLengthFromCache().

Referenced by SelectParticles().

619 {
620  float lengthSquared(0.f);
621 
622  if (particle.GetClusterU())
623  lengthSquared += this->GetLengthFromCache(particle.GetClusterU(), clusterLengthMap);
624 
625  if (particle.GetClusterV())
626  lengthSquared += this->GetLengthFromCache(particle.GetClusterV(), clusterLengthMap);
627 
628  if (particle.GetClusterW())
629  lengthSquared += this->GetLengthFromCache(particle.GetClusterW(), clusterLengthMap);
630 
631  return lengthSquared;
632 }
TFile f
Definition: plotHisto.C:6
float GetLengthFromCache(const pandora::Cluster *const pCluster, ClusterLengthMap &clusterLengthMap) const
Reduce number of length (squared) calculations by caching results when they are first obtained...
float lar_content::DeltaRayMatchingAlgorithm::GetLengthFromCache ( const pandora::Cluster *const  pCluster,
ClusterLengthMap clusterLengthMap 
) const
private

Reduce number of length (squared) calculations by caching results when they are first obtained.

Parameters
pClusterthe cluster
clusterLengthMapthe cluster length map
Returns
the length (squared)

Referenced by FindBestParentPfo(), and GetLength().

float lar_content::DeltaRayMatchingAlgorithm::GetLengthFromCache ( const pandora::ParticleFlowObject *const  pPfo,
PfoLengthMap pfoLengthMap 
) const
private

Reduce number of length (squared) calculations by caching results when they are first obtained.

Parameters
pPfothe pfo
pfoLengthMapthe pfo length map
Returns
the length (squared)

Definition at line 604 of file DeltaRayMatchingAlgorithm.cc.

References lar_content::LArPfoHelper::GetTwoDLengthSquared().

605 {
606  PfoLengthMap::const_iterator iter = pfoLengthMap.find(pPfo);
607 
608  if (pfoLengthMap.end() != iter)
609  return iter->second;
610 
611  const float lengthSquared(LArPfoHelper::GetTwoDLengthSquared(pPfo));
612  (void) pfoLengthMap.insert(PfoLengthMap::value_type(pPfo, lengthSquared));
613  return lengthSquared;
614 }
static float GetTwoDLengthSquared(const pandora::ParticleFlowObject *const pPfo)
Calculate length of Pfo using 2D clusters.
intermediate_table::const_iterator const_iterator
void lar_content::DeltaRayMatchingAlgorithm::GetTrackPfos ( const std::string &  inputPfoListName,
pandora::PfoVector &  pfoVector 
) const
private

Get a vector of track-like Pfos in the provided input Pfo lists.

Parameters
inputPfoListNamethe input Pfo list name
pfoVectorthe output vector of Pfos

Definition at line 152 of file DeltaRayMatchingAlgorithm.cc.

References GetAllPfos(), and lar_content::LArPfoHelper::IsTrack().

Referenced by CreateParticles(), and FindBestParentPfo().

153 {
154  PfoVector inputVector;
155  this->GetAllPfos(inputPfoListName, inputVector);
156 
157  for (PfoVector::const_iterator iter = inputVector.begin(), iterEnd = inputVector.end(); iter != iterEnd; ++iter)
158  {
159  const ParticleFlowObject *const pPfo = *iter;
160 
161  if (!LArPfoHelper::IsTrack(pPfo))
162  continue;
163 
164  pfoVector.push_back(pPfo);
165  }
166 
167  // ATTN Track pfo list is sorted only because the inputVector is sorted
168 }
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
void GetAllPfos(const std::string &inputPfoListName, pandora::PfoVector &pfoVector) const
Get a vector of all Pfos in the provided input Pfo lists.
intermediate_table::const_iterator const_iterator
void lar_content::DeltaRayMatchingAlgorithm::InitializeNearbyClusterMap ( const std::string &  clusterListName,
ClusterToClustersMap nearbyClusters 
)
private

Initialize a nearby cluster map with details relating to a specific cluster list.

Parameters
clusterListNamethe cluster list name
nearbyClustersMapto receive the nearby clusters map

Definition at line 72 of file DeltaRayMatchingAlgorithm.cc.

References lar_content::KDTreeLinkerAlgo< DATA, DIM >::build(), lar_content::build_2d_kd_search_region(), lar_content::fill_and_bound_2d_kd_tree(), m_searchRegion1D, and lar_content::KDTreeLinkerAlgo< DATA, DIM >::search().

Referenced by InitializeNearbyClusterMaps().

73 {
74  const ClusterList *pClusterList = NULL;
75  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this,
76  clusterListName, pClusterList))
77 
78  if ((NULL == pClusterList) || pClusterList->empty())
79  return;
80 
81  HitToClusterMap hitToClusterMap;
82  CaloHitList allCaloHits;
83 
84  for (const Cluster *const pCluster : *pClusterList)
85  {
86  CaloHitList daughterHits;
87  pCluster->GetOrderedCaloHitList().FillCaloHitList(daughterHits);
88  allCaloHits.insert(allCaloHits.end(), daughterHits.begin(), daughterHits.end());
89 
90  for (const CaloHit *const pCaloHit : daughterHits)
91  (void) hitToClusterMap.insert(HitToClusterMap::value_type(pCaloHit, pCluster));
92  }
93 
94  HitKDTree2D kdTree;
95  HitKDNode2DList hitKDNode2DList;
96 
97  KDTreeBox hitsBoundingRegion2D(fill_and_bound_2d_kd_tree(allCaloHits, hitKDNode2DList));
98  kdTree.build(hitKDNode2DList, hitsBoundingRegion2D);
99 
100  for (const Cluster *const pCluster : *pClusterList)
101  {
102  CaloHitList daughterHits;
103  pCluster->GetOrderedCaloHitList().FillCaloHitList(daughterHits);
104 
105  for (const CaloHit *const pCaloHit : daughterHits)
106  {
108 
109  HitKDNode2DList found;
110  kdTree.search(searchRegionHits, found);
111 
112  for (const auto &hit : found)
113  {
114  ClusterList &nearbyClusterList(nearbyClusters[pCluster]);
115  const Cluster *const pNearbyCluster(hitToClusterMap.at(hit.data));
116 
117  if (nearbyClusterList.end() == std::find(nearbyClusterList.begin(), nearbyClusterList.end(), pNearbyCluster))
118  nearbyClusterList.push_back(pNearbyCluster);
119  }
120  }
121  }
122 }
for(int i=0;i< 401;i++)
if(nlines<=0)
float m_searchRegion1D
Search region, applied to each dimension, for look-up from kd-trees.
Detector simulation of raw signals on wires.
std::unordered_map< const pandora::CaloHit *, const pandora::Cluster * > HitToClusterMap
KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
KDTreeBox fill_and_bound_2d_kd_tree(const MANAGED_CONTAINER< const T * > &points, std::vector< KDTreeNodeInfoT< const T *, 2 > > &nodes)
fill_and_bound_2d_kd_tree
KDTreeBox build_2d_kd_search_region(const pandora::CaloHit *const point, const float x_span, const float z_span)
build_2d_kd_search_region
KDTreeBoxT< 2 > KDTreeBox
void lar_content::DeltaRayMatchingAlgorithm::InitializeNearbyClusterMaps ( )
private

Initialize nearby cluster maps.

Definition at line 62 of file DeltaRayMatchingAlgorithm.cc.

References ClearNearbyClusterMaps(), InitializeNearbyClusterMap(), m_inputClusterListNameU, m_inputClusterListNameV, m_inputClusterListNameW, m_nearbyClustersU, m_nearbyClustersV, and m_nearbyClustersW.

Referenced by Run().

63 {
64  this->ClearNearbyClusterMaps();
68 }
void InitializeNearbyClusterMap(const std::string &clusterListName, ClusterToClustersMap &nearbyClusters)
Initialize a nearby cluster map with details relating to a specific cluster list. ...
ClusterToClustersMap m_nearbyClustersU
The nearby clusters map for the u view.
ClusterToClustersMap m_nearbyClustersV
The nearby clusters map for the v view.
ClusterToClustersMap m_nearbyClustersW
The nearby clusters map for the w view.
std::string m_inputClusterListNameV
The input cluster list name for the v view.
std::string m_inputClusterListNameW
The input cluster list name for the w view.
std::string m_inputClusterListNameU
The input cluster list name for the u view.
void ClearNearbyClusterMaps()
Clear nearby cluster maps.
void lar_content::DeltaRayMatchingAlgorithm::OneViewMatching ( ClusterLengthMap clusterLengthMap) const
private

Match clusters using single views.

Parameters
clusterLengthMapthe cluster length map

Definition at line 230 of file DeltaRayMatchingAlgorithm.cc.

References AreClustersMatched(), CreateParticles(), FindBestParentPfo(), GetClusters(), m_inputClusterListNameU, m_inputClusterListNameV, m_inputClusterListNameW, SelectParticles(), ThreeViewMatching(), and TwoViewMatching().

Referenced by Run().

231 {
232  ClusterVector clustersU, clustersV, clustersW;
233  this->GetClusters(m_inputClusterListNameU, clustersU);
234  this->GetClusters(m_inputClusterListNameV, clustersV);
235  this->GetClusters(m_inputClusterListNameW, clustersW);
236 
237  PfoLengthMap pfoLengthMap;
238  ParticleList initialParticleList, finalParticleList;
239  this->ThreeViewMatching(clustersU, clustersV, clustersW, clusterLengthMap, pfoLengthMap, initialParticleList);
240  this->OneViewMatching(clustersU, clusterLengthMap, pfoLengthMap, initialParticleList);
241  this->OneViewMatching(clustersV, clusterLengthMap, pfoLengthMap, initialParticleList);
242  this->OneViewMatching(clustersW, clusterLengthMap, pfoLengthMap, initialParticleList);
243  this->SelectParticles(initialParticleList, clusterLengthMap, finalParticleList);
244  this->CreateParticles(finalParticleList);
245 }
void CreateParticles(const ParticleList &particleList) const
Build new particle flow objects.
std::unordered_map< const pandora::ParticleFlowObject *, float > PfoLengthMap
std::string m_inputClusterListNameV
The input cluster list name for the v view.
std::string m_inputClusterListNameW
The input cluster list name for the w view.
void OneViewMatching(ClusterLengthMap &clusterLengthMap) const
Match clusters using single views.
void ThreeViewMatching(ClusterLengthMap &clusterLengthMap) const
Match clusters using all three views.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
std::string m_inputClusterListNameU
The input cluster list name for the u view.
void SelectParticles(const ParticleList &inputParticles, ClusterLengthMap &clusterLengthMap, ParticleList &outputParticles) const
Resolve any ambiguities between candidate particles.
void GetClusters(const std::string &clusterListName, pandora::ClusterVector &clusterVector) const
Get a vector containing all available input clusters in the provided cluster list, storing sliding linear fits in the algorithm cache.
void lar_content::DeltaRayMatchingAlgorithm::OneViewMatching ( const pandora::ClusterVector &  clusters,
ClusterLengthMap clusterLengthMap,
PfoLengthMap pfoLengthMap,
ParticleList particleList 
) const
private

Match clusters using a single view.

Parameters
clustersthe list of clusters in the provided view
clusterLengthMapthe cluster length map
pfoLengthMapthe pfo length map
particleListthe output list of particles
StatusCode lar_content::DeltaRayMatchingAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 780 of file DeltaRayMatchingAlgorithm.cc.

References m_daughterPfoListName, m_distanceForMatching, m_inputClusterListNameU, m_inputClusterListNameV, m_inputClusterListNameW, m_minCaloHitsPerCluster, m_parentPfoListName, m_pseudoChi2Cut, m_searchRegion1D, and m_xOverlapWindow.

781 {
782  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "ParentPfoListName", m_parentPfoListName));
783  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "DaughterPfoListName", m_daughterPfoListName));
784  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListNameU", m_inputClusterListNameU));
785  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListNameV", m_inputClusterListNameV));
786  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputClusterListNameW", m_inputClusterListNameW));
787 
788  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
789  "MinCaloHitsPerCluster", m_minCaloHitsPerCluster));
790 
791  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
792  "OverlapWindow", m_xOverlapWindow));
793 
794  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
795  "DistanceForMatching", m_distanceForMatching));
796 
797  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
798  "PseudoChi2Cut", m_pseudoChi2Cut));
799 
800  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
801  "SearchRegion1D", m_searchRegion1D));
802 
803  return STATUS_CODE_SUCCESS;
804 }
float m_xOverlapWindow
The maximum allowed displacement in x position.
float m_pseudoChi2Cut
Pseudo chi2 cut for three view matching.
unsigned int m_minCaloHitsPerCluster
The min number of calo hits per candidate cluster.
std::string m_inputClusterListNameV
The input cluster list name for the v view.
std::string m_parentPfoListName
The parent pfo list name.
std::string m_inputClusterListNameW
The input cluster list name for the w view.
float m_searchRegion1D
Search region, applied to each dimension, for look-up from kd-trees.
std::string m_inputClusterListNameU
The input cluster list name for the u view.
float m_distanceForMatching
The maximum allowed distance between tracks and delta rays.
std::string m_daughterPfoListName
The daughter pfo list name for new daughter particles.
StatusCode lar_content::DeltaRayMatchingAlgorithm::Run ( )
private

Definition at line 35 of file DeltaRayMatchingAlgorithm.cc.

References ClearNearbyClusterMaps(), GetAllPfos(), InitializeNearbyClusterMaps(), m_parentPfoListName, OneViewMatching(), ThreeViewMatching(), and TwoViewMatching().

36 {
37  PfoVector pfoVector;
38  this->GetAllPfos(m_parentPfoListName, pfoVector);
39 
40  if (pfoVector.empty())
41  {
42  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
43  std::cout << "DeltaRayMatchingAlgorithm: pfo list " << m_parentPfoListName << " unavailable." << std::endl;
44 
45  return STATUS_CODE_SUCCESS;
46  }
47 
49 
50  ClusterLengthMap clusterLengthMap;
51  this->ThreeViewMatching(clusterLengthMap);
52  this->TwoViewMatching(clusterLengthMap);
53  this->OneViewMatching(clusterLengthMap);
54 
55  this->ClearNearbyClusterMaps();
56 
57  return STATUS_CODE_SUCCESS;
58 }
void TwoViewMatching(ClusterLengthMap &clusterLengthMap) const
Match clusters using pairs of views.
std::unordered_map< const pandora::Cluster *, float > ClusterLengthMap
void GetAllPfos(const std::string &inputPfoListName, pandora::PfoVector &pfoVector) const
Get a vector of all Pfos in the provided input Pfo lists.
std::string m_parentPfoListName
The parent pfo list name.
void OneViewMatching(ClusterLengthMap &clusterLengthMap) const
Match clusters using single views.
void ThreeViewMatching(ClusterLengthMap &clusterLengthMap) const
Match clusters using all three views.
void InitializeNearbyClusterMaps()
Initialize nearby cluster maps.
void ClearNearbyClusterMaps()
Clear nearby cluster maps.
void lar_content::DeltaRayMatchingAlgorithm::SelectParticles ( const ParticleList inputParticles,
ClusterLengthMap clusterLengthMap,
ParticleList outputParticles 
) const
private

Resolve any ambiguities between candidate particles.

Parameters
inputParticlesthe input list of candidate particles
clusterLengthMapthe cluster length map
outputParticlesthe output list of candidate particles

Definition at line 340 of file DeltaRayMatchingAlgorithm.cc.

References GetLength().

Referenced by OneViewMatching(), ThreeViewMatching(), and TwoViewMatching().

341 {
342  for (const Particle &particle1 : initialParticles)
343  {
344  bool isGoodParticle(true);
345 
346  for (const Particle &particle2 : initialParticles)
347  {
348  const bool commonU(particle1.GetClusterU() == particle2.GetClusterU());
349  const bool commonV(particle1.GetClusterV() == particle2.GetClusterV());
350  const bool commonW(particle1.GetClusterW() == particle2.GetClusterW());
351 
352  const bool ambiguousU(commonU && NULL != particle1.GetClusterU());
353  const bool ambiguousV(commonV && NULL != particle1.GetClusterV());
354  const bool ambiguousW(commonW && NULL != particle1.GetClusterW());
355 
356  if (commonU && commonV && commonW)
357  continue;
358 
359  if (ambiguousU || ambiguousV || ambiguousW)
360  {
361  if (particle2.GetNViews() > particle1.GetNViews())
362  {
363  isGoodParticle = false;
364  }
365  else if (particle2.GetNViews() == particle1.GetNViews() && NULL != particle2.GetParentPfo())
366  {
367  if ((NULL == particle1.GetParentPfo()) || (particle2.GetNCaloHits() > particle1.GetNCaloHits()) ||
368  (particle2.GetNCaloHits() == particle1.GetNCaloHits() && this->GetLength(particle2, clusterLengthMap) >= this->GetLength(particle1, clusterLengthMap)) )
369  {
370  isGoodParticle = false;
371  }
372  }
373 
374  if (!isGoodParticle)
375  break;
376  }
377  }
378 
379  if (isGoodParticle && NULL != particle1.GetParentPfo())
380  finalParticles.push_back(particle1);
381  }
382 }
float GetLength(const Particle &particle, ClusterLengthMap &clusterLengthMap) const
Get the length (squared) of a candidate particle.
void lar_content::DeltaRayMatchingAlgorithm::ThreeViewMatching ( ClusterLengthMap clusterLengthMap) const
private

Match clusters using all three views.

Parameters
clusterLengthMapthe cluster length map

Definition at line 196 of file DeltaRayMatchingAlgorithm.cc.

References CreateParticles(), GetClusters(), m_inputClusterListNameU, m_inputClusterListNameV, m_inputClusterListNameW, and SelectParticles().

Referenced by OneViewMatching(), and Run().

197 {
198  ClusterVector clustersU, clustersV, clustersW;
199  this->GetClusters(m_inputClusterListNameU, clustersU);
200  this->GetClusters(m_inputClusterListNameV, clustersV);
201  this->GetClusters(m_inputClusterListNameW, clustersW);
202 
203  PfoLengthMap pfoLengthMap;
204  ParticleList initialParticleList, finalParticleList;
205  this->ThreeViewMatching(clustersU, clustersV, clustersW, clusterLengthMap, pfoLengthMap, initialParticleList);
206  this->SelectParticles(initialParticleList, clusterLengthMap, finalParticleList);
207  this->CreateParticles(finalParticleList);
208 }
void CreateParticles(const ParticleList &particleList) const
Build new particle flow objects.
std::unordered_map< const pandora::ParticleFlowObject *, float > PfoLengthMap
std::string m_inputClusterListNameV
The input cluster list name for the v view.
std::string m_inputClusterListNameW
The input cluster list name for the w view.
void ThreeViewMatching(ClusterLengthMap &clusterLengthMap) const
Match clusters using all three views.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
std::string m_inputClusterListNameU
The input cluster list name for the u view.
void SelectParticles(const ParticleList &inputParticles, ClusterLengthMap &clusterLengthMap, ParticleList &outputParticles) const
Resolve any ambiguities between candidate particles.
void GetClusters(const std::string &clusterListName, pandora::ClusterVector &clusterVector) const
Get a vector containing all available input clusters in the provided cluster list, storing sliding linear fits in the algorithm cache.
void lar_content::DeltaRayMatchingAlgorithm::ThreeViewMatching ( const pandora::ClusterVector &  clusters1,
const pandora::ClusterVector &  clusters2,
const pandora::ClusterVector &  clusters3,
ClusterLengthMap clusterLengthMap,
PfoLengthMap pfoLengthMap,
ParticleList particleList 
) const
private

Match clusters using all three views.

Parameters
clusters1the list of clusters in the first view
clusters2the list of clusters in the second view
clusters3the list of clusters in the third view
clusterLengthMapthe cluster length map
pfoLengthMapthe pfo length map
particleListthe output list of particles
void lar_content::DeltaRayMatchingAlgorithm::TwoViewMatching ( ClusterLengthMap clusterLengthMap) const
private

Match clusters using pairs of views.

Parameters
clusterLengthMapthe cluster length map

Definition at line 212 of file DeltaRayMatchingAlgorithm.cc.

References CreateParticles(), GetClusters(), m_inputClusterListNameU, m_inputClusterListNameV, m_inputClusterListNameW, and SelectParticles().

Referenced by OneViewMatching(), and Run().

213 {
214  ClusterVector clustersU, clustersV, clustersW;
215  this->GetClusters(m_inputClusterListNameU, clustersU);
216  this->GetClusters(m_inputClusterListNameV, clustersV);
217  this->GetClusters(m_inputClusterListNameW, clustersW);
218 
219  PfoLengthMap pfoLengthMap;
220  ParticleList initialParticleList, finalParticleList;
221  this->TwoViewMatching(clustersU, clustersV, clusterLengthMap, pfoLengthMap, initialParticleList);
222  this->TwoViewMatching(clustersV, clustersW, clusterLengthMap, pfoLengthMap, initialParticleList);
223  this->TwoViewMatching(clustersW, clustersU, clusterLengthMap, pfoLengthMap, initialParticleList);
224  this->SelectParticles(initialParticleList, clusterLengthMap, finalParticleList);
225  this->CreateParticles(finalParticleList);
226 }
void TwoViewMatching(ClusterLengthMap &clusterLengthMap) const
Match clusters using pairs of views.
void CreateParticles(const ParticleList &particleList) const
Build new particle flow objects.
std::unordered_map< const pandora::ParticleFlowObject *, float > PfoLengthMap
std::string m_inputClusterListNameV
The input cluster list name for the v view.
std::string m_inputClusterListNameW
The input cluster list name for the w view.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
std::string m_inputClusterListNameU
The input cluster list name for the u view.
void SelectParticles(const ParticleList &inputParticles, ClusterLengthMap &clusterLengthMap, ParticleList &outputParticles) const
Resolve any ambiguities between candidate particles.
void GetClusters(const std::string &clusterListName, pandora::ClusterVector &clusterVector) const
Get a vector containing all available input clusters in the provided cluster list, storing sliding linear fits in the algorithm cache.
void lar_content::DeltaRayMatchingAlgorithm::TwoViewMatching ( const pandora::ClusterVector &  clusters1,
const pandora::ClusterVector &  clusters2,
ClusterLengthMap clusterLengthMap,
PfoLengthMap pfoLengthMap,
ParticleList particleList 
) const
private

Match clusters using a pair of views.

Parameters
clusters1the list of clusters in the first view
clusters2the list of clusters in the second view
clusterLengthMapthe cluster length map
pfoLengthMapthe pfo length map
particleListthe output list of particles

Member Data Documentation

std::string lar_content::DeltaRayMatchingAlgorithm::m_daughterPfoListName
private

The daughter pfo list name for new daughter particles.

Definition at line 298 of file DeltaRayMatchingAlgorithm.h.

Referenced by CreateDaughterPfo(), CreateParticles(), FindBestParentPfo(), and ReadSettings().

float lar_content::DeltaRayMatchingAlgorithm::m_distanceForMatching
private

The maximum allowed distance between tracks and delta rays.

Definition at line 306 of file DeltaRayMatchingAlgorithm.h.

Referenced by FindBestParentPfo(), and ReadSettings().

std::string lar_content::DeltaRayMatchingAlgorithm::m_inputClusterListNameU
private

The input cluster list name for the u view.

Definition at line 300 of file DeltaRayMatchingAlgorithm.h.

Referenced by AddToDaughterPfo(), InitializeNearbyClusterMaps(), OneViewMatching(), ReadSettings(), ThreeViewMatching(), and TwoViewMatching().

std::string lar_content::DeltaRayMatchingAlgorithm::m_inputClusterListNameV
private

The input cluster list name for the v view.

Definition at line 301 of file DeltaRayMatchingAlgorithm.h.

Referenced by AddToDaughterPfo(), InitializeNearbyClusterMaps(), OneViewMatching(), ReadSettings(), ThreeViewMatching(), and TwoViewMatching().

std::string lar_content::DeltaRayMatchingAlgorithm::m_inputClusterListNameW
private

The input cluster list name for the w view.

Definition at line 302 of file DeltaRayMatchingAlgorithm.h.

Referenced by AddToDaughterPfo(), InitializeNearbyClusterMaps(), OneViewMatching(), ReadSettings(), ThreeViewMatching(), and TwoViewMatching().

unsigned int lar_content::DeltaRayMatchingAlgorithm::m_minCaloHitsPerCluster
private

The min number of calo hits per candidate cluster.

Definition at line 304 of file DeltaRayMatchingAlgorithm.h.

Referenced by GetClusters(), and ReadSettings().

ClusterToClustersMap lar_content::DeltaRayMatchingAlgorithm::m_nearbyClustersU
private

The nearby clusters map for the u view.

Definition at line 310 of file DeltaRayMatchingAlgorithm.h.

Referenced by ClearNearbyClusterMaps(), GetDistanceSquaredToPfo(), and InitializeNearbyClusterMaps().

ClusterToClustersMap lar_content::DeltaRayMatchingAlgorithm::m_nearbyClustersV
private

The nearby clusters map for the v view.

Definition at line 311 of file DeltaRayMatchingAlgorithm.h.

Referenced by ClearNearbyClusterMaps(), GetDistanceSquaredToPfo(), and InitializeNearbyClusterMaps().

ClusterToClustersMap lar_content::DeltaRayMatchingAlgorithm::m_nearbyClustersW
private

The nearby clusters map for the w view.

Definition at line 312 of file DeltaRayMatchingAlgorithm.h.

Referenced by ClearNearbyClusterMaps(), GetDistanceSquaredToPfo(), and InitializeNearbyClusterMaps().

std::string lar_content::DeltaRayMatchingAlgorithm::m_parentPfoListName
private

The parent pfo list name.

Definition at line 297 of file DeltaRayMatchingAlgorithm.h.

Referenced by CreateParticles(), FindBestParentPfo(), ReadSettings(), and Run().

float lar_content::DeltaRayMatchingAlgorithm::m_pseudoChi2Cut
private

Pseudo chi2 cut for three view matching.

Definition at line 307 of file DeltaRayMatchingAlgorithm.h.

Referenced by AreClustersMatched(), and ReadSettings().

float lar_content::DeltaRayMatchingAlgorithm::m_searchRegion1D
private

Search region, applied to each dimension, for look-up from kd-trees.

Definition at line 309 of file DeltaRayMatchingAlgorithm.h.

Referenced by InitializeNearbyClusterMap(), and ReadSettings().

float lar_content::DeltaRayMatchingAlgorithm::m_xOverlapWindow
private

The maximum allowed displacement in x position.

Definition at line 305 of file DeltaRayMatchingAlgorithm.h.

Referenced by AreClustersMatched(), and ReadSettings().


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