00001 #ifndef SCTDATA_FITOBJECT_H
00002 #define SCTDATA_FITOBJECT_H
00003
00004 #include "Sct/Streamable.h"
00005 #include <vector>
00006 #include <string>
00007 #include <iostream>
00008 #include <memory>
00009 #include "Sct/Exception.h"
00010 #include "Sct/LogicErrors.h"
00011
00012 class TF1;
00013
00014 using namespace std;
00015 using Sct::LogicError;
00016
00017 namespace SctData{
00018
00039 class FitObject : public virtual Sct::Streamable {
00040 public:
00041
00046 virtual shared_ptr<FitObject> clone() const throw() = 0;
00047
00054 virtual auto_ptr<TF1> makeRootTF1() const throw(LogicError);
00055
00060 FitObject& operator=(const TF1&) throw(LogicError);
00061
00063
00064 void print() const throw(LogicError) ;
00065
00066
00067
00068
00070 inline int getNDim() const throw(){ return m_varMax.size();}
00071
00073 inline int getNPar() const throw() { return m_parameter.size();}
00074
00076 char* getParName(const int ipar) const throw(LogicError) ;
00077
00082 int getParIndex(const string& name) const throw(LogicError) ;
00083
00085
00086
00087 double getParameter(const int ipar) const throw(LogicError);
00090 double getParameter(const string& name) const throw(LogicError) ;
00092
00096 double getParError(const int ipar) const throw(LogicError);
00097
00101 double getParError(const string& name) const throw(LogicError);
00102
00104 double getChiSquared() const throw() {return m_chiSquared;}
00105
00107 int getNDF() const throw() { return m_nDF;}
00108
00110 double getVarMax(const int ivar) const throw(LogicError);
00111
00113 double getVarMin(const int ivar) const throw(LogicError);
00114
00116 void setVarMax(const int ivar, const double value) throw(LogicError) ;
00117
00119 void setVarMin(const int ivar, const double value) throw(LogicError) ;
00120
00122 char* getFormula() const throw() {
00123 return const_cast <char*> ( m_formula.c_str() ) ;
00124 }
00125
00128 void fixParameter(int ipar, bool fix) ;
00129
00132 bool isFixed(int ipar) const;
00133
00135 void setParameter(const int ipar, const double value) throw (LogicError) ;
00136
00138 void setParError(const int ipar, const double value) throw (LogicError) ;
00139
00141
00142 void setParName(const int ipar, const char* name) throw (LogicError) ;
00143
00145 void setChiSquared(const double c) throw() { m_chiSquared=c; }
00146
00148 void setNDF(const int d) throw() { m_nDF=d; }
00149
00150
00152 virtual ~FitObject() throw() {;}
00153
00155 void reset() throw() ;
00156 protected:
00157
00158 vector <double> m_parameter;
00159 vector <double> m_parError;
00160 vector <string> m_parName;
00161 vector <bool> m_parFixed;
00162 vector <double> m_varMax;
00163 vector <double> m_varMin;
00164 double m_chiSquared;
00165 int m_nDF;
00166 string m_formula ;
00167
00168
00171 FitObject(string formula, unsigned int nPar, const vector<string>& parNames, unsigned int nDim=1);
00172
00174 FitObject(string formula, unsigned int nPar, const vector<string>& parNames, const TF1& f) ;
00175
00181 virtual auto_ptr<TF1> makeBasicRootTF1() const throw(LogicError) =0;
00182 };
00183
00184
00185 inline double FitObject::getParameter(const string& name) const throw(LogicError) {
00186 return getParameter(getParIndex(name));
00187 }
00188
00189 inline double FitObject::getParError(const string& name) const throw(LogicError) {
00190 return getParError(getParIndex(name));
00191 }
00192
00193 ostream& operator << (ostream&, const SctData::FitObject& ) throw (LogicError) ;
00194
00195 }
00196
00197
00198 #endif // #ifndef SCTDATA_FITOBJECT_H