Belle II Software light-2406-ragdoll
GeneralOptions Class Reference

General options which are shared by all MVA trainings. More...

#include <Options.h>

Inheritance diagram for GeneralOptions:
Collaboration diagram for GeneralOptions:

Public Member Functions

virtual void load (const boost::property_tree::ptree &pt) override
 Load mechanism (used by Weightfile) to load Options from a xml tree.
 
virtual void save (boost::property_tree::ptree &pt) const override
 Save mechanism (used by Weightfile) to store Options in a xml tree.
 
virtual po::options_description getDescription () override
 Returns a program options description for all available options.
 

Public Attributes

std::string m_method
 Name of the MVA method to use.
 
std::string m_identifier
 Identifier containing the finished training.
 
std::vector< std::string > m_datafiles
 Name of the datafiles containing the training data.
 
std::string m_treename = "ntuple"
 Name of the TTree inside the datafile containing the training data.
 
std::vector< std::string > m_variables
 Vector of all variables (branch names) used in the training.
 
std::vector< std::string > m_spectators
 Vector of all spectators (branch names) used in the training.
 
int m_signal_class = 1
 Signal class which is used as signal in a classification problem.
 
unsigned int m_nClasses = 2
 Number of classes in a classification problem.
 
std::string m_target_variable = "isSignal"
 Target variable (branch name) defining the target.
 
std::string m_weight_variable = "__weight__"
 Weight variable (branch name) defining the weights.
 
unsigned int m_max_events = 0
 Maximum number of events to process, 0 means all.
 

Detailed Description

General options which are shared by all MVA trainings.

Definition at line 62 of file Options.h.

Member Function Documentation

◆ getDescription()

po::options_description getDescription ( )
overridevirtual

Returns a program options description for all available options.

Implements Options.

Definition at line 19 of file Options.cc.

20 {
21 po::options_description description("General options");
22 description.add_options()
23 ("help", "print this message")
24 ("datafiles", po::value<std::vector<std::string>>(&m_datafiles)->required()->multitoken(),
25 "ROOT files containing the training dataset")
26 ("treename", po::value<std::string>(&m_treename), "Name of tree in ROOT datafile")
27 ("identifier", po::value<std::string>(&m_identifier)->required(), "Identifier of the outputted weightfile")
28 ("variables", po::value<std::vector<std::string>>(&m_variables)->required()->multitoken(),
29 "feature variables used in the training")
30 ("spectators", po::value<std::vector<std::string>>(&m_spectators)->multitoken(),
31 "spectator variables used in the training")
32 ("target_variable", po::value<std::string>(&m_target_variable),
33 "target variable used to distinguish between signal and background, isSignal is used as default.")
34 ("signal_class", po::value<int>(&m_signal_class), "integer which identifies signal events")
35 ("nClasses", po::value<unsigned int>(&m_nClasses),
36 "number of classes under consideration. Must be supplied for multiclass classifications. Not all methods support multiclass classification.")
37 ("weight_variable", po::value<std::string>(&m_weight_variable), "weight variable used to weight each event")
38 ("max_events", po::value<unsigned int>(&m_max_events), "maximum number of events to process, 0 means all")
39 ("method", po::value<std::string>(&m_method)->required(),
40 "MVA Method [FastBDT|TMVAClassification|TMVARegression|Python|FANN|]");
41 return description;
42 }
std::vector< std::string > m_datafiles
Name of the datafiles containing the training data.
Definition: Options.h:84
int m_signal_class
Signal class which is used as signal in a classification problem.
Definition: Options.h:88
std::vector< std::string > m_variables
Vector of all variables (branch names) used in the training.
Definition: Options.h:86
std::string m_weight_variable
Weight variable (branch name) defining the weights.
Definition: Options.h:91
std::vector< std::string > m_spectators
Vector of all spectators (branch names) used in the training.
Definition: Options.h:87
std::string m_method
Name of the MVA method to use.
Definition: Options.h:82
unsigned int m_max_events
Maximum number of events to process, 0 means all.
Definition: Options.h:92
std::string m_treename
Name of the TTree inside the datafile containing the training data.
Definition: Options.h:85
std::string m_target_variable
Target variable (branch name) defining the target.
Definition: Options.h:90
unsigned int m_nClasses
Number of classes in a classification problem.
Definition: Options.h:89
std::string m_identifier
Identifier containing the finished training.
Definition: Options.h:83

◆ load()

void load ( const boost::property_tree::ptree &  pt)
overridevirtual

Load mechanism (used by Weightfile) to load Options from a xml tree.

