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