2 #include "TMDFParameters.h"
9 TArrayD *TMDFParameters::GetTerms(Double_t *x) {
10 TArrayD *TV =
new TArrayD[fNvar];
11 for (Int_t i = 0; i < fNvar; i++) {
12 Int_t N = fMaxPower[i];
14 if (xx < fVmin[i]) xx = fVmin[i];
15 if (xx > fVmax[i]) xx = fVmax[i];
16 Double_t X = 1 + 2./(fVmax[i] - fVmin[i])*(xx - fVmax[i]);
20 Tcheb(X,N,TV[i].GetArray());
25 Double_t TMDFParameters::Eval(Double_t *x) {
26 TArrayD *TV = GetTerms(x);
27 Double_t value = fMean;
28 for (Int_t i = 0; i < fNcoef; i++) {
29 Double_t term = fCoef[i];
31 for (Int_t j = fNvar - 1; j >= 0; j--) {
32 Int_t k = p%10; assert(k >= 0);
42 Double_t TMDFParameters::dEval(Double_t *x) {
43 TArrayD *TV = GetTerms(x);
45 for (Int_t i = 0; i < fNcoef; i++) {
46 Double_t term = fdCoef[i];
48 for (Int_t j = fNvar - 1; j >= 0; j--) {
49 Int_t k = p%10; assert(k >= 0);
56 return TMath::Sqrt(value);
59 Double_t *TMDFParameters::Tcheb(Double_t x, Int_t N, Double_t *T) {
60 T[0] = 1; T[1] = T[2] = 0;
61 for (Int_t j = 1; j <= N; j++) {
63 else T[j] = 2 * x * T[j-1] - T[j-2];
68 Double_t TMDFParameters::Func(Double_t *x, Double_t *p) {
69 if (! p)
return Instance()->Eval(x);
70 TArrayD X(Instance()->Nvar(),x);
72 for (Int_t i = 0; i < Instance()->Nvar(); i++) {
73 if (p[i] > -999.0) X[i] = p[i];
76 return Instance()->Eval(X.GetArray());
79 TF1 *TMDFParameters::ProjectionX(Int_t code) {
80 if (code < 0 || code >= Instance()->Nvar())
return 0;
81 TF1 *f =
new TF1(Form(
"Func%i",code),Func,Vmin(code),Vmax(code),4);
83 for (Int_t i = 0; i < Instance()->Nvar(); i++) {
85 if (i != code) params[i] = Vmax(i) - (Vmean(i) - 1)*(Vmin(i) - Vmax(i))/2.;
87 f->SetParameters(params);
91 TF2 *TMDFParameters::ProjectionXY(Int_t code1, Int_t code2) {
92 if (code1 == code2)
return 0;
93 if (code1 < 0 || code1 >= Instance()->Nvar())
return 0;
94 if (code2 < 0 || code2 >= Instance()->Nvar())
return 0;
95 TF2 *f =
new TF2(Form(
"Func%i_%i",code1,code2),Func,Vmin(code1),Vmax(code1),Vmin(code2),Vmax(code2),4);
97 for (Int_t i = 0; i < Instance()->Nvar(); i++) {
99 if (i != code1 && i != code2) params[i] = Vmax(i) - (Vmean(i) - 1)*(Vmin(i) - Vmax(i))/2.;
101 f->SetParameters(params);
105 void TMDFParameters::Print(Option_t *)
const {
106 cout <<
"Sample statistics:" <<
"\n"
107 <<
"------------------" <<
"\n"
109 for (Int_t i = 0; i < fNvar; i++)
110 cout <<
" " << setw(10) << i+1 <<
"\n";
111 cout <<
"\n" <<
" Max: " <<
"\n";
112 for (Int_t i = 0; i < fNvar; i++)
113 cout <<
" " << setw(10) << setprecision(4)
115 cout <<
"\n" <<
" Min: " <<
"\n";
116 for (Int_t i = 0; i < fNvar; i++)
117 cout <<
" " << setw(10) << setprecision(4)
119 cout <<
"\n" <<
" Mean: " <<
"\n";
120 for (Int_t i = 0; i < fNvar; i++)
121 cout <<
" " << setw(10) << setprecision(4)
122 << fVmean[i] <<
"\n";
124 cout <<
"Coefficients:" <<
"\n"
125 <<
"-------------" <<
"\n"
126 <<
" # Value Error Powers" <<
"\n"
127 <<
" ---------------------------------------" <<
"\n";
128 for (Int_t i = 0; i < fNcoef; i++) {
129 cout <<
" " << setw(3) << i <<
" "
130 << setw(12) << fCoef[i] <<
" "
131 << setw(12) << fdCoef[i] <<
" " <<
"\n";
133 TArrayI Power(fNvar);
134 for (Int_t j = fNvar - 1; j >= 0; j--) {Power[j] = p%10; p /= 10;}
135 for (Int_t j = 0; j < fNvar; j++) cout <<
" " << setw(3) << Power[j] - 1 <<
"\n";