Skip to content

Commit

Permalink
Merge pull request #33890 from guitargeek/gbrforest
Browse files Browse the repository at this point in the history
Remove direct boost and ROOT dependencies from CondFormats/GBRForest etc.
  • Loading branch information
cmsbuild authored Jun 9, 2021
2 parents ddff3ef + 3c1e3af commit 5eb70f3
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 55 deletions.
2 changes: 0 additions & 2 deletions CondFormats/GBRForest/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<use name="FWCore/Utilities"/>
<use name="CondFormats/Serialization"/>
<use name="boost_serialization"/>
<use name="root"/>
<export>
<lib name="1"/>
</export>
13 changes: 6 additions & 7 deletions CondFormats/GBRForest/interface/GBRForest.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#ifndef EGAMMAOBJECTS_GBRForest
#define EGAMMAOBJECTS_GBRForest

Expand All @@ -19,12 +18,12 @@
#include "CondFormats/Serialization/interface/Serializable.h"
#include "CondFormats/GBRForest/interface/GBRTree.h"

#include <vector>
#include <cmath>
#include <vector>

class GBRForest {
public:
GBRForest();
GBRForest() {}

double GetResponse(const float* vector) const;
double GetGradBoostClassifier(const float* vector) const;
Expand All @@ -39,7 +38,7 @@ class GBRForest {
const std::vector<GBRTree>& Trees() const { return fTrees; }

protected:
double fInitialResponse;
double fInitialResponse = 0.0;
std::vector<GBRTree> fTrees;

COND_SERIALIZABLE;
Expand All @@ -48,16 +47,16 @@ class GBRForest {
//_______________________________________________________________________
inline double GBRForest::GetResponse(const float* vector) const {
double response = fInitialResponse;
for (std::vector<GBRTree>::const_iterator it = fTrees.begin(); it != fTrees.end(); ++it) {
response += it->GetResponse(vector);
for (auto const& tree : fTrees) {
response += tree.GetResponse(vector);
}
return response;
}

//_______________________________________________________________________
inline double GBRForest::GetGradBoostClassifier(const float* vector) const {
double response = GetResponse(vector);
return 2.0 / (1.0 + exp(-2.0 * response)) - 1; //MVA output between -1 and 1
return 2.0 / (1.0 + std::exp(-2.0 * response)) - 1; //MVA output between -1 and 1
}

#endif
9 changes: 4 additions & 5 deletions CondFormats/GBRForest/interface/GBRForest2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
#include "CondFormats/Serialization/interface/Serializable.h"

#include "GBRTree2D.h"
#include <cstdio>

#include <vector>

class GBRForest2D {
public:
GBRForest2D();
~GBRForest2D() {}
GBRForest2D() {}

void GetResponse(const float *vector, double &x, double &y) const;

Expand All @@ -38,8 +37,8 @@ class GBRForest2D {
const std::vector<GBRTree2D> &Trees() const { return fTrees; }

protected:
double fInitialResponseX;
double fInitialResponseY;
double fInitialResponseX = 0.0;
double fInitialResponseY = 0.0;
std::vector<GBRTree2D> fTrees;

COND_SERIALIZABLE;
Expand Down
11 changes: 4 additions & 7 deletions CondFormats/GBRForest/interface/GBRForestD.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,17 @@

#include "CondFormats/Serialization/interface/Serializable.h"

#include <vector>
#include "GBRTreeD.h"
#include <cmath>
#include <cstdio>
#include "Rtypes.h"

#include <vector>

class GBRForestD {
public:
typedef GBRTreeD TreeT;

GBRForestD();
GBRForestD() {}
template <typename InputForestT>
GBRForestD(const InputForestT &forest);
virtual ~GBRForestD();

double GetResponse(const float *vector) const;

Expand All @@ -42,7 +39,7 @@ class GBRForestD {
const std::vector<GBRTreeD> &Trees() const { return fTrees; }

protected:
double fInitialResponse;
double fInitialResponse = 0.0;
std::vector<GBRTreeD> fTrees;

COND_SERIALIZABLE;
Expand Down
2 changes: 1 addition & 1 deletion CondFormats/GBRForest/interface/GBRTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

class GBRTree {
public:
GBRTree();
GBRTree() {}
explicit GBRTree(int nIntermediate, int nTerminal);

double GetResponse(const float *vector) const;
Expand Down
2 changes: 0 additions & 2 deletions CondFormats/GBRForest/interface/GBRTree2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
#include "CondFormats/Serialization/interface/Serializable.h"

#include <vector>
#include <map>

class GBRTree2D {
public:
GBRTree2D() {}
~GBRTree2D() {}

void GetResponse(const float *vector, double &x, double &y) const;
int TerminalIndex(const float *vector) const;
Expand Down
5 changes: 0 additions & 5 deletions CondFormats/GBRForest/interface/GBRTreeD.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,12 @@
#include "CondFormats/Serialization/interface/Serializable.h"

#include <vector>
#include <map>
#include <cstdio>
#include <cmath>
#include "Rtypes.h"

class GBRTreeD {
public:
GBRTreeD() {}
template <typename InputTreeT>
GBRTreeD(const InputTreeT &tree);
virtual ~GBRTreeD();

//double GetResponse(const float* vector) const;
double GetResponse(int termidx) const { return fResponses[termidx]; }
Expand Down
4 changes: 0 additions & 4 deletions CondFormats/GBRForest/src/GBRForest.cxx

This file was deleted.

7 changes: 0 additions & 7 deletions CondFormats/GBRForest/src/GBRForest2D.cxx

This file was deleted.

7 changes: 0 additions & 7 deletions CondFormats/GBRForest/src/GBRForestD.cc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include "CondFormats/GBRForest/interface/GBRTree.h"

//_______________________________________________________________________
GBRTree::GBRTree() {}

//_______________________________________________________________________
GBRTree::GBRTree(int nIntermediate, int nTerminal) {
//special case, root node is terminal
Expand Down
1 change: 0 additions & 1 deletion CondFormats/GBRForest/src/GBRTree2D.cxx

This file was deleted.

4 changes: 0 additions & 4 deletions CondFormats/GBRForest/src/GBRTreeD.cc

This file was deleted.

0 comments on commit 5eb70f3

Please sign in to comment.