CMS 3D CMS Logo

Spline.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_MVAComputer_Spline_h
2 #define PhysicsTools_MVAComputer_Spline_h
3 // -*- C++ -*-
4 //
5 // Package: MVAComputer
6 // Class : Spline
7 //
8 
9 //
10 // Author: Christophe Saout <christophe.saout@cern.ch>
11 // Created: Sat Apr 24 15:18 CEST 2007
12 //
13 
14 namespace PhysicsTools {
15 
25  class Spline {
26  public:
27  Spline();
28  Spline(const Spline &orig);
29 
31  Spline(unsigned int n, const double *vals);
32  ~Spline();
33 
34  Spline &operator=(const Spline &orig);
35 
37  void set(unsigned int n, const double *vals);
38 
40  float eval(float x) const;
41 
43  float deriv(float x) const;
44 
46  float integral(float x) const;
47 
49  float getArea() const { return area; }
50 
52  inline unsigned int numberOfEntries() const { return n + 1; }
53 
54  private:
56  struct Segment {
57  float coeffs[4];
58  float area;
59 
60  float eval(float x) const;
61  float deriv(float x) const;
62  float integral(float x) const;
63  };
64 
65  unsigned int n;
67  float area;
68  };
69 
70 } // namespace PhysicsTools
71 
72 #endif // PhysicsTools_MVAComputer_Spline_h
PhysicsTools::Spline::numberOfEntries
unsigned int numberOfEntries() const
return the number of entries
Definition: Spline.h:52
PhysicsTools::Spline::Segment::area
float area
Definition: Spline.h:58
PhysicsTools::Spline::Segment
internal class describing a "segment" (between two x points)
Definition: Spline.h:56
PhysicsTools::Spline::area
float area
Definition: Spline.h:67
PhysicsTools::Spline::Segment::coeffs
float coeffs[4]
Definition: Spline.h:57
PhysicsTools::Spline::Spline
Spline()
Definition: Spline.cc:58
PhysicsTools::Spline::eval
float eval(float x) const
compute y coordinate at x coordinate x
Definition: Spline.cc:127
PhysicsTools::Spline::Segment::deriv
float deriv(float x) const
Definition: Spline.cc:34
PhysicsTools::Spline::integral
float integral(float x) const
compute integral under curve between 0 and x
Definition: Spline.cc:153
PhysicsTools::Spline::segments
Segment * segments
Definition: Spline.h:66
PhysicsTools::Spline::Segment::integral
float integral(float x) const
Definition: Spline.cc:45
PhysicsTools::Spline::operator=
Spline & operator=(const Spline &orig)
Definition: Spline.cc:118
PhysicsTools::Spline::~Spline
~Spline()
Definition: Spline.cc:116
PhysicsTools
Definition: Histogram.h:13
PhysicsTools::Spline::set
void set(unsigned int n, const double *vals)
initialize spline from n y coordinates in array vals
Definition: Spline.cc:67
PhysicsTools::Spline::getArea
float getArea() const
total area (integral between 0 and 1) under curve
Definition: Spline.h:49
PhysicsTools::Spline::deriv
float deriv(float x) const
compute the derivate at x coordinate x
Definition: Spline.cc:139
PhysicsTools::Spline::n
unsigned int n
Definition: Spline.h:65
PhysicsTools::Spline
A simple class for cubic splines.
Definition: Spline.h:25
PhysicsTools::Spline::Segment::eval
float eval(float x) const
Definition: Spline.cc:21