test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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;
67 
68  // Utility functions
69  std::unique_ptr<const GBRForest> createSingleReader(const int iCategory, const edm::FileInPath &weightFile) ;
70 
71  virtual int getNCategories() const override final {return nCategories;};
72  bool isEndcapCategory( int category ) const;
73  virtual const std::string& getName() const override final { return _name; }
74  virtual const std::string& getTag() const override final { return _tag; }
75 
76  // Functions that should work on both pat and reco electrons
77  // (use the fact that pat::Electron inherits from reco::GsfElectron)
78  std::vector<float> fillMVAVariables(const edm::Ptr<reco::Candidate>& particle, const edm::Event&) const override;
79  int findCategory(const edm::Ptr<reco::Candidate>& particle) const;
80  // The function below ensures that the variables passed to MVA are
81  // within reasonable bounds
82  void constrainMVAVariables(AllVariables& vars) const;
83 
84  // Call this function once after the constructor to declare
85  // the needed event content pieces to the framework
86  // DEPRECATED
87  void setConsumes(edm::ConsumesCollector&&) const override;
88  // Call this function once per event to retrieve all needed
89  // event content pices
90  // DEPRECATED
91  // void getEventContent(const edm::Event& iEvent) const override;
92 
93 
94  private:
95 
96  // MVA name. This is a unique name for this MVA implementation.
97  // It will be used as part of ValueMap names.
98  // For simplicity, keep it set to the class name.
99  const std::string _name = "PhotonMVAEstimatorRun2Phys14NonTrig";
100  // MVA tag. This is an additional string variable to distinguish
101  // instances of the estimator of this class configured with different
102  // weight files.
104 
105  // Data members
106  std::vector<std::unique_ptr<const GBRForest> > _gbrForests;
107 
108  // All variables needed by this MVA
111 
112  // This MVA implementation relies on several ValueMap objects
113  // produced upstream.
114 
115  //
116  // Declare all tokens that will be needed to retrieve misc
117  // data from the event content required by this MVA
118  //
119  const bool _useValueMaps;
127  //
131  // token for rho
133 };
134 
135 #endif
std::unique_ptr< const GBRForest > createSingleReader(const int iCategory, const edm::FileInPath &weightFile)
std::vector< float > fillMVAVariables(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override
void setConsumes(edm::ConsumesCollector &&) const override
PhotonMVAEstimatorRun2Phys14NonTrig(const edm::ParameterSet &conf)
float mvaValue(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const
string const
Definition: compareJSON.py:14
int findCategory(const edm::Ptr< reco::Candidate > &particle) const
std::vector< std::unique_ptr< const GBRForest > > _gbrForests
virtual const std::string & getName() const overridefinal
virtual const std::string & getTag() const overridefinal