LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
lar_content::CandidateVertexCreationAlgorithm Class Reference

CandidateVertexCreationAlgorithm::Algorithm class. More...

#include "CandidateVertexCreationAlgorithm.h"

Inheritance diagram for lar_content::CandidateVertexCreationAlgorithm:

Public Member Functions

 CandidateVertexCreationAlgorithm ()
 Default constructor. More...
 

Private Types

typedef std::unordered_map< const pandora::Cluster *, pandora::CartesianPointVector > ClusterToSpacepointsMap
 

Private Member Functions

pandora::StatusCode Run ()
 
void SelectClusters (pandora::ClusterVector &clusterVectorU, pandora::ClusterVector &clusterVectorV, pandora::ClusterVector &clusterVectorW)
 Select a subset of input clusters (contained in the input list names) for processing in this algorithm. More...
 
void CreateEndpointCandidates (const pandora::ClusterVector &clusterVector1, const pandora::ClusterVector &clusterVector2) const
 Create candidate vertex positions by comparing pairs of cluster end positions. More...
 
void CreateEndpointVertex (const pandora::CartesianVector &position1, const pandora::HitType hitType1, const TwoDSlidingFitResult &fitResult2) const
 Create a candidate vertex position, using an end-point position from one cluster and sliding fit to a second cluster. More...
 
void CreateCrossingCandidates (const pandora::ClusterVector &clusterVectorU, const pandora::ClusterVector &clusterVectorV, const pandora::ClusterVector &clusterVectorW) const
 Extrapolate 2D clusters, find where they cross, and match crossing points between views to create vertex candidates. More...
 
void FindCrossingPoints (const pandora::ClusterVector &clusterVector, pandora::CartesianPointVector &crossingPoints) const
 Identify where (extrapolated) clusters plausibly cross in 2D. More...
 
void GetSpacepoints (const pandora::Cluster *const pCluster, pandora::CartesianPointVector &spacePoints) const
 Get a list of spacepoints representing cluster 2D hit positions and extrapolated positions. More...
 
void FindCrossingPoints (const pandora::CartesianPointVector &spacepoints1, const pandora::CartesianPointVector &spacepoints2, pandora::CartesianPointVector &crossingPoints) const
 Identify where (extrapolated) clusters plausibly cross in 2D. More...
 
void CreateCrossingVertices (const pandora::CartesianPointVector &crossingPoints1, const pandora::CartesianPointVector &crossingPoints2, const pandora::HitType hitType1, const pandora::HitType hitType2, unsigned int &nCrossingCandidates) const
 Attempt to create candidate vertex positions, using 2D crossing points in 2 views. More...
 
void AddToSlidingFitCache (const pandora::Cluster *const pCluster)
 Creates a 2D sliding fit of a cluster and stores it for later use. More...
 
const TwoDSlidingFitResultGetCachedSlidingFitResult (const pandora::Cluster *const pCluster) const
 Get a sliding fit result from the algorithm cache. More...
 
void TidyUp ()
 Clear relevant algorithm member variables between events. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

pandora::StringVector m_inputClusterListNames
 The list of cluster list names. More...
 
std::string m_outputVertexListName
 The name under which to save the output vertex list. More...
 
bool m_replaceCurrentVertexList
 Whether to replace the current vertex list with the output list. More...
 
unsigned int m_slidingFitWindow
 The layer window for the sliding linear fits. More...
 
TwoDSlidingFitResultMap m_slidingFitResultMap
 The sliding fit result map. More...
 
unsigned int m_minClusterCaloHits
 The min number of hits in base cluster selection method. More...
 
float m_minClusterLengthSquared
 The min length (squared) in base cluster selection method. More...
 
float m_chiSquaredCut
 The chi squared cut (accept only 3D vertex positions with values below cut) More...
 
bool m_enableEndpointCandidates
 Whether to create endpoint-based candidates. More...
 
float m_maxEndpointXDiscrepancy
 The max cluster endpoint discrepancy. More...
 
bool m_enableCrossingCandidates
 Whether to create crossing vertex candidates. More...
 
unsigned int m_nMaxCrossingCandidates
 The max number of crossing candidates to create. More...
 
float m_maxCrossingXDiscrepancy
 The max cluster endpoint discrepancy. More...
 
unsigned int m_extrapolationNSteps
 Number of extrapolation steps, at each end of cluster, of specified size. More...
 
float m_extrapolationStepSize
 The extrapolation step size in cm. More...
 
float m_maxCrossingSeparationSquared
 The separation (squared) between spacepoints below which a crossing can be identified. More...
 
float m_minNearbyCrossingDistanceSquared
 The minimum allowed distance between identified crossing positions. More...
 

Detailed Description

CandidateVertexCreationAlgorithm::Algorithm class.

