MINT2
SplineGenerator.h
Go to the documentation of this file.
1 #ifndef __SPLINEGENERATOR_H__
2 #define __SPLINEGENERATOR_H__
3 
4 #include <TSpline.h>
5 #include <vector>
6 class TRandom3 ;
7 
8 // Class to generate random numbers according to a spline interpolator.
10  private :
11  struct BinInfo {
12  double xmin ;
13  double xmax ;
14  double integral ;
15  double ymin ;
16  double ymax ;
17  double boxintegral ;
18  } ;
19 
20  TRandom3* m_rndm ;
21  mutable TSpline3 m_spline ; // Cause ROOT is crap at const correctness.
22  double m_integral ;
23  double m_boxintegral ;
24  double m_mean ;
25  std::vector<BinInfo> m_bins ;
26 
27  public :
28  SplineGenerator(TRandom3* rndm, const TSpline3& spline) ;
29 
30  // Total integral between the minimum and maximum knots.
31  double integral() const ;
32 
33  // Mean of the PDF.
34  double mean() const ;
35 
36  // Generate a random number from the spline.
37  double gen_random() const ;
38 
39  // Get the integral of the spline between xmin and xmax.
40  double integral(double xmin, double xmax) ;
41 
42  // Get the spline.
43  const TSpline3& spline() const ;
44 
45  private :
46  // Partial integral for knot i at x.
47  double partial_integral(int i, double x) ;
48 
49  // Integral for knot i between xmin and xmax.
50  double integral(int i, double xmin, double xmax) ;
51 
52  // Get the turning points of knot i.
53  std::pair<double, double> turning_points(int i) const ;
54 
55  // The partial integral of x * f(x) used for calculating the mean.
56  double mean_part_integral(int i, double x) ;
57 
58  // Get the mean between xmin and xmax for knot i.
59  double mean(int i, double xmin, double xmax) ;
60 } ;
61 
62 #endif
double mean() const
double integral() const
double gen_random() const
SplineGenerator(TRandom3 *rndm, const TSpline3 &spline)
std::pair< double, double > turning_points(int i) const
std::vector< BinInfo > m_bins
double mean_part_integral(int i, double x)
double partial_integral(int i, double x)
const TSpline3 & spline() const
TRandom3 * m_rndm