LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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 472 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().

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

References lar_content::LArPointingCluster::GetLengthSquared(), lar_content::LArGeometryHelper::GetWireZPitch(), and m_slidingFitHalfWindow.

Referenced by Run().

113 {
114  const float slidingFitPitch(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
115 
116  for (ClusterVector::const_iterator iter = clusterVector.begin(), iterEnd = clusterVector.end(); iter != iterEnd; ++iter)
117  {
118  if (slidingFitResultMap.end() == slidingFitResultMap.find(*iter))
119  {
120  try
121  {
122  const TwoDSlidingFitResult slidingFitResult(*iter, m_slidingFitHalfWindow, slidingFitPitch);
123  const LArPointingCluster pointingCluster(slidingFitResult);
124 
125  if (pointingCluster.GetLengthSquared() < std::numeric_limits<float>::epsilon())
126  continue;
127 
128  if (!slidingFitResultMap.insert(TwoDSlidingFitResultMap::value_type(*iter, slidingFitResult)).second)
129  throw StatusCodeException(STATUS_CODE_FAILURE);
130  }
131  catch (StatusCodeException &statusCodeException)
132  {
133  if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
134  throw statusCodeException;
135  }
136  }
137  }
138 }
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
intermediate_table::const_iterator const_iterator
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 74 of file VertexBasedPfoRecoveryAlgorithm.cc.

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

Referenced by Run().

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

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

Referenced by GetOuterVertex().

447 {
448  const float innerDistance((vertex - cluster.GetInnerVertex().GetPosition()).GetMagnitudeSquared());
449  const float outerDistance((vertex - cluster.GetOuterVertex().GetPosition()).GetMagnitudeSquared());
450 
451  if (innerDistance < outerDistance)
452  return cluster.GetInnerVertex();
453  else
454  return cluster.GetOuterVertex();
455 }
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 459 of file VertexBasedPfoRecoveryAlgorithm.cc.

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

Referenced by MatchTwoViews().

461 {
462  const LArPointingCluster::Vertex &innerVertex = this->GetInnerVertex(vertex, cluster);
463 
464  if (innerVertex.IsInnerVertex())
465  return cluster.GetOuterVertex();
466  else
467  return cluster.GetInnerVertex();
468 }
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.
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 184 of file VertexBasedPfoRecoveryAlgorithm.cc.

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

Referenced by Run().

186 {
187  while (true)
188  {
189  ClusterVector availableClusters, clustersU, clustersV, clustersW;
190  this->SelectAvailableClusters(vetoList, inputClusters, availableClusters);
191  this->SelectClusters(TPC_VIEW_U, availableClusters, clustersU);
192  this->SelectClusters(TPC_VIEW_V, availableClusters, clustersV);
193  this->SelectClusters(TPC_VIEW_W, availableClusters, clustersW);
194 
195  float chi2(m_threeViewChi2Cut);
196  const Cluster *pCluster1(NULL);
197  const Cluster *pCluster2(NULL);
198  const Cluster *pCluster3(NULL);
199 
200  this->GetBestChi2(pVertex, slidingFitResultMap, clustersU, clustersV, clustersW, pCluster1, pCluster2, pCluster3, chi2);
201 
202  if (NULL == pCluster1 || NULL == pCluster2 || NULL == pCluster3)
203  return;
204 
205  const HitType hitType1(LArClusterHelper::GetClusterHitType(pCluster1));
206  const HitType hitType2(LArClusterHelper::GetClusterHitType(pCluster2));
207  const HitType hitType3(LArClusterHelper::GetClusterHitType(pCluster3));
208 
209  const Cluster *const pClusterU((TPC_VIEW_U == hitType1) ? pCluster1 : (TPC_VIEW_U == hitType2) ? pCluster2 :
210  (TPC_VIEW_U == hitType3) ? pCluster3 : NULL);
211  const Cluster *const pClusterV((TPC_VIEW_V == hitType1) ? pCluster1 : (TPC_VIEW_V == hitType2) ? pCluster2 :
212  (TPC_VIEW_V == hitType3) ? pCluster3 : NULL);
213  const Cluster *const pClusterW((TPC_VIEW_W == hitType1) ? pCluster1 : (TPC_VIEW_W == hitType2) ? pCluster2 :
214  (TPC_VIEW_W == hitType3) ? pCluster3 : NULL);
215 
216  particleList.push_back(Particle(pClusterU, pClusterV, pClusterW));
217 
218  vetoList.insert(pCluster1);
219  vetoList.insert(pCluster2);
220  vetoList.insert(pCluster3);
221  }
222 }
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.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void SelectAvailableClusters(const pandora::ClusterSet &vetoList, const pandora::ClusterVector &inputVector, pandora::ClusterVector &outputVector) const
Select cluster which haven&#39;t been vetoed.
void SelectClusters(const pandora::HitType hitType, const pandora::ClusterVector &inputVector, pandora::ClusterVector &outputVector) const
Select clusters of a specified hit type.
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 226 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().

228 {
229  while (true)
230  {
231  ClusterVector availableClusters, clustersU, clustersV, clustersW;
232  this->SelectAvailableClusters(vetoList, inputClusters, availableClusters);
233  this->SelectClusters(TPC_VIEW_U, availableClusters, clustersU);
234  this->SelectClusters(TPC_VIEW_V, availableClusters, clustersV);
235  this->SelectClusters(TPC_VIEW_W, availableClusters, clustersW);
236 
237  float chi2(m_twoViewChi2Cut);
238  const Cluster *pCluster1(NULL);
239  const Cluster *pCluster2(NULL);
240 
241  this->GetBestChi2(pVertex, slidingFitResultMap, clustersU, clustersV, pCluster1, pCluster2, chi2);
242  this->GetBestChi2(pVertex, slidingFitResultMap, clustersV, clustersW, pCluster1, pCluster2, chi2);
243  this->GetBestChi2(pVertex, slidingFitResultMap, clustersW, clustersU, pCluster1, pCluster2, chi2);
244 
245  if (NULL == pCluster1 || NULL == pCluster2)
246  return;
247 
248  const HitType hitType1(LArClusterHelper::GetClusterHitType(pCluster1));
249  const HitType hitType2(LArClusterHelper::GetClusterHitType(pCluster2));
250 
251  const Cluster *const pClusterU((TPC_VIEW_U == hitType1) ? pCluster1 : (TPC_VIEW_U == hitType2) ? pCluster2 : NULL);
252  const Cluster *const pClusterV((TPC_VIEW_V == hitType1) ? pCluster1 : (TPC_VIEW_V == hitType2) ? pCluster2 : NULL);
253  const Cluster *const pClusterW((TPC_VIEW_W == hitType1) ? pCluster1 : (TPC_VIEW_W == hitType2) ? pCluster2 : NULL);
254 
255  particleList.push_back(Particle(pClusterU, pClusterV, pClusterW));
256 
257  vetoList.insert(pCluster1);
258  vetoList.insert(pCluster2);
259  }
260 }
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.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void SelectAvailableClusters(const pandora::ClusterSet &vetoList, const pandora::ClusterVector &inputVector, pandora::ClusterVector &outputVector) const
Select cluster which haven&#39;t been vetoed.
void SelectClusters(const pandora::HitType hitType, const pandora::ClusterVector &inputVector, pandora::ClusterVector &outputVector) const
Select clusters of a specified hit type.
StatusCode lar_content::VertexBasedPfoRecoveryAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 537 of file VertexBasedPfoRecoveryAlgorithm.cc.

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

538 {
539  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
540  "InputClusterListNames", m_inputClusterListNames));
541 
542  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
543  "OutputPfoListName", m_outputPfoListName));
544 
545  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
546  "SlidingFitHalfWindow", m_slidingFitHalfWindow));
547 
548  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
549  "MaxLongitudinalDisplacement", m_maxLongitudinalDisplacement));
550 
551  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
552  "MaxTransverseDisplacement", m_maxTransverseDisplacement));
553 
554  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
555  "TwoViewChi2Cut", m_twoViewChi2Cut));
556 
557  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
558  "ThreeViewChi2Cut", m_threeViewChi2Cut));
559 
560  return STATUS_CODE_SUCCESS;
561 }
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((pVertexList && (pVertexList->size() == 1) && (VERTEX_3D == (*(pVertexList->begin()))->GetVertexType())) ? *(pVertexList->begin()) : NULL);
39 
40  if (!pSelectedVertex)
41  {
42  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
43  std::cout << "VertexBasedPfoRecoveryAlgorithm: unable to find vertex in current list " << std::endl;
44 
45  return STATUS_CODE_SUCCESS;
46  }
47 
48  // Get the available clusters from each view
49  ClusterVector availableClusters;
50  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->GetAvailableClusters(m_inputClusterListNames, availableClusters));
51 
52  // Build a set of sliding fit results
53  TwoDSlidingFitResultMap slidingFitResultMap;
54  this->BuildSlidingFitResultMap(availableClusters, slidingFitResultMap);
55 
56  // Select seed clusters (adjacent to vertex)
57  ClusterVector selectedClusters;
58  this->SelectVertexClusters(pSelectedVertex, slidingFitResultMap, availableClusters, selectedClusters);
59 
60  // Match the cluster end points
61  ClusterSet vetoList;
62  ParticleList particleList;
63  this->MatchThreeViews(pSelectedVertex, slidingFitResultMap, selectedClusters, vetoList, particleList);
64  this->MatchTwoViews(pSelectedVertex, slidingFitResultMap, selectedClusters, vetoList, particleList);
65 
66  // Build new particles
67  this->BuildParticles(particleList);
68 
69  return STATUS_CODE_SUCCESS;
70 }
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.
std::unordered_map< const pandora::Cluster *, TwoDSlidingFitResult > TwoDSlidingFitResultMap
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::vector< art::Ptr< recob::Cluster > > ClusterVector
std::list< Vertex > VertexList
Definition: DCEL.h:178
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 422 of file VertexBasedPfoRecoveryAlgorithm.cc.

