CMS 3D CMS Logo

PhotonMVAEstimatorRun2Spring16NonTrig.h
Go to the documentation of this file.
1 #ifndef RecoEgamma_PhotonIdentification_PhotonMVAEstimatorRun2Spring16NonTrig_H
2 #define RecoEgamma_PhotonIdentification_PhotonMVAEstimatorRun2Spring16NonTrig_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 
24 
25  public:
26 
27  // Define here the number and the meaning of the categories
28  // for this specific MVA
29  const uint nCategories = 2;
31  UNDEFINED = -1,
32  CAT_EB = 0,
33  CAT_EE = 1
34  };
35 
36  // Define the struct that contains all necessary for MVA variables
37  struct AllVariables {
38 
39  float scPhi;
40  float varR9;
41  float varSieie;
42  float varSieip;
44  float varSCEta;
45  float varRawE;
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;// for barrel only in 2016
54  float varPhoIsoCorr;//for endcap only in 2016
55  float varChIsoRaw;
57 
58  };
59 
60  // Constructor and destructor
63 
64  // Calculation of the MVA value
65  float mvaValue( const edm::Ptr<reco::Candidate>& particle, const edm::Event&) const;
66 
67  // Utility functions
68  std::unique_ptr<const GBRForest> createSingleReader(const int iCategory, const edm::FileInPath &weightFile);
69 
70  virtual int getNCategories() const { return nCategories; }
71  bool isEndcapCategory( int category ) const;
72  virtual const std::string& getName() const override final { return name_; }
73  virtual const std::string& getTag() const override final { return tag_; }
74 
75  // Functions that should work on both pat and reco electrons
76  // (use the fact that pat::Electron inherits from reco::GsfElectron)
77  std::vector<float> fillMVAVariables(const edm::Ptr<reco::Candidate>& particle, const edm::Event& iEvent) const override;
78  int findCategory( const edm::Ptr<reco::Candidate>& particle ) const override;
79  // The function below ensures that the variables passed to MVA are
80  // within reasonable bounds
82 
83  // Call this function once after the constructor to declare
84  // the needed event content pieces to the framework
85  void setConsumes(edm::ConsumesCollector&&) const override;
86  // Call this function once per event to retrieve all needed
87  // event content pices
88  //void getEventContent(const edm::Event& iEvent) override;
89 
90 
91  private:
92 
93  // MVA name. This is a unique name for this MVA implementation.
94  // It will be used as part of ValueMap names.
95  // For simplicity, keep it set to the class name.
96  const std::string name_ = "PhotonMVAEstimatorRun2Spring16NonTrig";
97 
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  //
121 
122  // Other objects needed by the MVA
124  std::vector<double> phoIsoPtScalingCoeff_;
126 };
127 
128 #endif
std::unique_ptr< const GBRForest > createSingleReader(const int iCategory, const edm::FileInPath &weightFile)
PhotonMVAEstimatorRun2Spring16NonTrig(const edm::ParameterSet &conf)
int findCategory(const edm::Ptr< reco::Candidate > &particle) const override
std::vector< float > fillMVAVariables(const edm::Ptr< reco::Candidate > &particle, const edm::Event &iEvent) const override
int iEvent
Definition: GenABIO.cc:230
std::vector< std::unique_ptr< const GBRForest > > gbrForests_
float mvaValue(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const
virtual const std::string & getTag() const override final
virtual const std::string & getName() const override final
void setConsumes(edm::ConsumesCollector &&) const override