CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronMVAEstimatorRun2Phys14NonTrig.h
Go to the documentation of this file.
1 #ifndef RecoEgamma_ElectronIdentification_ElectronMVAEstimatorRun2Phys14NonTrig_H
2 #define RecoEgamma_ElectronIdentification_ElectronMVAEstimatorRun2Phys14NonTrig_H
3 
5 
7 
8 #include <vector>
9 #include <string>
10 #include <TROOT.h>
11 #include "TMVA/Factory.h"
12 #include "TMVA/Tools.h"
13 #include "TMVA/Reader.h"
14 
16 
17  public:
18 
19  // Define here the number and the meaning of the categories
20  // for this specific MVA
21  const int nCategories = 6;
23  UNDEFINED = -1,
30  };
31 
32  // Define the struct that contains all necessary for MVA variables
33  struct AllVariables {
34  float kfhits;
35  // Pure ECAL -> shower shapes
36  float see;
37  float spp;
39  float R9;
40  float etawidth;
41  float phiwidth;
42  float HoE;
43  // Endcap only variables
45  //Pure tracking variables
46  float kfchi2;
47  float gsfchi2;
48  // Energy matching
49  float fbrem;
50  float EoP;
51  float eleEoPout;
52  float IoEmIoP;
53  // Geometrical matchings
54  float deta;
55  float dphi;
56  float detacalo;
57  // Spectator variables
58  float pt;
59  float isBarrel;
60  float isEndcap;
61  float SCeta;
62  };
63 
64  // Constructor and destructor
67 
68  // Calculation of the MVA value
69  float mvaValue( const edm::Ptr<reco::Candidate>& particle);
70 
71  // Utility functions
72  TMVA::Reader *createSingleReader(const int iCategory, const edm::FileInPath &weightFile);
73 
74  inline int getNCategories(){return nCategories;};
75  bool isEndcapCategory( int category );
76  const inline std::string getName(){return name_;};
77 
78  // Functions that should work on both pat and reco electrons
79  // (use the fact that pat::Electron inherits from reco::GsfElectron)
80  void fillMVAVariables(const edm::Ptr<reco::Candidate>& particle);
81  int findCategory( const edm::Ptr<reco::Candidate>& particle);
82  // The function below ensures that the variables passed to MVA are
83  // within reasonable bounds
84  void constrainMVAVariables();
85 
86  private:
87 
88  // MVA name. This is a unique name for this MVA implementation.
89  // It will be used as part of ValueMap names.
90  // For simplicity, keep it set to the class name.
91  const std::string name_ = "ElectronMVAEstimatorRun2Phys14NonTrig";
92 
93  // Data members
94  std::vector< std::unique_ptr<TMVA::Reader> > _tmvaReaders;
95 
96  // All variables needed by this MVA
99 
100 };
101 
104  "ElectronMVAEstimatorRun2Phys14NonTrig");
105 
106 #endif
std::vector< std::unique_ptr< TMVA::Reader > > _tmvaReaders
ElectronMVAEstimatorRun2Phys14NonTrig(const edm::ParameterSet &conf)
tuple conf
Definition: dbtoconf.py:185
TMVA::Reader * createSingleReader(const int iCategory, const edm::FileInPath &weightFile)
int findCategory(const edm::Ptr< reco::Candidate > &particle)
float mvaValue(const edm::Ptr< reco::Candidate > &particle)
void fillMVAVariables(const edm::Ptr< reco::Candidate > &particle)
#define DEFINE_EDM_PLUGIN(factory, type, name)