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