CMS 3D CMS Logo

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 override;
67 
68  // Utility functions
69  int getNCategories() const override { 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& 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  //void getEventContent(const edm::Event& iEvent) override;
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 = "PhotonMVAEstimatorRun2Spring15NonTrig";
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  //
116  const bool _useValueMaps;
124  //
129 };
130 
131 #endif
int iEvent
Definition: GenABIO.cc:230
PhotonMVAEstimatorRun2Spring15NonTrig(const edm::ParameterSet &conf)
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
std::vector< std::unique_ptr< const GBRForest > > _gbrForests
std::vector< float > fillMVAVariables(const edm::Ptr< reco::Candidate > &particle, const edm::Event &iEvent) const override