LArPointingCluster.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArObjects/LArPointingCluster.cc
3  *
4  * @brief Implementation of the lar pointing cluster class.
5  *
6  * $Log: $
7  */
8 
11 
12 using namespace pandora;
13 
14 namespace lar_content
15 {
16 
17 LArPointingCluster::LArPointingCluster(const Cluster *const pCluster, const unsigned int fitHalfLayerWindow, const float fitLayerPitch)
18 {
19  // TODO remove default layer fit window and z pitch values
20  if (TPC_3D == LArClusterHelper::GetClusterHitType(pCluster))
21  {
22  const ThreeDSlidingFitResult slidingFitResult(pCluster, fitHalfLayerWindow, fitLayerPitch);
23  this->BuildPointingCluster(slidingFitResult);
24  }
25  else
26  {
27  const TwoDSlidingFitResult slidingFitResult(pCluster, fitHalfLayerWindow, fitLayerPitch);
28  this->BuildPointingCluster(slidingFitResult);
29  }
30 }
31 
32 //------------------------------------------------------------------------------------------------------------------------------------------
33 
34 LArPointingCluster::LArPointingCluster(const TwoDSlidingFitResult &slidingFitResult)
35 {
36  this->BuildPointingCluster(slidingFitResult);
37 }
38 
39 //------------------------------------------------------------------------------------------------------------------------------------------
40 
41 LArPointingCluster::LArPointingCluster(const ThreeDSlidingFitResult &slidingFitResult)
42 {
43  this->BuildPointingCluster(slidingFitResult);
44 }
45 
46 //------------------------------------------------------------------------------------------------------------------------------------------
47 
48 void LArPointingCluster::BuildPointingCluster(const TwoDSlidingFitResult &slidingFitResult)
49 {
50  const HitType hitType(LArClusterHelper::GetClusterHitType(slidingFitResult.GetCluster()));
51 
52  if (!((TPC_VIEW_U == hitType) || (TPC_VIEW_V == hitType) || (TPC_VIEW_W == hitType)))
53  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
54 
55  if (slidingFitResult.GetMinLayer() >= slidingFitResult.GetMaxLayer())
56  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
57 
58  const bool isInner((slidingFitResult.GetGlobalMinLayerPosition().GetZ() < slidingFitResult.GetGlobalMaxLayerPosition().GetZ()));
59 
60  m_pCluster = slidingFitResult.GetCluster();
61 
62  const Vertex minVertex(m_pCluster, slidingFitResult.GetGlobalMinLayerPosition(), slidingFitResult.GetGlobalMinLayerDirection(),
63  slidingFitResult.GetMinLayerRms(), isInner);
64  const Vertex maxVertex(m_pCluster, slidingFitResult.GetGlobalMaxLayerPosition(), slidingFitResult.GetGlobalMaxLayerDirection() * -1.f,
65  slidingFitResult.GetMaxLayerRms(), !isInner);
66 
67  m_innerVertex = (isInner ? minVertex : maxVertex);
68  m_outerVertex = (isInner ? maxVertex : minVertex);
69 }
70 
71 //------------------------------------------------------------------------------------------------------------------------------------------
72 
73 void LArPointingCluster::BuildPointingCluster(const ThreeDSlidingFitResult &slidingFitResult)
74 {
75  if (TPC_3D != LArClusterHelper::GetClusterHitType(slidingFitResult.GetCluster()))
76  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
77 
78  if (slidingFitResult.GetMinLayer() >= slidingFitResult.GetMaxLayer())
79  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
80 
81  const bool isInner((slidingFitResult.GetGlobalMinLayerPosition().GetZ() < slidingFitResult.GetGlobalMaxLayerPosition().GetZ()) &&
82  (slidingFitResult.GetMinLayer() < slidingFitResult.GetMaxLayer()));
83 
84  m_pCluster = slidingFitResult.GetCluster();
85 
86  const Vertex minVertex(m_pCluster, slidingFitResult.GetGlobalMinLayerPosition(), slidingFitResult.GetGlobalMinLayerDirection(),
87  slidingFitResult.GetMinLayerRms(), isInner);
88  const Vertex maxVertex(m_pCluster, slidingFitResult.GetGlobalMaxLayerPosition(), slidingFitResult.GetGlobalMaxLayerDirection() * -1.f,
89  slidingFitResult.GetMaxLayerRms(), !isInner);
90 
91  m_innerVertex = (isInner ? minVertex : maxVertex);
92  m_outerVertex = (isInner ? maxVertex : minVertex);
93 }
94 
95 //------------------------------------------------------------------------------------------------------------------------------------------
96 
98  m_pCluster(NULL),
99  m_position(0.f, 0.f, 0.f),
100  m_direction(0.f, 0.f, 0.f),
101  m_rms(std::numeric_limits<float>::max()),
102  m_isInner(false),
103  m_isInitialized(false)
104 {
105 }
106 
107 //------------------------------------------------------------------------------------------------------------------------------------------
108 
110  const Cluster *const pCluster, const CartesianVector &position, const CartesianVector &direction, const float rms, const bool isInner) :
111  m_pCluster(pCluster),
112  m_position(position),
113  m_direction(direction),
114  m_rms(rms),
115  m_isInner(isInner),
116  m_isInitialized(true)
117 {
118 }
119 
120 //------------------------------------------------------------------------------------------------------------------------------------------
121 
123  m_pCluster(rhs.m_pCluster),
124  m_position(rhs.m_position),
126  m_rms(rhs.m_rms),
127  m_isInner(rhs.m_isInner),
129 {
130 }
131 
132 //------------------------------------------------------------------------------------------------------------------------------------------
133 
135 {
136 }
137 
138 //------------------------------------------------------------------------------------------------------------------------------------------
139 
141 {
142  m_pCluster = rhs.m_pCluster;
143  m_position = rhs.m_position;
144  m_direction = rhs.m_direction;
145  m_rms = rhs.m_rms;
146  m_isInner = rhs.m_isInner;
148 
149  return *this;
150 }
151 
152 } // namespace lar_content
Header file for the lar pointing cluster class.
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:40
enum cvn::HType HitType
const pandora::CartesianVector & GetGlobalMinLayerDirection() const
Get global direction corresponding to the fit result in minimum fit layer.
float GetMaxLayerRms() const
Get rms at maximum layer.
int GetMaxLayer() const
Get the maximum occupied layer in the sliding fit.
float GetMaxLayerRms() const
Get rms at maximum layer.
STL namespace.
float GetMinLayerRms() const
Get rms at minimum layer.
Vertex & operator=(const Vertex &rhs)
Vertex assigment operator.
pandora::CartesianVector GetGlobalMinLayerDirection() const
Get global direction corresponding to the fit result in minimum fit layer.
const pandora::Cluster * m_pCluster
The address of the cluster.
int GetMaxLayer() const
Get the maximum occupied layer in the sliding fit.
int GetMinLayer() const
Get the minimum occupied layer in the sliding fit.
Header file for the cluster helper class.
const pandora::CartesianVector & GetGlobalMaxLayerDirection() const
Get global direction corresponding to the fit result in maximum fit layer.
bool m_isInner
Whether this is the inner vertex.
pandora::CartesianVector GetGlobalMinLayerPosition() const
Get global position corresponding to the fit result in minimum fit layer.
static int max(int a, int b)
int GetMinLayer() const
Get the minimum occupied layer in the sliding fit.
const pandora::CartesianVector & GetGlobalMaxLayerPosition() const
Get global position corresponding to the fit result in maximum fit layer.
float GetMinLayerRms() const
Get rms at minimum layer.
const pandora::Cluster * GetCluster() const
Get the address of the cluster, if originally provided.
pandora::CartesianVector GetGlobalMaxLayerDirection() const
Get global direction corresponding to the fit result in maximum fit layer.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
const pandora::Cluster * GetCluster() const
Get the address of the cluster.
bool m_isInitialized
Whether the vertex has been initialized.
pandora::CartesianVector m_direction
The vertex direction.
pandora::CartesianVector GetGlobalMaxLayerPosition() const
Get global position corresponding to the fit result in maximum fit layer.
pandora::CartesianVector m_position
The vertex position.
const pandora::CartesianVector & GetGlobalMinLayerPosition() const
Get global position corresponding to the fit result in minimum fit layer.