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

VertexBasedPfoRecoveryAlgorithm class. More...

#include "VertexBasedPfoRecoveryAlgorithm.h"

Inheritance diagram for lar_content::VertexBasedPfoRecoveryAlgorithm:

Classes

class  Particle
 Particle class. More...
 

Public Member Functions

 VertexBasedPfoRecoveryAlgorithm ()
 Default constructor. More...
 

Private Types

typedef std::vector< ParticleParticleList
 

Private Member Functions

pandora::StatusCode Run ()
 
pandora::StatusCode GetAvailableClusters (const pandora::StringVector inputClusterListName, pandora::ClusterVector &clusterVector) const
 Get a vector of available clusters. More...
 
void BuildSlidingFitResultMap (const pandora::ClusterVector &clusterVector, TwoDSlidingFitResultMap &slidingFitResultMap) const
 Build the map of sliding fit results. More...
 
void SelectVertexClusters (const pandora::Vertex *const pVertex, const TwoDSlidingFitResultMap &slidingFitResultMap, const pandora::ClusterVector &inputClusters, pandora::ClusterVector &outputClusters) const
 Select clusters in proximity to reconstructed vertex. More...
 
void MatchThreeViews (const pandora::Vertex *const pVertex, const TwoDSlidingFitResultMap &slidingFitResultMap, const pandora::ClusterVector &selectedClusters, pandora::ClusterSet &vetoList, ParticleList &particleList) const
 Match clusters from three views. More...
 
void MatchTwoViews (const pandora::Vertex *const pVertex, const TwoDSlidingFitResultMap &slidingFitResultMap, const pandora::ClusterVector &selectedClusters, pandora::ClusterSet &vetoList, ParticleList &particleList) const
 Match clusters from two views. More...
 
void GetBestChi2 (const pandora::Vertex *const pVertex, const TwoDSlidingFitResultMap &slidingFitResultMap, const pandora::ClusterVector &clusters1, const pandora::ClusterVector &clusters2, const pandora::ClusterVector &clusters3, const pandora::Cluster *&pBestCluster1, const pandora::Cluster *&pBestCluster2, const pandora::Cluster *&pBestCluster3, float &chi2) const
 Get best-matched triplet of clusters from a set of input cluster vectors. More...
 
void GetBestChi2 (const pandora::Vertex *const pVertex, const TwoDSlidingFitResultMap &slidingFitResultMap, const pandora::ClusterVector &clusters1, const pandora::ClusterVector &clusters2, const pandora::Cluster *&pBestCluster1, const pandora::Cluster *&pBestCluster2, float &chi2) const
 Get best-matched pair of clusters from a set of input cluster vectors. More...
 
float GetChi2 (const pandora::Vertex *const pVertex, const LArPointingCluster &pointingCluster1, const LArPointingCluster &pointingCluster2) const
 Merge two pointing clusters and return chi-squared metric giving consistency of matching. More...
 
float GetChi2 (const pandora::Vertex *const pVertex, const LArPointingCluster &pointingCluster1, const LArPointingCluster &pointingCluster2, const LArPointingCluster &pointingCluster3) const
 Merge three clusters between views and return chi-squared metric giving consistency of matching. More...
 
void SelectAvailableClusters (const pandora::ClusterSet &vetoList, const pandora::ClusterVector &inputVector, pandora::ClusterVector &outputVector) const
 Select cluster which haven't been vetoed. More...
 
void SelectClusters (const pandora::HitType hitType, const pandora::ClusterVector &inputVector, pandora::ClusterVector &outputVector) const
 Select clusters of a specified hit type. More...
 
const LArPointingCluster::VertexGetInnerVertex (const pandora::CartesianVector &vertex, const LArPointingCluster &cluster) const
 Find nearest end of pointing cluster to a specified position vector. More...
 
const LArPointingCluster::VertexGetOuterVertex (const pandora::CartesianVector &vertex, const LArPointingCluster &cluster) const
 Find furthest end of pointing cluster from a specified position vector. More...
 
void BuildParticles (const ParticleList &particleList)
 Build particle flow objects from matched clusters. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

pandora::StringVector m_inputClusterListNames
 The list of input cluster list names. More...
 
std::string m_outputPfoListName
 The name of the output pfo list. More...
 
unsigned int m_slidingFitHalfWindow
 
float m_maxLongitudinalDisplacement
 
float m_maxTransverseDisplacement
 
float m_twoViewChi2Cut
 
float m_threeViewChi2Cut
 

Detailed Description

Member Typedef Documentation

