FitObject.h

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 Sct::LogicError;
00015 
00016 namespace SctData{
00017 
00038 class FitObject : public virtual Sct::Streamable {
00039  public:
00040 
00045     virtual shared_ptr<FitObject> clone() const throw() = 0;
00046     
00053     virtual std::auto_ptr<TF1> makeRootTF1() const throw(LogicError);
00054 
00059     FitObject& operator=(const TF1&) throw(LogicError);
00060 
00062 
00063     void print() const throw(LogicError) ;
00064 
00065     //Serializable override
00066     //virtual string getClassName() const throw() ;
00067 
00069     inline int getNDim() const throw(){ return m_varMax.size();}
00070 
00072     inline int getNPar() const throw() { return m_parameter.size();}
00073 
00075     char* getParName(const int ipar) const throw(LogicError) ;
00076 
00081     int getParIndex(const std::string& name) const throw(LogicError) ;
00082 
00084 
00085 
00086     double getParameter(const int ipar) const throw(LogicError);
00089     double getParameter(const std::string& name) const throw(LogicError) ;
00091 
00095     double getParError(const int ipar) const throw(LogicError);
00096 
00100     double getParError(const std::string& name) const throw(LogicError);
00101 
00103     double getChiSquared() const throw() {return m_chiSquared;}
00104 
00106     int getNDF() const throw() { return m_nDF;}
00107 
00109     double getVarMax(const int ivar) const throw(LogicError);
00110 
00112     double getVarMin(const int ivar) const throw(LogicError);
00113 
00115     void setVarMax(const int ivar, const double value) throw(LogicError) ;
00116 
00118     void setVarMin(const int ivar, const double value) throw(LogicError) ;
00119 
00121     char* getFormula() const throw() {
00122     return const_cast <char*> ( m_formula.c_str() ) ;
00123     }
00124 
00127     void fixParameter(int ipar, bool fix) ;
00128     
00131     bool isFixed(int ipar) const;
00132     
00134     void setParameter(const int ipar, const double value) throw (LogicError) ;
00135 
00137     void setParError(const int ipar, const double value) throw (LogicError) ;
00138 
00140 
00141     void setParName(const int ipar, const char* name) throw (LogicError) ;
00142     
00144     void setChiSquared(const double c) throw() { m_chiSquared=c; }
00145 
00147     void setNDF(const int d) throw() { m_nDF=d; }
00148 
00149 
00151     virtual ~FitObject() throw() {;}
00152 
00154     void reset() throw() ;
00155 protected:
00156     //Most data objects protected. Accessible through setXxx and getXxx functions.
00157     std::vector <double> m_parameter;     
00158     std::vector <double> m_parError;      
00159     std::vector <std::string> m_parName;       
00160     std::vector <bool> m_parFixed;        
00161     std::vector <double> m_varMax;        
00162     std::vector <double> m_varMin;        
00163     double m_chiSquared;             
00164     int m_nDF;                       
00165     std::string m_formula ;               
00166 
00167 
00170     FitObject(std::string formula, unsigned int nPar, const std::vector<std::string>& parNames, unsigned int nDim=1);
00171 
00173     FitObject(std::string formula, unsigned int nPar, const std::vector<std::string>& parNames, const TF1& f) ;
00174 
00180     virtual std::auto_ptr<TF1> makeBasicRootTF1() const throw(LogicError) =0;
00181 }; // end declaration of FitObject
00182 
00183 //Inlines
00184 inline double FitObject::getParameter(const std::string& name) const throw(LogicError) {
00185     return getParameter(getParIndex(name));
00186 }
00187 
00188 inline double FitObject::getParError(const std::string& name) const throw(LogicError) {
00189     return getParError(getParIndex(name));
00190 }
00191 
00192 std::ostream& operator << (std::ostream&, const SctData::FitObject& ) throw (LogicError) ;
00193 
00194 } 
00195 
00196 
00197 #endif // #ifndef SCTDATA_FITOBJECT_H

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