QCurveCrawler.hh

Go to the documentation of this file.
00001 
00012 #ifndef __QCURVECRAWLER_HH_
00013 #define __QCURVECRAWLER_HH_
00014 
00015 #include <vector>
00016 #include "QCurveCrawler.hh"
00017 #include "QObject.hh"
00018 #include "TGraph.h"
00019 #include "TSpline.h"
00020 
00021 struct LineSegment
00022 {
00023         double xmin; // range of segment
00024         double xmax;    
00025         double c0; // y intercept
00026         double c1; // slope (= tan(theta))
00027         double theta; // angle between line and x axis
00028         double median_deviation; // med. dy between datapoints and line segment (from fitting procedure)
00029         double median_fractional_deviation;
00030         
00031         double y(double x) {return c0+c1*x;}
00032         bool inRange(double x) {return ((x>=xmin) && (x<=xmax));}
00033 };
00034 
00035 
00036 Q_BEGIN_NAMESPACE
00037 
00038 
00039 class QCurveCrawler : public QObject {
00040         public:
00044                 QCurveCrawler();
00045                 
00050                 QCurveCrawler(const QCurveCrawler& orig);
00051                 
00059                 QCurveCrawler(double xMin, double xMax=10000, double StepSize=300, int MinPointsPerStep=15);
00060 
00064                 virtual ~QCurveCrawler();
00065                 
00069                 void SetXMax(double xMax) {fxMax = xMax;}
00070                 
00074                 void SetXMin(double xMin) {fxMin = xMin;}
00075                 
00079                 void SetStepSize(double StepSize) {fStepSize = StepSize;}
00080                 
00084                 std::vector<LineSegment> GetLineSegments() {return fSegments;}
00085                 
00089                 void SetMinPointsPerStep(int MinPointsPerStep) {fMinPointsPerStep = MinPointsPerStep;}
00090 
00097                 std::vector<TGraph*> Crawl(const std::vector<double> &xVals, const std::vector<double> &yVals);
00098                 
00105                 int Crop(std::vector<double> &xVals, std::vector<double> &yVals, double nMedianDeviations, bool UseFractionalDeviation=true);
00106                 
00114                 std::vector<double> GetYDeviations(const std::vector<double> &xVals, const std::vector<double> &yVals);
00115                 
00122                 TGraph* Spline(const std::vector<double> &xVals, const std::vector<double> &yVals, TGraph* &grKnots);
00123                 
00124                 
00128                 void Print();
00129                 
00130         
00131         
00132         protected: 
00133         
00134         private:
00136                 std::vector<LineSegment> fSegments;
00137                  
00139                 double fxMin;
00140                 double fxMax;
00141                 double fStepSize;
00142                 unsigned int fMinPointsPerStep;
00143                  
00153                 TGraph* DoFit(std::vector<double> & vx, std::vector<double> & vy, double x0, double y0, LineSegment & seg, double prev_theta);
00154                 
00155                 
00156 
00157  
00158 };
00159 
00160 Q_END_NAMESPACE
00161 
00162 #endif

Generated on Tue Nov 16 10:49:57 2010 for CUORE Software by  doxygen 1.5.6