Constructor & Destructor Documentation

Member Function Documentation

void lar_content::VertexBasedPfoRecoveryAlgorithm::BuildParticles ( const ParticleList particleList)
private

Build particle flow objects from matched clusters.

Parameters
particleListthe input list of matched clusters

Definition at line 474 of file VertexBasedPfoRecoveryAlgorithm.cc.

References f, m_outputPfoListName, lar_content::VertexBasedPfoRecoveryAlgorithm::Particle::m_pClusterU, lar_content::VertexBasedPfoRecoveryAlgorithm::Particle::m_pClusterV, and lar_content::VertexBasedPfoRecoveryAlgorithm::Particle::m_pClusterW.

Referenced by Run().

475 {
476  if (particleList.empty())
477  return;
478 
479  const PfoList *pPfoList = NULL;
480  std::string pfoListName;
481  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pPfoList, pfoListName));
482 
483  for (ParticleList::const_iterator iter = particleList.begin(), iterEnd = particleList.end(); iter != iterEnd; ++iter)
484  {
485  const Particle &particle = *iter;
486 
487  ClusterList clusterList;
488  const Cluster *const pClusterU = particle.m_pClusterU;
489  const Cluster *const pClusterV = particle.m_pClusterV;
490  const Cluster *const pClusterW = particle.m_pClusterW;
491 
492  const bool isAvailableU((NULL != pClusterU) ? pClusterU->IsAvailable() : true);
493  const bool isAvailableV((NULL != pClusterV) ? pClusterV->IsAvailable() : true);
494  const bool isAvailableW((NULL != pClusterW) ? pClusterW->IsAvailable() : true);
495 
496  if (!(isAvailableU && isAvailableV && isAvailableW))
497  throw StatusCodeException(STATUS_CODE_FAILURE);
498 
499  if (pClusterU)
500  clusterList.push_back(pClusterU);
501  if (pClusterV)
502  clusterList.push_back(pClusterV);
503  if (pClusterW)
504  clusterList.push_back(pClusterW);
505 
506  // TODO Correct these placeholder parameters
507  PandoraContentApi::ParticleFlowObject::Parameters pfoParameters;
508  pfoParameters.m_particleId = MU_MINUS; // TRACK
509  pfoParameters.m_charge = PdgTable::GetParticleCharge(pfoParameters.m_particleId.Get());
510  pfoParameters.m_mass = PdgTable::GetParticleMass(pfoParameters.m_particleId.Get());
511  pfoParameters.m_energy = 0.f;
512  pfoParameters.m_momentum = CartesianVector(0.f, 0.f, 0.f);
513  pfoParameters.m_clusterList = clusterList;
514 
515  const ParticleFlowObject *pPfo(NULL);
516  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, pfoParameters, pPfo));
517  }
518 
519  if (!pPfoList->empty())
520  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Pfo>(*this, m_outputPfoListName));
521 }
std::string m_outputPfoListName
The name of the output pfo list.
intermediate_table::const_iterator const_iterator
TFile f
Definition: plotHisto.C:6
void lar_content::VertexBasedPfoRecoveryAlgorithm::BuildSlidingFitResultMap ( const pandora::ClusterVector &  clusterVector,
TwoDSlidingFitResultMap slidingFitResultMap 
) const
private

Build the map of sliding fit results.

Parameters
clusterVectorthe vector of selected clusters
halfWindowLayersthe half-window to use for the sliding fits
slidingFitResultMapthe sliding fit result map

Definition at line 112 of file VertexBasedPfoRecoveryAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), lar_content::LArPointingCluster::GetLengthSquared(), lar_content::LArGeometryHelper::GetWirePitch(), and m_slidingFitHalfWindow.

Referenced by Run().

113 {
114  for (ClusterVector::const_iterator iter = clusterVector.begin(), iterEnd = clusterVector.end(); iter != iterEnd; ++iter)
115  {
116  if (slidingFitResultMap.end() == slidingFitResultMap.find(*iter))
117  {
118  try
119  {
120  const float slidingFitPitch(LArGeometryHelper::GetWirePitch(this->GetPandora(), LArClusterHelper::GetClusterHitType(*iter)));
121  const TwoDSlidingFitResult slidingFitResult(*iter, m_slidingFitHalfWindow, slidingFitPitch);
122  const LArPointingCluster pointingCluster(slidingFitResult);
123 
124  if (pointingCluster.GetLengthSquared() < std::numeric_limits<float>::epsilon())
125  continue;
126 
127  if (!slidingFitResultMap.insert(TwoDSlidingFitResultMap::value_type(*iter, slidingFitResult)).second)
128  throw StatusCodeException(STATUS_CODE_FAILURE);
129  }
130  catch (StatusCodeException &statusCodeException)
131  {
132  if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
133  throw statusCodeException;
134  }
135  }
136  }
137 }
intermediate_table::const_iterator const_iterator
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
StatusCode lar_content::VertexBasedPfoRecoveryAlgorithm::GetAvailableClusters ( const pandora::StringVector  inputClusterListName,
pandora::ClusterVector &  clusterVector 
) const
private