Definition at line 23 of file CandidateVertexCreationAlgorithm.h.

Member Typedef Documentation

typedef std::unordered_map<const pandora::Cluster*, pandora::CartesianPointVector> lar_content::CandidateVertexCreationAlgorithm::ClusterToSpacepointsMap
private

Definition at line 128 of file CandidateVertexCreationAlgorithm.h.

Constructor & Destructor Documentation

lar_content::CandidateVertexCreationAlgorithm::CandidateVertexCreationAlgorithm ( )

Default constructor.

Definition at line 23 of file CandidateVertexCreationAlgorithm.cc.

23  :
28  m_chiSquaredCut(2.f),
38 {
39 }
float m_minClusterLengthSquared
The min length (squared) in base cluster selection method.
float m_extrapolationStepSize
The extrapolation step size in cm.
float m_maxCrossingSeparationSquared
The separation (squared) between spacepoints below which a crossing can be identified.
bool m_enableEndpointCandidates
Whether to create endpoint-based candidates.
bool m_replaceCurrentVertexList
Whether to replace the current vertex list with the output list.
float m_maxEndpointXDiscrepancy
The max cluster endpoint discrepancy.
TFile f
Definition: plotHisto.C:6
bool m_enableCrossingCandidates
Whether to create crossing vertex candidates.
float m_maxCrossingXDiscrepancy
The max cluster endpoint discrepancy.
float m_minNearbyCrossingDistanceSquared
The minimum allowed distance between identified crossing positions.
unsigned int m_minClusterCaloHits
The min number of hits in base cluster selection method.
unsigned int m_extrapolationNSteps
Number of extrapolation steps, at each end of cluster, of specified size.
unsigned int m_nMaxCrossingCandidates
The max number of crossing candidates to create.
float m_chiSquaredCut
The chi squared cut (accept only 3D vertex positions with values below cut)
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.

Member Function Documentation

void lar_content::CandidateVertexCreationAlgorithm::AddToSlidingFitCache ( const pandora::Cluster *const  pCluster)
private

Creates a 2D sliding fit of a cluster and stores it for later use.

Parameters
pClusteraddress of the relevant cluster

Definition at line 348 of file CandidateVertexCreationAlgorithm.cc.

References lar_content::LArGeometryHelper::GetWireZPitch(), m_slidingFitResultMap, and m_slidingFitWindow.

Referenced by SelectClusters().

