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