Get a vector of available clusters.

Parameters
inputClusterListNamethe input vector of the cluster list names
clusterVectorthe output vector of available clusters

Definition at line 75 of file VertexBasedPfoRecoveryAlgorithm.cc.

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

Referenced by Run().

76 {
77  for (StringVector::const_iterator iter = inputClusterListNames.begin(), iterEnd = inputClusterListNames.end(); iter != iterEnd; ++iter)
78  {
79  const ClusterList *pClusterList(NULL);
80  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, *iter, pClusterList));
81 
82  if (NULL == pClusterList)
83  {
84  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
85  std::cout << "VertexBasedPfoRecoveryAlgorithm: could not find cluster list " << *iter << std::endl;
86  continue;
87  }
88 
89  for (ClusterList::const_iterator cIter = pClusterList->begin(), cIterEnd = pClusterList->end(); cIter != cIterEnd; ++cIter)
90  {
91  const Cluster *const pCluster = *cIter;
92 
93  if (!pCluster->IsAvailable())
94  continue;
95 
96  if (pCluster->GetNCaloHits() <= 1)
97  continue;
98 
99  if (TPC_3D == LArClusterHelper::GetClusterHitType(pCluster))
100  continue;
101 
102  clusterVector.push_back(pCluster);
103  }
104  }
105 
106  std::sort(clusterVector.begin(), clusterVector.end(), LArClusterHelper::SortByNHits);
107 
108  return STATUS_CODE_SUCCESS;
109 }
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.
intermediate_table::const_iterator const_iterator
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
void lar_content::VertexBasedPfoRecoveryAlgorithm::GetBestChi2 ( const pandora::Vertex *const  pVertex,
const TwoDSlidingFitResultMap slidingFitResultMap,
const pandora::ClusterVector &  clusters1,
const pandora::ClusterVector &  clusters2,
const pandora::ClusterVector &  clusters3,
const pandora::Cluster *&  pBestCluster1,
const pandora::Cluster *&  pBestCluster2,
const pandora::Cluster *&  pBestCluster3,
float &  chi2 
) const
private

Get best-matched triplet of clusters from a set of input cluster vectors.

Parameters
pVertexthe input vertex
slidingFitResultMapthe mapping between clusters and sliding fit results
clusters1the clusters in the first view
clusters2the clusters in the second view
clusters3the clusters in the third view
pBestCluster1the best-matched cluster from the first view
pBestCluster2the best-matched cluster from the second view
pBestCluster3the best-matched cluster from the third view
chi2the chi-squared metric from the best match

Referenced by MatchThreeViews(), and MatchTwoViews().

void lar_content::VertexBasedPfoRecoveryAlgorithm::GetBestChi2 ( const pandora::Vertex *const  pVertex,
const TwoDSlidingFitResultMap slidingFitResultMap,
const pandora::ClusterVector &  clusters1,
const pandora::ClusterVector &  clusters2,
const pandora::Cluster *&  pBestCluster1,
const pandora::Cluster *&  pBestCluster2,
float &  chi2 
) const
private

Get best-matched pair of clusters from a set of input cluster vectors.

Parameters
pVertexthe input vertex
slidingFitResultMapthe mapping between clusters and sliding fit results
clusters1the clusters in the first view
clusters2the clusters in the second view
pBestCluster1the best-matched cluster from the first view
pBestCluster2the best-matched cluster from the second view
chi2the chi-squared metric from the best match
float lar_content::VertexBasedPfoRecoveryAlgorithm::GetChi2 ( const pandora::Vertex *const  pVertex,
const LArPointingCluster pointingCluster1,
const LArPointingCluster pointingCluster2 
) const
private

Merge two pointing clusters and return chi-squared metric giving consistency of matching.

Parameters
pVertexthe input vertex
pointingCluster1the first pointing cluster
pointingCluster2the second pointing cluster

Referenced by MatchTwoViews().