349 {
350  const float slidingFitPitch(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
351  const TwoDSlidingFitResult slidingFitResult(pCluster, m_slidingFitWindow, slidingFitPitch);
352 
353  if (!m_slidingFitResultMap.insert(TwoDSlidingFitResultMap::value_type(pCluster, slidingFitResult)).second)
354  throw StatusCodeException(STATUS_CODE_FAILURE);
355 }
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
TwoDSlidingFitResultMap m_slidingFitResultMap
The sliding fit result map.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
void lar_content::CandidateVertexCreationAlgorithm::CreateCrossingCandidates ( const pandora::ClusterVector &  clusterVectorU,
const pandora::ClusterVector &  clusterVectorV,
const pandora::ClusterVector &  clusterVectorW 
) const
private

Extrapolate 2D clusters, find where they cross, and match crossing points between views to create vertex candidates.

Parameters
clusterVectorUthe clusters in the u view
clusterVectorVthe clusters in the v view
clusterVectorWthe clusters in the w view

Definition at line 201 of file CandidateVertexCreationAlgorithm.cc.

References CreateCrossingVertices(), FindCrossingPoints(), and GetSpacepoints().

Referenced by Run().

203 {
204  CartesianPointVector crossingsU, crossingsV, crossingsW;
205  this->FindCrossingPoints(clusterVectorU, crossingsU);
206  this->FindCrossingPoints(clusterVectorV, crossingsV);
207  this->FindCrossingPoints(clusterVectorW, crossingsW);
208 
209  unsigned int nCrossingCandidates(0);
210  this->CreateCrossingVertices(crossingsU, crossingsV, TPC_VIEW_U, TPC_VIEW_V, nCrossingCandidates);
211  this->CreateCrossingVertices(crossingsU, crossingsW, TPC_VIEW_U, TPC_VIEW_W, nCrossingCandidates);
212  this->CreateCrossingVertices(crossingsV, crossingsW, TPC_VIEW_V, TPC_VIEW_W, nCrossingCandidates);
213 }
void FindCrossingPoints(const pandora::ClusterVector &clusterVector, pandora::CartesianPointVector &crossingPoints) const
Identify where (extrapolated) clusters plausibly cross in 2D.
void CreateCrossingVertices(const pandora::CartesianPointVector &crossingPoints1, const pandora::CartesianPointVector &crossingPoints2, const pandora::HitType hitType1, const pandora::HitType hitType2, unsigned int &nCrossingCandidates) const
Attempt to create candidate vertex positions, using 2D crossing points in 2 views.
void lar_content::CandidateVertexCreationAlgorithm::CreateCrossingVertices ( const pandora::CartesianPointVector &  crossingPoints1,
const pandora::CartesianPointVector &  crossingPoints2,
const pandora::HitType  hitType1,
const pandora::HitType  hitType2,
unsigned int &  nCrossingCandidates 
) const
private

Attempt to create candidate vertex positions, using 2D crossing points in 2 views.

Parameters
crossingPoints1the crossing points in view 1
crossingPoints2the crossing points in view 2
hitType1the hit type of crossing points 1
hitType2the hit type of crossing points 2
nCrossingCandidatesto count the number of crossing candidates created

Definition at line 313 of file CandidateVertexCreationAlgorithm.cc.

References f, m_chiSquaredCut, m_maxCrossingXDiscrepancy, m_nMaxCrossingCandidates, and lar_content::LArGeometryHelper::MergeTwoPositions3D().

Referenced by CreateCrossingCandidates().

315 {
316 
317  for (const CartesianVector &position1: crossingPoints1)
318  {
319  for (const CartesianVector &position2: crossingPoints2)
320  {
321  if (nCrossingCandidates > m_nMaxCrossingCandidates)
322  return;
323 
324  if (std::fabs(position1.GetX() - position2.GetX()) > m_maxCrossingXDiscrepancy)
325  continue;
326 
327  float chiSquared(0.f);
328  CartesianVector position3D(0.f, 0.f, 0.f);
329  LArGeometryHelper::MergeTwoPositions3D(this->GetPandora(), hitType1, hitType2, position1, position2, position3D, chiSquared);
330 
331  if (chiSquared > m_chiSquaredCut)
332  continue;
333 
334  PandoraContentApi::Vertex::Parameters parameters;
335  parameters.m_position = position3D;
336  parameters.m_vertexLabel = VERTEX_INTERACTION;
337  parameters.m_vertexType = VERTEX_3D;
338 
339  const Vertex *pVertex(NULL);
340  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*this, parameters, pVertex));
341  ++nCrossingCandidates;
342  }
343  }
344 }
static void MergeTwoPositions3D(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const pandora::CartesianVector &position1, const pandora::CartesianVector &position2, pandora::CartesianVector &position3D, float &chiSquared)
Merge 2D positions from two views to give unified 3D position.
TFile f
Definition: plotHisto.C:6
float m_maxCrossingXDiscrepancy
The max cluster endpoint discrepancy.
unsigned int m_nMaxCrossingCandidates
The max number of crossing candidates to create.
float m_chiSquaredCut
The chi squared cut (accept only 3D vertex positions with values below cut)
void lar_content::CandidateVertexCreationAlgorithm::CreateEndpointCandidates ( const pandora::ClusterVector &  clusterVector1,
const pandora::ClusterVector &  clusterVector2 
) const
private

Create candidate vertex positions by comparing pairs of cluster end positions.

Parameters
clusterVector1the clusters in view 1
clusterVector1the clusters in view 2

Definition at line 136 of file CandidateVertexCreationAlgorithm.cc.

References CreateEndpointVertex(), GetCachedSlidingFitResult(), lar_content::LArClusterHelper::GetClusterHitType(), lar_content::TwoDSlidingFitResult::GetGlobalMaxLayerPosition(), and lar_content::TwoDSlidingFitResult::GetGlobalMinLayerPosition().

Referenced by Run().

137 {
138  for (const Cluster *const pCluster1 : clusterVector1)
139  {
140  const HitType hitType1(LArClusterHelper::GetClusterHitType(pCluster1));
141 
142  const TwoDSlidingFitResult &fitResult1(this->GetCachedSlidingFitResult(pCluster1));
143  const CartesianVector minLayerPosition1(fitResult1.GetGlobalMinLayerPosition());
144  const CartesianVector maxLayerPosition1(fitResult1.GetGlobalMaxLayerPosition());
145 
146  for (const Cluster *const pCluster2 : clusterVector2)
147  {
148  const HitType hitType2(LArClusterHelper::GetClusterHitType(pCluster2));
149 
150  const TwoDSlidingFitResult &fitResult2(this->GetCachedSlidingFitResult(pCluster2));
151  const CartesianVector minLayerPosition2(fitResult2.GetGlobalMinLayerPosition());
152  const CartesianVector maxLayerPosition2(fitResult2.GetGlobalMaxLayerPosition());
153 
154  this->CreateEndpointVertex(maxLayerPosition1, hitType1, fitResult2);
155  this->CreateEndpointVertex(minLayerPosition1, hitType1, fitResult2);
156  this->CreateEndpointVertex(maxLayerPosition2, hitType2, fitResult1);
157  this->CreateEndpointVertex(minLayerPosition2, hitType2, fitResult1);
158  }
159  }
160 }
void CreateEndpointVertex(const pandora::CartesianVector &position1, const pandora::HitType hitType1, const TwoDSlidingFitResult &fitResult2) const
Create a candidate vertex position, using an end-point position from one cluster and sliding fit to a...
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
const TwoDSlidingFitResult & GetCachedSlidingFitResult(const pandora::Cluster *const pCluster) const
Get a sliding fit result from the algorithm cache.
void lar_content::CandidateVertexCreationAlgorithm::CreateEndpointVertex ( const pandora::CartesianVector &  position1,
const pandora::HitType  hitType1,
const TwoDSlidingFitResult fitResult2 
) const
private

