00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4FitDependency.h"
00017
00018 #include "Riostream.h"
00019
00020 #include "TFormula.h"
00021
00022 TGo4FitDependency::TGo4FitDependency() :
00023 TObject(), fxParameter(), fxExpression(), fdInitValue(0.), fiNumPar(0), fxFormula(0) {
00024 }
00025
00026
00027 TGo4FitDependency::TGo4FitDependency(const char* iParameter, const char* iExpression) :
00028 TObject(), fxParameter(iParameter), fxExpression(iExpression), fdInitValue(0.), fiNumPar(0), fxFormula(0) {
00029 }
00030
00031 TGo4FitDependency::TGo4FitDependency(const char* iParameter, Double_t InitValue) :
00032 TObject(), fxParameter(iParameter), fxExpression(), fdInitValue(InitValue), fiNumPar(0), fxFormula(0) {
00033 }
00034
00035 TGo4FitDependency::~TGo4FitDependency() {
00036 if (fxFormula) delete fxFormula;
00037 }
00038
00039 void TGo4FitDependency::SetParameter(const char* iParameter) {
00040 fxParameter = iParameter;
00041 }
00042
00043 void TGo4FitDependency::SetInitValue(Double_t InitValue)
00044 {
00045 fxExpression.Remove(0);
00046 fdInitValue = InitValue;
00047
00048 }
00049 void TGo4FitDependency::SetExpression(const char* iExpression)
00050 {
00051 fxExpression = iExpression;
00052 }
00053
00054 void TGo4FitDependency::Initialize(Int_t iNumPar, const char* iFormula)
00055 {
00056 fiNumPar = iNumPar;
00057 if (iFormula) {
00058 if (fxFormula) delete fxFormula;
00059 fxFormula = new TFormula("", iFormula);
00060 } else fxFormula=0;
00061 }
00062
00063 Double_t TGo4FitDependency::ExecuteDependency(Double_t* Params)
00064 {
00065 Double_t res = (fxFormula!=0) ? fxFormula->EvalPar(0,Params) : fdInitValue;
00066 if (fiNumPar>=0) Params[fiNumPar] = res;
00067 return res;
00068 }
00069
00070 void TGo4FitDependency::Finalize() {
00071 if (fxFormula) { delete fxFormula; fxFormula=0; }
00072 }
00073
00074 void TGo4FitDependency::Print(Option_t* option) const
00075 {
00076 cout << "Pars dependency: " << fxParameter << " = ";
00077 if (fxExpression.Length()>0) cout << fxExpression << endl;
00078 else cout << fdInitValue << endl;
00079 }
00080
00081