NagFitStrategy.h

00001 #ifndef NAGFITSTRATEGY_H
00002 #define NAGFITSTRATEGY_H
00003 #include "../FitStrategy.h"
00004 #include <nag.h>
00005 #include <nage04.h>
00006 #include <vector>
00007 
00008 using namespace Sct;
00009 using namespace std;
00010 
00011 namespace SctFitter{
00025     class NagFitStrategy : public FitStrategy {
00026     public:
00028     NagFitStrategy(string opt=string("")) throw();
00030     ~NagFitStrategy() throw();
00032     virtual void fitTH1(const TH1& hist, TF1& fit) const throw(LogicError, MathsError);
00034     virtual void fitTGraph(const TGraph& graph, TF1& fit) const throw(LogicError, MathsError);
00036     virtual void fitTGraphErrors(const TGraphErrors& graph, TF1& fit) const throw(LogicError, MathsError);
00038     virtual void fitTGraphAsymmErrors(const TGraphAsymmErrors& graph, TF1& fit) const throw(LogicError, MathsError);
00039     
00041     virtual const string& getName() const throw();
00042     private:
00043     NagFitStrategy( const NagFitStrategy& ); 
00044     const string name; 
00045     static bool inMap; 
00046     
00055         const int getNumberFitPoints(TH1& hist, const TF1& fit, 
00056                         int& iFirstBin) const throw(LogicError);
00065     void getFitPoints(TGraph& graph, const TF1& fit, vector<bool>& active) const throw(LogicError);
00067     class Cache{
00068     public:
00070         Cache(const TH1& hist, const unsigned npoints, 
00071           const unsigned firstpoint, TF1& fit) throw(LogicError, MathsError) ;
00072 
00074         Cache(const TGraph& graph, TF1& fit, const vector<bool>& active) throw(LogicError, MathsError) ;
00075 
00077         Cache(const TGraphErrors& graph, TF1& fit, const vector<bool>& active) throw(LogicError, MathsError) ;
00078 
00080         Cache(const TGraphAsymmErrors& graph, TF1& fit, const vector<bool>& active) throw(LogicError, MathsError) ;
00081 
00083         void convertPars(double inPars[]);
00084                 
00086         void setupPars(TF1& fit); 
00087         
00088         ~Cache() throw();                
00089         vector<double> m_y; 
00090         vector<double> m_x; 
00091         vector<double> m_ey; 
00092         TF1* function;           
00093         double* pars;       
00094         unsigned int nVarPars;  
00095         double* inPars;     
00096         
00097     private:        
00098         int* map;               
00099     };
00100 
00104     void nagFit(Cache* cache, TF1& fit, bool quiet) const throw(MathsError);
00105 
00107     bool ranged() const throw();
00108 
00110     bool quiet() const throw();
00111 
00113     static void chiSquaredFunctionForNag(Integer m, Integer n, double x[], double fvec[],
00114                          Nag_Comm *comm) throw();
00115     };
00116 
00117 } // end of namespace SctFitter;
00118 
00119 
00120 #endif // #ifndef NAGFITSTRATEGY_H

Generated on Mon Feb 6 14:01:23 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6