Referenced by MatchThreeViews(), and MatchTwoViews().

424 {
425  for (ClusterVector::const_iterator iter = inputVector.begin(), iterEnd = inputVector.end(); iter != iterEnd; ++iter)
426  {
427  if (0 == vetoList.count(*iter))
428  outputVector.push_back(*iter);
429  }
430 }
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 434 of file VertexBasedPfoRecoveryAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType().

Referenced by MatchThreeViews(), and MatchTwoViews().

435 {
436  for (ClusterVector::const_iterator iter = inputVector.begin(), iterEnd = inputVector.end(); iter != iterEnd; ++iter)
437  {
438  if (hitType == LArClusterHelper::GetClusterHitType(*iter))
439  outputVector.push_back(*iter);
440  }
441 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
intermediate_table::const_iterator const_iterator
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 142 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().

144 {
145  const CartesianVector vertexU(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_U));
146  const CartesianVector vertexV(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_V));
147  const CartesianVector vertexW(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_W));
148 
149  for (ClusterVector::const_iterator cIter = inputClusters.begin(), cIterEnd = inputClusters.end(); cIter != cIterEnd; ++cIter)
150  {
151  const Cluster *const pCluster = *cIter;
152  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
153 
154  if (TPC_3D == hitType)
155  continue;
156 
157  const CartesianVector vertexPosition((TPC_VIEW_U == hitType) ? vertexU : (TPC_VIEW_V == hitType) ? vertexV : vertexW);
158 
159  TwoDSlidingFitResultMap::const_iterator sIter = slidingFitResultMap.find(pCluster);
160  if (slidingFitResultMap.end() == sIter)
161  continue;
162 
163  const TwoDSlidingFitResult &slidingFitResult = sIter->second;
164  const LArPointingCluster pointingCluster(slidingFitResult);
165 
166  for (unsigned int iVtx = 0; iVtx < 2; ++iVtx)
167  {
168  const LArPointingCluster::Vertex &pointingVertex((0 == iVtx) ? pointingCluster.GetInnerVertex() : pointingCluster.GetOuterVertex());
169 
170  float rL(0.f), rT(0.f);
171  LArPointingClusterHelper::GetImpactParameters(pointingVertex, vertexPosition, rL, rT);
172 
173  if (rL > -1.f && rL < m_maxLongitudinalDisplacement && rT < m_maxTransverseDisplacement)
174  {
175  outputClusters.push_back(pCluster);
176  break;
177  }
178  }
179  }
180 }
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.
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
intermediate_table::const_iterator const_iterator

