CMS 3D CMS Logo

GBRForest2D.h
Go to the documentation of this file.
1 
2 #ifndef EGAMMAOBJECTS_GBRForest2D
3 #define EGAMMAOBJECTS_GBRForest2D
4 
6 // //
7 // GBRForest2D //
8 // //
9 // A fast minimal implementation of Gradient-Boosted Regression Trees //
10 // which has been especially optimized for size on disk and in memory. //
11 // //
12 // Designed to be built from TMVA-trained trees, but could also be //
13 // generalized to otherwise-trained trees, classification, //
14 // or other boosting methods in the future //
15 // //
16 // Josh Bendavid - MIT //
18 
20 
21 #include "GBRTree2D.h"
22 
23 #include <vector>
24 
25 class GBRForest2D {
26 public:
28 
29  void GetResponse(const float *vector, double &x, double &y) const;
30 
31  void SetInitialResponse(double x, double y) {
34  }
35 
36  std::vector<GBRTree2D> &Trees() { return fTrees; }
37  const std::vector<GBRTree2D> &Trees() const { return fTrees; }
38 
39 protected:
40  double fInitialResponseX = 0.0;
41  double fInitialResponseY = 0.0;
42  std::vector<GBRTree2D> fTrees;
43 
45 };
46 
47 //_______________________________________________________________________
48 inline void GBRForest2D::GetResponse(const float *vector, double &x, double &y) const {
51  double tx, ty;
52  for (std::vector<GBRTree2D>::const_iterator it = fTrees.begin(); it != fTrees.end(); ++it) {
53  it->GetResponse(vector, tx, ty);
54  x += tx;
55  y += ty;
56  }
57  return;
58 }
59 
60 #endif
void GetResponse(const float *vector, double &x, double &y) const
Definition: GBRForest2D.h:48
void SetInitialResponse(double x, double y)
Definition: GBRForest2D.h:31
double fInitialResponseX
Definition: GBRForest2D.h:40
std::vector< GBRTree2D > & Trees()
Definition: GBRForest2D.h:36
double fInitialResponseY
Definition: GBRForest2D.h:41
const std::vector< GBRTree2D > & Trees() const
Definition: GBRForest2D.h:37
#define COND_SERIALIZABLE
Definition: Serializable.h:39
std::vector< GBRTree2D > fTrees
Definition: GBRForest2D.h:42
float x