npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
logLikelihoodPeak.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_LOGLIKELIHOODPEAK_HH_
2 #define NPSTAT_LOGLIKELIHOODPEAK_HH_
3 
4 /*!
5 // \file logLikelihoodPeak.hh
6 //
7 // \brief Summarize properties of one-dimensional log-likelihood curves
8 //
9 // Author: I. Volobouev
10 //
11 // May 2010
12 */
13 
14 #ifdef SWIG
15 #include <vector>
16 #endif // SWIG
17 
18 namespace npstat {
19  /** Coordinate of a point on a likelihood curve, with assigned status */
21  {
22  public:
23  enum Status {
24  OK = 0,
25  NOT_FOUND,
26  ON_THE_EDGE,
27  INVALID
28  };
29 
30  inline LikelihoodPoint() : coord_(0.0), status_(INVALID) {}
31  inline LikelihoodPoint(const double coord, const Status s)
32  : coord_(coord), status_(s) {}
33 
34  inline double coord() const {return coord_;}
35  inline Status status() const {return status_;}
36 
37  private:
38  double coord_;
39  Status status_;
40  };
41 
42  /**
43  // Class for storing the location of the likelihood peak and the points
44  // where the log-likelihood curve descends down by a certain magnitude
45  */
47  {
48  public:
49  inline LikelihoodSummary() : down_(0.0) {}
50  inline LikelihoodSummary(const LikelihoodPoint& peak,
51  const LikelihoodPoint& left,
52  const LikelihoodPoint& right,
53  const double down)
54  : peak_(peak), left_(left), right_(right), down_(down) {}
55 
56  inline const LikelihoodPoint& peak() const {return peak_;}
57  inline const LikelihoodPoint& left() const {return left_;}
58  inline const LikelihoodPoint& right() const {return right_;}
59  inline double down() const {return down_;}
60 
61  inline double peakCoord() const
62  {return peak_.coord();}
63  inline double leftError() const
64  {return peak_.coord() - left().coord();}
65  inline double rightError() const
66  {return right().coord() - peak_.coord();}
67  inline double averageError() const
68  {return (right().coord() - left().coord())/2.0;}
69 
70  inline bool isOK() const {return down_ > 0.0 &&
71  peak_.status() == LikelihoodPoint::OK &&
72  left_.status() == LikelihoodPoint::OK &&
73  right_.status() == LikelihoodPoint::OK;}
74  private:
75  LikelihoodPoint peak_;
76  LikelihoodPoint left_;
77  LikelihoodPoint right_;
78  double down_;
79  };
80 
81  /**
82  // Function which summarizes properties of one-dimensional
83  // log-likelihoods.
84  //
85  // The number of points in the curve must be at least 3.
86  // Typical value of "down" is 0.5 for 1 sigma, 2.0 for 2 sigmas,
87  // 4.5 for 3 sigmas, etc.
88  //
89  // leftPointCoordinate and rightPointCoordinate are the leftmost
90  // and rightmost coordinates which correspont to the first and the
91  // last value of the "curve" array, respectively. It is assumed that
92  // all other point coordinates are equidistantly spaced in between.
93  */
95  const double* curve, unsigned npoints, double down,
96  double leftPointCoordinate, double rightPointCoordinate);
97 
98 #ifdef SWIG
99  inline LikelihoodSummary logLikelihoodPeak2(
100  const std::vector<double>& curve, const double down,
101  const double leftPointCoordinate, const double rightPointCoordinate)
102  {
103  const unsigned n = curve.size();
104  const double* data = n ? &curve[0] : NULL;
105  return logLikelihoodPeak(data, n, down, leftPointCoordinate,
106  rightPointCoordinate);
107  }
108 #endif // SWIG
109 }
110 
111 #endif // NPSTAT_LOGLIKELIHOODPEAK_HH_
Definition: logLikelihoodPeak.hh:21
Definition: logLikelihoodPeak.hh:47
Definition: AbsArrayProjector.hh:14
LikelihoodSummary logLikelihoodPeak(const double *curve, unsigned npoints, double down, double leftPointCoordinate, double rightPointCoordinate)