CMS 3D CMS Logo

ElectronMVAEstimatorRun2Spring15NonTrig.h
Go to the documentation of this file.
1 #ifndef RecoEgamma_ElectronIdentification_ElectronMVAEstimatorRun2Spring15NonTrig_H
2 #define RecoEgamma_ElectronIdentification_ElectronMVAEstimatorRun2Spring15NonTrig_H
3 
5 
7 
9 
13 
15 
16 #include <vector>
17 #include <string>
18 #include <TROOT.h>
19 
21 
22  public:
23 
24  // Define here the number and the meaning of the categories
25  // for this specific MVA
26  const int nCategories = 6;
28  UNDEFINED = -1,
35  };
36 
37  // Define the struct that contains all necessary for MVA variables
38  // Note: all variables have to be floats for TMVA Reader, even if
39  // the training was done with ints.
40  struct AllVariables {
41  // Pure ECAL -> shower shapes
42  float see; // 0
43  float spp; // 1
44  float OneMinusE1x5E5x5; // 2
45  float R9; // 3
46  float etawidth; // 4
47  float phiwidth; // 5
48  float HoE; // 6
49  // Endcap only variables
50  float PreShowerOverRaw; // 7
51  //Pure tracking variables
52  float kfhits; // 8
53  float kfchi2; // 9
54  float gsfchi2; // 10
55  // Energy matching
56  float fbrem; // 11
57 
58  float gsfhits; // 12
60  float convVtxFitProbability; // 14
61 
62  float EoP; // 15
63  float eleEoPout; // 16
64  float IoEmIoP; // 17
65  // Geometrical matchings
66  float deta; // 18
67  float dphi; // 19
68  float detacalo; // 20
69  // Spectator variables
70  float pt; // 21
71  float isBarrel; // 22
72  float isEndcap; // 23
73  float SCeta; // 24
74  //
75  float eClass; // 25
76  float pfRelIso; // 26
77  float expectedInnerHits; // 27
78  float vtxconv; // 28
79  float mcEventWeight; // 29
80  float mcCBmatchingCategory; // 30
81 
82  };
83 
84  // Constructor and destructor
87 
88  // Calculation of the MVA value
89  float mvaValue( const edm::Ptr<reco::Candidate>& particle, const edm::Event&) const override;
90 
91  // Utility functions
92  int getNCategories() const override { return nCategories; }
93  bool isEndcapCategory( int category ) const;
94  const std::string& getName() const final { return _name; }
95  const std::string& getTag() const final { return _tag; }
96 
97  // Functions that should work on both pat and reco electrons
98  // (use the fact that pat::Electron inherits from reco::GsfElectron)
99  std::vector<float> fillMVAVariables(const edm::Ptr<reco::Candidate>& particle, const edm::Event&) const override;
100  int findCategory( const edm::Ptr<reco::Candidate>& particle) const override;
101  // The function below ensures that the variables passed to MVA are
102  // within reasonable bounds
103  void constrainMVAVariables(AllVariables&) const;
104 
105  // Call this function once after the constructor to declare
106  // the needed event content pieces to the framework
107  void setConsumes(edm::ConsumesCollector&&) const final;
108  // Call this function once per event to retrieve all needed
109  // event content pices
110 
111  private:
112 
113  // MVA name. This is a unique name for this MVA implementation.
114  // It will be used as part of ValueMap names.
115  // For simplicity, keep it set to the class name.
116  const std::string _name = "ElectronMVAEstimatorRun2Spring15NonTrig";
117  // MVA tag. This is an additional string variable to distinguish
118  // instances of the estimator of this class configured with different
119  // weight files.
121 
122  // Data members
123  std::vector< std::unique_ptr<const GBRForest> > _gbrForests;
124 
125  // All variables needed by this MVA
128 
129  //
130  // Declare all tokens that will be needed to retrieve misc
131  // data from the event content required by this MVA
132  //
134  // Conversions in AOD and miniAOD have different names
137 
138 
139 };
140 
141 #endif
std::vector< std::unique_ptr< const GBRForest > > _gbrForests
int findCategory(const edm::Ptr< reco::Candidate > &particle) const override
void setConsumes(edm::ConsumesCollector &&) const final
float mvaValue(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override
std::vector< float > fillMVAVariables(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override