GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4FitModelPolynom.cxx
Go to the documentation of this file.
1 // $Id: TGo4FitModelPolynom.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 "TGo4FitModelPolynom.h"
15 
16 #include "TMath.h"
17 #include "TArrayD.h"
18 
19 #include "TGo4FitParameter.h"
20 
22 }
23 
24 TGo4FitModelPolynom::TGo4FitModelPolynom(const char* iName, Double_t iOrderX) :
25  TGo4FitModel(iName,"polynomial function",kTRUE), fxAllOrders(0) {
26  CreateOrdersPars(&iOrderX, 0, 0);
28 }
29 
30 TGo4FitModelPolynom::TGo4FitModelPolynom(const char* iName, Double_t iOrderX, Double_t iOrderY) :
31  TGo4FitModel(iName,"polynomial function",kTRUE), fxAllOrders(0) {
32  Double_t arr[2] = { iOrderX, iOrderY };
33  CreateOrdersPars(arr, 0, 1);
35 }
36 
37 TGo4FitModelPolynom::TGo4FitModelPolynom(const char* iName, Double_t iOrderX, Double_t iOrderY, Double_t iOrderZ) :
38  TGo4FitModel(iName,"polynomial function",kTRUE), fxAllOrders(0) {
39  Double_t arr[3] = { iOrderX, iOrderY, iOrderZ };
40  CreateOrdersPars(arr, 0, 2);
42 }
43 
44 TGo4FitModelPolynom::TGo4FitModelPolynom(const char* iName, const TArrayD& iPolynomOrders) :
45  TGo4FitModel(iName,"polynomial function",kTRUE), fxAllOrders(0) {
46  CreateOrdersPars(iPolynomOrders.GetArray(),0,iPolynomOrders.GetSize()-1);
48 }
49 
51  if (fxAllOrders) delete fxAllOrders;
52 }
53 
54 void TGo4FitModelPolynom::CreateOrdersPars(const Double_t* orders, Int_t startaxis, Int_t maxaxis, Int_t AtIndx) {
55  for(Int_t n=startaxis;n<=maxaxis;n++) {
56  TString infostr;
57  infostr.Form("Polynom order for axis %d",n);
58  if (orders) NewParameter(GetOrderParName(n),infostr.Data(),orders[n],kTRUE, AtIndx);
59  else NewParameter(GetOrderParName(n),infostr.Data(),0.,kTRUE, AtIndx);
60  }
61 }
62 
64 {
65  TString res;
66  res.Form("Order%d",naxis);
67  return res;
68 }
69 
70 Double_t TGo4FitModelPolynom::GetPolynomOrder(Int_t naxis) {
72  if (par==0) return 0.;
73  else return par->GetValue();
74 }
75 
77  Int_t naxis = 0;
78  while (FindPar(GetOrderParName(naxis))!=0) naxis++;
79  return naxis-1;
80 }
81 
82 Bool_t TGo4FitModelPolynom::SetMaxNumAxis(Int_t numaxis) {
83  Int_t numaxisold = GetMaxNumAxis();
84  if ((numaxis<0) || (numaxis==numaxisold)) return kFALSE;
85  if (numaxis<numaxisold)
86  for(Int_t n=numaxis+1;n<=numaxisold;n++)
88  else {
89  Int_t indx = GetParIndex(FindPar(GetOrderParName(numaxisold)));
90  CreateOrdersPars(0,numaxisold+1,numaxis, indx+1);
91  }
92 
93  return kTRUE;
94 }
95 
96 Bool_t TGo4FitModelPolynom::BeforeEval(Int_t NDimension) {
97  if (fxAllOrders) delete fxAllOrders;
98  Par_ndim = NDimension;
99  fxAllOrders = new TArrayD(Par_ndim);
100  fxAllOrders->Reset(0.);
101  Par_orders = fxAllOrders->GetArray();
102  for(Int_t i=0;i<Par_ndim;i++)
104  return kTRUE;
105 }
106 
107 Double_t TGo4FitModelPolynom::EvalN(const Double_t* v) {
108  Double_t zn = 1.;
109  for(Int_t n=0;n<Par_ndim;n++)
110  zn *= TMath::Power(v[n],Par_orders[n]);
111  return zn;
112 }
113 
115  if (fxAllOrders) { delete fxAllOrders; fxAllOrders=0; }
116 }
117 
118 void TGo4FitModelPolynom::Print(Option_t* option) const {
119  TGo4FitModel::Print(option);
120 }
TString GetOrderParName(Int_t naxis)
virtual Bool_t BeforeEval(Int_t NDimension)
TGo4FitParameter * NewParameter(const char *Name, const char *Title, Double_t iValue=0., Bool_t Fixed=kFALSE, Int_t AtIndx=-1)
Bool_t RemovePar(const char *name)
TGo4FitParameter * FindPar(const char *ParName)
virtual void Print(Option_t *option) const
Bool_t SetMaxNumAxis(Int_t numaxis)
Int_t GetParIndex(const TGo4FitParameter *par)
Double_t GetValue() const
virtual Double_t EvalN(const Double_t *v)
void CreateOrdersPars(const Double_t *orders, Int_t startaxis, Int_t maxaxis, Int_t AtIndx=-1)
Double_t GetPolynomOrder(Int_t naxis)
void SetBackgroundGroupIndex()
Definition: TGo4FitModel.h:114
virtual void Print(Option_t *option) const