GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4FitterConfig.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 "TGo4FitterConfig.h"
15 
16 #include <iostream>
17 
18 #include "TGo4FitterAbstract.h"
19 #include "TGo4FitParameter.h"
20 #include "TGo4FitDependency.h"
21 
23  : TGo4FitterAction(), fxParsCfg(), fxParsNew(), fxParsInit(), fxParsDepend(), fxResults(), fbFixedByDefault(kFALSE)
24 {
25 }
26 
27 TGo4FitterConfig::TGo4FitterConfig(const char *iName, const char *iTitle)
28  : TGo4FitterAction(iName, iTitle), fxParsCfg(kTRUE), fxParsNew(kTRUE), fxParsInit(), fxParsDepend(), fxResults(),
29  fbFixedByDefault(kFALSE)
30 {
31  fxParsInit.SetOwner(kTRUE);
32  fxParsDepend.SetOwner(kTRUE);
33  fxResults.SetOwner(kTRUE);
34 }
35 
37 
39 {
40  TGo4FitParameter *par = fxParsCfg.FindPar(ParName);
41  if (!par)
42  par = fxParsCfg.CreatePar(ParName, "config", 0.);
43  return par;
44 }
45 
46 Bool_t TGo4FitterConfig::SetParFixed(const char *ParName, Bool_t iFixed)
47 {
48  TGo4FitParameter *par = MakeParForProperties(ParName);
49  if (par)
50  par->SetFixed(iFixed);
51  return par != nullptr;
52 }
53 
54 Bool_t TGo4FitterConfig::SetParRange(const char *ParName, Double_t RangeMin, Double_t RangeMax)
55 {
56  TGo4FitParameter *par = MakeParForProperties(ParName);
57  if (par)
58  par->SetRange(RangeMin, RangeMax);
59  return par != nullptr;
60 }
61 
62 Bool_t TGo4FitterConfig::SetParEpsilon(const char *ParName, Double_t Epsilon)
63 {
64  TGo4FitParameter *par = MakeParForProperties(ParName);
65  if (par)
66  par->SetEpsilon(Epsilon);
67  return par != nullptr;
68 }
69 
70 Bool_t TGo4FitterConfig::GetParFixed(const char *ParName)
71 {
72  return fxParsCfg.GetParFixed(ParName);
73 }
74 
75 Bool_t TGo4FitterConfig::GetParRange(const char *ParName, Double_t &RangeMin, Double_t &RangeMax)
76 {
77  return fxParsCfg.GetParRange(ParName, RangeMin, RangeMax);
78 }
79 
80 Bool_t TGo4FitterConfig::GetParEpsilon(const char *ParName, Double_t &Epsilon)
81 {
82  return fxParsCfg.GetParEpsilon(ParName, Epsilon);
83 }
84 
85 TGo4FitDependency *TGo4FitterConfig::FindDepen(const char *FullName, TObjArray *list)
86 {
87  for (Int_t n = 0; n <= list->GetLast(); n++) {
88  TGo4FitDependency *par = (TGo4FitDependency *)list->At(n);
89  if (strcmp(par->GetParameter().Data(), FullName) == 0)
90  return par;
91  }
92  return nullptr;
93 }
94 
95 void TGo4FitterConfig::SetParInit(const char *FullName, Double_t iValue)
96 {
97  TGo4FitDependency *par = FindDepen(FullName, &fxParsInit);
98  if (par)
99  par->SetInitValue(iValue);
100  else
101  fxParsInit.Add(new TGo4FitDependency(FullName, iValue));
102 }
103 
104 void TGo4FitterConfig::SetParInit(const char *FullName, const char *iExpression)
105 {
106  TGo4FitDependency *par = FindDepen(FullName, &fxParsInit);
107  if (par)
108  par->SetExpression(iExpression);
109  else
110  fxParsInit.Add(new TGo4FitDependency(FullName, iExpression));
111 }
112 
113 void TGo4FitterConfig::SetParDepend(const char *FullName, const char *iExpression)
114 {
115  TGo4FitDependency *par = FindDepen(FullName, &fxParsDepend);
116  if (par)
117  par->SetExpression(iExpression);
118  else
119  fxParsDepend.Add(new TGo4FitDependency(FullName, iExpression));
120 }
121 
122 void TGo4FitterConfig::AddResult(const char *Expression)
123 {
124  fxResults.Add(new TGo4FitDependency("", Expression));
125 }
126 
127 void TGo4FitterConfig::AddResult(Double_t Value)
128 {
129  fxResults.Add(new TGo4FitDependency("", Value));
130 }
131 
133 {
134  if (Fitter)
135  Fitter->ApplyConfig(this);
136 }
137 
138 void TGo4FitterConfig::Print(Option_t *option) const
139 {
140  TGo4FitterAction::Print(option);
141  std::cout << "List of minimization config for parameters: " << std::endl;
142  fxParsCfg.Print(option);
143  std::cout << "List of new parameters declarations: " << std::endl;
144  fxParsNew.Print(option);
145  std::cout << "Order of parameters initialization: " << std::endl;
146  fxParsInit.Print(option);
147  std::cout << "Dependency for parameters: " << std::endl;
148  fxParsDepend.Print(option);
149  std::cout << "Results values: " << std::endl;
150  fxResults.Print(option);
151 }
virtual Bool_t SetParEpsilon(const char *ParName, Double_t Epsilon)
TGo4FitDependency * FindDepen(const char *FullName, TObjArray *list)
TGo4FitParameter * MakeParForProperties(const char *ParName)
void SetExpression(const char *iExpression)
TGo4FitParameter * CreatePar(const char *ParName, const char *Title, Double_t iValue=0)
virtual Bool_t GetParEpsilon(const char *ParName, Double_t &Epsilon)
void SetParDepend(const char *FullName, const char *iExpression)
virtual Bool_t GetParEpsilon(const char *ParName, Double_t &Epsilon)
void DoAction(TGo4FitterAbstract *Fitter) override
TGo4FitParsList fxParsNew
virtual Bool_t GetParFixed(const char *ParName)
virtual ~TGo4FitterConfig()
void SetInitValue(Double_t InitValue)
void SetParInit(const char *FullName, Double_t iValue)
TGo4FitParameter * FindPar(const char *ParName)
virtual Bool_t GetParRange(const char *ParName, Double_t &RangeMin, Double_t &RangeMax)
const TString & GetParameter() const
void Print(Option_t *option="") const override
virtual Bool_t GetParFixed(const char *ParName)
void AddResult(const char *Expression)
TGo4FitParsList fxParsCfg
void SetEpsilon(Double_t iEpsilon)
void Print(Option_t *option="") const override
void Print(Option_t *option="") const override
void SetFixed(Bool_t iFixed)
Bool_t ApplyConfig(TGo4FitterConfig *Config)
virtual Bool_t SetParFixed(const char *ParName, Bool_t iFixed=kTRUE)
void SetRange(Double_t iRangeMin, Double_t iRangeMax)
virtual Bool_t GetParRange(const char *ParName, Double_t &RangeMin, Double_t &RangeMax)
virtual Bool_t SetParRange(const char *ParName, Double_t RangeMin, Double_t RangeMax)