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