00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4FitterConfig.h"
00017
00018 #include "Riostream.h"
00019
00020 #include "TString.h"
00021
00022 #include "TGo4FitterAbstract.h"
00023 #include "TGo4FitParameter.h"
00024 #include "TGo4FitDependency.h"
00025
00026 TGo4FitterConfig::TGo4FitterConfig() :
00027 TGo4FitterAction(),
00028 fxParsCfg(), fxParsNew(), fxParsInit(), fxParsDepend(), fxResults(), fbFixedByDefault(kFALSE) {
00029 }
00030
00031 TGo4FitterConfig::TGo4FitterConfig(const char* iName, const char* iTitle) :
00032 TGo4FitterAction(iName,iTitle),
00033 fxParsCfg(kTRUE), fxParsNew(kTRUE), fxParsInit(), fxParsDepend(), fxResults(), fbFixedByDefault(kFALSE) {
00034 fxParsInit.SetOwner(kTRUE);
00035 fxParsDepend.SetOwner(kTRUE);
00036 fxResults.SetOwner(kTRUE);
00037 }
00038
00039 TGo4FitterConfig::~TGo4FitterConfig() {
00040 }
00041
00042 TGo4FitParameter* TGo4FitterConfig::MakeParForProperties(const char* ParName) {
00043 TGo4FitParameter* par = fxParsCfg.FindPar(ParName);
00044 if (par==0) par = fxParsCfg.CreatePar(ParName,"config",0.);
00045 return par;
00046 }
00047
00048 Bool_t TGo4FitterConfig::SetParFixed(const char* ParName, Bool_t iFixed) {
00049 TGo4FitParameter* par = MakeParForProperties(ParName);
00050 if(par) par->SetFixed(iFixed);
00051 return (par!=0);
00052 }
00053
00054 Bool_t TGo4FitterConfig::SetParRange(const char* ParName, Double_t RangeMin, Double_t RangeMax) {
00055 TGo4FitParameter* par = MakeParForProperties(ParName);
00056 if(par) par->SetRange(RangeMin,RangeMax);
00057 return (par!=0);
00058 }
00059
00060 Bool_t TGo4FitterConfig::SetParEpsilon(const char* ParName, Double_t Epsilon) {
00061 TGo4FitParameter* par = MakeParForProperties(ParName);
00062 if(par) par->SetEpsilon(Epsilon);
00063 return (par!=0);
00064 }
00065
00066 Bool_t TGo4FitterConfig::GetParFixed(const char* ParName) {
00067 return fxParsCfg.GetParFixed(ParName);
00068 }
00069
00070 Bool_t TGo4FitterConfig::GetParRange(const char * ParName, Double_t & RangeMin, Double_t & RangeMax) {
00071 return fxParsCfg.GetParRange(ParName, RangeMin, RangeMax);
00072 }
00073
00074 Bool_t TGo4FitterConfig::GetParEpsilon(const char* ParName, Double_t& Epsilon) {
00075 return fxParsCfg.GetParEpsilon(ParName, Epsilon);
00076 }
00077
00078 TGo4FitDependency* TGo4FitterConfig::FindDepen(const char* FullName, TObjArray* list) {
00079 for(Int_t n=0;n<=list->GetLast();n++) {
00080 TGo4FitDependency* par = (TGo4FitDependency*) list->At(n);
00081 if (strcmp(par->GetParameter().Data(),FullName)==0) return par;
00082 }
00083 return 0;
00084 }
00085
00086 void TGo4FitterConfig::SetParInit(const char* FullName, Double_t iValue) {
00087 TGo4FitDependency* par = FindDepen(FullName,&fxParsInit);
00088 if(par) par->SetInitValue(iValue);
00089 else fxParsInit.Add( new TGo4FitDependency(FullName,iValue));
00090 }
00091
00092 void TGo4FitterConfig::SetParInit(const char* FullName, const char* iExpression) {
00093 TGo4FitDependency* par = FindDepen(FullName,&fxParsInit);
00094 if(par) par->SetExpression(iExpression);
00095 else fxParsInit.Add( new TGo4FitDependency(FullName,iExpression));
00096 }
00097
00098 void TGo4FitterConfig::SetParDepend(const char* FullName, const char* iExpression) {
00099 TGo4FitDependency* par = FindDepen(FullName,&fxParsDepend);
00100 if(par) par->SetExpression(iExpression);
00101 else fxParsDepend.Add( new TGo4FitDependency(FullName,iExpression));
00102 }
00103
00104 void TGo4FitterConfig::AddResult(const char* Expression) {
00105 fxResults.Add( new TGo4FitDependency("",Expression));
00106 }
00107
00108 void TGo4FitterConfig::AddResult(Double_t Value) {
00109 fxResults.Add( new TGo4FitDependency("",Value));
00110 }
00111
00112 void TGo4FitterConfig::DoAction(TGo4FitterAbstract* Fitter) {
00113 if (Fitter) Fitter->ApplyConfig(this);
00114 }
00115
00116 void TGo4FitterConfig::Print(Option_t* option) const {
00117 TGo4FitterAction::Print(option);
00118 cout << "List of minimization config for parameters: " << endl;
00119 fxParsCfg.Print(option);
00120 cout << "List of new parameters declarations: " << endl;
00121 fxParsNew.Print(option);
00122 cout << "Order of parameters initialization: " << endl;
00123 fxParsInit.Print(option);
00124 cout << "Dependency for parameters: " << endl;
00125 fxParsDepend.Print(option);
00126 cout << "Results values: " << endl;
00127 fxResults.Print(option);
00128 }
00129
00130