Create a candidate vertex position, using an end-point position from one cluster and sliding fit to a second cluster.

Parameters
position1an end-point position for the first cluster
hitType1the hit type of the first cluster
fitResult2the two dimensional sliding fit result for the second cluster

Definition at line 164 of file CandidateVertexCreationAlgorithm.cc.

References f, lar_content::TwoDSlidingFitResult::GetCluster(), lar_content::LArClusterHelper::GetClusterHitType(), lar_content::TwoDSlidingFitResult::GetExtrapolatedPositionAtX(), lar_content::TwoDSlidingFitResult::GetGlobalMaxLayerPosition(), lar_content::TwoDSlidingFitResult::GetGlobalMinLayerPosition(), m_chiSquaredCut, m_maxEndpointXDiscrepancy, and lar_content::LArGeometryHelper::MergeTwoPositions3D().

Referenced by CreateEndpointCandidates().

165 {
166  const CartesianVector minLayerPosition2(fitResult2.GetGlobalMinLayerPosition());
167  const CartesianVector maxLayerPosition2(fitResult2.GetGlobalMaxLayerPosition());
168 
169  if ((((position1.GetX() < minLayerPosition2.GetX()) && (position1.GetX() < maxLayerPosition2.GetX())) ||
170  ((position1.GetX() > minLayerPosition2.GetX()) && (position1.GetX() > maxLayerPosition2.GetX()))) &&
171  (std::fabs(position1.GetX() - minLayerPosition2.GetX()) > m_maxEndpointXDiscrepancy) &&
172  (std::fabs(position1.GetX() - maxLayerPosition2.GetX()) > m_maxEndpointXDiscrepancy))
173  {
174  return;
175  }
176 
177  CartesianVector position2(0.f, 0.f, 0.f);
178  if (STATUS_CODE_SUCCESS != fitResult2.GetExtrapolatedPositionAtX(position1.GetX(), position2))
179  return;
180 
181  const HitType hitType2(LArClusterHelper::GetClusterHitType(fitResult2.GetCluster()));
182 
183  float chiSquared(0.f);
184  CartesianVector position3D(0.f, 0.f, 0.f);
185  LArGeometryHelper::MergeTwoPositions3D(this->GetPandora(), hitType1, hitType2, position1, position2, position3D, chiSquared);
186 
187  if (chiSquared > m_chiSquaredCut)
188  return;
189 
190  PandoraContentApi::Vertex::Parameters parameters;
191  parameters.m_position = position3D;
192  parameters.m_vertexLabel = VERTEX_INTERACTION;
193  parameters.m_vertexType = VERTEX_3D;
194 
195  const Vertex *pVertex(NULL);
196  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*this, parameters, pVertex));
197 }
static void MergeTwoPositions3D(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const pandora::CartesianVector &position1, const pandora::CartesianVector &position2, pandora::CartesianVector &position3D, float &chiSquared)
Merge 2D positions from two views to give unified 3D position.
float m_maxEndpointXDiscrepancy
The max cluster endpoint discrepancy.
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
float m_chiSquaredCut
The chi squared cut (accept only 3D vertex positions with values below cut)
void lar_content::CandidateVertexCreationAlgorithm::FindCrossingPoints ( const pandora::ClusterVector &  clusterVector,
pandora::CartesianPointVector &  crossingPoints 
) const
private

Identify where (extrapolated) clusters plausibly cross in 2D.

Parameters
clusterVectorthe input clusters
crossingPointsto receive the 2D crossing points

Referenced by CreateCrossingCandidates(), and GetSpacepoints().

void lar_content::CandidateVertexCreationAlgorithm::FindCrossingPoints ( const pandora::CartesianPointVector &  spacepoints1,
const pandora::CartesianPointVector &  spacepoints2,
pandora::CartesianPointVector &  crossingPoints 
) const
private

