SynAPSE  0.6.0
Synergistic Analysis of Phase Space Evolution
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
DFunction.hh
1 #ifndef DFUNCTION_HH
2 #define DFUNCTION_HH
3 
4 // C++ includes
5 #include <iostream>
6 
7 // ROOT includes
8 #include "TStyle.h"
9 #include "TObject.h"
10 #include "TLine.h"
11 #include "TGraph.h"
12 #include "TH2F.h"
13 #include "TF3.h"
14 #include "TRandom3.h"
15 #include "TCanvas.h"
16 
17 // Other includes
18 #include "Pitch.hh"
19 #include "Exception.hh"
20 #include "Assert.hh"
21 
27 class DFunction {
28  public:
30  DFunction();
31 
33  DFunction(const DFunction& df);
34 
36  DFunction& operator=(const DFunction& df);
37 
42  double operator()(const std::vector<double>& v) const { return Evaluate(v); }
43 
49  double operator()(const double& v) const { return Evaluate(v); }
50 
55  double operator()(const double* v) const { return Evaluate(v); }
56 
58  ~DFunction();
59 
64  virtual double CDF(const double& v) const = 0;
65 
70  virtual double CDFRadial(const double& R) const = 0;
71 
76  virtual std::vector<TLine*> Contour1D(const double alpha) const = 0;
77 
82  virtual std::vector<TObject*> Contour2D(const double alpha) const = 0;
83 
88  virtual TF3* Contour3D(const double alpha) const = 0;
89 
94  virtual std::vector<TLine*> ContourRadial(const double alpha) const = 0;
95 
100  virtual double ContourVolume(const double alpha) const = 0;
101 
103  size_t Dimension() const { return _dim; }
104 
109  virtual double Evaluate(const std::vector<double>& v) const = 0;
110 
115  double Evaluate(const double& v) const;
116 
121  double Evaluate(const double* v) const;
122 
127  virtual double Level(const double alpha) const = 0;
128 
130  void SetLowerBound(const double lower, const size_t i=0);
131 
133  double LowerBound(const size_t i=0) const { return _lower[i]; }
134 
136  void SetLowerBounds(std::vector<double> lower) { _lower = lower; }
137 
139  std::vector<double> LowerBounds() const { return _lower; }
140 
142  void SetName(const std::string& name) { _name = name; }
143 
145  std::string Name() const { return _name; }
146 
148  virtual double Norm() const = 0;
149 
154  virtual double Radial(const double R) const = 0;
155 
157  virtual double Random() = 0;
158 
160  virtual std::vector<double> RandomVector() = 0;
161 
163  void SetRange(const double lower,
164  const double upper,
165  const size_t i=0);
166 
168  void SetRange(const std::vector<double>& lower,
169  const std::vector<double>& upper);
170 
172  void Range(std::vector<double>& lower,
173  std::vector<double>& upper) const;
174 
176  void SetTitle(const std::string& title) { _title = title; }
177 
179  std::string Title() const { return _title; }
180 
182  void SetUpperBound(const double upper, const size_t i=0);
183 
185  double UpperBound(const size_t i=0) const { return _upper[i]; }
186 
188  void SetUpperBounds(std::vector<double> upper) { _upper = upper; }
189 
191  std::vector<double> UpperBounds() const { return _upper; }
192 
198  TGraph* Graph(size_t idx=0, std::vector<double> x=std::vector<double>()) const;
199 
201  TGraph* GraphRadial() const;
202 
209  TH2F* Graph2D(size_t idx=0, size_t idy=1, std::vector<double> x=std::vector<double>()) const;
210 
212  TGraph* GraphCDFRadial() const;
213 
221  void Draw(const std::string opt="", int idx=0, int idy=1,
222  std::vector<double> x=std::vector<double>()) const;
223 
228  void DrawRadial(const std::string opt="") const;
229 
237  void Print(const std::string opt="", int idx=0, int idy=1,
238  std::vector<double> x=std::vector<double>()) const;
239 
244  void PrintRadial(const std::string opt="") const;
245 
246  protected:
247 
248  size_t _dim;
249  std::vector<double> _lower;
250  std::vector<double> _upper;
251  std::string _name;
252  std::string _title;
253  TRandom3 _rdmzer;
254 };
255 
256 #endif
virtual std::vector< TObject * > Contour2D(const double alpha) const =0
Geometrical objects that encompass a certain p-value in 2 dimensions.
void SetLowerBound(const double lower, const size_t i=0)
Sets the lower bound of axis i.
Definition: DFunction.cc:38
virtual std::vector< double > RandomVector()=0
Returns a random vector sampled from the distribution.
TRandom3 _rdmzer
Pseudorandom number generator.
Definition: DFunction.hh:253
TGraph * GraphRadial() const
Returns a radial graph of the function.
Definition: DFunction.cc:115
double operator()(const std::vector< double > &v) const
Overloaded function operator, calls Evaluate.
Definition: DFunction.hh:42
double operator()(const double *v) const
Overloaded function operator, calls Evaluate.
Definition: DFunction.hh:55
void PrintRadial(const std::string opt="") const
Creates a canvas, draws the radial function on it and save it to a file.
Definition: DFunction.cc:244
double LowerBound(const size_t i=0) const
Returns the lower bound of axis i.
Definition: DFunction.hh:133
void SetName(const std::string &name)
Returns the name of the function.
Definition: DFunction.hh:142
virtual double Evaluate(const std::vector< double > &v) const =0
Returns the value of the PDF.
double UpperBound(const size_t i=0) const
Returns the upper bound of axis i.
Definition: DFunction.hh:185
DFunction()
Default constructor, initilizes everything to 0.
Definition: DFunction.cc:3
virtual double Random()=0
Returns a random value sampled from the distribution.
virtual double CDF(const double &v) const =0
Cumulative distribution function at v.
double operator()(const double &v) const
Overloaded function operator, calls Evaluate.
Definition: DFunction.hh:49
DFunction & operator=(const DFunction &df)
Equality operator.
Definition: DFunction.cc:11
~DFunction()
Destructor.
Definition: DFunction.cc:25
virtual double Radial(const double R) const =0
If the function has an L1, L2 or Linf symmetry, returns its value at radius R.
std::string _name
Name of the function.
Definition: DFunction.hh:251
size_t _dim
Dimension of the space the function lives in.
Definition: DFunction.hh:248
std::string Title() const
Returns the name of the function.
Definition: DFunction.hh:179
std::vector< double > _upper
Array of upper bounds.
Definition: DFunction.hh:250
void DrawRadial(const std::string opt="") const
Draws the radial function on whichever TCanvas is currently being used (ROOT)
Definition: DFunction.cc:217
virtual double Norm() const =0
Returns the probability content within the defined interval.
std::vector< double > LowerBounds() const
Returns the array of lower bounds.
Definition: DFunction.hh:139
void SetLowerBounds(std::vector< double > lower)
Sets the vector of lower bounds.
Definition: DFunction.hh:136
size_t Dimension() const
Returns the dimension of the space.
Definition: DFunction.hh:103
void Range(std::vector< double > &lower, std::vector< double > &upper) const
Returns the upper bound of axis i.
Definition: DFunction.cc:50
std::vector< double > _lower
Array of lower bounds.
Definition: DFunction.hh:249
void SetRange(const double lower, const double upper, const size_t i=0)
Returns the upper bound of axis i.
Definition: DFunction.cc:57
void SetUpperBound(const double upper, const size_t i=0)
Sets the upper bound of axis i.
Definition: DFunction.cc:44
std::vector< double > UpperBounds() const
Returns the array of upper bounds.
Definition: DFunction.hh:191
void Print(const std::string opt="", int idx=0, int idy=1, std::vector< double > x=std::vector< double >()) const
Creates a canvas, draws the function on it and save it to a file.
Definition: DFunction.cc:229
TGraph * GraphCDFRadial() const
Returns a radial graph of the cummulative density function.
Definition: DFunction.cc:173
TGraph * Graph(size_t idx=0, std::vector< double > x=std::vector< double >()) const
Returns a 1D graph of the function in the requested axis.
Definition: DFunction.cc:86
void SetTitle(const std::string &title)
Returns the name of the function.
Definition: DFunction.hh:176
virtual double CDFRadial(const double &R) const =0
If the function has an L1, L2 or Linf symmetry, returns its CDF at radius R.
TH2F * Graph2D(size_t idx=0, size_t idy=1, std::vector< double > x=std::vector< double >()) const
Returns a 2D histogram of the function in the requested axis.
Definition: DFunction.cc:143
void Draw(const std::string opt="", int idx=0, int idy=1, std::vector< double > x=std::vector< double >()) const
Draws the function on whichever TCanvas is currently being used (ROOT)
Definition: DFunction.cc:201
std::string Name() const
Returns the name of the function.
Definition: DFunction.hh:145
virtual std::vector< TLine * > Contour1D(const double alpha) const =0
Segments that encompass a certain p-value in 1 dimension.
Parent class for all the probability density functions D*.
Definition: DFunction.hh:27
std::string _title
Title of the function.
Definition: DFunction.hh:252
virtual double ContourVolume(const double alpha) const =0
Volume of the smallest contour of a given p-value.
void SetUpperBounds(std::vector< double > upper)
Sets the vector of upper bounds.
Definition: DFunction.hh:188
virtual double Level(const double alpha) const =0
Returns the level of the alpha-contour.
virtual std::vector< TLine * > ContourRadial(const double alpha) const =0
Segments that encompass a certain p-value in radius.
virtual TF3 * Contour3D(const double alpha) const =0
TF3 contour that encompasses a certain p-value in 3 dimensions.