GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4FitterConfig.cxx
Go to the documentation of this file.
1 // $Id: TGo4FitterConfig.cxx 2749 2020-04-16 10:05:15Z 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 "TGo4FitterConfig.h"
15 
16 #include <iostream>
17 
18 #include "TGo4FitterAbstract.h"
19 #include "TGo4FitParameter.h"
20 #include "TGo4FitDependency.h"
21 
24  fxParsCfg(), fxParsNew(), fxParsInit(), fxParsDepend(), fxResults(), fbFixedByDefault(kFALSE) {
25 }
26 
27 TGo4FitterConfig::TGo4FitterConfig(const char* iName, const char* iTitle) :
28  TGo4FitterAction(iName,iTitle),
29  fxParsCfg(kTRUE), fxParsNew(kTRUE), fxParsInit(), fxParsDepend(), fxResults(), fbFixedByDefault(kFALSE) {
30  fxParsInit.SetOwner(kTRUE);
31  fxParsDepend.SetOwner(kTRUE);
32  fxResults.SetOwner(kTRUE);
33 }
34 
36 }
37 
39  TGo4FitParameter* par = fxParsCfg.FindPar(ParName);
40  if (par==0) par = fxParsCfg.CreatePar(ParName,"config",0.);
41  return par;
42 }
43 
44 Bool_t TGo4FitterConfig::SetParFixed(const char* ParName, Bool_t iFixed) {
45  TGo4FitParameter* par = MakeParForProperties(ParName);
46  if(par) par->SetFixed(iFixed);
47  return (par!=0);
48 }
49 
50 Bool_t TGo4FitterConfig::SetParRange(const char* ParName, Double_t RangeMin, Double_t RangeMax) {
51  TGo4FitParameter* par = MakeParForProperties(ParName);
52  if(par) par->SetRange(RangeMin,RangeMax);
53  return (par!=0);
54 }
55 
56 Bool_t TGo4FitterConfig::SetParEpsilon(const char* ParName, Double_t Epsilon) {
57  TGo4FitParameter* par = MakeParForProperties(ParName);
58  if(par) par->SetEpsilon(Epsilon);
59  return (par!=0);
60 }
61 
62 Bool_t TGo4FitterConfig::GetParFixed(const char* ParName) {
63  return fxParsCfg.GetParFixed(ParName);
64 }
65 
66 Bool_t TGo4FitterConfig::GetParRange(const char * ParName, Double_t & RangeMin, Double_t & RangeMax) {
67  return fxParsCfg.GetParRange(ParName, RangeMin, RangeMax);
68 }
69 
70 Bool_t TGo4FitterConfig::GetParEpsilon(const char* ParName, Double_t& Epsilon) {
71  return fxParsCfg.GetParEpsilon(ParName, Epsilon);
72 }
73 
74 TGo4FitDependency* TGo4FitterConfig::FindDepen(const char* FullName, TObjArray* list) {
75  for(Int_t n=0;n<=list->GetLast();n++) {
76  TGo4FitDependency* par = (TGo4FitDependency*) list->At(n);
77  if (strcmp(par->GetParameter().Data(),FullName)==0) return par;
78  }
79  return 0;
80 }
81 
82 void TGo4FitterConfig::SetParInit(const char* FullName, Double_t iValue) {
83  TGo4FitDependency* par = FindDepen(FullName,&fxParsInit);
84  if(par) par->SetInitValue(iValue);
85  else fxParsInit.Add( new TGo4FitDependency(FullName,iValue));
86 }
87 
88 void TGo4FitterConfig::SetParInit(const char* FullName, const char* iExpression) {
89  TGo4FitDependency* par = FindDepen(FullName,&fxParsInit);
90  if(par) par->SetExpression(iExpression);
91  else fxParsInit.Add( new TGo4FitDependency(FullName,iExpression));
92 }
93 
94 void TGo4FitterConfig::SetParDepend(const char* FullName, const char* iExpression) {
95  TGo4FitDependency* par = FindDepen(FullName,&fxParsDepend);
96  if(par) par->SetExpression(iExpression);
97  else fxParsDepend.Add( new TGo4FitDependency(FullName,iExpression));
98 }
99 
100 void TGo4FitterConfig::AddResult(const char* Expression) {
101  fxResults.Add( new TGo4FitDependency("",Expression));
102 }
103 
104 void TGo4FitterConfig::AddResult(Double_t Value) {
105  fxResults.Add( new TGo4FitDependency("",Value));
106 }
107 
109  if (Fitter) Fitter->ApplyConfig(this);
110 }
111 
112 void TGo4FitterConfig::Print(Option_t* option) const {
113  TGo4FitterAction::Print(option);
114  std::cout << "List of minimization config for parameters: " << std::endl;
115  fxParsCfg.Print(option);
116  std::cout << "List of new parameters declarations: " << std::endl;
117  fxParsNew.Print(option);
118  std::cout << "Order of parameters initialization: " << std::endl;
119  fxParsInit.Print(option);
120  std::cout << "Dependency for parameters: " << std::endl;
121  fxParsDepend.Print(option);
122  std::cout << "Results values: " << std::endl;
123  fxResults.Print(option);
124 }
virtual Bool_t SetParEpsilon(const char *ParName, Double_t Epsilon)
TGo4FitDependency * FindDepen(const char *FullName, TObjArray *list)
TGo4FitParameter * MakeParForProperties(const char *ParName)
const TString & GetParameter() const
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)
virtual void Print(Option_t *option) const
TGo4FitParsList fxParsNew
virtual Bool_t GetParFixed(const char *ParName)
void Print(Option_t *option) const
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)
virtual Bool_t GetParFixed(const char *ParName)
virtual void DoAction(TGo4FitterAbstract *Fitter)
virtual void Print(Option_t *option) const
void AddResult(const char *Expression)
TGo4FitParsList fxParsCfg
void SetEpsilon(Double_t iEpsilon)
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)