Identify where (extrapolated) clusters plausibly cross in 2D.

Parameters
spacepoints1space points for cluster 1
spacepoints2space points for cluster 2
crossingPointsto receive the list of plausible 2D crossing points
const TwoDSlidingFitResult & lar_content::CandidateVertexCreationAlgorithm::GetCachedSlidingFitResult ( const pandora::Cluster *const  pCluster) const
private

Get a sliding fit result from the algorithm cache.

Parameters
pClusteraddress of the relevant cluster

Definition at line 359 of file CandidateVertexCreationAlgorithm.cc.

References m_slidingFitResultMap.

Referenced by CreateEndpointCandidates(), and GetSpacepoints().

360 {
362 
363  if (m_slidingFitResultMap.end() == iter)
364  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
365 
366  return iter->second;
367 }
intermediate_table::const_iterator const_iterator
TwoDSlidingFitResultMap m_slidingFitResultMap
The sliding fit result map.
void lar_content::CandidateVertexCreationAlgorithm::GetSpacepoints ( const pandora::Cluster *const  pCluster,
pandora::CartesianPointVector &  spacePoints 
) const
private

Get a list of spacepoints representing cluster 2D hit positions and extrapolated positions.

Parameters
pClusteraddress of the cluster
spacePointsto receive the list of spacepoints

Definition at line 241 of file CandidateVertexCreationAlgorithm.cc.

References f, FindCrossingPoints(), GetCachedSlidingFitResult(), lar_content::LArClusterHelper::GetCoordinateVector(), lar_content::TwoDSlidingFitResult::GetExtrapolatedPosition(), lar_content::TwoDSlidingFitResult::GetL(), lar_content::TwoDSlidingFitResult::GetMaxLayer(), lar_content::TwoDSlidingFitResult::GetMinLayer(), m_extrapolationNSteps, m_extrapolationStepSize, m_maxCrossingSeparationSquared, m_minNearbyCrossingDistanceSquared, and lar_content::LArClusterHelper::SortCoordinatesByPosition().

Referenced by CreateCrossingCandidates().

242 {
243  LArClusterHelper::GetCoordinateVector(pCluster, spacepoints);
244 
245  const TwoDSlidingFitResult &fitResult(this->GetCachedSlidingFitResult(pCluster));
246  const float minLayerRL(fitResult.GetL(fitResult.GetMinLayer()));
247  const float maxLayerRL(fitResult.GetL(fitResult.GetMaxLayer()));
248 
249  for (unsigned int iStep = 0; iStep < m_extrapolationNSteps; ++ iStep)
250  {
251  const float deltaRL(static_cast<float>(iStep) * m_extrapolationStepSize);
252 
253  CartesianVector positionPositive(0.f, 0.f, 0.f), positionNegative(0.f, 0.f, 0.f);
254  fitResult.GetExtrapolatedPosition(maxLayerRL + deltaRL, positionPositive);
255  fitResult.GetExtrapolatedPosition(minLayerRL - deltaRL, positionNegative);
256 
257  spacepoints.push_back(positionPositive);
258  spacepoints.push_back(positionNegative);
259  }
260 
261  std::sort(spacepoints.begin(), spacepoints.end(), LArClusterHelper::SortCoordinatesByPosition);
262 }
float m_extrapolationStepSize
The extrapolation step size in cm.
TFile f
Definition: plotHisto.C:6
static bool SortCoordinatesByPosition(const pandora::CartesianVector &lhs, const pandora::CartesianVector &rhs)
Sort cartesian vectors by their position (use Z, followed by X, followed by Y)
unsigned int m_extrapolationNSteps
Number of extrapolation steps, at each end of cluster, of specified size.
const TwoDSlidingFitResult & GetCachedSlidingFitResult(const pandora::Cluster *const pCluster) const
Get a sliding fit result from the algorithm cache.
static void GetCoordinateVector(const pandora::Cluster *const pCluster, pandora::CartesianPointVector &coordinateVector)
Get vector of hit coordinates from an input cluster.
StatusCode lar_content::CandidateVertexCreationAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 378 of file CandidateVertexCreationAlgorithm.cc.

References m_chiSquaredCut, m_enableCrossingCandidates, m_enableEndpointCandidates, m_extrapolationNSteps, m_extrapolationStepSize, m_inputClusterListNames, m_maxCrossingSeparationSquared, m_maxCrossingXDiscrepancy, m_maxEndpointXDiscrepancy, m_minClusterCaloHits, m_minClusterLengthSquared, m_minNearbyCrossingDistanceSquared, m_nMaxCrossingCandidates, m_outputVertexListName, m_replaceCurrentVertexList, and m_slidingFitWindow.

