LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
LArTwoDSlidingFitResult.h
Go to the documentation of this file.
1 
8 #ifndef LAR_TWO_D_SLIDING_FIT_RESULT_H
9 #define LAR_TWO_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 
24 {
25 public:
33  template <typename T>
34  TwoDSlidingFitResult(const T *const pT, const unsigned int layerFitHalfWindow, const float layerPitch);
35 
46  template <typename T>
47  TwoDSlidingFitResult(const T *const pT, const unsigned int layerFitHalfWindow, const float layerPitch, const pandora::CartesianVector &axisIntercept,
48  const pandora::CartesianVector &axisDirection, const pandora::CartesianVector &orthoDirection);
49 
62  TwoDSlidingFitResult(const unsigned int layerFitHalfWindow, const float layerPitch, const pandora::CartesianVector &axisIntercept,
63  const pandora::CartesianVector &axisDirection, const pandora::CartesianVector &orthoDirection, const LayerFitContributionMap &layerFitContributionMap);
64 
72  const pandora::Cluster *GetCluster() const;
73 
79  unsigned int GetLayerFitHalfWindow() const;
80 
86  float GetLayerPitch() const;
87 
93  const pandora::CartesianVector &GetAxisIntercept() const;
94 
100  const pandora::CartesianVector &GetAxisDirection() const;
101 
107  const pandora::CartesianVector &GetOrthoDirection() const;
108 
115 
122 
128  const FitSegmentList &GetFitSegmentList() const;
129 
135  float GetLayerFitHalfWindowLength() const;
136 
142  int GetMinLayer() const;
143 
149  int GetMaxLayer() const;
150 
157  void GetMinAndMaxX(float &minX, float &maxX) const;
158 
165  void GetMinAndMaxZ(float &minZ, float &maxZ) const;
166 
172  int GetLayer(const float rL) const;
173 
179  float GetL(const int layer) const;
180 
188  void GetLocalPosition(const pandora::CartesianVector &position, float &rL, float &rT) const;
189 
196  void GetLocalDirection(const pandora::CartesianVector &direction, float &dTdL) const;
197 
205  void GetGlobalPosition(const float rL, const float rT, pandora::CartesianVector &position) const;
206 
213  void GetGlobalDirection(const float dTdL, pandora::CartesianVector &direction) const;
214 
220  pandora::CartesianVector GetGlobalMinLayerPosition() const;
221 
227  pandora::CartesianVector GetGlobalMaxLayerPosition() const;
228 
234  pandora::CartesianVector GetGlobalMinLayerDirection() const;
235 
241  pandora::CartesianVector GetGlobalMaxLayerDirection() const;
242 
248  float GetMinLayerRms() const;
249 
255  float GetMaxLayerRms() const;
256 
264  float GetFitRms(const float rL) const;
265 
271  float GetCosScatteringAngle(const float rL) const;
272 
281  pandora::StatusCode GetGlobalFitPosition(const float rL, pandora::CartesianVector &position) const;
282 
291  pandora::StatusCode GetGlobalFitDirection(const float rL, pandora::CartesianVector &direction) const;
292 
301  pandora::StatusCode GetGlobalFitPositionAtX(const float x, pandora::CartesianVector &position) const;
302 
311  pandora::StatusCode GetGlobalFitDirectionAtX(const float x, pandora::CartesianVector &direction) const;
312 
321  pandora::StatusCode GetGlobalFitProjection(const pandora::CartesianVector &inputPosition, pandora::CartesianVector &projectedPosition) const;
322 
331  pandora::StatusCode GetGlobalFitPositionListAtX(const float x, pandora::CartesianPointVector &positionList) const;
332 
342  pandora::StatusCode GetTransverseProjection(const float x, const FitSegment &fitSegment, pandora::CartesianVector &position) const;
343 
354  pandora::StatusCode GetTransverseProjection(const float x, const FitSegment &fitSegment, pandora::CartesianVector &position,
355  pandora::CartesianVector &direction) const;
356 
365  pandora::StatusCode GetExtrapolatedPosition(const float rL, pandora::CartesianVector &position) const;
366 
375  pandora::StatusCode GetExtrapolatedDirection(const float rL, pandora::CartesianVector &direction) const;
376 
385  pandora::StatusCode GetExtrapolatedPositionAtX(const float x, pandora::CartesianVector &position) const;
386 
392  const FitSegment &GetFitSegment(const float rL) const;
393 
394 private:
398  void CalculateAxes(const pandora::CartesianPointVector &coordinateVector, const float layerPitch);
399 
403  void FillLayerFitContributionMap(const pandora::CartesianPointVector &coordinateVector);
404 
409 
413  void FindSlidingFitSegments();
414 
422  void GetMinAndMaxCoordinate(const bool isX, float &min, float &max) const;
423 
431  pandora::CartesianVector GetGlobalFitPosition(const LayerInterpolation &layerInterpolation) const;
432 
440  pandora::CartesianVector GetGlobalFitDirection(const LayerInterpolation &layerInterpolation) const;
441 
449  float GetFitRms(const LayerInterpolation &layerInterpolation) const;
450 
459  pandora::StatusCode LongitudinalInterpolation(const float rL, LayerInterpolation &layerInterpolation) const;
460 
470  pandora::StatusCode TransverseInterpolation(const float x, const FitSegment &fitSegment, LayerInterpolation &layerInterpolation) const;
471 
480  pandora::StatusCode TransverseInterpolation(const float x, LayerInterpolationList &layerInterpolationList) const;
481 
491  pandora::StatusCode GetLongitudinalSurroundingLayers(const float rL, LayerFitResultMap::const_iterator &firstLayerIter,
492  LayerFitResultMap::const_iterator &secondLayerIter) const;
493 
505  pandora::StatusCode GetTransverseSurroundingLayers(const float x, const int minLayer, const int maxLayer,
506  LayerFitResultMap::const_iterator &firstLayerIter, LayerFitResultMap::const_iterator &secondLayerIter) const;
507 
517  void GetLongitudinalInterpolationWeights(const float rL, const LayerFitResultMap::const_iterator &firstLayerIter,
518  const LayerFitResultMap::const_iterator &secondLayerIter, double &firstWeight, double &secondWeight) const;
519 
529  void GetTransverseInterpolationWeights(const float x, const LayerFitResultMap::const_iterator &firstLayerIter,
530  const LayerFitResultMap::const_iterator &secondLayerIter, double &firstWeight, double &secondWeight) const;
531 
532  const pandora::Cluster *m_pCluster;
533  unsigned int m_layerFitHalfWindow;
534  float m_layerPitch;
535  pandora::CartesianVector m_axisIntercept;
536  pandora::CartesianVector m_axisDirection;
537  pandora::CartesianVector m_orthoDirection;
541 };
542 
543 typedef std::vector<TwoDSlidingFitResult> TwoDSlidingFitResultList;
544 typedef std::unordered_map<const pandora::Cluster*, TwoDSlidingFitResult> TwoDSlidingFitResultMap;
545 
546 //------------------------------------------------------------------------------------------------------------------------------------------
547 //------------------------------------------------------------------------------------------------------------------------------------------
548 
550 {
551  return m_layerFitHalfWindow;
552 }
553 
554 //------------------------------------------------------------------------------------------------------------------------------------------
555 
557 {
558  return m_layerPitch;
559 }
560 
561 //------------------------------------------------------------------------------------------------------------------------------------------
562 
563 inline const pandora::CartesianVector &TwoDSlidingFitResult::GetAxisIntercept() const
564 {
565  return m_axisIntercept;
566 }
567 
568 //------------------------------------------------------------------------------------------------------------------------------------------
569 
570 inline const pandora::CartesianVector &TwoDSlidingFitResult::GetAxisDirection() const
571 {
572  return m_axisDirection;
573 }
574 
575 //------------------------------------------------------------------------------------------------------------------------------------------
576 
577 inline const pandora::CartesianVector &TwoDSlidingFitResult::GetOrthoDirection() const
578 {
579  return m_orthoDirection;
580 }
581 
582 //------------------------------------------------------------------------------------------------------------------------------------------
583 
585 {
586  return m_layerFitResultMap;
587 }
588 
589 //------------------------------------------------------------------------------------------------------------------------------------------
590 
592 {
594 }
595 
596 //------------------------------------------------------------------------------------------------------------------------------------------
597 
599 {
600  return m_fitSegmentList;
601 }
602 
603 //------------------------------------------------------------------------------------------------------------------------------------------
604 
605 inline void TwoDSlidingFitResult::GetMinAndMaxX(float &minX, float &maxX) const
606 {
607  return this->GetMinAndMaxCoordinate(true, minX, maxX);
608 }
609 
610 //------------------------------------------------------------------------------------------------------------------------------------------
611 
612 inline void TwoDSlidingFitResult::GetMinAndMaxZ(float &minZ, float &maxZ) const
613 {
614  return this->GetMinAndMaxCoordinate(false, minZ, maxZ);
615 }
616 
617 } // namespace lar_content
618 
619 #endif // #ifndef LAR_TWO_D_SLIDING_FIT_RESULT_H
Float_t x
Definition: compare.C:6
void FillLayerFitContributionMap(const pandora::CartesianPointVector &coordinateVector)
Fill the layer fit contribution map.
unsigned int GetLayerFitHalfWindow() const
Get the layer fit half window.
void GetMinAndMaxCoordinate(const bool isX, float &min, float &max) const
Get the minimum and maximum x or z coordinates associated with the sliding fit.
pandora::CartesianVector m_axisIntercept
The axis intercept position.
void GetTransverseInterpolationWeights(const float x, const LayerFitResultMap::const_iterator &firstLayerIter, const LayerFitResultMap::const_iterator &secondLayerIter, double &firstWeight, double &secondWeight) const
Get interpolation weights for layers surrounding a specified transverse position. ...
pandora::StatusCode GetTransverseSurroundingLayers(const float x, const int minLayer, const int maxLayer, LayerFitResultMap::const_iterator &firstLayerIter, LayerFitResultMap::const_iterator &secondLayerIter) const
Get iterators for layers surrounding a specified transverse position.
const pandora::Cluster * m_pCluster
The address of the cluster.
void GetMinAndMaxX(float &minX, float &maxX) const
Get the minimum and maximum x coordinates associated with the sliding fit.
void FindSlidingFitSegments()
Find sliding fit segments; sections with tramsverse direction.
pandora::StatusCode GetExtrapolatedPositionAtX(const float x, pandora::CartesianVector &position) const
Get extrapolated position (beyond span) for a given input x coordinate.
void GetLocalDirection(const pandora::CartesianVector &direction, float &dTdL) const
Get local sliding fit gradient for a given global direction.
float GetMaxLayerRms() const
Get rms at maximum layer.
pandora::CartesianVector m_axisDirection
The axis direction vector.
void GetLongitudinalInterpolationWeights(const float rL, const LayerFitResultMap::const_iterator &firstLayerIter, const LayerFitResultMap::const_iterator &secondLayerIter, double &firstWeight, double &secondWeight) const
Get interpolation weights for layers surrounding a specified longitudinal position.
std::vector< FitSegment > FitSegmentList
float GetLayerFitHalfWindowLength() const
Get the layer fit half window length.
pandora::StatusCode LongitudinalInterpolation(const float rL, LayerInterpolation &layerInterpolation) const
Get the pair of layers surrounding a specified longitudinal position.
const pandora::CartesianVector & GetAxisDirection() const
Get the axis direction vector.
pandora::CartesianVector GetGlobalMinLayerDirection() const
Get global direction corresponding to the fit result in minimum fit layer.
std::unordered_map< const pandora::Cluster *, TwoDSlidingFitResult > TwoDSlidingFitResultMap
pandora::StatusCode GetLongitudinalSurroundingLayers(const float rL, LayerFitResultMap::const_iterator &firstLayerIter, LayerFitResultMap::const_iterator &secondLayerIter) const
Get iterators for layers surrounding the specified longitudinal position.
std::map< int, LayerFitContribution > LayerFitContributionMap
const pandora::CartesianVector & GetAxisIntercept() const
Get the axis intercept position.
float GetCosScatteringAngle(const float rL) const
Get scattering angle for a given longitudinal coordinate.
void GetMinAndMaxZ(float &minZ, float &maxZ) const
Get the minimum and maximum z coordinates associated with the sliding fit.
unsigned int m_layerFitHalfWindow
The layer fit half window.
TwoDSlidingFitResult(const T *const pT, const unsigned int layerFitHalfWindow, const float layerPitch)
Constructor using internal definition of primary axis.
Int_t max
Definition: plot.C:27
int GetMaxLayer() const
Get the maximum occupied layer in the sliding fit.
intermediate_table::const_iterator const_iterator
int GetMinLayer() const
Get the minimum occupied layer in the sliding fit.
float GetFitRms(const float rL) const
Get fit rms for a given longitudinal coordinate.
pandora::StatusCode GetGlobalFitPosition(const float rL, pandora::CartesianVector &position) const
Get global fit position for a given longitudinal coordinate.
pandora::StatusCode TransverseInterpolation(const float x, const FitSegment &fitSegment, LayerInterpolation &layerInterpolation) const
Get the surrounding pair of layers for a specified transverse position and fit segment.
pandora::StatusCode GetExtrapolatedPosition(const float rL, pandora::CartesianVector &position) const
Get extrapolated position (beyond span) for a given input coordinate.
const pandora::CartesianVector & GetOrthoDirection() const
Get the orthogonal direction vector.
std::map< int, LayerFitResult > LayerFitResultMap
std::vector< TwoDSlidingFitResult > TwoDSlidingFitResultList
float GetLayerPitch() const
Get the layer pitch, units cm.
void CalculateAxes(const pandora::CartesianPointVector &coordinateVector, const float layerPitch)
Calculate the longitudinal and transverse axes.
const FitSegment & GetFitSegment(const float rL) const
Get fit segment for a given longitudinal coordinate.
pandora::CartesianVector GetGlobalMinLayerPosition() const
Get global position corresponding to the fit result in minimum fit layer.
const FitSegmentList & GetFitSegmentList() const
Get the fit segment list.
pandora::StatusCode GetExtrapolatedDirection(const float rL, pandora::CartesianVector &direction) const
Get extrapolated direction (beyond span) for a given input coordinate.
std::vector< LayerInterpolation > LayerInterpolationList
void GetGlobalDirection(const float dTdL, pandora::CartesianVector &direction) const
Get global direction coordinates for given sliding linear fit gradient.
const LayerFitResultMap & GetLayerFitResultMap() const
Get the layer fit result map.
float GetMinLayerRms() const
Get rms at minimum layer.
const pandora::Cluster * GetCluster() const
Get the address of the cluster, if originally provided.
pandora::StatusCode GetGlobalFitPositionAtX(const float x, pandora::CartesianVector &position) const
Get global fit position for a given input x coordinate.
pandora::StatusCode GetGlobalFitDirection(const float rL, pandora::CartesianVector &direction) const
Get global fit direction for a given longitudinal coordinate.
Int_t min
Definition: plot.C:26
pandora::StatusCode GetGlobalFitProjection(const pandora::CartesianVector &inputPosition, pandora::CartesianVector &projectedPosition) const
Get projected position on global fit for a given position vector.
void PerformSlidingLinearFit()
Perform the sliding linear fit.
void GetGlobalPosition(const float rL, const float rT, pandora::CartesianVector &position) const
Get global coordinates for given sliding linear fit coordinates.
FitSegmentList m_fitSegmentList
The fit segment list.
pandora::CartesianVector GetGlobalMaxLayerDirection() const
Get global direction corresponding to the fit result in maximum fit layer.
float GetL(const int layer) const
Get longitudinal coordinate for a given sliding linear fit layer number.
LayerFitContributionMap m_layerFitContributionMap
The layer fit contribution map.
pandora::StatusCode GetGlobalFitDirectionAtX(const float x, pandora::CartesianVector &direction) const
Get global fit direction for a given input x coordinate.
pandora::StatusCode GetTransverseProjection(const float x, const FitSegment &fitSegment, pandora::CartesianVector &position) const
Get projected position for a given input x coordinate and fit segment.
Header file for the lar two dimensional sliding fit objects.
float m_layerPitch
The layer pitch, units cm.
pandora::StatusCode GetGlobalFitPositionListAtX(const float x, pandora::CartesianPointVector &positionList) const
Get a list of projected positions for a given input x coordinate.
const LayerFitContributionMap & GetLayerFitContributionMap() const
Get the layer fit contribution map.
LayerFitResultMap m_layerFitResultMap
The layer fit result map.
void GetLocalPosition(const pandora::CartesianVector &position, float &rL, float &rT) const
Get local sliding fit coordinates for a given global position.
pandora::CartesianVector m_orthoDirection
The orthogonal direction vector.
pandora::CartesianVector GetGlobalMaxLayerPosition() const
Get global position corresponding to the fit result in maximum fit layer.
int GetLayer(const float rL) const
Get layer number for given sliding linear fit longitudinal coordinate.