StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TF1F.cxx
1 #include "TF1F.h"
2 #include "TMath.h"
3 ClassImp(TF1F);
4 //________________________________________________________________________________
5 void TF1F::Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax) {
6  fXmin = xmin; fXmax = xmax; fStep = 20, fdX = 1./fStep; fNpx = TMath::Nint((fXmax - fXmin)/fdX);
7  TF1::Save(xmin,xmax,ymin,ymax,zmin,zmax);
8 }
9 //________________________________________________________________________________
10 Double_t TF1F::GetSaveL(Double_t *xx) {
11  // Get value corresponding to X in array of fSave values
12  if (xx[0] < fXmin || xx[0] > fXmax || fdX <= 0) return 0.;
13  Int_t bin = TMath::Nint((xx[0]-fXmin)/fdX);
14 #if 1 /* step function */
15  return fSave[bin];
16 #else
17  Double_t xlow = fXmin + bin*fdX;
18  Double_t xup = xlow + fdX;
19  Double_t ylow = fSave[bin];
20  Double_t yup = fSave[bin+1];
21  Double_t y = ((xup*ylow-xlow*yup) + xx[0]*(yup-ylow))/fdX;
22  return y;
23 #endif
24 }
25 //________________________________________________________________________________
26 Double_t TF1F::GetSaveL(Int_t N, Double_t x, Double_t *y) {
27  // Get values y[N] corresponding to x+i, i = [0, ..., N-1];
28  // memset(y, 0, N*sizeof(Double_t));
29  Int_t bin = TMath::Nint((x-fXmin)/fdX);
30  Int_t i1 = 0;
31  while (bin < 0) {i1++; bin += fStep;}
32  for (Int_t i = i1; i < N && bin < GetNpx() - 3; i++, bin += fStep) {
33  y[i] = fSave[bin];
34  }
35  return y[0];
36 }
37 //________________________________________________________________________________
38 Double_t TF1F::GetSaveL(Int_t N, Double_t *x, Double_t *y) {
39  // Get values y[N] corresponding to x[N] in array of fSave values
40  memset(y, 0, N*sizeof(Double_t));
41  if (GetNpx() <= 0) return 0.;
42  for (Int_t i = 0; i < N; i++) {
43  if (x[i] > fXmin) {
44  Int_t bin = Int_t((x[i]-fXmin)/fdX);
45  if (bin < GetNpx() - 3) y[i] = fSave[bin];
46  }
47  }
48  return y[0];
49 }
50 #if ROOT_VERSION_CODE >= 393216 /* = ROOT_VERSION(6,0,0) */
51 TF1F::TF1F(): TF1(){fNpx = 200;}
52 TF1F::TF1F(const char *name,const char *formula, Double_t xmin, Double_t xmax)
53  :TF1(name,formula,xmax,xmin) {fNpx = 200;}
54 TF1F::TF1F(const char *name, Double_t (*fcn)(Double_t *, Double_t *), Double_t xmin, Double_t xmax, Int_t npar, Int_t ndim)
55  : TF1(name, fcn, xmin, xmax, npar,ndim) {fNpx = 200;}
56 #if 0
57 TF1F::TF1F(const char *name, ROOT::Math::ParamFunctor f, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t npar, Int_t ndim)
58  : TF1(name, f, xmin, xmax, npar,ndim) {fNpx = 200;}
59 #endif
60 #endif /* ROOT 6 */
Definition: TF1F.h:5