CMS 3D CMS Logo

PhotonMVAEstimatorRun2Phys14NonTrig.h
Go to the documentation of this file.
1 #ifndef RecoEgamma_PhotonIdentification_PhotonMVAEstimatorRun2Phys14NonTrig_H
2 #define RecoEgamma_PhotonIdentification_PhotonMVAEstimatorRun2Phys14NonTrig_H
3 
5 
7 
9 
11 
13 
14 #include <vector>
15 #include <string>
16 #include <TROOT.h>
17 #include "TMVA/Factory.h"
18 #include "TMVA/Tools.h"
19 #include "TMVA/Reader.h"
20 
22 
23  public:
24 
25  // Define here the number and the meaning of the categories
26  // for this specific MVA
27  const int nCategories = 2;
29  UNDEFINED = -1,
30  CAT_EB = 0,
31  CAT_EE = 1
32  };
33 
34  // Define the struct that contains all necessary for MVA variables
35  struct AllVariables {
36  float varPhi;
37  float varR9;
38  float varSieie;
39  float varSieip;
43  float varSCEta;
44  float varRawE;
47  float varESEnOverRawE; // for endcap MVA only
48  float varESEffSigmaRR; // for endcap MVA only
49  // Pile-up
50  float varRho;
51  // Isolations
52  float varPhoIsoRaw;
53  float varChIsoRaw;
55  // Spectators
56  float varPt;
57  float varEta;
58 
59  };
60 
61  // Constructor and destructor
64 
65  // Calculation of the MVA value
66  float mvaValue(const edm::Ptr<reco::Candidate>& particle, const edm::Event&) const override;
67 
68  // Utility functions
69  int getNCategories() const final {return nCategories;};
70  bool isEndcapCategory( int category ) const;
71  const std::string& getName() const final { return _name; }
72  const std::string& getTag() const final { return _tag; }
73 
74  // Functions that should work on both pat and reco electrons
75  // (use the fact that pat::Electron inherits from reco::GsfElectron)
76  std::vector<float> fillMVAVariables(const edm::Ptr<reco::Candidate>& particle, const edm::Event&) const override;
77  int findCategory(const edm::Ptr<reco::Candidate>& particle) const override;
78  // The function below ensures that the variables passed to MVA are
79  // within reasonable bounds
80  void constrainMVAVariables(AllVariables& vars) const;
81 
82  // Call this function once after the constructor to declare
83  // the needed event content pieces to the framework
84  // DEPRECATED
85  void setConsumes(edm::ConsumesCollector&&) const override;
86  // Call this function once per event to retrieve all needed
87  // event content pices
88  // DEPRECATED
89  // void getEventContent(const edm::Event& iEvent) const override;
90 
91 
92  private:
93 
94  // MVA name. This is a unique name for this MVA implementation.
95  // It will be used as part of ValueMap names.
96  // For simplicity, keep it set to the class name.
97  const std::string _name = "PhotonMVAEstimatorRun2Phys14NonTrig";
98  // MVA tag. This is an additional string variable to distinguish
99  // instances of the estimator of this class configured with different
100  // weight files.
102 
103  // Data members
104  std::vector<std::unique_ptr<const GBRForest> > _gbrForests;
105 
106  // All variables needed by this MVA
109 
110  // This MVA implementation relies on several ValueMap objects
111  // produced upstream.
112 
113  //
114  // Declare all tokens that will be needed to retrieve misc
115  // data from the event content required by this MVA
116  //
117  const bool _useValueMaps;
125  //
129  // token for rho
131 };
132 
133 #endif
void setConsumes(edm::ConsumesCollector &&) const override
float mvaValue(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override
int findCategory(const edm::Ptr< reco::Candidate > &particle) const override
PhotonMVAEstimatorRun2Phys14NonTrig(const edm::ParameterSet &conf)
std::vector< std::unique_ptr< const GBRForest > > _gbrForests
std::vector< float > fillMVAVariables(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override