CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/CondFormats/EgammaObjects/interface/GBRForest.h

Go to the documentation of this file.
00001 
00002 #ifndef EGAMMAOBJECTS_GBRForest
00003 #define EGAMMAOBJECTS_GBRForest
00004 
00006 //                                                                      //
00007 // GBRForest                                                            //
00008 //                                                                      //
00009 // A fast minimal implementation of Gradient-Boosted Regression Trees   //
00010 // which has been especially optimized for size on disk and in memory.  //                                                                  
00011 //                                                                      //
00012 // Designed to be built from TMVA-trained trees, but could also be      //
00013 // generalized to otherwise-trained trees, classification,              //
00014 //  or other boosting methods in the future                             //
00015 //                                                                      //
00016 //  Josh Bendavid - MIT                                                 //
00018 
00019 #include <vector>
00020 #include "GBRTree.h"
00021 
00022 
00023   namespace TMVA {
00024     class MethodBDT;
00025   }
00026 
00027   class GBRForest {
00028 
00029     public:
00030 
00031        GBRForest();
00032        explicit GBRForest(const TMVA::MethodBDT *bdt);
00033        virtual ~GBRForest();
00034        
00035        double GetResponse(const float* vector) const;
00036       
00037        std::vector<GBRTree> &Trees() { return fTrees; }
00038        
00039     protected:
00040       double               fInitialResponse;
00041       std::vector<GBRTree> fTrees;  
00042       
00043   };
00044 
00045 //_______________________________________________________________________
00046 inline double GBRForest::GetResponse(const float* vector) const {
00047   double response = fInitialResponse;
00048   for (std::vector<GBRTree>::const_iterator it=fTrees.begin(); it!=fTrees.end(); ++it) {
00049     response += it->GetResponse(vector);
00050   }
00051   return response;
00052 }
00053   
00054 #endif