CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PhotonMVAEstimatorRun2Spring15NonTrig.h
Go to the documentation of this file.
1 #ifndef RecoEgamma_PhotonIdentification_PhotonMVAEstimatorRun2Spring15NonTrig_H
2 #define RecoEgamma_PhotonIdentification_PhotonMVAEstimatorRun2Spring15NonTrig_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 
37  float varPhi;
38  float varR9;
39  float varSieie;
40  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;
54  float varChIsoRaw;
56  // Spectators
57  float varPt;
58  float varEta;
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 { 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& iEvent) const override;
79  int findCategory( const edm::Ptr<reco::Candidate>& particle ) const override;
80  // The function below ensures that the variables passed to MVA are
81  // within reasonable bounds
82  void constrainMVAVariables(AllVariables&) const;
83 
84  // Call this function once after the constructor to declare
85  // the needed event content pieces to the framework
86  void setConsumes(edm::ConsumesCollector&&) const override;
87  // Call this function once per event to retrieve all needed
88  // event content pices
89  //void getEventContent(const edm::Event& iEvent) 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 = "PhotonMVAEstimatorRun2Spring15NonTrig";
98 
99  // MVA tag. This is an additional string variable to distinguish
100  // instances of the estimator of this class configured with different
101  // weight files.
103 
104  // Data members
105  std::vector< std::unique_ptr<const GBRForest> > _gbrForests;
106 
107  // All variables needed by this MVA
110 
111  // This MVA implementation relies on several ValueMap objects
112  // produced upstream.
113 
114  //
115  // Declare all tokens that will be needed to retrieve misc
116  // data from the event content required by this MVA
117  //
125  //
130 };
131 
134  "PhotonMVAEstimatorRun2Spring15NonTrig");
135 
136 #endif
virtual const std::string & getName() const overridefinal
float mvaValue(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const
std::unique_ptr< const GBRForest > createSingleReader(const int iCategory, const edm::FileInPath &weightFile)
int iEvent
Definition: GenABIO.cc:230
PhotonMVAEstimatorRun2Spring15NonTrig(const edm::ParameterSet &conf)
tuple conf
Definition: dbtoconf.py:185
std::vector< float > fillMVAVariables(const edm::Ptr< reco::Candidate > &particle, const edm::Event &iEvent) const override
string const
Definition: compareJSON.py:14
int findCategory(const edm::Ptr< reco::Candidate > &particle) const override
void setConsumes(edm::ConsumesCollector &&) const override
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< std::unique_ptr< const GBRForest > > _gbrForests
virtual const std::string & getTag() const overridefinal