float lar_content::VertexBasedPfoRecoveryAlgorithm::GetChi2 ( const pandora::Vertex *const  pVertex,
const LArPointingCluster pointingCluster1,
const LArPointingCluster pointingCluster2,
const LArPointingCluster pointingCluster3 
) const
private

Merge three clusters between views and return chi-squared metric giving consistency of matching.

Parameters
pVertexthe input vertex
pointingCluster1the first pointing cluster
pointingCluster2the second pointing cluster
pointingCluster3the third pointing cluster
const LArPointingCluster::Vertex & lar_content::VertexBasedPfoRecoveryAlgorithm::GetInnerVertex ( const pandora::CartesianVector &  vertex,
const LArPointingCluster cluster 
) const
private

Find nearest end of pointing cluster to a specified position vector.

Parameters
vertexthe input position
clusterthe input cluster

Definition at line 449 of file VertexBasedPfoRecoveryAlgorithm.cc.

References lar_content::LArPointingCluster::GetInnerVertex(), lar_content::LArPointingCluster::GetOuterVertex(), and lar_content::LArPointingCluster::Vertex::GetPosition().

Referenced by GetOuterVertex().

450 {
451  const float innerDistance((vertex - cluster.GetInnerVertex().GetPosition()).GetMagnitudeSquared());
452  const float outerDistance((vertex - cluster.GetOuterVertex().GetPosition()).GetMagnitudeSquared());
453 
454  if (innerDistance < outerDistance)
455  return cluster.GetInnerVertex();
456  else
457  return cluster.GetOuterVertex();
458 }
Cluster finding and building.
vertex reconstruction
const LArPointingCluster::Vertex & lar_content::VertexBasedPfoRecoveryAlgorithm::GetOuterVertex ( const pandora::CartesianVector &  vertex,
const LArPointingCluster cluster 
) const
private

Find furthest end of pointing cluster from a specified position vector.

Parameters
vertexthe input position
clusterthe input pointing cluster

Definition at line 462 of file VertexBasedPfoRecoveryAlgorithm.cc.

References lar_content::LArPointingCluster::GetInnerVertex(), GetInnerVertex(), lar_content::LArPointingCluster::GetOuterVertex(), and lar_content::LArPointingCluster::Vertex::IsInnerVertex().

Referenced by MatchTwoViews().

463 {
464  const LArPointingCluster::Vertex &innerVertex = this->GetInnerVertex(vertex, cluster);
465 
466  if (innerVertex.IsInnerVertex())
467  return cluster.GetOuterVertex();
468  else
469  return cluster.GetInnerVertex();
470 }
const LArPointingCluster::Vertex & GetInnerVertex(const pandora::CartesianVector &vertex, const LArPointingCluster &cluster) const
Find nearest end of pointing cluster to a specified position vector.
Cluster finding and building.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
vertex reconstruction
void lar_content::VertexBasedPfoRecoveryAlgorithm::MatchThreeViews ( const pandora::Vertex *const  pVertex,
const TwoDSlidingFitResultMap slidingFitResultMap,
const pandora::ClusterVector &  selectedClusters,
pandora::ClusterSet &  vetoList,
ParticleList particleList 
) const
private

Match clusters from three views.

Parameters
pVertexthe input vertex
slidingFitResultMapthe mapping between clusters and sliding fit results
selectedClustersthe input vertex clusters
vetoListthe list of matched clusters
particleListthe output list of matched clusters

Definition at line 183 of file VertexBasedPfoRecoveryAlgorithm.cc.

References GetBestChi2(), lar_content::LArClusterHelper::GetClusterHitType(), m_threeViewChi2Cut, SelectAvailableClusters(), and SelectClusters().

Referenced by Run().

