LArThreeDSlidingFitResult.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArObjects/LArThreeDSlidingFitResult.h
3  *
4  * @brief Header file for the lar three dimensional sliding fit result class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_THREE_D_SLIDING_FIT_RESULT_H
9 #define LAR_THREE_D_SLIDING_FIT_RESULT_H 1
10 
11 #include "Api/PandoraApi.h"
12 
14 
15 #include <unordered_map>
16 
17 namespace lar_content
18 {
19 
20 /**
21  * @brief ThreeDSlidingFitResult class
22  */
24 {
25 public:
26  /**
27  * @brief Constructor
28  *
29  * @param pT describing the positions to be fitted
30  * @param slidingFitWindow the sliding fit window
31  * @param slidingFitLayerPitch the sliding fit z pitch, units cm
32  */
33  template <typename T>
34  ThreeDSlidingFitResult(const T *const pT, const unsigned int slidingFitWindow, const float slidingFitLayerPitch);
35 
36  /**
37  * @brief Get the address of the cluster
38  *
39  * @return the address of the cluster
40  */
41  const pandora::Cluster *GetCluster() const;
42 
43  /**
44  * @brief Get the axis intercept position
45  *
46  * @return the axis intercept position
47  */
48  const pandora::CartesianVector &GetAxisIntercept() const;
49 
50  /**
51  * @brief Get the axis direction vector
52  *
53  * @return the axis direction vector
54  */
55  const pandora::CartesianVector &GetAxisDirection() const;
56 
57  /**
58  * @brief Get the first sliding fit result for this cluster
59  *
60  * @return the first sliding fit result for this cluster
61  */
63 
64  /**
65  * @brief Get the second sliding fit result for this cluster
66  *
67  * @return the second sliding fit result for this cluster
68  */
70 
71  /**
72  * @brief Get global position corresponding to the fit result in minimum fit layer
73  *
74  * @return the position
75  */
76  const pandora::CartesianVector &GetGlobalMinLayerPosition() const;
77 
78  /**
79  * @brief Get global position corresponding to the fit result in maximum fit layer
80  *
81  * @return the position
82  */
83  const pandora::CartesianVector &GetGlobalMaxLayerPosition() const;
84 
85  /**
86  * @brief Get global direction corresponding to the fit result in minimum fit layer
87  *
88  * @return the position
89  */
90  const pandora::CartesianVector &GetGlobalMinLayerDirection() const;
91 
92  /**
93  * @brief Get global direction corresponding to the fit result in maximum fit layer
94  *
95  * @return the position
96  */
97  const pandora::CartesianVector &GetGlobalMaxLayerDirection() const;
98 
99  /**
100  * @brief Get the minimum occupied layer in the sliding fit
101  *
102  * @param the minimum occupied layer in the sliding fit
103  */
104  int GetMinLayer() const;
105 
106  /**
107  * @brief Get the maximum occupied layer in the sliding fit
108  *
109  * @param the maximum occupied layer in the sliding fit
110  */
111  int GetMaxLayer() const;
112 
113  /**
114  * @brief Get rms at minimum layer
115  *
116  * @return the rms
117  */
118  float GetMinLayerRms() const;
119 
120  /**
121  * @brief Get rms at maximum layer
122  *
123  * @return the rms
124  */
125  float GetMaxLayerRms() const;
126 
127  /**
128  * @brief Get fit rms for a given longitudinal coordinate
129  *
130  * @param rL the longitudinal coordinate
131  *
132  * @return the fit rms
133  */
134  float GetFitRms(const float rL) const;
135 
136  /**
137  * @brief Get longitudinal projection onto primary axis
138  *
139  * @param position the input coordinates
140  *
141  * @return the longitudinal distance along the axis direction from the axis intercept
142  */
143  float GetLongitudinalDisplacement(const pandora::CartesianVector &position) const;
144 
145  /**
146  * @brief Get global fit position for a given longitudinal coordinate
147  *
148  * @param rL the longitudinal coordinate
149  * @param position the fitted position at these coordinates
150  *
151  * @return status code, faster than throwing in regular use-cases
152  */
153  pandora::StatusCode GetGlobalFitPosition(const float rL, pandora::CartesianVector &position) const;
154 
155  /**
156  * @brief Get global fit direction for a given longitudinal coordinate
157  *
158  * @param rL the longitudinal coordinate
159  * @param direction the fitted direction at these coordinates
160  *
161  * @return status code, faster than throwing in regular use-cases
162  */
163  pandora::StatusCode GetGlobalFitDirection(const float rL, pandora::CartesianVector &direction) const;
164 
165 private:
166  /**
167  * @brief Get global coordinates for a given pair of sliding linear fit coordinates
168  *
169  * @param rL the longitudinal coordinate
170  * @param rT1 the first transverse coordinate
171  * @param rT2 the second transverse coordinate
172  * @param position to receive the position cartesian vector
173  */
174  void GetGlobalPosition(const float rL, const float rT1, const float rT2, pandora::CartesianVector &position) const;
175 
176  /**
177  * @brief Get global direction coordinates for a given pair of sliding linear fit gradients
178  *
179  * @param dTdL1 the first transverse coordinate
180  * @param dTdL2 the second transverse coordinate
181  * @param direction to receive the direction cartesian vector
182  */
183  void GetGlobalDirection(const float dTdL1, const float dTdL2, pandora::CartesianVector &direction) const;
184 
185  /**
186  * @brief Calculate the position and direction of the primary axis
187  *
188  * @param pCluster the address of the input cluster
189  * @param slidingFitLayerPitch the sliding fit z pitch, units cm
190  *
191  * @return pandora::TrackState object containing the position and direction
192  */
193  static pandora::TrackState GetPrimaryAxis(const pandora::Cluster *const pCluster, const float slidingFitLayerPitch);
194 
195  /**
196  * @brief Calculate the position and direction of the primary axis
197  *
198  * @param pPointVector the address of the input point vector
199  * @param slidingFitLayerPitch the sliding fit z pitch, units cm
200  *
201  * @return pandora::TrackState object containing the position and direction
202  */
203  static pandora::TrackState GetPrimaryAxis(const pandora::CartesianPointVector *const pPointVector, const float slidingFitLayerPitch);
204 
205  /**
206  * @brief Generate a seed vector to be used in calculating the orthogonal axes
207  *
208  * @param axisDirection the primary axis
209  *
210  * @return the seed direction vector
211  */
212  static pandora::CartesianVector GetSeedDirection(const pandora::CartesianVector &axisDirection);
213 
214  const pandora::TrackState m_primaryAxis; ///< The primary axis position and direction
215  const pandora::CartesianVector m_axisIntercept; ///< The axis intercept position
216  const pandora::CartesianVector m_axisDirection; ///< The axis direction vector
217  const pandora::CartesianVector m_firstOrthoDirection; ///< The orthogonal direction vector
218  const pandora::CartesianVector m_secondOrthoDirection; ///< The orthogonal direction vector
219  const TwoDSlidingFitResult m_firstFitResult; ///< The first sliding fit result
220  const TwoDSlidingFitResult m_secondFitResult; ///< The second sliding fit result
221  const int m_minLayer; ///< The minimum combined layer
222  const int m_maxLayer; ///< The maximum combined layer
223 
224  pandora::CartesianVector m_minLayerPosition; ///< The global position at the minimum combined layer
225  pandora::CartesianVector m_maxLayerPosition; ///< The global position at the maximum combined layer
226  pandora::CartesianVector m_minLayerDirection; ///< The global direction at the minimum combined layer
227  pandora::CartesianVector m_maxLayerDirection; ///< The global direction at the maximum combined layer
228 };
229 
230 typedef std::vector<ThreeDSlidingFitResult> ThreeDSlidingFitResultList;
231 typedef std::unordered_map<const pandora::Cluster *, ThreeDSlidingFitResult> ThreeDSlidingFitResultMap;
232 
233 //------------------------------------------------------------------------------------------------------------------------------------------
234 //------------------------------------------------------------------------------------------------------------------------------------------
235 
236 inline const pandora::CartesianVector &ThreeDSlidingFitResult::GetAxisIntercept() const
237 {
238  return m_axisIntercept;
239 }
240 
241 //------------------------------------------------------------------------------------------------------------------------------------------
242 
243 inline const pandora::CartesianVector &ThreeDSlidingFitResult::GetAxisDirection() const
244 {
245  return m_axisDirection;
246 }
247 
248 //------------------------------------------------------------------------------------------------------------------------------------------
249 
251 {
252  return m_firstFitResult;
253 }
254 
255 //------------------------------------------------------------------------------------------------------------------------------------------
256 
258 {
259  return m_secondFitResult;
260 }
261 
262 //------------------------------------------------------------------------------------------------------------------------------------------
263 
264 inline const pandora::CartesianVector &ThreeDSlidingFitResult::GetGlobalMinLayerPosition() const
265 {
266  return m_minLayerPosition;
267 }
268 
269 //------------------------------------------------------------------------------------------------------------------------------------------
270 
271 inline const pandora::CartesianVector &ThreeDSlidingFitResult::GetGlobalMaxLayerPosition() const
272 {
273  return m_maxLayerPosition;
274 }
275 
276 //------------------------------------------------------------------------------------------------------------------------------------------
277 
278 inline const pandora::CartesianVector &ThreeDSlidingFitResult::GetGlobalMinLayerDirection() const
279 {
280  return m_minLayerDirection;
281 }
282 
283 //------------------------------------------------------------------------------------------------------------------------------------------
284 
285 inline const pandora::CartesianVector &ThreeDSlidingFitResult::GetGlobalMaxLayerDirection() const
286 {
287  return m_maxLayerDirection;
288 }
289 
290 } // namespace lar_content
291 
292 #endif // #ifndef LAR_THREE_D_SLIDING_FIT_RESULT_H
const int m_maxLayer
The maximum combined layer.
const pandora::CartesianVector & GetAxisIntercept() const
Get the axis intercept position.
static pandora::TrackState GetPrimaryAxis(const pandora::Cluster *const pCluster, const float slidingFitLayerPitch)
Calculate the position and direction of the primary axis.
const TwoDSlidingFitResult & GetSecondFitResult() const
Get the second sliding fit result for this cluster.
std::vector< ThreeDSlidingFitResult > ThreeDSlidingFitResultList
const pandora::CartesianVector & GetGlobalMinLayerDirection() const
Get global direction corresponding to the fit result in minimum fit layer.
const pandora::TrackState m_primaryAxis
The primary axis position and direction.
int GetMaxLayer() const
Get the maximum occupied layer in the sliding fit.
static pandora::CartesianVector GetSeedDirection(const pandora::CartesianVector &axisDirection)
Generate a seed vector to be used in calculating the orthogonal axes.
float GetMaxLayerRms() const
Get rms at maximum layer.
float GetMinLayerRms() const
Get rms at minimum layer.
float GetLongitudinalDisplacement(const pandora::CartesianVector &position) const
Get longitudinal projection onto primary axis.
pandora::CartesianVector m_maxLayerPosition
The global position at the maximum combined layer.
void GetGlobalDirection(const float dTdL1, const float dTdL2, pandora::CartesianVector &direction) const
Get global direction coordinates for a given pair of sliding linear fit gradients.
pandora::CartesianVector m_minLayerPosition
The global position at the minimum combined layer.
const int m_minLayer
The minimum combined layer.
const pandora::CartesianVector & GetAxisDirection() const
Get the axis direction vector.
std::unordered_map< const pandora::Cluster *, ThreeDSlidingFitResult > ThreeDSlidingFitResultMap
const pandora::CartesianVector m_axisIntercept
The axis intercept position.
const TwoDSlidingFitResult m_secondFitResult
The second sliding fit result.
const pandora::CartesianVector & GetGlobalMaxLayerDirection() const
Get global direction corresponding to the fit result in maximum fit layer.
const TwoDSlidingFitResult m_firstFitResult
The first sliding fit result.
Header file for the lar two dimensional sliding fit result class.
pandora::StatusCode GetGlobalFitDirection(const float rL, pandora::CartesianVector &direction) const
Get global fit direction for a given longitudinal coordinate.
const pandora::CartesianVector m_secondOrthoDirection
The orthogonal direction vector.
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.
const pandora::CartesianVector m_firstOrthoDirection
The orthogonal direction vector.
void GetGlobalPosition(const float rL, const float rT1, const float rT2, pandora::CartesianVector &position) const
Get global coordinates for a given pair of sliding linear fit coordinates.
float GetFitRms(const float rL) const
Get fit rms for a given longitudinal coordinate.
const TwoDSlidingFitResult & GetFirstFitResult() const
Get the first sliding fit result for this cluster.
pandora::CartesianVector m_minLayerDirection
The global direction at the minimum combined layer.
pandora::CartesianVector m_maxLayerDirection
The global direction at the maximum combined layer.
pandora::StatusCode GetGlobalFitPosition(const float rL, pandora::CartesianVector &position) const
Get global fit position for a given longitudinal coordinate.
const pandora::CartesianVector m_axisDirection
The axis direction vector.
const pandora::Cluster * GetCluster() const
Get the address of the cluster.
ThreeDSlidingFitResult(const T *const pT, const unsigned int slidingFitWindow, const float slidingFitLayerPitch)
Constructor.
const pandora::CartesianVector & GetGlobalMinLayerPosition() const
Get global position corresponding to the fit result in minimum fit layer.