CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MvaSoftElectronEstimator.cc
Go to the documentation of this file.
1 #include <TFile.h>
3 #include <cmath>
4 #include <vector>
5 using namespace std;
6 
20 //#include "EgammaAnalysis/ElectronTools/interface/ElectronEffectiveArea.h"
23 using namespace reco;
24 
25 //--------------------------------------------------------------------------------------------------
27 {
28  TMVAReader = new TMVA::Reader("Color:Silent:Error");
29  TMVAReader->SetVerbose(false);
30  TMVAReader->AddVariable("sip3d", &mva_sip3d);
31  TMVAReader->AddVariable("sip2d", &mva_sip2d);
32  TMVAReader->AddVariable("ptRel", &mva_ptRel);
33  TMVAReader->AddVariable("deltaR", &mva_deltaR);
34  TMVAReader->AddVariable("ratio", &mva_ratio);
35  TMVAReader->AddVariable("mva_e_pi", &mva_e_pi);
36  reco::details::loadTMVAWeights(TMVAReader, "BDT", weightFile.c_str());
37 
38 }
39 //--------------------------------------------------------------------------------------------------
41 {
42  delete TMVAReader;
43 }
44 
45 //--------------------------------------------------------------------------------------------------
46 
47 Double_t MvaSoftEleEstimator::mvaValue(Float_t sip2d, Float_t sip3d, Float_t ptRel, float deltaR, Float_t ratio, Float_t mva_e_pi) {
48 
49  mva_sip3d = sip3d;
50  mva_sip2d = sip2d;
51  mva_ptRel = ptRel;
52  mva_deltaR = deltaR;
53  mva_ratio = ratio;
54  mva_e_pi = mva_e_pi;
55 
56  float tag = TMVAReader->EvaluateMVA("BDT");
57  // Transform output between 0 and 1
58  tag = (tag+1.0)/2.0;
59 
60  return tag;
61 }
62 //--------------------------------------------------------------------------------------------------------
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
Double_t mvaValue(Float_t, Float_t, Float_t, Float_t, Float_t, Float_t)
void loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)