185 {
186  while (true)
187  {
188  ClusterVector availableClusters, clustersU, clustersV, clustersW;
189  this->SelectAvailableClusters(vetoList, inputClusters, availableClusters);
190  this->SelectClusters(TPC_VIEW_U, availableClusters, clustersU);
191  this->SelectClusters(TPC_VIEW_V, availableClusters, clustersV);
192  this->SelectClusters(TPC_VIEW_W, availableClusters, clustersW);
193 
194  float chi2(m_threeViewChi2Cut);
195  const Cluster *pCluster1(NULL);
196  const Cluster *pCluster2(NULL);
197  const Cluster *pCluster3(NULL);
198 
199  this->GetBestChi2(pVertex, slidingFitResultMap, clustersU, clustersV, clustersW, pCluster1, pCluster2, pCluster3, chi2);
200 
201  if (NULL == pCluster1 || NULL == pCluster2 || NULL == pCluster3)
202  return;
203 
204  const HitType hitType1(LArClusterHelper::GetClusterHitType(pCluster1));
205  const HitType hitType2(LArClusterHelper::GetClusterHitType(pCluster2));
206  const HitType hitType3(LArClusterHelper::GetClusterHitType(pCluster3));
207 
208  const Cluster *const pClusterU((TPC_VIEW_U == hitType1) ? pCluster1
209  : (TPC_VIEW_U == hitType2) ? pCluster2
210  : (TPC_VIEW_U == hitType3) ? pCluster3
211  : NULL);
212  const Cluster *const pClusterV((TPC_VIEW_V == hitType1) ? pCluster1
213  : (TPC_VIEW_V == hitType2) ? pCluster2
214  : (TPC_VIEW_V == hitType3) ? pCluster3
215  : NULL);
216  const Cluster *const pClusterW((TPC_VIEW_W == hitType1) ? pCluster1
217  : (TPC_VIEW_W == hitType2) ? pCluster2
218  : (TPC_VIEW_W == hitType3) ? pCluster3
219  : NULL);
220 
221  particleList.push_back(Particle(pClusterU, pClusterV, pClusterW));
222 
223  vetoList.insert(pCluster1);
224  vetoList.insert(pCluster2);
225  vetoList.insert(pCluster3);
226  }
227 }
void GetBestChi2(const pandora::Vertex *const pVertex, const TwoDSlidingFitResultMap &slidingFitResultMap, const pandora::ClusterVector &clusters1, const pandora::ClusterVector &clusters2, const pandora::ClusterVector &clusters3, const pandora::Cluster *&pBestCluster1, const pandora::Cluster *&pBestCluster2, const pandora::Cluster *&pBestCluster3, float &chi2) const
Get best-matched triplet of clusters from a set of input cluster vectors.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
void SelectAvailableClusters(const pandora::ClusterSet &vetoList, const pandora::ClusterVector &inputVector, pandora::ClusterVector &outputVector) const
Select cluster which haven&#39;t been vetoed.
HitType
Definition: HitType.h:12
void SelectClusters(const pandora::HitType hitType, const pandora::ClusterVector &inputVector, pandora::ClusterVector &outputVector) const
Select clusters of a specified hit type.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void lar_content::VertexBasedPfoRecoveryAlgorithm::MatchTwoViews ( const pandora::Vertex *const  pVertex,
const TwoDSlidingFitResultMap slidingFitResultMap,
const pandora::ClusterVector &  selectedClusters,
pandora::ClusterSet &  vetoList,
ParticleList particleList 
) const
private

Match clusters from two views.

Parameters
pVertexthe input vertex
slidingFitResultMapthe mapping between clusters and sliding fit results
selectedClustersthe input vertex clusters
vetoListthe list of matched clusters
particleListthe output list of matched clusters

Definition at line 231 of file VertexBasedPfoRecoveryAlgorithm.cc.

References f, GetBestChi2(), GetChi2(), lar_content::LArPointingCluster::GetCluster(), lar_content::LArClusterHelper::GetClusterHitType(), GetOuterVertex(), lar_content::LArPointingCluster::Vertex::GetPosition(), m_twoViewChi2Cut, lar_content::LArGeometryHelper::MergeThreePositions3D(), lar_content::LArGeometryHelper::MergeTwoPositions3D(), lar_content::LArGeometryHelper::ProjectPosition(), SelectAvailableClusters(), and SelectClusters().

Referenced by Run().