Parameters
ptxml tree

Implements Options.

Definition at line 44 of file Options.cc.

45 {
46 m_method = pt.get<std::string>("method");
47 m_identifier = pt.get<std::string>("weightfile");
48 m_treename = pt.get<std::string>("treename");
49 m_target_variable = pt.get<std::string>("target_variable");
50 m_weight_variable = pt.get<std::string>("weight_variable");
51 m_signal_class = pt.get<int>("signal_class");
52 m_max_events = pt.get<unsigned int>("max_events", 0u);
53 m_nClasses = pt.get<unsigned int>("nClasses", 2u);
54
55 unsigned int numberOfFiles = pt.get<unsigned int>("number_data_files", 0);
56 m_datafiles.resize(numberOfFiles);
57 for (unsigned int i = 0; i < numberOfFiles; ++i) {
58 m_datafiles[i] = pt.get<std::string>(std::string("datafile") + std::to_string(i));
59 }
60
61 unsigned int numberOfSpectators = pt.get<unsigned int>("number_spectator_variables", 0u);
62 m_spectators.resize(numberOfSpectators);
63 for (unsigned int i = 0; i < numberOfSpectators; ++i) {
64 m_spectators[i] = pt.get<std::string>(std::string("spectator") + std::to_string(i));
65 }
66
67 auto numberOfFeatures = pt.get<unsigned int>("number_feature_variables");
68 m_variables.resize(numberOfFeatures);
69 for (unsigned int i = 0; i < numberOfFeatures; ++i) {
70 m_variables[i] = pt.get<std::string>(std::string("variable") + std::to_string(i));
71 }
72 }

◆ save()

void save ( boost::property_tree::ptree &  pt) const
overridevirtual

Save mechanism (used by Weightfile) to store Options in a xml tree.

Parameters
ptxml tree

Implements Options.

Definition at line 74 of file Options.cc.

75 {
76 pt.put("method", m_method);
77 pt.put("weightfile", m_identifier);
78 pt.put("treename", m_treename);
79 pt.put("target_variable", m_target_variable);
80 pt.put("weight_variable", m_weight_variable);
81 pt.put("signal_class", m_signal_class);
82 pt.put("max_events", m_max_events);
83 pt.put("nClasses", m_nClasses);
84
85 pt.put("number_feature_variables", m_variables.size());
86 for (unsigned int i = 0; i < m_variables.size(); ++i) {
87 pt.put(std::string("variable") + std::to_string(i), m_variables[i]);
88 }
89
90 pt.put("number_spectator_variables", m_spectators.size());
91 for (unsigned int i = 0; i < m_spectators.size(); ++i) {
92 pt.put(std::string("spectator") + std::to_string(i), m_spectators[i]);
93 }
94
95 pt.put("number_data_files", m_datafiles.size());
96 for (unsigned int i = 0; i < m_datafiles.size(); ++i) {
97 pt.put(std::string("datafile") + std::to_string(i), m_datafiles[i]);
98 }
99 }

Member Data Documentation

◆ m_datafiles

std::vector<std::string> m_datafiles

Name of the datafiles containing the training data.

Definition at line 84 of file Options.h.

◆ m_identifier

std::string m_identifier

Identifier containing the finished training.

Definition at line 83 of file Options.h.

◆ m_max_events

unsigned int m_max_events = 0

Maximum number of events to process, 0 means all.

Definition at line 92 of file Options.h.

◆ m_method

std::string m_method

Name of the MVA method to use.

Definition at line 82 of file Options.h.

◆ m_nClasses

unsigned int m_nClasses = 2

Number of classes in a classification problem.

Definition at line 89 of file Options.h.

◆ m_signal_class

int m_signal_class = 1

Signal class which is used as signal in a classification problem.

Definition at line 88 of file Options.h.

◆ m_spectators

std::vector<std::string> m_spectators

Vector of all spectators (branch names) used in the training.

Definition at line 87 of file Options.h.

◆ m_target_variable

std::string m_target_variable = "isSignal"

Target variable (branch name) defining the target.

Definition at line 90 of file Options.h.

◆ m_treename

std::string m_treename = "ntuple"

Name of the TTree inside the datafile containing the training data.

Definition at line 85 of file Options.h.

◆ m_variables

std::vector<std::string> m_variables

Vector of all variables (branch names) used in the training.

Definition at line 86 of file Options.h.

◆ m_weight_variable

std::string m_weight_variable = "__weight__"

Weight variable (branch name) defining the weights.

Definition at line 91 of file Options.h.


The documentation for this class was generated from the following files: