GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4FitDependency.cxx
Go to the documentation of this file.
1 // $Id: TGo4FitDependency.cxx 2769 2020-04-16 14:54:23Z 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 fuer 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 <iostream>
17 
18 #include "TFormula.h"
19 
21  TObject(), fxParameter(), fxExpression(), fdInitValue(0.), fiNumPar(0), fxFormula(0) {
22 }
23 
24 
25 TGo4FitDependency::TGo4FitDependency(const char* iParameter, const char* iExpression) :
26  TObject(), fxParameter(iParameter), fxExpression(iExpression), fdInitValue(0.), fiNumPar(0), fxFormula(0) {
27 }
28 
29 TGo4FitDependency::TGo4FitDependency(const char* iParameter, Double_t InitValue) :
30  TObject(), fxParameter(iParameter), fxExpression(), fdInitValue(InitValue), fiNumPar(0), fxFormula(0) {
31 }
32 
34  if (fxFormula) delete fxFormula;
35 }
36 
37 void TGo4FitDependency::SetParameter(const char* iParameter) {
38  fxParameter = iParameter;
39 }
40 
41 void TGo4FitDependency::SetInitValue(Double_t InitValue)
42 {
43  fxExpression.Remove(0);
44  fdInitValue = InitValue;
45 
46 }
47 void TGo4FitDependency::SetExpression(const char* iExpression)
48 {
49  fxExpression = iExpression;
50 }
51 
52 void TGo4FitDependency::Initialize(Int_t iNumPar, const char* iFormula)
53 {
54  fiNumPar = iNumPar;
55  if (iFormula) {
56  if (fxFormula) delete fxFormula;
57  fxFormula = new TFormula("", iFormula);
58  } else fxFormula=0;
59 }
60 
61 Double_t TGo4FitDependency::ExecuteDependency(Double_t* Params)
62 {
63  Double_t res = (fxFormula!=0) ? fxFormula->EvalPar(0,Params) : fdInitValue;
64  if (fiNumPar>=0) Params[fiNumPar] = res;
65  return res;
66 }
67 
69  if (fxFormula) { delete fxFormula; fxFormula=0; }
70 }
71 
72 void TGo4FitDependency::Print(Option_t* option) const
73 {
74  std::cout << "Pars dependency: " << fxParameter << " = ";
75  if (fxExpression.Length()>0) std::cout << fxExpression << std::endl;
76  else std::cout << fdInitValue << std::endl;
77 }
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