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