Belle II Software  release-05-01-25
Utility.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Thomas Keck *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <mva/utility/Utility.h>
12 #include <mva/utility/DataDriven.h>
13 #include <mva/methods/PDF.h>
14 #include <mva/methods/Reweighter.h>
15 #include <mva/methods/Trivial.h>
16 #include <mva/methods/Combination.h>
17 
18 #include <framework/logging/Logger.h>
19 
20 #include <framework/utilities/MakeROOTCompatible.h>
21 
22 #include <boost/algorithm/string/predicate.hpp>
23 #include <boost/property_tree/xml_parser.hpp>
24 
25 #include <iostream>
26 #include <chrono>
27 #include <string>
28 #include <regex>
29 #include <fstream>
30 
31 namespace Belle2 {
36  namespace MVA {
37 
38  void loadRootDictionary() { }
39 
40  void download(const std::string& identifier, const std::string& filename, int experiment, int run, int event)
41  {
42  Belle2::EventMetaData emd(event, run, experiment);
44  if (boost::ends_with(filename, ".root")) {
45  Belle2::MVA::Weightfile::saveToROOTFile(weightfile, filename);
46  } else if (boost::ends_with(filename, ".xml")) {
47  Belle2::MVA::Weightfile::saveToXMLFile(weightfile, filename);
48  } else {
49  std::cerr << "Unkown file extension, fallback to xml" << std::endl;
50  Belle2::MVA::Weightfile::saveToXMLFile(weightfile, filename);
51  }
52  }
53 
54  void upload(const std::string& filename, const std::string& identifier, int exp1, int run1, int exp2, int run2)
55  {
56  Belle2::IntervalOfValidity iov(exp1, run1, exp2, run2);
57  Belle2::MVA::Weightfile weightfile;
58  if (boost::ends_with(filename, ".root")) {
59  weightfile = Belle2::MVA::Weightfile::loadFromROOTFile(filename);
60  } else if (boost::ends_with(filename, ".xml")) {
61  weightfile = Belle2::MVA::Weightfile::loadFromXMLFile(filename);
62  } else {
63  std::cerr << "Unkown file extension, fallback to xml" << std::endl;
64  weightfile = Belle2::MVA::Weightfile::loadFromXMLFile(filename);
65  }
66  Belle2::MVA::Weightfile::saveToDatabase(weightfile, identifier, iov);
67  }
68 
69  void upload_array(std::vector<std::string>& filenames, const std::string& identifier, int exp1, int run1, int exp2, int run2)
70  {
71  Belle2::IntervalOfValidity iov(exp1, run1, exp2, run2);
72 
73  std::vector<Belle2::MVA::Weightfile> weightfiles;
74  for (const auto& filename : filenames) {
75 
76  Belle2::MVA::Weightfile weightfile;
77  if (boost::ends_with(filename, ".root")) {
78  weightfile = Belle2::MVA::Weightfile::loadFromROOTFile(filename);
79  } else if (boost::ends_with(filename, ".xml")) {
80  weightfile = Belle2::MVA::Weightfile::loadFromXMLFile(filename);
81  } else {
82  std::cerr << "Unkown file extension, fallback to xml" << std::endl;
83  weightfile = Belle2::MVA::Weightfile::loadFromXMLFile(filename);
84  }
85  weightfiles.push_back(weightfile);
86  }
87  Belle2::MVA::Weightfile::saveArrayToDatabase(weightfiles, identifier, iov);
88  }
89 
90  void extract(const std::string& filename, const std::string& directory)
91  {
92 
94  auto supported_interfaces = AbstractInterface::getSupportedInterfaces();
95  auto weightfile = Weightfile::load(filename);
96  weightfile.setRemoveTemporaryDirectories(false);
97  weightfile.setTemporaryDirectory(directory);
98  GeneralOptions general_options;
99  weightfile.getOptions(general_options);
100  auto expert = supported_interfaces[general_options.m_method]->getExpert();
101  expert->load(weightfile);
102 
103  }
104 
105  std::string info(const std::string& filename)
106  {
107 
109  auto supported_interfaces = AbstractInterface::getSupportedInterfaces();
110  auto weightfile = Weightfile::load(filename);
111  GeneralOptions general_options;
112  weightfile.getOptions(general_options);
113 
114  auto specific_options = supported_interfaces[general_options.m_method]->getOptions();
115  specific_options->load(weightfile.getXMLTree());
116 
117  boost::property_tree::ptree temp_tree;
118  general_options.save(temp_tree);
119  specific_options->save(temp_tree);
120  std::ostringstream oss;
121 
122 #if BOOST_VERSION < 105600
123  boost::property_tree::xml_writer_settings<char> settings('\t', 1);
124 #else
125  boost::property_tree::xml_writer_settings<std::string> settings('\t', 1);
126 #endif
127  boost::property_tree::xml_parser::write_xml(oss, temp_tree, settings);;
128 
129  return oss.str();
130 
131  }
132 
133  bool available(const std::string& filename, int experiment, int run, int event)
134  {
135 
136  try {
137  auto weightfile = Weightfile::load(filename, Belle2::EventMetaData(event, run, experiment));
138  return true;
139  } catch (...) {
140  return false;
141  }
142 
143  }
144 
145  void expert(const std::vector<std::string>& filenames, const std::vector<std::string>& datafiles, const std::string& treename,
146  const std::string& outputfile, int experiment, int run, int event, bool copy_target)
147  {
148 
149  std::vector<Weightfile> weightfiles;
150  std::vector<TBranch*> branches;
151 
152  TFile file(outputfile.c_str(), "RECREATE");
153  file.cd();
154  TTree tree("variables", "variables");
155  float result = 0;
156 
157  for (auto& filename : filenames) {
158  Belle2::EventMetaData emd(event, run, experiment);
159  auto weightfile = Weightfile::load(filename, emd);
160  weightfiles.push_back(weightfile);
161 
162  std::string branchname = Belle2::makeROOTCompatible(filename);
163  auto branch = tree.Branch(branchname.c_str(), &result, (branchname + "/F").c_str());
164  branches.push_back(branch);
165  }
166 
168  auto supported_interfaces = AbstractInterface::getSupportedInterfaces();
169 
170  unsigned int i = 0;
171  for (auto& weightfile : weightfiles) {
172  GeneralOptions general_options;
173  weightfile.getOptions(general_options);
174  general_options.m_treename = treename;
175  // Override possible restriction of number of events in training
176  // otherwise this would apply to the expert as well.
177  general_options.m_max_events = 0;
178 
179  auto expert = supported_interfaces[general_options.m_method]->getExpert();
180  expert->load(weightfile);
181  // define if target variables should be copied
182  if (not copy_target) {
183  general_options.m_target_variable = std::string();
184  }
185 
186  general_options.m_datafiles = datafiles;
187  auto& branch = branches[i];
188  ROOTDataset data(general_options);
189  std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now();
190  auto results = expert->apply(data);
191  std::chrono::high_resolution_clock::time_point stop = std::chrono::high_resolution_clock::now();
192  std::chrono::duration<double, std::milli> training_time = stop - start;
193  B2INFO("Elapsed application time in ms " << training_time.count() << " for " << general_options.m_identifier);
194  for (auto& r : results) {
195  result = r;
196  branch->Fill();
197  }
198 
199 
200  if (not general_options.m_target_variable.empty()) {
201  std::string branchname = Belle2::makeROOTCompatible(std::string(branch->GetName()) + "_" + general_options.m_target_variable);
202  float target = 0;
203  auto target_branch = tree.Branch(branchname.c_str(), &target, (branchname + "/F").c_str());
204  auto targets = data.getTargets();
205  for (auto& t : targets) {
206  target = t;
207  target_branch->Fill();
208  }
209  }
210 
211  ++i;
212  }
213 
214  tree.SetEntries();
215  file.Write("variables");
216 
217  }
218 
219  void save_custom_weightfile(const GeneralOptions& general_options, const SpecificOptions& specific_options,
220  const std::string& custom_weightfile, const std::string& output_identifier)
221  {
222  std::ifstream ifile(custom_weightfile);
223  if (!(bool)ifile) {
224  B2FATAL("Input weight file: " << custom_weightfile << " does not exist!");
225  }
226 
227  Weightfile weightfile;
228  weightfile.addOptions(general_options);
229  weightfile.addOptions(specific_options);
230  weightfile.addFile(general_options.m_identifier + "_Weightfile", custom_weightfile);
231  std::string output_weightfile(custom_weightfile);
232  if (!output_identifier.empty()) {
233  std::regex to_replace("(\\.\\S+$)");
234  std::string replacement = "_" + output_identifier + "$0";
235  output_weightfile = std::regex_replace(output_weightfile, to_replace, replacement);
236  }
237  Weightfile::save(weightfile, output_weightfile);
238  }
239 
240  void teacher(const GeneralOptions& general_options, const SpecificOptions& specific_options, const MetaOptions& meta_options)
241  {
242  unsigned int number_of_enabled_meta_trainings = 0;
243  if (meta_options.m_use_splot)
244  number_of_enabled_meta_trainings++;
245  if (meta_options.m_use_sideband_substraction)
246  number_of_enabled_meta_trainings++;
247  if (meta_options.m_use_reweighting)
248  number_of_enabled_meta_trainings++;
249 
250  if (number_of_enabled_meta_trainings > 1) {
251  B2ERROR("You enabled more than one meta training option. You can only use one (sPlot, SidebandSubstraction or Reweighting)");
252  return;
253  }
254 
255  if (meta_options.m_use_splot) {
256  teacher_splot(general_options, specific_options, meta_options);
257  } else if (meta_options.m_use_sideband_substraction) {
258  teacher_sideband_substraction(general_options, specific_options, meta_options);
259  } else if (meta_options.m_use_reweighting) {
260  teacher_reweighting(general_options, specific_options, meta_options);
261  } else {
262  ROOTDataset data(general_options);
263  teacher_dataset(general_options, specific_options, data);
264  }
265  }
266 
267 
268  std::unique_ptr<Belle2::MVA::Expert> teacher_dataset(GeneralOptions general_options, const SpecificOptions& specific_options,
269  Dataset& data)
270  {
271  if (general_options.m_method.empty()) {
272  general_options.m_method = specific_options.getMethod();
273  } else {
274  if (general_options.m_method != specific_options.getMethod()) {
275  B2ERROR("The method specified in the general options is in conflict with the provided specific option:" << general_options.m_method
276  << " " << specific_options.getMethod());
277  }
278  }
280  auto supported_interfaces = AbstractInterface::getSupportedInterfaces();
281  if (supported_interfaces.find(general_options.m_method) != supported_interfaces.end()) {
282  auto teacher = supported_interfaces[general_options.m_method]->getTeacher(general_options, specific_options);
283  std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now();
284  auto weightfile = teacher->train(data);
285  std::chrono::high_resolution_clock::time_point stop = std::chrono::high_resolution_clock::now();
286  std::chrono::duration<double, std::milli> training_time = stop - start;
287  B2INFO("Elapsed training time in ms " << training_time.count() << " for " << general_options.m_identifier);
288  Weightfile::save(weightfile, general_options.m_identifier);
289  auto expert = supported_interfaces[general_options.m_method]->getExpert();
290  expert->load(weightfile);
291  return expert;
292  } else {
293  B2ERROR("Interface doesn't support chosen method" << general_options.m_method);
294  throw std::runtime_error("Interface doesn't support chosen method" + general_options.m_method);
295  }
296  }
297 
298  std::unique_ptr<Belle2::MVA::Expert> teacher_splot(const GeneralOptions& general_options, const SpecificOptions& specific_options,
299  const MetaOptions& meta_options)
300  {
301 
302  GeneralOptions data_general_options = general_options;
303  data_general_options.m_target_variable = "";
304  if (meta_options.m_splot_combined)
305  data_general_options.m_identifier = general_options.m_identifier + "_splot.xml";
306  ROOTDataset data_dataset(data_general_options);
307  // Reset target variable so that it shows up in the weightfile at the end
308  data_general_options.m_target_variable = general_options.m_target_variable;
309 
310  GeneralOptions discriminant_general_options = general_options;
311  discriminant_general_options.m_target_variable = "";
312  discriminant_general_options.m_variables = {meta_options.m_splot_variable};
313  ROOTDataset discriminant_dataset(discriminant_general_options);
314  // Reset target variable so that it shows up in the weightfile at the end
315  discriminant_general_options.m_target_variable = general_options.m_target_variable;
316 
317  GeneralOptions mc_general_options = general_options;
318  mc_general_options.m_datafiles = meta_options.m_splot_mc_files;
319  mc_general_options.m_variables = {meta_options.m_splot_variable};
320  ROOTDataset mc_dataset(mc_general_options);
321 
322  auto mc_signals = mc_dataset.getSignals();
323  auto mc_weights = mc_dataset.getWeights();
324  auto mc_feature = mc_dataset.getFeature(0);
325  auto data_feature = discriminant_dataset.getFeature(0);
326  auto data_weights = discriminant_dataset.getWeights();
327 
328  Binning binning = Binning::CreateEqualFrequency(mc_feature , mc_weights, mc_signals, 100);
329 
330  float signalFraction = binning.m_signal_yield / (binning.m_signal_yield + binning.m_bckgrd_yield);
331 
332  std::vector<double> data(100, 0);
333  double total_data = 0.0;
334  for (unsigned int iEvent = 0; iEvent < data_dataset.getNumberOfEvents(); ++iEvent) {
335  data[binning.getBin(data_feature[iEvent])] += data_weights[iEvent];
336  total_data += data_weights[iEvent];
337  }
338 
339  // We do a simple fit here to estimate the signal and backgrund yields
340  // We could use RooFit here to avoid using custom code,
341  // but I found RooFit to be difficult and unstable ...
342 
343  float best_yield = 0.0;
344  double best_chi2 = 1000000000.0;
345  bool empty_bin = false;
346  for (double yield = 0; yield < total_data; yield += 1) {
347  double chi2 = 0.0;
348  for (unsigned int iBin = 0; iBin < 100; ++iBin) {
349  double deviation = (data[iBin] - (yield * binning.m_signal_pdf[iBin] + (total_data - yield) * binning.m_bckgrd_pdf[iBin]) *
350  (binning.m_boundaries[iBin + 1] - binning.m_boundaries[iBin]) / (binning.m_boundaries[100] - binning.m_boundaries[0]));
351  if (data[iBin] > 0)
352  chi2 += deviation * deviation / data[iBin];
353  else
354  empty_bin = true;
355  }
356  if (chi2 < best_chi2) {
357  best_chi2 = chi2;
358  best_yield = yield;
359  }
360  }
361 
362  if (empty_bin) {
363  B2WARNING("Encountered empty bin in data histogram during fit of the components for sPlot");
364  }
365 
366  B2INFO("sPlot best yield " << best_yield);
367  B2INFO("sPlot Yields On MC " << binning.m_signal_yield << " " << binning.m_bckgrd_yield);
368 
369  binning.m_signal_yield = best_yield;
370  binning.m_bckgrd_yield = (total_data - best_yield);
371 
372  B2INFO("sPlot Yields Fitted On Data " << binning.m_signal_yield << " " << binning.m_bckgrd_yield);
373 
374  if (meta_options.m_splot_boosted) {
375  GeneralOptions boost_general_options = data_general_options;
376  boost_general_options.m_identifier = general_options.m_identifier + "_boost.xml";
377  SPlotDataset splot_dataset(boost_general_options, data_dataset, getBoostWeights(discriminant_dataset, binning), signalFraction);
378  auto boost_expert = teacher_dataset(boost_general_options, specific_options, splot_dataset);
379 
380  SPlotDataset aplot_dataset(data_general_options, data_dataset, getAPlotWeights(discriminant_dataset, binning,
381  boost_expert->apply(data_dataset)), signalFraction);
382  auto splot_expert = teacher_dataset(data_general_options, specific_options, aplot_dataset);
383  if (not meta_options.m_splot_combined)
384  return splot_expert;
385  } else {
386  SPlotDataset splot_dataset(data_general_options, data_dataset, getSPlotWeights(discriminant_dataset, binning), signalFraction);
387  auto splot_expert = teacher_dataset(data_general_options, specific_options, splot_dataset);
388  if (not meta_options.m_splot_combined)
389  return splot_expert;
390  }
391 
392  mc_general_options.m_identifier = general_options.m_identifier + "_pdf.xml";
393  mc_general_options.m_method = "PDF";
394  PDFOptions pdf_options;
395  auto pdf_expert = teacher_dataset(mc_general_options, pdf_options, mc_dataset);
396 
397  GeneralOptions combination_general_options = general_options;
398  combination_general_options.m_method = "Combination";
399  combination_general_options.m_variables.push_back(meta_options.m_splot_variable);
400  CombinationOptions combination_options;
401  combination_options.m_weightfiles = {data_general_options.m_identifier, mc_general_options.m_identifier};
402  auto combination_expert = teacher_dataset(combination_general_options, combination_options, data_dataset);
403 
404  return combination_expert;
405  }
406 
407  std::unique_ptr<Belle2::MVA::Expert> teacher_reweighting(const GeneralOptions& general_options,
408  const SpecificOptions& specific_options,
409  const MetaOptions& meta_options)
410  {
411  if (std::find(general_options.m_variables.begin(), general_options.m_variables.end(),
412  meta_options.m_reweighting_variable) != general_options.m_variables.end()) {
413  B2ERROR("You cannot use the reweighting variable as a feature in your training");
414  return nullptr;
415  }
416 
417  GeneralOptions data_general_options = general_options;
418  data_general_options.m_target_variable = "";
419  data_general_options.m_datafiles = meta_options.m_reweighting_data_files;
420  ROOTDataset data_dataset(data_general_options);
421 
422  GeneralOptions mc_general_options = general_options;
423  mc_general_options.m_datafiles = meta_options.m_reweighting_mc_files;
424  ROOTDataset mc_dataset(mc_general_options);
425 
426  CombinedDataset boost_dataset(general_options, data_dataset, mc_dataset);
427 
428  GeneralOptions boost_general_options = general_options;
429  boost_general_options.m_identifier = general_options.m_identifier + "_boost.xml";
430  auto boost_expert = teacher_dataset(boost_general_options, specific_options, boost_dataset);
431 
432  GeneralOptions reweighter_general_options = general_options;
433  reweighter_general_options.m_identifier = meta_options.m_reweighting_identifier;
434  reweighter_general_options.m_method = "Reweighter";
435  ReweighterOptions reweighter_specific_options;
436  reweighter_specific_options.m_weightfile = boost_general_options.m_identifier;
437  reweighter_specific_options.m_variable = meta_options.m_reweighting_variable;
438 
439  if (meta_options.m_reweighting_variable != "") {
440  if (std::find(reweighter_general_options.m_spectators.begin(), reweighter_general_options.m_spectators.end(),
441  meta_options.m_reweighting_variable) == reweighter_general_options.m_spectators.end() and
442  std::find(reweighter_general_options.m_variables.begin(), reweighter_general_options.m_variables.end(),
443  meta_options.m_reweighting_variable) == reweighter_general_options.m_variables.end() and
444  reweighter_general_options.m_target_variable != meta_options.m_reweighting_variable and
445  reweighter_general_options.m_weight_variable != meta_options.m_reweighting_variable) {
446  reweighter_general_options.m_spectators.push_back(meta_options.m_reweighting_variable);
447  }
448  }
449 
450  ROOTDataset dataset(reweighter_general_options);
451  auto reweight_expert = teacher_dataset(reweighter_general_options, reweighter_specific_options, dataset);
452  auto weights = reweight_expert->apply(dataset);
453  ReweightingDataset reweighted_dataset(general_options, dataset, weights);
454  auto expert = teacher_dataset(general_options, specific_options, reweighted_dataset);
455 
456  return expert;
457  }
458 
459  std::unique_ptr<Belle2::MVA::Expert> teacher_sideband_substraction(const GeneralOptions& general_options,
460  const SpecificOptions& specific_options,
461  const MetaOptions& meta_options)
462  {
463 
464  if (std::find(general_options.m_variables.begin(), general_options.m_variables.end(),
465  meta_options.m_sideband_variable) != general_options.m_variables.end()) {
466  B2ERROR("You cannot use the sideband variable as a feature in your training");
467  return nullptr;
468  }
469 
470  GeneralOptions data_general_options = general_options;
471  if (std::find(data_general_options.m_spectators.begin(), data_general_options.m_spectators.end(),
472  meta_options.m_sideband_variable) == data_general_options.m_spectators.end()) {
473  data_general_options.m_spectators.push_back(meta_options.m_sideband_variable);
474  }
475  ROOTDataset data_dataset(data_general_options);
476 
477  GeneralOptions mc_general_options = general_options;
478  mc_general_options.m_datafiles = meta_options.m_sideband_mc_files;
479  if (std::find(mc_general_options.m_spectators.begin(), mc_general_options.m_spectators.end(),
480  meta_options.m_sideband_variable) == mc_general_options.m_spectators.end()) {
481  mc_general_options.m_spectators.push_back(meta_options.m_sideband_variable);
482  }
483  ROOTDataset mc_dataset(mc_general_options);
484 
485  GeneralOptions sideband_general_options = general_options;
486  SidebandDataset sideband_dataset(sideband_general_options, data_dataset, mc_dataset, meta_options.m_sideband_variable);
487  auto expert = teacher_dataset(general_options, specific_options, sideband_dataset);
488 
489  return expert;
490  }
491 
492 
493  }
495 }
Belle2::IntervalOfValidity
A class that describes the interval of experiments/runs for which an object in the database is valid.
Definition: IntervalOfValidity.h:35
Belle2::MVA::AbstractInterface::getSupportedInterfaces
static std::map< std::string, AbstractInterface * > getSupportedInterfaces()
Returns interfaces supported by the MVA Interface.
Definition: Interface.h:55
Belle2::MVA::Weightfile::getOptions
void getOptions(Options &options) const
Fills an Option object from the xml tree.
Definition: Weightfile.cc:76
Belle2::MVA::Binning::CreateEqualFrequency
static Binning CreateEqualFrequency(const std::vector< float > &data, const std::vector< float > &weights, const std::vector< bool > &isSignal, unsigned int nBins)
Create an equal frequency (aka equal-statistics) binning.
Definition: Binning.cc:103
Belle2::MVA::Weightfile::saveToDatabase
static void saveToDatabase(Weightfile &weightfile, const std::string &identifier, const Belle2::IntervalOfValidity &iov=Belle2::IntervalOfValidity(0, 0, -1, -1))
Static function which saves a Weightfile in the basf2 condition database.
Definition: Weightfile.cc:267
Belle2::MVA::Weightfile::setTemporaryDirectory
void setTemporaryDirectory(const std::string &temporary_directory)
set temporary directory which is used to store temporary directories
Definition: Weightfile.h:286
Belle2::MVA::Weightfile
The Weightfile class serializes all information about a training into an xml tree.
Definition: Weightfile.h:40
Belle2::MVA::Weightfile::getXMLTree
const boost::property_tree::ptree & getXMLTree() const
Get xml tree.
Definition: Weightfile.h:291
Belle2::makeROOTCompatible
std::string makeROOTCompatible(std::string str)
Remove special characters that ROOT dislikes in branch names, e.g.
Definition: MakeROOTCompatible.cc:74
Belle2::MVA::Weightfile::loadFromROOTFile
static Weightfile loadFromROOTFile(const std::string &filename)
Static function which loads a Weightfile from a ROOT file.
Definition: Weightfile.cc:226
Belle2::MVA::Weightfile::load
static Weightfile load(const std::string &filename, const Belle2::EventMetaData &emd=Belle2::EventMetaData(0, 0, 0))
Static function which loads a Weightfile from a file or fomr the database.
Definition: Weightfile.cc:204
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::MVA::Weightfile::addOptions
void addOptions(const Options &options)
Add an Option object to the xml tree.
Definition: Weightfile.cc:71
Belle2::MVA::Weightfile::loadFromXMLFile
static Weightfile loadFromXMLFile(const std::string &filename)
Static function which loads a Weightfile from a XML file.
Definition: Weightfile.cc:249
Belle2::MVA::Weightfile::saveToXMLFile
static void saveToXMLFile(Weightfile &weightfile, const std::string &filename)
Static function which saves a Weightfile to a XML file.
Definition: Weightfile.cc:184
Belle2::MVA::AbstractInterface::initSupportedInterfaces
static void initSupportedInterfaces()
Static function which initliazes all supported interfaces, has to be called once before getSupportedI...
Definition: Interface.cc:55
Belle2::MVA::Weightfile::save
static void save(Weightfile &weightfile, const std::string &filename, const Belle2::IntervalOfValidity &iov=Belle2::IntervalOfValidity(0, 0, -1, -1))
Static function which saves a Weightfile to a file.
Definition: Weightfile.cc:163
Belle2::MVA::Weightfile::loadFromDatabase
static Weightfile loadFromDatabase(const std::string &identifier, const Belle2::EventMetaData &emd=Belle2::EventMetaData(0, 0, 0))
Static function which loads a Weightfile from the basf2 condition database.
Definition: Weightfile.cc:290
Belle2::EventMetaData
Store event, run, and experiment numbers.
Definition: EventMetaData.h:43
Belle2::MVA::Weightfile::setRemoveTemporaryDirectories
void setRemoveTemporaryDirectories(bool remove_temporary_directories)
Set the deletion behaviour of the weightfile object for temporary directories For debugging it can be...
Definition: Weightfile.h:281
Belle2::MVA::Weightfile::saveToROOTFile
static void saveToROOTFile(Weightfile &weightfile, const std::string &filename)
Static function which saves a Weightfile to a ROOT file.
Definition: Weightfile.cc:174
Belle2::MVA::Weightfile::saveArrayToDatabase
static void saveArrayToDatabase(std::vector< Weightfile > &weightfiles, const std::string &identifier, const Belle2::IntervalOfValidity &iov=Belle2::IntervalOfValidity(0, 0, -1, -1))
Static function which saves an array of Weightfile objects in the basf2 condition database.
Definition: Weightfile.cc:276