Member Data Documentation

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

The list of input cluster list names.

Definition at line 206 of file VertexBasedPfoRecoveryAlgorithm.h.

Referenced by ReadSettings(), and Run().

float lar_content::VertexBasedPfoRecoveryAlgorithm::m_maxLongitudinalDisplacement
private

Definition at line 210 of file VertexBasedPfoRecoveryAlgorithm.h.

Referenced by ReadSettings(), and SelectVertexClusters().

float lar_content::VertexBasedPfoRecoveryAlgorithm::m_maxTransverseDisplacement
private

Definition at line 211 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 207 of file VertexBasedPfoRecoveryAlgorithm.h.

Referenced by BuildParticles(), and ReadSettings().

unsigned int lar_content::VertexBasedPfoRecoveryAlgorithm::m_slidingFitHalfWindow
private

Definition at line 209 of file VertexBasedPfoRecoveryAlgorithm.h.

Referenced by BuildSlidingFitResultMap(), and ReadSettings().

float lar_content::VertexBasedPfoRecoveryAlgorithm::m_threeViewChi2Cut
private

Definition at line 213 of file VertexBasedPfoRecoveryAlgorithm.h.

Referenced by MatchThreeViews(), and ReadSettings().

float lar_content::VertexBasedPfoRecoveryAlgorithm::m_twoViewChi2Cut
private

Definition at line 212 of file VertexBasedPfoRecoveryAlgorithm.h.

Referenced by MatchTwoViews(), and ReadSettings().


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