GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
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
26
27TGo4FitterConfig::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
46Bool_t TGo4FitterConfig::SetParFixed(const char *ParName, Bool_t iFixed)
47{
49 if (par)
50 par->SetFixed(iFixed);
51 return par != nullptr;
52}
53
54Bool_t TGo4FitterConfig::SetParRange(const char *ParName, Double_t RangeMin, Double_t RangeMax)
55{
57 if (par)
58 par->SetRange(RangeMin, RangeMax);
59 return par != nullptr;
60}
61
62Bool_t TGo4FitterConfig::SetParEpsilon(const char *ParName, Double_t Epsilon)
63{
65 if (par)
66 par->SetEpsilon(Epsilon);
67 return par != nullptr;
68}
69
70Bool_t TGo4FitterConfig::GetParFixed(const char *ParName)
71{
72 return fxParsCfg.GetParFixed(ParName);
73}
74
75Bool_t TGo4FitterConfig::GetParRange(const char *ParName, Double_t &RangeMin, Double_t &RangeMax)
76{
77 return fxParsCfg.GetParRange(ParName, RangeMin, RangeMax);
78}
79
80Bool_t TGo4FitterConfig::GetParEpsilon(const char *ParName, Double_t &Epsilon)
81{
82 return fxParsCfg.GetParEpsilon(ParName, Epsilon);
83}
84
85TGo4FitDependency *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
95void 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
104void 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
113void 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
122void TGo4FitterConfig::AddResult(const char *Expression)
123{
124 fxResults.Add(new TGo4FitDependency("", Expression));
125}
126
127void TGo4FitterConfig::AddResult(Double_t Value)
128{
129 fxResults.Add(new TGo4FitDependency("", Value));
130}
131
133{
134 if (Fitter)
135 Fitter->ApplyConfig(this);
136}
137
138void TGo4FitterConfig::Print(Option_t *option) const
139{
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}
Object, used to store dependency of one parameter from other, calculated via expression.
void SetExpression(const char *iExpression)
const TString & GetParameter() const
void SetInitValue(Double_t InitValue)
void Print(Option_t *option="") const override
Model and data objects parameter.
void SetEpsilon(Double_t iEpsilon)
Return epsilon value of parameter.
void SetRange(Double_t iRangeMin, Double_t iRangeMax)
Set range minimum and maximum values.
void SetFixed(Bool_t iFixed)
Set status of parameter fixed or not.
Abstract fitter class.
Bool_t ApplyConfig(TGo4FitterConfig *Config)
Set active configuration object.
TGo4FitterAction()
Default constructor.
void Print(Option_t *option="") const override
Print information on standard output.
virtual Bool_t SetParFixed(const char *ParName, Bool_t iFixed=kTRUE)
Sets, that parameter with ParName should be fixed or not.
void SetParInit(const char *FullName, Double_t iValue)
Set initial value for parameter.
virtual Bool_t SetParEpsilon(const char *ParName, Double_t Epsilon)
Sets epsilon for parameter ParName.
TGo4FitParsList fxParsNew
List of parameters object, which can be used in dependency calculations and minimization.
TGo4FitParameter * MakeParForProperties(const char *ParName)
Bool_t fbFixedByDefault
Determine, if all parameters should be fixed by default.
void SetParDepend(const char *FullName, const char *iExpression)
Set dependency expression for parameter.
void DoAction(TGo4FitterAbstract *Fitter) override
Do configuration action.
TGo4FitterConfig()
Default constructor.
virtual Bool_t GetParEpsilon(const char *ParName, Double_t &Epsilon)
Return kTRUE, if parameter ParName has explicit configuration for epsilon value in minimization.
TObjArray fxResults
Array of TGo4FitDependency objects, which represent equations to calculate result values in fitter.
virtual Bool_t GetParFixed(const char *ParName)
Return kTRUE, if parameter ParName should be fixed in minimization.
TObjArray fxParsDepend
Array of dependencies (TGo4FitDependency) for introducing dependency between fitted parameters.
virtual Bool_t GetParRange(const char *ParName, Double_t &RangeMin, Double_t &RangeMax)
Return kTRUE, if parameter ParName has explicit configuration for valid range in minimization.
TObjArray fxParsInit
Array of dependencies for parameters initialization.
void AddResult(const char *Expression)
Add expression for calculating result value.
TGo4FitDependency * FindDepen(const char *FullName, TObjArray *list)
virtual Bool_t SetParRange(const char *ParName, Double_t RangeMin, Double_t RangeMax)
Sets valid range for parameter ParName.
virtual ~TGo4FitterConfig()
Destroys TGo4FitterConfig object.
TGo4FitParsList fxParsCfg
List of parameters objects, used for alternative configuration of parameters, which should be fitted.