CMS 3D CMS Logo

AnyMVAEstimatorRun2Base.h
Go to the documentation of this file.
1 #ifndef RecoEgamma_EgammaTools_AnyMVAEstimatorRun2Base_H
2 #define RecoEgamma_EgammaTools_AnyMVAEstimatorRun2Base_H
3 
5 
8 
10 
12 
13  public:
14  // Constructor, destructor
16  : conf_ (conf)
17  , name_ (conf.getParameter<std::string>("mvaName"))
18  , tag_ (conf.getParameter<std::string>("mvaTag"))
19  , nCategories_ (conf.getParameter<int>("nCategories"))
20  , methodName_ ("BDTG method")
21  , debug_ (conf.getUntrackedParameter<bool>("debug", false))
22  {}
24 
25  // Functions that must be provided in derived classes
26  // These function should work on electrons or photons
27  // of the reco or pat type
28 
29  virtual float mvaValue( const edm::Ptr<reco::Candidate>& particle, const edm::EventBase&, int &iCategory) const = 0;
30  float mvaValue( const edm::Ptr<reco::Candidate>& candPtr, const edm::EventBase& iEvent) const {
31  int iCategory;
32  return mvaValue(candPtr, iEvent, iCategory);
33  };
34 
35  // A specific implementation of MVA is expected to have one or more categories
36  // defined with respect to eta, pt, etc.
37  // This function determines the category for a given particle.
38  virtual int findCategory( const edm::Ptr<reco::Candidate>& candPtr) const = 0;
39  int getNCategories() const { return nCategories_; }
40  // The name is a unique name associated with a particular MVA implementation,
41  // it is found as a const data member in a derived class.
42  const std::string& getName() const { return name_; }
43  // An extra variable string set during construction that can be used
44  // to distinguish different instances of the estimator configured with
45  // different weight files. The tag can be used to construct names of ValueMaps, etc.
46  const std::string& getTag() const { return tag_; }
47 
48  bool isDebug() const { return debug_; }
49  //
50  // Extra event content - if needed.
51  //
52  // Some MVA implementation may require direct access to event content.
53  // Implement these methods only if needed in the derived classes (use "override"
54  // for certainty).
55 
56  // This method needs to be used only once after this MVA estimator is constructed
57  virtual void setConsumes(edm::ConsumesCollector &&cc) {};
58 
59  private:
60 
61  //
62  // Data members
63  //
64 
65  // Configuration
67 
68  // MVA name. This is a unique name for this MVA implementation.
69  // It will be used as part of ValueMap names.
70  // For simplicity, keep it set to the class name.
72 
73  // MVA tag. This is an additional string variable to distinguish
74  // instances of the estimator of this class configured with different
75  // weight files.
77 
78  // The number of categories and number of variables per category
79  const int nCategories_;
80 
82 
83  const bool debug_;
84 };
85 
86 // define the factory for this base class
90 
91 #endif
AnyMVAEstimatorRun2Base(const edm::ParameterSet &conf)
const std::string & getName() const
const std::string & getTag() const
virtual void setConsumes(edm::ConsumesCollector &&cc)
const edm::ParameterSet conf_
int iEvent
Definition: GenABIO.cc:230
float mvaValue(const edm::Ptr< reco::Candidate > &candPtr, const edm::EventBase &iEvent) const
virtual int findCategory(const edm::Ptr< reco::Candidate > &candPtr) const =0
virtual float mvaValue(const edm::Ptr< reco::Candidate > &particle, const edm::EventBase &, int &iCategory) const =0
edmplugin::PluginFactory< AnyMVAEstimatorRun2Base *(const edm::ParameterSet &) > AnyMVAEstimatorRun2Factory