233 {
234  while (true)
235  {
236  ClusterVector availableClusters, clustersU, clustersV, clustersW;
237  this->SelectAvailableClusters(vetoList, inputClusters, availableClusters);
238  this->SelectClusters(TPC_VIEW_U, availableClusters, clustersU);
239  this->SelectClusters(TPC_VIEW_V, availableClusters, clustersV);
240  this->SelectClusters(TPC_VIEW_W, availableClusters, clustersW);
241 
242  float chi2(m_twoViewChi2Cut);
243  const Cluster *pCluster1(NULL);
244  const Cluster *pCluster2(NULL);
245 
246  this->GetBestChi2(pVertex, slidingFitResultMap, clustersU, clustersV, pCluster1, pCluster2, chi2);
247  this->GetBestChi2(pVertex, slidingFitResultMap, clustersV, clustersW, pCluster1, pCluster2, chi2);
248  this->GetBestChi2(pVertex, slidingFitResultMap, clustersW, clustersU, pCluster1, pCluster2, chi2);
249 
250  if (NULL == pCluster1 || NULL == pCluster2)
251  return;
252 
253  const HitType hitType1(LArClusterHelper::GetClusterHitType(pCluster1));
254  const HitType hitType2(LArClusterHelper::GetClusterHitType(pCluster2));
255 
256  const Cluster *const pClusterU((TPC_VIEW_U == hitType1) ? pCluster1 : (TPC_VIEW_U == hitType2) ? pCluster2 : NULL);
257  const Cluster *const pClusterV((TPC_VIEW_V == hitType1) ? pCluster1 : (TPC_VIEW_V == hitType2) ? pCluster2 : NULL);
258  const Cluster *const pClusterW((TPC_VIEW_W == hitType1) ? pCluster1 : (TPC_VIEW_W == hitType2) ? pCluster2 : NULL);
259 
260  particleList.push_back(Particle(pClusterU, pClusterV, pClusterW));
261 
262  vetoList.insert(pCluster1);
263  vetoList.insert(pCluster2);
264  }
265 }
void GetBestChi2(const pandora::Vertex *const pVertex, const TwoDSlidingFitResultMap &slidingFitResultMap, const pandora::ClusterVector &clusters1, const pandora::ClusterVector &clusters2, const pandora::ClusterVector &clusters3, const pandora::Cluster *&pBestCluster1, const pandora::Cluster *&pBestCluster2, const pandora::Cluster *&pBestCluster3, float &chi2) const
Get best-matched triplet of clusters from a set of input cluster vectors.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
void SelectAvailableClusters(const pandora::ClusterSet &vetoList, const pandora::ClusterVector &inputVector, pandora::ClusterVector &outputVector) const
Select cluster which haven&#39;t been vetoed.
HitType
Definition: HitType.h:12
void SelectClusters(const pandora::HitType hitType, const pandora::ClusterVector &inputVector, pandora::ClusterVector &outputVector) const
Select clusters of a specified hit type.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
StatusCode lar_content::VertexBasedPfoRecoveryAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 543 of file VertexBasedPfoRecoveryAlgorithm.cc.

References m_inputClusterListNames, m_maxLongitudinalDisplacement, m_maxTransverseDisplacement, m_outputPfoListName, m_slidingFitHalfWindow, m_threeViewChi2Cut, and m_twoViewChi2Cut.

544 {
545  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "InputClusterListNames", m_inputClusterListNames));
546 
547  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "OutputPfoListName", m_outputPfoListName));
548 
549  PANDORA_RETURN_RESULT_IF_AND_IF(
550  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitHalfWindow", m_slidingFitHalfWindow));
551 
552  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
553  XmlHelper::ReadValue(xmlHandle, "MaxLongitudinalDisplacement", m_maxLongitudinalDisplacement));
554 
555  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
556  XmlHelper::ReadValue(xmlHandle, "MaxTransverseDisplacement", m_maxTransverseDisplacement));
557 
558  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "TwoViewChi2Cut", m_twoViewChi2Cut));
559 
560  PANDORA_RETURN_RESULT_IF_AND_IF(
561  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ThreeViewChi2Cut", m_threeViewChi2Cut));
562 
563  return STATUS_CODE_SUCCESS;
564 }
std::string m_outputPfoListName
The name of the output pfo list.
pandora::StringVector m_inputClusterListNames
The list of input cluster list names.
StatusCode lar_content::VertexBasedPfoRecoveryAlgorithm::Run ( )
private

Definition at line 33 of file VertexBasedPfoRecoveryAlgorithm.cc.

References BuildParticles(), BuildSlidingFitResultMap(), GetAvailableClusters(), m_inputClusterListNames, MatchThreeViews(), MatchTwoViews(), and SelectVertexClusters().

