GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4FitDependency.cxx
Go to the documentation of this file.
1 // $Id: TGo4FitDependency.cxx 933 2013-01-29 15:27:58Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4FitDependency.h"
15 
16 #include "Riostream.h"
17 #include "TFormula.h"
18 
20  TObject(), fxParameter(), fxExpression(), fdInitValue(0.), fiNumPar(0), fxFormula(0) {
21 }
22 
23 
24 TGo4FitDependency::TGo4FitDependency(const char* iParameter, const char* iExpression) :
25  TObject(), fxParameter(iParameter), fxExpression(iExpression), fdInitValue(0.), fiNumPar(0), fxFormula(0) {
26 }
27 
28 TGo4FitDependency::TGo4FitDependency(const char* iParameter, Double_t InitValue) :
29  TObject(), fxParameter(iParameter), fxExpression(), fdInitValue(InitValue), fiNumPar(0), fxFormula(0) {
30 }
31 
33  if (fxFormula) delete fxFormula;
34 }
35 
36 void TGo4FitDependency::SetParameter(const char* iParameter) {
37  fxParameter = iParameter;
38 }
39 
40 void TGo4FitDependency::SetInitValue(Double_t InitValue)
41 {
42  fxExpression.Remove(0);
43  fdInitValue = InitValue;
44 
45 }
46 void TGo4FitDependency::SetExpression(const char* iExpression)
47 {
48  fxExpression = iExpression;
49 }
50 
51 void TGo4FitDependency::Initialize(Int_t iNumPar, const char* iFormula)
52 {
53  fiNumPar = iNumPar;
54  if (iFormula) {
55  if (fxFormula) delete fxFormula;
56  fxFormula = new TFormula("", iFormula);
57  } else fxFormula=0;
58 }
59 
60 Double_t TGo4FitDependency::ExecuteDependency(Double_t* Params)
61 {
62  Double_t res = (fxFormula!=0) ? fxFormula->EvalPar(0,Params) : fdInitValue;
63  if (fiNumPar>=0) Params[fiNumPar] = res;
64  return res;
65 }
66 
68  if (fxFormula) { delete fxFormula; fxFormula=0; }
69 }
70 
71 void TGo4FitDependency::Print(Option_t* option) const
72 {
73  std::cout << "Pars dependency: " << fxParameter << " = ";
74  if (fxExpression.Length()>0) std::cout << fxExpression << std::endl;
75  else std::cout << fdInitValue << std::endl;
76 }
void SetExpression(const char *iExpression)
void Initialize(Int_t iNumPar, const char *iFormula)
void SetParameter(const char *iParameter)
void SetInitValue(Double_t InitValue)
Double_t ExecuteDependency(Double_t *Params)
virtual void Print(Option_t *option) const