FunctionController.h

Go to the documentation of this file.
00001 /* -*- mode: c++ -*- */
00002 
00014 #ifndef _FunctionController_H_
00015 #define _FunctionController_H_
00016 
00017 #include "axes/AxesType.h"
00018 
00019 // for incomplete type warning
00020 #ifdef _MSC_VER
00021 #include "functions/FunctionBase.h"
00022 #endif
00023 
00024 #include <list>
00025 #include <vector>
00026 
00027 namespace hippodraw {
00028 
00029 class DataRep;
00030 class Fitter;
00031 class FunctionBase;
00032 class FunctionParameter;
00033 class FunctionRep;
00034 class NTuple;
00035 class PlotterBase;
00036 class ProjectorBase;
00037 class Range;
00038 class TupleCut;
00039 class ViewBase;
00040 class ViewFactory;
00041 
00049 class MDL_HIPPOPLOT_API FunctionController
00050 {
00051 
00052 private:
00053   
00056   mutable std::vector < FunctionRep * > m_func_reps;
00057 
00059   std::vector < std::string > m_f_names;
00060 
00063   std::vector < double > m_deltaXSq;
00064   
00066   static FunctionController * s_instance;
00067 
00069   PlotterBase * m_plotter;
00070 
00074   mutable int m_x;
00075   
00079   mutable int m_y;
00080   
00083   unsigned int m_confid_count;
00084 
00086   FunctionController ();
00087 
00089   FunctionController ( const FunctionController & );
00090 
00096   void findFunctions ( const PlotterBase * plotter ) const;
00097 
00101   void setErrorsFromComposite ( const PlotterBase * plotter, 
00102                                 const FunctionRep * composite );
00103 
00108   void fillFunctionReps ( std::vector < FunctionRep * > & freps,
00109                           const PlotterBase * plotter,
00110                           const DataRep * data_rep ) const;
00111 
00112 public:
00113 
00115   static FunctionController * instance ();
00116 
00118   ~FunctionController();
00119 
00122   const std::vector < std::string > & getFitterNames () const;
00123 
00126   const std::string & getDefaultFitter () const;
00127 
00130   FunctionRep * createFunctionRep ( const std::string & name,
00131                                     DataRep * rep  );
00132     
00135    FunctionRep * createFunctionRep ( FunctionBase * function,
00136                                      DataRep * rep  );
00137     
00149   FunctionRep * getFunctionRep ( const PlotterBase * plotter ) const;
00150 
00156   FunctionRep * getFunctionRep ( const PlotterBase * plotter,
00157                                  const DataRep * data ) const;
00158   
00159 
00165   void fillTopLevelFunctionReps ( std::vector < FunctionRep * > & reps,
00166                                   const PlotterBase * plotter,
00167                                   const DataRep * data_rep ) const;
00168 
00171   FunctionRep * getComposite ( const PlotterBase * plotter,
00172                                FunctionRep * rep );
00173 
00176   FunctionBase *  addFunction ( PlotterBase * plotter, 
00177                                 const std::string & name );
00178 
00186   FunctionRep * addFunction ( PlotterBase * plotter,
00187                               const std::string & name,
00188                               FunctionRep * frep,
00189                               DataRep * data_rep );
00190 
00194   void addFunction ( PlotterBase * plotter, FunctionRep * func_rep );
00195 
00204   void addDataRep ( PlotterBase * plotter, DataRep * rep );
00205 
00215   FunctionRep * addFunctionRep ( PlotterBase * plotter,
00216                                  DataRep *,
00217                                  FunctionRep * frep,
00218                                  FunctionRep * func_rep );
00219 
00222   void removeFunction ( PlotterBase * plotter, FunctionRep * function );
00223 
00231   bool hasFunction ( const PlotterBase * plotter,
00232                      const DataRep * rep );
00233 
00237   int getUniqueNonFunctionIndex ( const PlotterBase * plotter ) const;
00238 
00245   const std::vector < std::string > & 
00246   functionNames ( PlotterBase *, DataRep * rep );
00247 
00250   const std::vector < std::string > &
00251   getFunctionNames () const;
00252 
00255   Fitter * getFitter ( const PlotterBase * plotter );
00256 
00260   const std::string & getFitterName ( const PlotterBase * plotter );
00261 
00268   bool setFitter ( const PlotterBase * plotter, const std::string & name );
00269 
00272   bool changeFitter ( const PlotterBase * plotter,
00273                       const DataRep * datarep,
00274                       const std::string & name );
00275 
00283   bool setFitter ( FunctionRep * frep, const std::string & name );
00284 
00288   void setDefaultFitter ( const std::string & name );
00289 
00296   bool fitFunction ( PlotterBase * plotter, FunctionRep * rep );
00297 
00305   bool tryFitFunction ( PlotterBase * plotter, FunctionRep * );
00306 
00313   bool fitFunction ( PlotterBase * plotter, unsigned int );
00314 
00322   void saveParameters ( PlotterBase * plotter );
00323 
00328   void restoreParameters ( PlotterBase * plotter );
00329 
00330 
00335   double getObjectiveValue ( const PlotterBase *, const DataRep * );
00336 
00339   const std::vector < std::vector < double > > &
00340   getCovarianceMatrix ( const PlotterBase * );
00341 
00346   double getChiSquared ( const PlotterBase * );
00347 
00352   int getDegreesOfFreedom ( const PlotterBase * );
00353 
00356   ViewBase * createFuncView ( const ViewFactory * factory,
00357                               PlotterBase * plotter,
00358                               const std::string & type );
00359 
00362   NTuple * createNTuple ( const PlotterBase * plotter,
00363                           const FunctionRep * rep );
00364 
00371   PlotterBase * createResidualsDisplay ( PlotterBase * plotter,
00372                                          const FunctionRep * );
00373 
00384   void ellipsoidNTuple ( PlotterBase * plotter, FunctionRep * ,
00385                          NTuple* nt, int n,
00386                          double & xmin, double & xmax,
00387                          double & ymin, double & ymax );
00388   
00393   PlotterBase * createNewEllipsoidDisplay ( PlotterBase * plotter,
00394                                             FunctionRep * rep );
00395 
00400   PlotterBase * refreshEllipsoidDisplay ( PlotterBase * plotter,
00401                                           FunctionRep * );
00402     
00407   NTuple * ellipse( const std::vector< double > & xbar,
00408                     std::vector< std::vector < double > > & SigmaInv,
00409                     double Csq );
00410   
00413   int setEllpsoidParamIndex ( Axes::Type axes, int index );
00414 
00422   bool isCompatible ( const std::string & function,
00423                       const std::string & fitter );
00424 
00427   bool functionExists ( const std::string & name );
00428 
00430   void setFitRange ( PlotterBase * plotter, const Range & range );
00431 
00433   void setFitRange ( PlotterBase * plotter, double low, double high );
00434 
00438   void setTupleCut ( FunctionRep * rep );
00439 
00443   void setTupleCut ( const PlotterBase * plotter,
00444                      DataRep * data_rep );
00445 
00448   void removeTupleCut ( const PlotterBase * plotter,
00449                         DataRep * data_rep );
00450 
00451 };
00452 
00453 } // namespace hippodraw
00454 
00455 #endif // _FunctionController_H_

Generated for HippoDraw Class Library by doxygen