379 {
380  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
381  "InputClusterListNames", m_inputClusterListNames));
382 
383  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
384  "OutputVertexListName", m_outputVertexListName));
385 
386  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
387  "ReplaceCurrentVertexList", m_replaceCurrentVertexList));
388 
389  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
390  "SlidingFitWindow", m_slidingFitWindow));
391 
392  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
393  "MinClusterCaloHits", m_minClusterCaloHits));
394 
395  float minClusterLength = std::sqrt(m_minClusterLengthSquared);
396  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
397  "MinClusterLength", minClusterLength));
398  m_minClusterLengthSquared = minClusterLength * minClusterLength;
399 
400  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
401  "ChiSquaredCut", m_chiSquaredCut));
402 
403  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
404  "EnableEndpointCandidates", m_enableEndpointCandidates));
405 
406  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
407  "MaxEndpointXDiscrepancy", m_maxEndpointXDiscrepancy));
408 
409  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
410  "EnableCrossingCandidates", m_enableCrossingCandidates));
411 
412  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
413  "NMaxCrossingCandidates", m_nMaxCrossingCandidates));
414 
415  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
416  "MaxCrossingXDiscrepancy", m_maxCrossingXDiscrepancy));
417 
418  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
419  "ExtrapolationNSteps", m_extrapolationNSteps));
420 
421  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
422  "ExtrapolationStepSize", m_extrapolationStepSize));
423 
424  float maxCrossingSeparation = std::sqrt(m_maxCrossingSeparationSquared);
425  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
426  "MaxCrossingSeparation", maxCrossingSeparation));
427  m_maxCrossingSeparationSquared = maxCrossingSeparation * maxCrossingSeparation;
428 
429  float minNearbyCrossingDistance = std::sqrt(m_minNearbyCrossingDistanceSquared);
430  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
431  "MinNearbyCrossingDistance", minNearbyCrossingDistance));
432  m_minNearbyCrossingDistanceSquared = minNearbyCrossingDistance * minNearbyCrossingDistance;
433 
434  return STATUS_CODE_SUCCESS;
435 }
float m_minClusterLengthSquared
The min length (squared) in base cluster selection method.
float m_extrapolationStepSize
The extrapolation step size in cm.
float m_maxCrossingSeparationSquared
The separation (squared) between spacepoints below which a crossing can be identified.
bool m_enableEndpointCandidates
Whether to create endpoint-based candidates.
bool m_replaceCurrentVertexList
Whether to replace the current vertex list with the output list.
float m_maxEndpointXDiscrepancy
The max cluster endpoint discrepancy.
bool m_enableCrossingCandidates
Whether to create crossing vertex candidates.
float m_maxCrossingXDiscrepancy
The max cluster endpoint discrepancy.
float m_minNearbyCrossingDistanceSquared
The minimum allowed distance between identified crossing positions.
unsigned int m_minClusterCaloHits
The min number of hits in base cluster selection method.
unsigned int m_extrapolationNSteps
Number of extrapolation steps, at each end of cluster, of specified size.
std::string m_outputVertexListName
The name under which to save the output vertex list.
pandora::StringVector m_inputClusterListNames
The list of cluster list names.
unsigned int m_nMaxCrossingCandidates
The max number of crossing candidates to create.
float m_chiSquaredCut
The chi squared cut (accept only 3D vertex positions with values below cut)
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
StatusCode lar_content::CandidateVertexCreationAlgorithm::Run ( )
private

Definition at line 43 of file CandidateVertexCreationAlgorithm.cc.

References CreateCrossingCandidates(), CreateEndpointCandidates(), m_enableCrossingCandidates, m_enableEndpointCandidates, m_outputVertexListName, m_replaceCurrentVertexList, SelectClusters(), and TidyUp().

