GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4FitDependency.cxx
Go to the documentation of this file.
1 // $Id$
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(nullptr) {
22 }
23 
24 
25 TGo4FitDependency::TGo4FitDependency(const char *iParameter, const char *iExpression) :
26  TObject(), fxParameter(iParameter), fxExpression(iExpression), fdInitValue(0.), fiNumPar(0), fxFormula(nullptr) {
27 }
28 
29 TGo4FitDependency::TGo4FitDependency(const char *iParameter, Double_t InitValue) :
30  TObject(), fxParameter(iParameter), fxExpression(), fdInitValue(InitValue), fiNumPar(0), fxFormula(nullptr) {
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 {
59  fxFormula = nullptr;
60  }
61 }
62 
63 Double_t TGo4FitDependency::ExecuteDependency(Double_t *Params)
64 {
65  Double_t res = fxFormula ? fxFormula->EvalPar(nullptr,Params) : fdInitValue;
66  if (fiNumPar >= 0) Params[fiNumPar] = res;
67  return res;
68 }
69 
71 {
72  if (fxFormula) {
73  delete fxFormula;
74  fxFormula = nullptr;
75  }
76 }
77 
78 void TGo4FitDependency::Print(Option_t *option) const
79 {
80  std::cout << "Pars dependency: " << fxParameter << " = ";
81  if (fxExpression.Length()>0) std::cout << fxExpression << std::endl;
82  else std::cout << fdInitValue << std::endl;
83 }
void SetExpression(const char *iExpression)
void Print(Option_t *option="") const override
void Initialize(Int_t iNumPar, const char *iFormula)
void SetParameter(const char *iParameter)
void SetInitValue(Double_t InitValue)
Double_t ExecuteDependency(Double_t *Params)