10 #include <mva/modules/MVAExpert/MVAPrototypeModule.h>
11 #include <mva/interface/Interface.h>
13 #include <boost/algorithm/string/predicate.hpp>
26 setDescription(
"Prototype of a module which uses the MVA package");
31 setPropertyFlags(c_ParallelProcessingCertified);
35 addParam(
"identifier", m_identifier,
"The database identifier or filename which is used to load the weights during the training.");
41 addParam(
"signalFraction", m_signal_fraction_override,
42 "signalFraction to calculate probability (if -1 the signalFraction of the training data is used)", -1.0);
66 std::stringstream ss((*m_weightfile_representation)->m_data);
93 m_expert = supported_interfaces[general_options.m_method]->getExpert();
100 std::vector<float> dummy(general_options.m_variables.size(), 0);
101 m_dataset = std::make_unique<MVA::SingleDataset>(general_options, dummy, 0);
111 B2ERROR(
"MVA Expert is not loaded! I will return 0");
117 for (
unsigned int i = 0; i <
m_dataset->getNumberOfFeatures(); ++i) {
126 B2INFO(
"The probability is " << probability);
This module can be used as a prototype for your own module which uses MVA weightfiles.
std::unique_ptr< MVA::SingleDataset > m_dataset
Pointer to the current dataset.
std::unique_ptr< MVA::Expert > m_expert
Pointer to the current MVA Expert.
double m_signal_fraction_override
Signal Fraction which should be used.
std::unique_ptr< DBObjPtr< DatabaseRepresentationOfWeightfile > > m_weightfile_representation
Database pointer to the Database representation of the weightfile.
std::string m_identifier
database identifier or filename of the weightfile
static std::map< std::string, AbstractInterface * > getSupportedInterfaces()
Returns interfaces supported by the MVA Interface.
static void initSupportedInterfaces()
Static function which initliazes all supported interfaces, has to be called once before getSupportedI...
General options which are shared by all MVA trainings.
The Weightfile class serializes all information about a training into an xml tree.
static Weightfile loadFromStream(std::istream &stream)
Static function which deserializes a Weightfile from a stream.
void getOptions(Options &options) const
Fills an Option object from the xml tree.
static Weightfile loadFromFile(const std::string &filename)
Static function which loads a Weightfile from a file.
void addSignalFraction(float signal_fraction)
Saves the signal fraction in the xml tree.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
virtual void initialize() override
Initialize the module.
virtual void event() override
Called for each event.
virtual void beginRun() override
Called at the beginning of a new run.
void init_mva(MVA::Weightfile &weightfile)
Initialize mva expert, dataset and features Called every time the weightfile in the database changes ...
Abstract base class for different kinds of events.