44 {
45  try
46  {
47  ClusterVector clusterVectorU, clusterVectorV, clusterVectorW;
48  this->SelectClusters(clusterVectorU, clusterVectorV, clusterVectorW);
49 
50  const VertexList *pVertexList(NULL); std::string temporaryListName;
51  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pVertexList, temporaryListName));
52 
54  {
55  this->CreateEndpointCandidates(clusterVectorU, clusterVectorV);
56  this->CreateEndpointCandidates(clusterVectorU, clusterVectorW);
57  this->CreateEndpointCandidates(clusterVectorV, clusterVectorW);
58  }
59 
61  this->CreateCrossingCandidates(clusterVectorU, clusterVectorV, clusterVectorW);
62 
63  if (!pVertexList->empty())
64  {
65  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Vertex>(*this, m_outputVertexListName));
66 
68  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Vertex>(*this, m_outputVertexListName));
69  }
70  }
71  catch (StatusCodeException &statusCodeException)
72  {
73  this->TidyUp();
74  throw statusCodeException;
75  }
76 
77  this->TidyUp();
78 
79  return STATUS_CODE_SUCCESS;
80 }
void CreateCrossingCandidates(const pandora::ClusterVector &clusterVectorU, const pandora::ClusterVector &clusterVectorV, const pandora::ClusterVector &clusterVectorW) const
Extrapolate 2D clusters, find where they cross, and match crossing points between views to create ver...
bool m_enableEndpointCandidates
Whether to create endpoint-based candidates.
bool m_replaceCurrentVertexList
Whether to replace the current vertex list with the output list.
bool m_enableCrossingCandidates
Whether to create crossing vertex candidates.
void CreateEndpointCandidates(const pandora::ClusterVector &clusterVector1, const pandora::ClusterVector &clusterVector2) const
Create candidate vertex positions by comparing pairs of cluster end positions.
void TidyUp()
Clear relevant algorithm member variables between events.
std::string m_outputVertexListName
The name under which to save the output vertex list.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void SelectClusters(pandora::ClusterVector &clusterVectorU, pandora::ClusterVector &clusterVectorV, pandora::ClusterVector &clusterVectorW)
Select a subset of input clusters (contained in the input list names) for processing in this algorith...
std::list< Vertex > VertexList
Definition: DCEL.h:178
void lar_content::CandidateVertexCreationAlgorithm::SelectClusters ( pandora::ClusterVector &  clusterVectorU,
pandora::ClusterVector &  clusterVectorV,
pandora::ClusterVector &  clusterVectorW 
)
private

Select a subset of input clusters (contained in the input list names) for processing in this algorithm.

Parameters
clusterVectorUto receive the selected clusters in the u view
clusterVectorVto receive the selected clusters in the v view
clusterVectorWto receive the selected clusters in the w view

Definition at line 84 of file CandidateVertexCreationAlgorithm.cc.

References AddToSlidingFitCache(), lar_content::LArClusterHelper::GetClusterHitType(), lar_content::LArClusterHelper::GetLengthSquared(), m_inputClusterListNames, m_minClusterCaloHits, m_minClusterLengthSquared, and lar_content::LArClusterHelper::SortByNHits().

Referenced by Run().

85 {
86  for (const std::string &clusterListName : m_inputClusterListNames)
87  {
88  const ClusterList *pClusterList(NULL);
89  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, clusterListName, pClusterList));
90 
91  if (!pClusterList || pClusterList->empty())
92  {
93  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
94  std::cout << "CandidateVertexCreationAlgorithm: unable to find cluster list " << clusterListName << std::endl;
95 
96  continue;
97  }
98 
99  const HitType hitType(LArClusterHelper::GetClusterHitType(*(pClusterList->begin())));
100 
101  if ((TPC_VIEW_U != hitType) && (TPC_VIEW_V != hitType) && (TPC_VIEW_W != hitType))
102  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
103 
104  ClusterVector &selectedClusterVector((TPC_VIEW_U == hitType) ? clusterVectorU : (TPC_VIEW_V == hitType) ? clusterVectorV : clusterVectorW);
105 
106  if (!selectedClusterVector.empty())
107  throw StatusCodeException(STATUS_CODE_FAILURE);
108 
109  ClusterVector sortedClusters(pClusterList->begin(), pClusterList->end());
110  std::sort(sortedClusters.begin(), sortedClusters.end(), LArClusterHelper::SortByNHits);
111 
112  for (const Cluster *const pCluster : sortedClusters)
113  {
114  if (pCluster->GetNCaloHits() < m_minClusterCaloHits)
115  continue;
116 
118  continue;
119 
120  try
121  {
122  this->AddToSlidingFitCache(pCluster);
123  selectedClusterVector.push_back(pCluster);
124  }
125  catch (StatusCodeException &statusCodeException)
126  {
127  if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
128  throw statusCodeException;
129  }
130  }
131  }
132 }
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.
float m_minClusterLengthSquared
The min length (squared) in base cluster selection method.
void AddToSlidingFitCache(const pandora::Cluster *const pCluster)
Creates a 2D sliding fit of a cluster and stores it for later use.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
unsigned int m_minClusterCaloHits
The min number of hits in base cluster selection method.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
pandora::StringVector m_inputClusterListNames
The list of cluster list names.
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
void lar_content::CandidateVertexCreationAlgorithm::TidyUp ( )
private

Clear relevant algorithm member variables between events.

Definition at line 371 of file CandidateVertexCreationAlgorithm.cc.

References m_slidingFitResultMap.

Referenced by Run().

372 {
373  m_slidingFitResultMap.clear();
374 }
TwoDSlidingFitResultMap m_slidingFitResultMap
The sliding fit result map.

Member Data Documentation

