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