LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
VertexSplittingAlgorithm.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
13 
15 
16 using namespace pandora;
17 
18 namespace lar_content
19 {
20 
21 VertexSplittingAlgorithm::VertexSplittingAlgorithm() :
22  m_splitDisplacementSquared(4.f * 4.f),
23  m_vertexDisplacementSquared(1.f * 1.f)
24 {
25  // ATTN Some default values differ from base class
26  m_minClusterLength = 1.f;
27 }
28 
29 //------------------------------------------------------------------------------------------------------------------------------------------
30 
31 StatusCode VertexSplittingAlgorithm::FindBestSplitPosition(const TwoDSlidingFitResult &slidingFitResult, CartesianVector &splitPosition) const
32 {
33  // Identify event vertex
34  const VertexList *pVertexList(NULL);
35  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pVertexList));
36 
37  if (pVertexList->empty())
38  return STATUS_CODE_NOT_INITIALIZED;
39 
40  if (pVertexList->size() != 1)
41  return STATUS_CODE_OUT_OF_RANGE;
42 
43  const Cluster *const pCluster(slidingFitResult.GetCluster());
44  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
45 
46  const Vertex *const pSelectedVertex(*(pVertexList->begin()));
47 
48  if (VERTEX_3D != pSelectedVertex->GetVertexType())
49  return STATUS_CODE_INVALID_PARAMETER;
50 
51  const CartesianVector theVertex2D(LArGeometryHelper::ProjectPosition(this->GetPandora(), pSelectedVertex->GetPosition(), hitType));
52 
53  const CartesianVector innerVertex2D(slidingFitResult.GetGlobalMinLayerPosition());
54  const CartesianVector outerVertex2D(slidingFitResult.GetGlobalMaxLayerPosition());
55 
56  if ((outerVertex2D - innerVertex2D).GetMagnitudeSquared() < 4.f * m_vertexDisplacementSquared)
57  return STATUS_CODE_NOT_FOUND;
58 
59  bool foundSplit(false);
60  const StatusCode statusCode(slidingFitResult.GetGlobalFitProjection(theVertex2D, splitPosition));
61 
62  if (STATUS_CODE_SUCCESS != statusCode)
63  return statusCode;
64 
65  const float splitDisplacementSquared((splitPosition - theVertex2D).GetMagnitudeSquared());
66  const float vertexDisplacementSquared(
67  std::min((splitPosition - innerVertex2D).GetMagnitudeSquared(), (splitPosition - outerVertex2D).GetMagnitudeSquared()));
68 
69  if ((splitDisplacementSquared < m_splitDisplacementSquared) && (vertexDisplacementSquared > m_vertexDisplacementSquared) &&
70  (splitDisplacementSquared < vertexDisplacementSquared))
71  {
72  foundSplit = true;
73  }
74 
75  if (!foundSplit)
76  return STATUS_CODE_NOT_FOUND;
77 
78  return STATUS_CODE_SUCCESS;
79 }
80 
81 //------------------------------------------------------------------------------------------------------------------------------------------
82 
83 StatusCode VertexSplittingAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
84 {
85  float splitDisplacement = std::sqrt(m_splitDisplacementSquared);
86  PANDORA_RETURN_RESULT_IF_AND_IF(
87  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SplitDisplacement", splitDisplacement));
88  m_splitDisplacementSquared = splitDisplacement * splitDisplacement;
89 
90  float vertexDisplacement = std::sqrt(m_vertexDisplacementSquared);
91  PANDORA_RETURN_RESULT_IF_AND_IF(
92  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "VertexDisplacement", vertexDisplacement));
93  m_vertexDisplacementSquared = vertexDisplacement * vertexDisplacement;
94 
96 }
97 
98 } // namespace lar_content
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
pandora::StatusCode FindBestSplitPosition(const TwoDSlidingFitResult &slidingFitResult, pandora::CartesianVector &splitPosition) const
Use sliding linear fit to identify the best split position.
Header file for the vertex splitting algorithm class.
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
Header file for the geometry helper class.
Header file for the cluster helper class.
pandora::CartesianVector GetGlobalMinLayerPosition() const
Get global position corresponding to the fit result in minimum fit layer.
float m_vertexDisplacementSquared
Maximum displacement squared.
const pandora::Cluster * GetCluster() const
Get the address of the cluster, if originally provided.
HitType
Definition: HitType.h:12
float m_splitDisplacementSquared
Maximum displacement squared.
pandora::StatusCode GetGlobalFitProjection(const pandora::CartesianVector &inputPosition, pandora::CartesianVector &projectedPosition) const
Get projected position on global fit for a given position vector.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
std::list< Vertex > VertexList
Definition: DCEL.h:169
pandora::CartesianVector GetGlobalMaxLayerPosition() const
Get global position corresponding to the fit result in maximum fit layer.