npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
findPeak2D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_FINDPEAK2D_HH_
2 #define NPSTAT_FINDPEAK2D_HH_
3 
4 /*!
5 // \file findPeak2D.hh
6 //
7 // \brief Peak finding for noisy two-dimensional surfaces
8 //
9 // Operations useful in 2-dimensional peak finding. Here, peak finding
10 // works by expanding local surface patches into 2-d orthogonal polynomials
11 // of degree 2 (this is equivalent to fitting a quadratic surface using the
12 // L2 norm) and then finding the peak locations of those polynomials.
13 //
14 // Author: I. Volobouev
15 //
16 // July 2011
17 */
18 
19 namespace npstat {
20  /** Structure to store peak finding results */
21  struct Peak2D
22  {
23  inline Peak2D()
24  : x(0.0), y(0.0), magnitude(0.0), valid(false), inside(false)
25  {hessian[0] = hessian[1] = hessian[2] = 0.0;}
26 
27  /** Shift and scale the peak coordinates */
28  void rescaleCoords(double centerCellCoordinateInX,
29  double gridCellWidthInX,
30  double centerCellCoordinateInY,
31  double gridCellWidthInY);
32 
33  double x; ///< Peak x coordinate.
34  double y; ///< Peak y coordinate.
35  double magnitude; ///< Value of the quadratic fit at the peak position.
36 
37  /**
38  // hessian[0] = Hxx,
39  // hessian[1] = Hxy,
40  // hessian[2] = Hyy.
41  */
42  double hessian[3]; ///< Hessian of the fitted quadratic polynomial.
43  bool valid; ///< True if the Hessian is negative-definite.
44  bool inside; ///< True if the peak is inside the fitted patch.
45  };
46 
47  /**
48  // The "findPeak3by3" function assumes that the grid locations
49  // are -1, 0, and 1 in both directions. Correct shifting
50  // and scaling is up to the user of this function (use the
51  // "rescaleCoords" method of the Peak2D class). The function
52  // returns "true" if a valid peak is found inside the 3x3 mask
53  // and "false" otherwise.
54  */
55  bool findPeak3by3(const double gridValues[3][3], Peak2D* peak);
56 
57  /**
58  // The "findPeak5by5" function assumes that the grid locations
59  // are -2, -1, 0, 1, and 2 in both directions. Correct shifting
60  // and scaling is up to the user of this function (use the
61  // "rescaleCoords" method of the Peak2D class). The function
62  // returns "true" if a valid peak is found inside the 5x5 mask
63  // and "false" otherwise.
64  */
65  bool findPeak5by5(const double gridValues[5][5], Peak2D* peak);
66 }
67 
68 #endif // NPSTAT_FINDPEAK2D_HH_
Definition: AbsArrayProjector.hh:14
bool findPeak3by3(const double gridValues[3][3], Peak2D *peak)
bool findPeak5by5(const double gridValues[5][5], Peak2D *peak)
Definition: findPeak2D.hh:22
void rescaleCoords(double centerCellCoordinateInX, double gridCellWidthInX, double centerCellCoordinateInY, double gridCellWidthInY)
double x
Peak x coordinate.
Definition: findPeak2D.hh:33
double hessian[3]
Hessian of the fitted quadratic polynomial.
Definition: findPeak2D.hh:42
bool inside
True if the peak is inside the fitted patch.
Definition: findPeak2D.hh:44
double magnitude
Value of the quadratic fit at the peak position.
Definition: findPeak2D.hh:35
double y
Peak y coordinate.
Definition: findPeak2D.hh:34
bool valid
True if the Hessian is negative-definite.
Definition: findPeak2D.hh:43