34 {
35  const VertexList *pVertexList = NULL;
36  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetCurrentList(*this, pVertexList));
37 
38  const Vertex *const pSelectedVertex(
39  (pVertexList && (pVertexList->size() == 1) && (VERTEX_3D == (*(pVertexList->begin()))->GetVertexType())) ? *(pVertexList->begin()) : NULL);
40 
41  if (!pSelectedVertex)
42  {
43  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
44  std::cout << "VertexBasedPfoRecoveryAlgorithm: unable to find vertex in current list " << std::endl;
45 
46  return STATUS_CODE_SUCCESS;
47  }
48 
49  // Get the available clusters from each view
50  ClusterVector availableClusters;
51  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->GetAvailableClusters(m_inputClusterListNames, availableClusters));
52 
53  // Build a set of sliding fit results
54  TwoDSlidingFitResultMap slidingFitResultMap;
55  this->BuildSlidingFitResultMap(availableClusters, slidingFitResultMap);
56 
57  // Select seed clusters (adjacent to vertex)
58  ClusterVector selectedClusters;
59  this->SelectVertexClusters(pSelectedVertex, slidingFitResultMap, availableClusters, selectedClusters);
60 
61  // Match the cluster end points
62  ClusterSet vetoList;
63  ParticleList particleList;
64  this->MatchThreeViews(pSelectedVertex, slidingFitResultMap, selectedClusters, vetoList, particleList);
65  this->MatchTwoViews(pSelectedVertex, slidingFitResultMap, selectedClusters, vetoList, particleList);
66 
67  // Build new particles
68  this->BuildParticles(particleList);
69 
70  return STATUS_CODE_SUCCESS;
71 }
void SelectVertexClusters(const pandora::Vertex *const pVertex, const TwoDSlidingFitResultMap &slidingFitResultMap, const pandora::ClusterVector &inputClusters, pandora::ClusterVector &outputClusters) const
Select clusters in proximity to reconstructed vertex.
void MatchTwoViews(const pandora::Vertex *const pVertex, const TwoDSlidingFitResultMap &slidingFitResultMap, const pandora::ClusterVector &selectedClusters, pandora::ClusterSet &vetoList, ParticleList &particleList) const
Match clusters from two views.
void MatchThreeViews(const pandora::Vertex *const pVertex, const TwoDSlidingFitResultMap &slidingFitResultMap, const pandora::ClusterVector &selectedClusters, pandora::ClusterSet &vetoList, ParticleList &particleList) const
Match clusters from three views.
pandora::StringVector m_inputClusterListNames
The list of input cluster list names.
pandora::StatusCode GetAvailableClusters(const pandora::StringVector inputClusterListName, pandora::ClusterVector &clusterVector) const
Get a vector of available clusters.
void BuildSlidingFitResultMap(const pandora::ClusterVector &clusterVector, TwoDSlidingFitResultMap &slidingFitResultMap) const
Build the map of sliding fit results.
std::unordered_map< const pandora::Cluster *, TwoDSlidingFitResult > TwoDSlidingFitResultMap
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
std::vector< art::Ptr< recob::Cluster > > ClusterVector
std::list< Vertex > VertexList
Definition: DCEL.h:169
void BuildParticles(const ParticleList &particleList)
Build particle flow objects from matched clusters.
void lar_content::VertexBasedPfoRecoveryAlgorithm::SelectAvailableClusters ( const pandora::ClusterSet &  vetoList,
const pandora::ClusterVector &  inputVector,
pandora::ClusterVector &  outputVector 
) const
private

Select cluster which haven't been vetoed.

Parameters
vetoListthe list of vetoed clusters
inputVectorthe input vector of clusters
outputVectorthe output vector of clusters

Definition at line 427 of file VertexBasedPfoRecoveryAlgorithm.cc.

Referenced by MatchThreeViews(), and MatchTwoViews().

428 {
429  for (ClusterVector::const_iterator iter = inputVector.begin(), iterEnd = inputVector.end(); iter != iterEnd; ++iter)
430  {
431  if (0 == vetoList.count(*iter))
432  outputVector.push_back(*iter);
433  }
434 }
intermediate_table::const_iterator const_iterator
void lar_content::VertexBasedPfoRecoveryAlgorithm::SelectClusters ( const pandora::HitType  hitType,
const pandora::ClusterVector &  inputVector,
pandora::ClusterVector &  outputVector 
) const
private

Select clusters of a specified hit type.

Parameters
hitTypethe specified hit type
inputVectorthe input vector of clusters
outputVectorthe output vector of clusters

Definition at line 438 of file VertexBasedPfoRecoveryAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType().

Referenced by MatchThreeViews(), and MatchTwoViews().

439 {
440  for (ClusterVector::const_iterator iter = inputVector.begin(), iterEnd = inputVector.end(); iter != iterEnd; ++iter)
441  {
442  if (hitType == LArClusterHelper::GetClusterHitType(*iter))
443  outputVector.push_back(*iter);
444  }
445 }
intermediate_table::const_iterator const_iterator
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
void lar_content::VertexBasedPfoRecoveryAlgorithm::SelectVertexClusters ( const pandora::Vertex *const  pVertex,
const TwoDSlidingFitResultMap slidingFitResultMap,
const pandora::ClusterVector &  inputClusters,
pandora::ClusterVector &  outputClusters 
) const
private

Select clusters in proximity to reconstructed vertex.

