Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:01

0001 #ifndef RecoEgamma_EgammaTools_AnyMVAEstimatorRun2Base_H
0002 #define RecoEgamma_EgammaTools_AnyMVAEstimatorRun2Base_H
0003 
0004 // Note on Python/FWLite support: please forward declare as much as possible in
0005 // this header, because there are usecases of generating the dictionaries for
0006 // this class on the fly (see notes in ElectronMVAEstimatorRun2.h for more
0007 // details).
0008 
0009 #include <string>
0010 #include <vector>
0011 
0012 namespace edm {
0013   class ParameterSet;
0014 }  // namespace edm
0015 
0016 namespace reco {
0017   class Candidate;
0018 }  // namespace reco
0019 
0020 class AnyMVAEstimatorRun2Base {
0021 public:
0022   // Constructor, destructor
0023   AnyMVAEstimatorRun2Base(const edm::ParameterSet& conf);
0024 
0025   AnyMVAEstimatorRun2Base(const ::std::string& mvaName, const ::std::string& mvaTag, int nCategories, bool debug)
0026       : name_(mvaName), tag_(mvaTag), nCategories_(nCategories), debug_(debug) {}
0027   virtual ~AnyMVAEstimatorRun2Base(){};
0028 
0029   // Functions that must be provided in derived classes
0030   // These function should work on electrons or photons
0031   // of the reco or pat type
0032 
0033   virtual float mvaValue(const reco::Candidate* candidate,
0034                          std::vector<float> const& auxVariables,
0035                          int& iCategory) const = 0;
0036   float mvaValue(const reco::Candidate* candidate, std::vector<float> const& auxVariables) const {
0037     int iCategory;
0038     return mvaValue(candidate, auxVariables, iCategory);
0039   };
0040 
0041   // A specific implementation of MVA is expected to have one or more categories
0042   // defined with respect to eta, pt, etc.
0043   // This function determines the category for a given candidate.
0044   virtual int findCategory(const reco::Candidate* candidate) const = 0;
0045   int getNCategories() const { return nCategories_; }
0046   const std::string& getName() const { return name_; }
0047   // An extra variable string set during construction that can be used
0048   // to distinguish different instances of the estimator configured with
0049   // different weight files. The tag can be used to construct names of ValueMaps, etc.
0050   const std::string& getTag() const { return tag_; }
0051 
0052   bool isDebug() const { return debug_; }
0053   //
0054   // Extra event content - if needed.
0055   //
0056   // Some MVA implementation may require direct access to event content.
0057   // Implement these methods only if needed in the derived classes (use "override"
0058   // for certainty).
0059 
0060 private:
0061   //
0062   // Data members
0063   //
0064   const std::string name_;
0065 
0066   // MVA tag. This is an additional string variable to distinguish
0067   // instances of the estimator of this class configured with different
0068   // weight files.
0069   const std::string tag_;
0070 
0071   // The number of categories and number of variables per category
0072   const int nCategories_;
0073 
0074   const bool debug_;
0075 };
0076 
0077 #endif