LArVertexHelper.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArHelpers/LArVertexHelper.cc
3  *
4  * @brief Implementation of the vertex helper class.
5  *
6  * $Log: $
7  */
8 
13 
14 #include <limits>
15 
16 using namespace pandora;
17 
18 namespace lar_content
19 {
20 
21 LArVertexHelper::ClusterDirection LArVertexHelper::GetClusterDirectionInZ(
22  const Pandora &pandora, const Vertex *const pVertex, const Cluster *const pCluster, const float tanAngle, const float apexShift)
23 {
24  if ((VERTEX_3D != pVertex->GetVertexType()) || (tanAngle < std::numeric_limits<float>::epsilon()))
25  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
26 
27  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
28  const CartesianVector theVertex2D(LArGeometryHelper::ProjectPosition(pandora, pVertex->GetPosition(), hitType));
29 
30  try
31  {
32  const LArPointingCluster pointingCluster(pCluster);
33  const float length((pointingCluster.GetInnerVertex().GetPosition() - pointingCluster.GetOuterVertex().GetPosition()).GetMagnitude());
34  const bool innerIsAtLowerZ(pointingCluster.GetInnerVertex().GetPosition().GetZ() < pointingCluster.GetOuterVertex().GetPosition().GetZ());
35 
38  LArPointingClusterHelper::GetImpactParameters(pointingCluster.GetInnerVertex(), theVertex2D, rLInner, rTInner);
39  LArPointingClusterHelper::GetImpactParameters(pointingCluster.GetOuterVertex(), theVertex2D, rLOuter, rTOuter);
40 
41  const bool innerIsVertexAssociated(rLInner > (rTInner / tanAngle) - (length * apexShift));
42  const bool outerIsVertexAssociated(rLOuter > (rTInner / tanAngle) - (length * apexShift));
43 
44  if (innerIsVertexAssociated == outerIsVertexAssociated)
45  return DIRECTION_UNKNOWN;
46 
47  if ((innerIsVertexAssociated && innerIsAtLowerZ) || (outerIsVertexAssociated && !innerIsAtLowerZ))
48  return DIRECTION_FORWARD_IN_Z;
49 
50  if ((innerIsVertexAssociated && !innerIsAtLowerZ) || (outerIsVertexAssociated && innerIsAtLowerZ))
51  return DIRECTION_BACKWARD_IN_Z;
52  }
53  catch (StatusCodeException &)
54  {
55  return DIRECTION_UNKNOWN;
56  }
57 
58  throw StatusCodeException(STATUS_CODE_FAILURE);
59 }
60 
61 } // namespace lar_content
enum cvn::HType HitType
LArPointingCluster class.
Header file for the geometry helper class.
Header file for the cluster helper class.
const Vertex & GetOuterVertex() const
Get the outer vertex.
const Vertex & GetInnerVertex() const
Get the inner vertex.
static int max(int a, int b)
Header file for the vertex helper class.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
const pandora::CartesianVector & GetPosition() const
Get the vertex position.