Belle II Software development
Interface.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10#ifndef INCLUDE_GUARD_BELLE2_MVA_INTERFACE_HEADER
11#define INCLUDE_GUARD_BELLE2_MVA_INTERFACE_HEADER
12
13#include <mva/interface/Teacher.h>
14#include <mva/interface/Expert.h>
15
16#include <map>
17#include <string>
18#include <memory>
19
20namespace Belle2 {
25 namespace MVA {
26
31 public:
36 explicit AbstractInterface(const std::string& name);
37
41 virtual ~AbstractInterface();
42
47 std::string getName() const;
48
53 static std::map<std::string, AbstractInterface*> getSupportedInterfaces() { return s_supported_interfaces; }
54
60 static void initSupportedInterfaces();
61
65 virtual std::unique_ptr<SpecificOptions> getOptions() const = 0;
66
72 virtual std::unique_ptr<Teacher> getTeacher(const GeneralOptions& general_options,
73 const SpecificOptions& specific_options) const = 0;
74
78 virtual std::unique_ptr<MVA::Expert> getExpert() const = 0;
79
80 private:
84 std::string m_name;
85
89 static std::map<std::string, AbstractInterface*> s_supported_interfaces;
90
91 };
92
93
98 template<class TemplateOptions, class TemplateTeacher, class TemplateExpert>
100 public:
104 Interface() : AbstractInterface(TemplateOptions().getMethod()) { }
105
109 virtual std::unique_ptr<SpecificOptions> getOptions() const override { return std::unique_ptr<SpecificOptions>(new TemplateOptions); }
110
116 virtual std::unique_ptr<Teacher> getTeacher(const GeneralOptions& general_options,
117 const SpecificOptions& specific_options) const override
118 {
119 return std::unique_ptr<Teacher>(new TemplateTeacher(general_options, dynamic_cast<const TemplateOptions&>(specific_options)));
120 }
121
125 virtual std::unique_ptr<MVA::Expert> getExpert() const override { return std::unique_ptr<MVA::Expert>(new TemplateExpert); }
126
127 };
128
129 }
131}
132#endif
Abstract Interface to third-party MVA libraries.
Definition: Interface.h:30
static void initSupportedInterfaces()
Static function which initliazes all supported interfaces, has to be called once before getSupportedI...
Definition: Interface.cc:45
std::string getName() const
Returns the name of the third-party MVA library.
Definition: Interface.cc:41
static std::map< std::string, AbstractInterface * > s_supported_interfaces
Map of supported interfaces.
Definition: Interface.h:89
virtual std::unique_ptr< MVA::Expert > getExpert() const =0
Get Exoert of this MVA library.
virtual std::unique_ptr< SpecificOptions > getOptions() const =0
Get Options of this MVA library.
virtual std::unique_ptr< Teacher > getTeacher(const GeneralOptions &general_options, const SpecificOptions &specific_options) const =0
Get Teacher of this MVA library.
std::string m_name
Name of the third-party library.
Definition: Interface.h:84
static std::map< std::string, AbstractInterface * > getSupportedInterfaces()
Returns interfaces supported by the MVA Interface.
Definition: Interface.h:53
virtual ~AbstractInterface()
Virtual destructor.
Definition: Interface.cc:36
General options which are shared by all MVA trainings.
Definition: Options.h:62
Template class to easily construct a interface for an MVA library using a library-specific Options,...
Definition: Interface.h:99
Interface()
Constructs a new interface.
Definition: Interface.h:104
virtual std::unique_ptr< MVA::Expert > getExpert() const override
Get Exoert of this MVA library.
Definition: Interface.h:125
virtual std::unique_ptr< Teacher > getTeacher(const GeneralOptions &general_options, const SpecificOptions &specific_options) const override
Get Teacher of this MVA library.
Definition: Interface.h:116
virtual std::unique_ptr< SpecificOptions > getOptions() const override
Get Options of this MVA library.
Definition: Interface.h:109
Specific Options, all method Options have to inherit from this class.
Definition: Options.h:98
Abstract base class for different kinds of events.