Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

FitPoint.h

Go to the documentation of this file.
00001 #ifndef ANP_FITPOINT_H
00002 #define ANP_FITPOINT_H
00003 
00004 // $Id: FitPoint.h,v 1.1 2007/11/30 16:03:57 rustem Exp $
00005 //
00006 // Point in local fit routine. Local regression is done with
00007 // linear or quadratic polynomial:
00008 // fDegree = 1: y = a x + b
00009 // fDegree = 2: y = a x^2 + b x + c
00010 
00011 // C++
00012 #include <iostream>
00013 #include <map>
00014 
00015 // ROOT
00016 #include "Rtypes.h"
00017 
00018 namespace Anp
00019 {   
00020    class FitPoint
00021    {
00022    public:
00023       
00024       FitPoint();
00025       FitPoint(int index, double x, double y);
00026       ~FitPoint();     
00027       
00028       int Index() const;
00029       
00030       double X() const;
00031       double Y() const;
00032       
00033       double FitY() const;
00034       double FitY(double x) const;
00035       
00036       bool Pass() const;
00037       
00038       short Degree() const;
00039       
00040       double A() const;
00041       double B() const;
00042       double C() const;
00043       
00044       double Weight() const;
00045       
00046       double Residual() const;
00047       double Derivative(double x) const;
00048       
00049       void Print(std::ostream &os = std::cout) const;
00050 
00051    private:
00052       
00053       friend class LocalFit;
00054 
00055       void SetWeight(double weight);
00056       bool SetWeight(unsigned int position, double weight);
00057 
00058       void SetL(double a, double b, bool pass);
00059       void SetQ(double a, double b, double c, bool pass);
00060       
00061       const std::map<unsigned int, double>& GetWeightMap() const;
00062 
00063    private:
00064 
00065       Int_t fIndex;      // global point index, set by user
00066       
00067       Double_t fX;       // x position
00068       Double_t fY;       // y position
00069       
00070       Double_t fA;       // a coefficient in linear or quadratic polynomial
00071       Double_t fB;       // b coefficient in linear or quadratic polynomial
00072       Double_t fC;       // c coefficient in quadratic polynomial
00073       
00074       Bool_t fPass;      // this point passed local regression
00075       
00076       Short_t fDegree;   // polynomial degree: =1 for linear and =2 for quadratic
00077       
00078       Double_t fWeight;  // global weight of this point
00079 
00080       std::map<unsigned int, double> fMap;  
00081    };
00082    
00083    
00084    bool operator==(const FitPoint &lhs, const FitPoint &rhs);
00085    bool operator <(const FitPoint &lhs, const FitPoint &rhs);
00086    bool operator <(double value, const FitPoint &fit);
00087    bool operator <(const FitPoint &rhs, double value);
00088    
00089    bool operator==(int index, const FitPoint &fit);
00090    bool operator==(const FitPoint &fit, int index);
00091    
00092    //
00093    // Inlined member functions
00094    //
00095    inline const std::map<unsigned int, double>& FitPoint::GetWeightMap() const
00096    {
00097       return fMap;
00098    }
00099    inline int FitPoint::Index() const
00100    {
00101       return fIndex;
00102    }
00103    inline double FitPoint::X() const
00104    {
00105       return fX;
00106    }
00107    inline double FitPoint::Y() const
00108    {
00109       return fY;
00110    }
00111    inline bool FitPoint::Pass() const
00112    {
00113       return fPass;
00114    }
00115    inline short FitPoint::Degree() const
00116    {
00117       return fDegree;
00118    }
00119    inline double FitPoint::A() const
00120    {
00121       return fA;
00122    }      
00123    inline double FitPoint::B() const
00124    {
00125       return fB;
00126    }
00127    inline double FitPoint::C() const
00128    {
00129       return fC;
00130    }
00131    inline double FitPoint::Weight() const
00132    {
00133       return fWeight;
00134    }
00135 }
00136 
00137 #endif

Generated on Mon Feb 15 11:06:43 2010 for loon by  doxygen 1.3.9.1