forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTF2.h
More file actions
157 lines (132 loc) · 8.58 KB
/
Copy pathTF2.h
File metadata and controls
157 lines (132 loc) · 8.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// @(#)root/hist:$Id$
// Author: Rene Brun 23/08/95
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
// ---------------------------------- F2.h
#ifndef ROOT_TF2
#define ROOT_TF2
//////////////////////////////////////////////////////////////////////////
// //
// TF2 //
// //
// The Parametric 2-D function //
// //
//////////////////////////////////////////////////////////////////////////
#include "TF1.h"
#include "TArrayD.h"
class TF2 : public TF1 {
protected:
Double_t fYmin; ///< Lower bound for the range in y
Double_t fYmax; ///< Upper bound for the range in y
Int_t fNpy; ///< Number of points along y used for the graphical representation
TArrayD fContour; ///< Array to display contour levels
public:
TF2();
TF2(const char *name, const char *formula, Double_t xmin = 0, Double_t xmax = 1, Double_t ymin = 0,
Double_t ymax = 1, EAddToList addToGlobList = EAddToList::kDefault, bool vectorize = false);
TF2(const char *name, const char *formula, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax,
Option_t *opt); // same as above but using a string for option
TF2(const char *name, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t npar, Int_t ndim = 2, EAddToList addToGlobList = EAddToList::kDefault);
TF2(const char *name, Double_t (*fcn)(Double_t *, Double_t *), Double_t xmin=0, Double_t xmax=1, Double_t ymin=0, Double_t ymax=1, Int_t npar=0,Int_t ndim = 2, EAddToList addToGlobList = EAddToList::kDefault);
TF2(const char *name, Double_t (*fcn)(const Double_t *, const Double_t *), Double_t xmin=0, Double_t xmax=1, Double_t ymin=0, Double_t ymax=1, Int_t npar=0, Int_t ndim = 2, EAddToList addToGlobList = EAddToList::kDefault);
// Constructor using a functor
TF2(const char *name, ROOT::Math::ParamFunctor f, Double_t xmin = 0, Double_t xmax = 1, Double_t ymin = 0, Double_t ymax = 1, Int_t npar = 0, Int_t ndim = 2, EAddToList addToGlobList = EAddToList::kDefault);
/// Template constructors from a pointer to any C++ class of type PtrObj with a specific member function of type MemFn.
template <class PtrObj, typename MemFn>
TF2(const char *name, const PtrObj& p, MemFn memFn, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t npar, Int_t ndim = 2, EAddToList addToGlobList = EAddToList::kDefault) :
TF1(name,p,memFn,xmin,xmax,npar,ndim, addToGlobList),
fYmin(ymin), fYmax(ymax), fNpy(30), fContour(0)
{
fNpx = 30;
}
/// Backward compatible ctor
template <class PtrObj, typename MemFn>
TF2(const char *name, const PtrObj& p, MemFn memFn, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t npar, const char * , const char *) :
TF1(name,p,memFn,xmin,xmax,npar,2),
fYmin(ymin), fYmax(ymax), fNpy(30), fContour(0)
{
fNpx = 30;
}
/// Template constructors from any C++ callable object, defining the operator() (double * , double *) and returning a double.
template <typename Func>
TF2(const char *name, Func f, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t npar,Int_t ndim = 2, EAddToList addToGlobList = EAddToList::kDefault) :
TF1(name,f,xmin,xmax,npar,ndim, addToGlobList),
fYmin(ymin), fYmax(ymax), fNpy(30), fContour(0)
{
fNpx = 30;
}
/// Backward compatible ctor
template <typename Func>
TF2(const char *name, Func f, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t npar,const char *) :
TF1(name,f,xmin,xmax,npar,2),
fYmin(ymin), fYmax(ymax), fNpy(30), fContour(0)
{
fNpx = 30;
}
TF2(const TF2 &f2);
TF2 &operator=(const TF2& rhs);
~TF2() override;
void Copy(TObject &f2) const override;
Int_t DistancetoPrimitive(Int_t px, Int_t py) override;
void Draw(Option_t *option="") override;
TF1 *DrawCopy(Option_t *option="") const override;
TObject *DrawDerivative(Option_t * ="al") override {return nullptr;}
TObject *DrawIntegral(Option_t * ="al") override {return nullptr;}
//virtual void DrawF2(const char *formula, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Option_t *option="");
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
virtual Int_t GetContour(Double_t *levels=nullptr);
virtual Double_t GetContourLevel(Int_t level) const;
Int_t GetNpy() const {return fNpy;}
char *GetObjectInfo(Int_t px, Int_t py) const override;
Double_t GetRandom(TRandom * rng = nullptr, Option_t * opt = nullptr) override;
Double_t GetRandom(Double_t xmin, Double_t xmax, TRandom * rng = nullptr, Option_t * opt = nullptr) override;
virtual void GetRandom2(Double_t &xrandom, Double_t &yrandom, TRandom * rng = nullptr);
using TF1::GetRange;
void GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const override;
void GetRange(Double_t &xmin, Double_t &ymin, Double_t &zmin, Double_t &xmax, Double_t &ymax, Double_t &zmax) const override;
Double_t GetSave(const Double_t *x) override;
virtual Double_t GetMinimumXY(Double_t &x, Double_t &y) const;
virtual Double_t GetMaximumXY(Double_t &x, Double_t &y) const;
using TF1::GetMinimum;
using TF1::GetMaximum;
virtual Double_t GetMinimum(Double_t *x ) const;
virtual Double_t GetMaximum(Double_t *x ) const;
virtual Double_t GetYmin() const {return fYmin;}
virtual Double_t GetYmax() const {return fYmax;}
static void InitStandardFunctions();
using TF1::Integral;
virtual Double_t Integral(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsrel=1.e-6);
Bool_t IsInside(const Double_t *x) const override;
TH1 *CreateHistogram() override;
void Paint(Option_t *option="") override;
void Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax) override;
void SavePrimitive(std::ostream &out, Option_t *option = "") override;
virtual void SetNpy(Int_t npy=100); // *MENU*
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=nullptr);
virtual void SetContourLevel(Int_t level, Double_t value);
void SetRange(Double_t xmin, Double_t xmax) override;
void SetRange(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax) override; // *MENU*
void SetRange(Double_t xmin, Double_t ymin, Double_t zmin, Double_t xmax, Double_t ymax, Double_t zmax) override;
void SetSavedPoint(Int_t point, Double_t value) override;
//Moments
virtual Double_t Moment2(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t epsilon=0.000001);
virtual Double_t CentralMoment2(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t epsilon=0.000001);
virtual Double_t Mean2X(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001) {return Moment2(1,ax,bx,0,ay,by,epsilon);}
virtual Double_t Mean2Y(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001) {return Moment2(0,ax,bx,1,ay,by,epsilon);}
virtual Double_t Variance2X(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001) {return CentralMoment2(2,ax,bx,0,ay,by,epsilon);}
virtual Double_t Variance2Y(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001) {return CentralMoment2(0,ax,bx,2,ay,by,epsilon);}
virtual Double_t Covariance2XY(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsilon=0.000001) {return CentralMoment2(1,ax,bx,1,ay,by,epsilon);}
protected:
virtual Double_t FindMinMax(Double_t* x, bool findmax) const;
ClassDefOverride(TF2,4) //The Parametric 2-D function
};
inline void TF2::SetRange(Double_t xmin, Double_t xmax)
{ TF1::SetRange(xmin, xmax); }
inline void TF2::SetRange(Double_t xmin, Double_t ymin, Double_t, Double_t xmax, Double_t ymax, Double_t)
{ SetRange(xmin, ymin, xmax, ymax); }
#endif