All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LArPointingCluster.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArObjects/LArPointingCluster.h
3  *
4  * @brief Header file for the lar pointing cluster class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_POINTING_CLUSTER_H
9 #define LAR_POINTING_CLUSTER_H 1
10 
13 
14 namespace lar_content
15 {
16 
17 /**
18  * @brief LArPointingCluster class
19  */
21 {
22 public:
23  /**
24  * @brief Vertex class
25  */
26  class Vertex
27  {
28  public:
29  /**
30  * @brief Default constructor
31  */
32  Vertex();
33 
34  /**
35  * @brief Constructor
36  *
37  * @param pCluster address of the cluster
38  * @param position the vertex position
39  * @param direction the vertex direction
40  * @param rms the rms from vertex fit
41  * @param isInner whether this is a cluster inner or outer vertex
42  */
43  Vertex(const pandora::Cluster *const pCluster, const pandora::CartesianVector &position, const pandora::CartesianVector &direction,
44  const float rms, const bool isInner);
45 
46  /**
47  * @brief Copy constructor
48  *
49  * @param rhs the vertex instance to copy
50  */
51  Vertex(const Vertex &rhs);
52 
53  /**
54  * @brief Destructor
55  *
56  */
57  ~Vertex();
58 
59  /**
60  * @brief Get the address of the cluster
61  *
62  * @return the address of the cluster
63  */
64  const pandora::Cluster *GetCluster() const;
65 
66  /**
67  * @brief Get the vertex position
68  *
69  * @return the vertex position
70  */
71  const pandora::CartesianVector &GetPosition() const;
72 
73  /**
74  * @brief Get the vertex direction
75  *
76  * @return the vertex direction
77  */
78  const pandora::CartesianVector &GetDirection() const;
79 
80  /**
81  * @brief Get rms from vertex fit
82  *
83  * @return the rms
84  */
85  float GetRms() const;
86 
87  /**
88  * @brief Is this the inner vertex
89  *
90  * @return boolean
91  */
92  bool IsInnerVertex() const;
93 
94  /**
95  * @brief Whether the vertex has been initialized
96  *
97  * @return boolean
98  */
99  bool IsInitialized() const;
100 
101  /**
102  * @brief Vertex assigment operator
103  *
104  * @param rhs the vertex to assign
105  */
106  Vertex &operator=(const Vertex &rhs);
107 
108  private:
109  const pandora::Cluster *m_pCluster; ///< The address of the cluster
110  pandora::CartesianVector m_position; ///< The vertex position
111  pandora::CartesianVector m_direction; ///< The vertex direction
112  float m_rms; ///< Rms from vertex fit
113  bool m_isInner; ///< Whether this is the inner vertex
114  bool m_isInitialized; ///< Whether the vertex has been initialized
115  };
116 
117  /**
118  * @brief Constructor
119  *
120  * @param pCluster address of the cluster
121  * @param fitHalfLayerWindow the fit layer half window
122  * @param fitLayerPitch the fit layer pitch, units cm
123  */
124  LArPointingCluster(const pandora::Cluster *const pCluster, const unsigned int fitHalfLayerWindow = 10, const float fitLayerPitch = 0.3f);
125 
126  /**
127  * @brief Constructor
128  *
129  * @param slidingFitResult the input sliding fit result
130  */
131  LArPointingCluster(const TwoDSlidingFitResult &slidingFitResult);
132 
133  /**
134  * @brief Constructor
135  *
136  * @param slidingFitResult the input sliding fit result
137  */
138  LArPointingCluster(const ThreeDSlidingFitResult &slidingFitResult);
139 
140  /**
141  * @brief Get the address of the cluster
142  *
143  * @return the address of the cluster
144  */
145  const pandora::Cluster *GetCluster() const;
146 
147  /**
148  * @brief Get the inner vertex
149  *
150  * @return the inner vertex
151  */
152  const Vertex &GetInnerVertex() const;
153 
154  /**
155  * @brief Get the outer vertex
156  *
157  * @return the outer vertex
158  */
159  const Vertex &GetOuterVertex() const;
160 
161  /**
162  * @brief Get length squared of pointing cluster
163  *
164  * @return the length squared
165  */
166  float GetLengthSquared() const;
167 
168  /**
169  * @brief Get length of pointing cluster
170  *
171  * @return the length
172  */
173  float GetLength() const;
174 
175 private:
176  /**
177  * @brief Build the pointing cluster object from the sliding fit result
178  *
179  * @param slidingFitResult the input sliding fit result
180  */
181  void BuildPointingCluster(const TwoDSlidingFitResult &slidingFitResult);
182 
183  /**
184  * @brief Build the pointing cluster object from the sliding fit result
185  *
186  * @param slidingFitResult the input sliding fit result
187  */
188  void BuildPointingCluster(const ThreeDSlidingFitResult &slidingFitResult);
189 
190  const pandora::Cluster *m_pCluster; ///< The address of the cluster
191  Vertex m_innerVertex; ///< The inner vertex
192  Vertex m_outerVertex; ///< The outer vertex
193 };
194 
195 typedef std::vector<LArPointingCluster> LArPointingClusterList;
196 typedef std::vector<LArPointingCluster::Vertex> LArPointingClusterVertexList;
197 typedef std::unordered_map<const pandora::Cluster *, LArPointingCluster> LArPointingClusterMap;
198 
199 //------------------------------------------------------------------------------------------------------------------------------------------
200 
201 inline const pandora::Cluster *LArPointingCluster::GetCluster() const
202 {
203  return m_pCluster;
204 }
205 
206 //------------------------------------------------------------------------------------------------------------------------------------------
207 
209 {
210  return m_innerVertex;
211 }
212 
213 //------------------------------------------------------------------------------------------------------------------------------------------
214 
216 {
217  return m_outerVertex;
218 }
219 
220 //------------------------------------------------------------------------------------------------------------------------------------------
221 
223 {
224  return (m_outerVertex.GetPosition() - m_innerVertex.GetPosition()).GetMagnitudeSquared();
225 }
226 
227 //------------------------------------------------------------------------------------------------------------------------------------------
228 
229 inline float LArPointingCluster::GetLength() const
230 {
231  return std::sqrt(this->GetLengthSquared());
232 }
233 
234 //------------------------------------------------------------------------------------------------------------------------------------------
235 //------------------------------------------------------------------------------------------------------------------------------------------
236 
237 inline const pandora::Cluster *LArPointingCluster::Vertex::GetCluster() const
238 {
239  if (!m_isInitialized)
240  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
241 
242  return m_pCluster;
243 }
244 
245 //------------------------------------------------------------------------------------------------------------------------------------------
246 
247 inline const pandora::CartesianVector &LArPointingCluster::Vertex::GetPosition() const
248 {
249  if (!m_isInitialized)
250  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
251 
252  return m_position;
253 }
254 
255 //------------------------------------------------------------------------------------------------------------------------------------------
256 
257 inline const pandora::CartesianVector &LArPointingCluster::Vertex::GetDirection() const
258 {
259  if (!m_isInitialized)
260  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
261 
262  return m_direction;
263 }
264 
265 //------------------------------------------------------------------------------------------------------------------------------------------
266 
268 {
269  if (!m_isInitialized)
270  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
271 
272  return m_rms;
273 }
274 
275 //------------------------------------------------------------------------------------------------------------------------------------------
276 
278 {
279  if (!m_isInitialized)
280  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
281 
282  return m_isInner;
283 }
284 
285 //------------------------------------------------------------------------------------------------------------------------------------------
286 
288 {
289  return m_isInitialized;
290 }
291 
292 } // namespace lar_content
293 
294 #endif // #ifndef LAR_POINTING_CLUSTER_H
std::unordered_map< const pandora::Cluster *, LArPointingCluster > LArPointingClusterMap
std::vector< LArPointingCluster > LArPointingClusterList
float GetLength() const
Get length of pointing cluster.
const pandora::Cluster * m_pCluster
The address of the cluster.
LArPointingCluster class.
Vertex & operator=(const Vertex &rhs)
Vertex assigment operator.
void BuildPointingCluster(const TwoDSlidingFitResult &slidingFitResult)
Build the pointing cluster object from the sliding fit result.
const pandora::Cluster * GetCluster() const
Get the address of the cluster.
std::vector< LArPointingCluster::Vertex > LArPointingClusterVertexList
const pandora::Cluster * m_pCluster
The address of the cluster.
const pandora::Cluster * GetCluster() const
Get the address of the cluster.
LArPointingCluster(const pandora::Cluster *const pCluster, const unsigned int fitHalfLayerWindow=10, const float fitLayerPitch=0.3f)
Constructor.
Vertex m_innerVertex
The inner vertex.
bool IsInitialized() const
Whether the vertex has been initialized.
const Vertex & GetOuterVertex() const
Get the outer vertex.
Vertex m_outerVertex
The outer vertex.
Header file for the lar two dimensional sliding fit result class.
const Vertex & GetInnerVertex() const
Get the inner vertex.
bool m_isInner
Whether this is the inner vertex.
float GetLengthSquared() const
Get length squared of pointing cluster.
Header file for the lar three dimensional sliding fit result class.
const pandora::CartesianVector & GetDirection() const
Get the vertex direction.
float GetRms() const
Get rms from vertex fit.
bool IsInnerVertex() const
Is this the inner vertex.
bool m_isInitialized
Whether the vertex has been initialized.
pandora::CartesianVector m_direction
The vertex direction.
const pandora::CartesianVector & GetPosition() const
Get the vertex position.
pandora::CartesianVector m_position
The vertex position.