QBruteForceTrendFinder.hh
Go to the documentation of this file.00001 #ifndef _Q_BRUTE_FORCE_TREND_FINDER_HH_
00002 #define _Q_BRUTE_FORCE_TREND_FINDER_HH_
00003
00016 #include <map>
00017 #include <string>
00018 #include <vector>
00019
00020 class QBruteForceTrendFinder {
00021
00022 public:
00023 class Line {
00024 public:
00025 double intercept;
00026 double intercept_error;
00027 double slope;
00028 double slope_error;
00029 };
00030
00031 QBruteForceTrendFinder();
00032
00033 virtual ~QBruteForceTrendFinder();
00034
00035 void FindTrends(int minPointsInInterval = 3);
00036
00037 const std::vector<Line>& GetBestFitLines()
00038 {
00039 return fBestFitLines;
00040 }
00041
00042 const std::vector<double>& GetBreakTimes()
00043 {
00044 return fBreakTimes;
00045 }
00046
00047 void RemoveOutliers(const double nMAD = 5.0 * 1.4826);
00048
00049 void SetMinProbability(const double minProbability)
00050 {
00051 fMinProbability = minProbability;
00052 }
00053
00054 void SetPoint(const double time,
00055 const double baseline,
00056 const double amplitude);
00057
00058 protected:
00059 double GetDeviation(const int start, const int stop);
00060 double GetDeviation(
00061 const int start, const int stop,
00062 double& intercept, double& slope
00063 );
00064 double GetDeviation(
00065 const int start, const int stop,
00066 double& intercept, double& slope,
00067 double& intercept_error, double& slope_error
00068 );
00069 double GetDeviation(const std::vector<int>& breakPoints);
00070 bool Next(std::vector<int>& breakPoints, int minPointsInInterval,
00071 int numPoints);
00072
00073 class Point {
00074 public:
00075 double time;
00076 double baseline;
00077 double amplitude;
00078
00079 bool operator<(const Point& other) const
00080 {
00081 return time < other.time;
00082 }
00083 };
00084
00085 double* fAmplitudes;
00086 double* fBaselines;
00087 std::vector<Line> fBestFitLines;
00088 std::vector<double> fBreakTimes;
00089 std::map< int, std::map<int, double> > fDeviationCache;
00090 double fMinProbability;
00091 std::vector<Point> fPoints;
00092
00093 };
00094
00095 #endif