float lar_content::CandidateVertexCreationAlgorithm::m_chiSquaredCut
private

The chi squared cut (accept only 3D vertex positions with values below cut)

Definition at line 139 of file CandidateVertexCreationAlgorithm.h.

Referenced by CreateCrossingVertices(), CreateEndpointVertex(), and ReadSettings().

bool lar_content::CandidateVertexCreationAlgorithm::m_enableCrossingCandidates
private

Whether to create crossing vertex candidates.

Definition at line 144 of file CandidateVertexCreationAlgorithm.h.

Referenced by ReadSettings(), and Run().

bool lar_content::CandidateVertexCreationAlgorithm::m_enableEndpointCandidates
private

Whether to create endpoint-based candidates.

Definition at line 141 of file CandidateVertexCreationAlgorithm.h.

Referenced by ReadSettings(), and Run().

unsigned int lar_content::CandidateVertexCreationAlgorithm::m_extrapolationNSteps
private

Number of extrapolation steps, at each end of cluster, of specified size.

Definition at line 147 of file CandidateVertexCreationAlgorithm.h.

Referenced by GetSpacepoints(), and ReadSettings().

float lar_content::CandidateVertexCreationAlgorithm::m_extrapolationStepSize
private

The extrapolation step size in cm.

Definition at line 148 of file CandidateVertexCreationAlgorithm.h.

Referenced by GetSpacepoints(), and ReadSettings().

pandora::StringVector lar_content::CandidateVertexCreationAlgorithm::m_inputClusterListNames
private

The list of cluster list names.

Definition at line 130 of file CandidateVertexCreationAlgorithm.h.

Referenced by ReadSettings(), and SelectClusters().

float lar_content::CandidateVertexCreationAlgorithm::m_maxCrossingSeparationSquared
private

The separation (squared) between spacepoints below which a crossing can be identified.

Definition at line 149 of file CandidateVertexCreationAlgorithm.h.

Referenced by GetSpacepoints(), and ReadSettings().

float lar_content::CandidateVertexCreationAlgorithm::m_maxCrossingXDiscrepancy
private

The max cluster endpoint discrepancy.

Definition at line 146 of file CandidateVertexCreationAlgorithm.h.

Referenced by CreateCrossingVertices(), and ReadSettings().

float lar_content::CandidateVertexCreationAlgorithm::m_maxEndpointXDiscrepancy
private

The max cluster endpoint discrepancy.

Definition at line 142 of file CandidateVertexCreationAlgorithm.h.

Referenced by CreateEndpointVertex(), and ReadSettings().

unsigned int lar_content::CandidateVertexCreationAlgorithm::m_minClusterCaloHits
private

The min number of hits in base cluster selection method.

Definition at line 137 of file CandidateVertexCreationAlgorithm.h.

Referenced by ReadSettings(), and SelectClusters().

float lar_content::CandidateVertexCreationAlgorithm::m_minClusterLengthSquared
private

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

Definition at line 138 of file CandidateVertexCreationAlgorithm.h.

Referenced by ReadSettings(), and SelectClusters().

float lar_content::CandidateVertexCreationAlgorithm::m_minNearbyCrossingDistanceSquared
private

The minimum allowed distance between identified crossing positions.

Definition at line 150 of file CandidateVertexCreationAlgorithm.h.

Referenced by GetSpacepoints(), and ReadSettings().

unsigned int lar_content::CandidateVertexCreationAlgorithm::m_nMaxCrossingCandidates
private

The max number of crossing candidates to create.

Definition at line 145 of file CandidateVertexCreationAlgorithm.h.

Referenced by CreateCrossingVertices(), and ReadSettings().

std::string lar_content::CandidateVertexCreationAlgorithm::m_outputVertexListName
private

The name under which to save the output vertex list.

Definition at line 131 of file CandidateVertexCreationAlgorithm.h.

Referenced by ReadSettings(), and Run().

bool lar_content::CandidateVertexCreationAlgorithm::m_replaceCurrentVertexList
private

Whether to replace the current vertex list with the output list.

Definition at line 132 of file CandidateVertexCreationAlgorithm.h.

Referenced by ReadSettings(), and Run().

TwoDSlidingFitResultMap lar_content::CandidateVertexCreationAlgorithm::m_slidingFitResultMap
private

The sliding fit result map.

Definition at line 135 of file CandidateVertexCreationAlgorithm.h.

Referenced by AddToSlidingFitCache(), GetCachedSlidingFitResult(), and TidyUp().

unsigned int lar_content::CandidateVertexCreationAlgorithm::m_slidingFitWindow
private

The layer window for the sliding linear fits.

Definition at line 134 of file CandidateVertexCreationAlgorithm.h.

Referenced by AddToSlidingFitCache(), and ReadSettings().


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