Parameters
pVertexthe input vertex
slidingFitResultMapthe mapping between clusters and sliding fit results
inputClustersthe input vector of clusters
outputClustersthe output vector of clusters

Definition at line 141 of file VertexBasedPfoRecoveryAlgorithm.cc.

References f, lar_content::LArClusterHelper::GetClusterHitType(), lar_content::LArPointingClusterHelper::GetImpactParameters(), lar_content::LArPointingCluster::GetInnerVertex(), lar_content::LArPointingCluster::GetOuterVertex(), m_maxLongitudinalDisplacement, m_maxTransverseDisplacement, and lar_content::LArGeometryHelper::ProjectPosition().

Referenced by Run().

143 {
144  const CartesianVector vertexU(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_U));
145  const CartesianVector vertexV(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_V));
146  const CartesianVector vertexW(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_W));
147 
148  for (ClusterVector::const_iterator cIter = inputClusters.begin(), cIterEnd = inputClusters.end(); cIter != cIterEnd; ++cIter)
149  {
150  const Cluster *const pCluster = *cIter;
151  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
152 
153  if (TPC_3D == hitType)
154  continue;
155 
156  const CartesianVector vertexPosition((TPC_VIEW_U == hitType) ? vertexU : (TPC_VIEW_V == hitType) ? vertexV : vertexW);
157 
158  TwoDSlidingFitResultMap::const_iterator sIter = slidingFitResultMap.find(pCluster);
159  if (slidingFitResultMap.end() == sIter)
160  continue;
161 
162  const TwoDSlidingFitResult &slidingFitResult = sIter->second;
163  const LArPointingCluster pointingCluster(slidingFitResult);
164 
165  for (unsigned int iVtx = 0; iVtx < 2; ++iVtx)
166  {
167  const LArPointingCluster::Vertex &pointingVertex((0 == iVtx) ? pointingCluster.GetInnerVertex() : pointingCluster.GetOuterVertex());
168 
169  float rL(0.f), rT(0.f);
170  LArPointingClusterHelper::GetImpactParameters(pointingVertex, vertexPosition, rL, rT);
171 
172  if (rL > -1.f && rL < m_maxLongitudinalDisplacement && rT < m_maxTransverseDisplacement)
173  {
174  outputClusters.push_back(pCluster);
175  break;
176  }
177  }
178  }
179 }
static void GetImpactParameters(const LArPointingCluster::Vertex &pointingVertex, const LArPointingCluster::Vertex &targetVertex, float &longitudinal, float &transverse)
Calculate impact parameters between a pair of pointing vertices.
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
intermediate_table::const_iterator const_iterator
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
HitType
Definition: HitType.h:12
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25

Member Data Documentation

pandora::StringVector lar_content::VertexBasedPfoRecoveryAlgorithm::m_inputClusterListNames
private

The list of input cluster list names.

Definition at line 201 of file VertexBasedPfoRecoveryAlgorithm.h.

Referenced by ReadSettings(), and Run().

float lar_content::VertexBasedPfoRecoveryAlgorithm::m_maxLongitudinalDisplacement
private

Definition at line 205 of file VertexBasedPfoRecoveryAlgorithm.h.

Referenced by ReadSettings(), and SelectVertexClusters().

float lar_content::VertexBasedPfoRecoveryAlgorithm::m_maxTransverseDisplacement
private

Definition at line 206 of file VertexBasedPfoRecoveryAlgorithm.h.

Referenced by ReadSettings(), and SelectVertexClusters().

std::string lar_content::VertexBasedPfoRecoveryAlgorithm::m_outputPfoListName
private

The name of the output pfo list.

Definition at line 202 of file VertexBasedPfoRecoveryAlgorithm.h.

Referenced by BuildParticles(), and ReadSettings().

unsigned int lar_content::VertexBasedPfoRecoveryAlgorithm::m_slidingFitHalfWindow
private

Definition at line 204 of file VertexBasedPfoRecoveryAlgorithm.h.

Referenced by BuildSlidingFitResultMap(), and ReadSettings().

float lar_content::VertexBasedPfoRecoveryAlgorithm::m_threeViewChi2Cut
private

Definition at line 208 of file VertexBasedPfoRecoveryAlgorithm.h.

Referenced by MatchThreeViews(), and ReadSettings().

float lar_content::VertexBasedPfoRecoveryAlgorithm::m_twoViewChi2Cut
private

Definition at line 207 of file VertexBasedPfoRecoveryAlgorithm.h.

Referenced by MatchTwoViews(), and ReadSettings().


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