CMS 3D CMS Logo

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