CMS 3D CMS Logo

PhotonMVAEstimatorRunIIFall17.h
Go to the documentation of this file.
1 #ifndef RecoEgamma_PhotonIdentification_PhotonMVAEstimatorRunIIFall17_H
2 #define RecoEgamma_PhotonIdentification_PhotonMVAEstimatorRunIIFall17_H
3 
5 
7 
9 
11 
13 
15 
16 #include <vector>
17 #include <string>
18 
19 #include "TMVA/Factory.h"
20 #include "TMVA/Tools.h"
21 #include "TMVA/Reader.h"
22 #include "TMVA/DataLoader.h"
23 
25 
26  public:
27 
28  // Define here the number and the meaning of the categories
29  // for this specific MVA
30  const uint nCategories = 2;
32  UNDEFINED = -1,
33  CAT_EB = 0,
34  CAT_EE = 1
35  };
36 
37  // Define the struct that contains all necessary for MVA variables
38  struct AllVariables {
39 
40  float varRawE;
41  float varR9;
42  float varSieie;
45  float varSieip;
47  float varSCEta;
48  float varESEnOverRawE; // for endcap MVA only
49  float varESEffSigmaRR; // for endcap MVA only
50  // Pile-up
51  float varRho;
52  // Isolations
53  float varPhoIsoRaw;
54  float varChIsoRaw;
56 
57  };
58 
59  // Constructor and destructor
62 
63  // Calculation of the MVA value
64  float mvaValue( const edm::Ptr<reco::Candidate>& particle, const edm::Event&) const;
65 
66  // Utility functions
67  std::unique_ptr<const GBRForest> createSingleReader(const int iCategory, const edm::FileInPath &weightFile);
68 
69  virtual int getNCategories() const { return nCategories; }
70  bool isEndcapCategory( int category ) const;
71  virtual const std::string& getName() const override final { return name_; }
72  virtual const std::string& getTag() const override 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& iEvent) 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
81 
82  // Call this function once after the constructor to declare
83  // the needed event content pieces to the framework
84  void setConsumes(edm::ConsumesCollector&&) const override;
85  // Call this function once per event to retrieve all needed
86  // event content pices
87 
88 
89 
90  private:
91 
92  // MVA name. This is a unique name for this MVA implementation.
93  // It will be used as part of ValueMap names.
94  // For simplicity, keep it set to the class name.
95  const std::string name_ = "PhotonMVAEstimatorRunIIFall17";
96 
97  // MVA tag. This is an additional string variable to distinguish
98  // instances of the estimator of this class configured with different
99  // weight files.
101 
102  // Data members
103  std::vector< std::unique_ptr<const GBRForest> > gbrForests_;
104 
105  // All variables needed by this MVA
108 
109  // This MVA implementation relies on several ValueMap objects
110  // produced upstream.
111 
112  //
113  // Declare all tokens that will be needed to retrieve misc
114  // data from the event content required by this MVA
115  //
120 
121  // Other objects needed by the MVA
123  std::vector<double> phoIsoPtScalingCoeff_;
124 
125 };
126 
127 #endif
std::vector< std::unique_ptr< const GBRForest > > gbrForests_
virtual const std::string & getTag() const override final
void constrainMVAVariables(AllVariables &) const
std::vector< float > fillMVAVariables(const edm::Ptr< reco::Candidate > &particle, const edm::Event &iEvent) const override
int iEvent
Definition: GenABIO.cc:230
float mvaValue(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const
def uint(string)
PhotonMVAEstimatorRunIIFall17(const edm::ParameterSet &conf)
std::unique_ptr< const GBRForest > createSingleReader(const int iCategory, const edm::FileInPath &weightFile)
void setConsumes(edm::ConsumesCollector &&) const override
virtual const std::string & getName() const override final
int findCategory(const edm::Ptr< reco::Candidate > &particle) const override