Belle II Software  release-08-01-10
Utility Class Reference

Wrapper class for some utility functions. More...

#include <Utility.h>

Static Public Member Functions

static void download (const std::string &identifier, const std::string &filename, int experiment=0, int run=0, int event=0)
 Convenience function which downloads a given weightfile from the database. More...
 
static void upload (const std::string &filename, const std::string &identifier, int exp1=0, int run1=0, int exp2=-1, int run2=-1)
 Convenience function which uploads a given weightfile to the database. More...
 
static void upload_array (const std::vector< std::string > &filenames, const std::string &identifier, int exp1=0, int run1=0, int exp2=-1, int run2=-1)
 Convenience function which uploads an array of weightfiles to the database. More...
 
static bool available (const std::string &filename, int experiment=0, int run=0, int event=0)
 Convenience function which checks if an experise is available. More...
 
static void extract (const std::string &filename, const std::string &directory)
 Convenience function which extracts the expertise in a given weightfile into a temporary directory. More...
 
static std::string info (const std::string &filename)
 Print information about the classifier stored in the given weightfile. More...
 
static void save_custom_weightfile (const GeneralOptions &general_options, const SpecificOptions &specific_options, const std::string &custom_weightfile, const std::string &output_identifier="")
 Convenience function which saves a pre-existing weightfile in a mva package-compliant format. More...
 
static void teacher (const GeneralOptions &general_options, const SpecificOptions &specific_options, const MetaOptions &meta_options=MetaOptions())
 Convenience function which performs a training with the given options. More...
 
static void expert (const std::vector< std::string > &filenames, const std::vector< std::string > &datafiles, const std::string &treename, const std::string &outputfile, int experiment=0, int run=0, int event=0, bool copy_target=true)
 Convenience function applies experts on given data. More...
 
static std::unique_ptr< Belle2::MVA::Expertteacher_dataset (GeneralOptions general_options, const SpecificOptions &specific_options, Dataset &data)
 Convenience function which performs a training on a dataset. More...
 
static std::unique_ptr< Belle2::MVA::Expertteacher_splot (const GeneralOptions &general_options, const SpecificOptions &specific_options, const MetaOptions &meta_options)
 Performs an splot training, convenience function. More...
 
static std::unique_ptr< Belle2::MVA::Expertteacher_sideband_subtraction (const GeneralOptions &general_options, const SpecificOptions &specific_options, const MetaOptions &meta_options)
 Performs a sideband subtraction training, convenience function. More...
 
static std::unique_ptr< Belle2::MVA::Expertteacher_reweighting (const GeneralOptions &general_options, const SpecificOptions &specific_options, const MetaOptions &meta_options)
 Performs a MC vs data pre-training and afterwards reweighted training, convenience function. More...
 

Detailed Description

Wrapper class for some utility functions.

Definition at line 20 of file Utility.h.

Member Function Documentation

◆ available()

bool available ( const std::string &  filename,
int  experiment = 0,
int  run = 0,
int  event = 0 
)
static

Convenience function which checks if an experise is available.

Parameters
filenamefilename or identifier of the expertise
experimentcurrent experiment
runcurrent run
eventcurrent event

Definition at line 126 of file Utility.cc.

127 {
128 
129  try {
130  auto weightfile = Weightfile::load(filename, Belle2::EventMetaData(event, run, experiment));
131  return true;
132  } catch (...) {
133  return false;
134  }
135 
136 }
Store event, run, and experiment numbers.
Definition: EventMetaData.h:33
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 from the database.
Definition: Weightfile.cc:195

◆ download()

void download ( const std::string &  identifier,
const std::string &  filename,
int  experiment = 0,
int  run = 0,
int  event = 0 
)
static

Convenience function which downloads a given weightfile from the database.

Parameters
identifieridentifier in the database
filenameof the weightfile
experimentcurrent experiment
runcurrent run
eventcurrent event

Definition at line 32 of file Utility.cc.

◆ expert()

void expert ( const std::vector< std::string > &  filenames,
const std::vector< std::string > &  datafiles,
const std::string &  treename,
const std::string &  outputfile,
int  experiment = 0,
int  run = 0,
int  event = 0,
bool  copy_target = true 
)
static

Convenience function applies experts on given data.

Parameters
filenamesvector of filenames or database identifiers
datafilesROOT files containing the data
treenametreename of ROOT file
outputfilename of the output ROOT file
experimentnumber of the experiment
runnumber of the run
eventnumber of the event
copy_targetdefine if the target variable should be copied, if no target is found, an exception will be raised

Definition at line 138 of file Utility.cc.

◆ extract()

void extract ( const std::string &  filename,
const std::string &  directory 
)
static

Convenience function which extracts the expertise in a given weightfile into a temporary directory.

Parameters
filenameof the weightfile
directorytemporary directory to use

Definition at line 83 of file Utility.cc.

◆ info()

std::string info ( const std::string &  filename)
static

Print information about the classifier stored in the given weightfile.

Parameters
filenamefilename of the weightfile

Definition at line 98 of file Utility.cc.

◆ save_custom_weightfile()

void save_custom_weightfile ( const GeneralOptions general_options,
const SpecificOptions specific_options,
const std::string &  custom_weightfile,
const std::string &  output_identifier = "" 
)
static

Convenience function which saves a pre-existing weightfile in a mva package-compliant format.

Parameters
general_optionsshared options
specific_optionsmethod specific options
custom_weightfilepath to the pre-existing weightfile
output_identifieran optional string to append to the output file name. By default the function overwrites the input file.

Definition at line 232 of file Utility.cc.

◆ teacher()

void teacher ( const GeneralOptions general_options,
const SpecificOptions specific_options,
const MetaOptions meta_options = MetaOptions() 
)
static

Convenience function which performs a training with the given options.

Parameters
general_optionsshared options
specific_optionsmethod specific options
meta_optionsoptional options

Definition at line 253 of file Utility.cc.

◆ teacher_dataset()

std::unique_ptr< Belle2::MVA::Expert > teacher_dataset ( GeneralOptions  general_options,
const SpecificOptions specific_options,
Dataset data 
)
static

Convenience function which performs a training on a dataset.

Parameters
general_optionsshared options
specific_optionsmethod specific options
datadata to use

Definition at line 282 of file Utility.cc.

◆ teacher_reweighting()

std::unique_ptr< Belle2::MVA::Expert > teacher_reweighting ( const GeneralOptions general_options,
const SpecificOptions specific_options,
const MetaOptions meta_options 
)
static

Performs a MC vs data pre-training and afterwards reweighted training, convenience function.

Parameters
general_optionsshared options of all methods
specific_optionsof the used mva method
meta_optionsoptions defining the splot training

Definition at line 424 of file Utility.cc.

◆ teacher_sideband_subtraction()

std::unique_ptr< Belle2::MVA::Expert > teacher_sideband_subtraction ( const GeneralOptions general_options,
const SpecificOptions specific_options,
const MetaOptions meta_options 
)
static

Performs a sideband subtraction training, convenience function.

Parameters
general_optionsshared options of all methods
specific_optionsof the used mva method
meta_optionsoptional options

Definition at line 477 of file Utility.cc.

◆ teacher_splot()

std::unique_ptr< Belle2::MVA::Expert > teacher_splot ( const GeneralOptions general_options,
const SpecificOptions specific_options,
const MetaOptions meta_options 
)
static

Performs an splot training, convenience function.

Parameters
general_optionsshared options of all methods
specific_optionsof the used mva method
meta_optionsoptional options

Definition at line 313 of file Utility.cc.

◆ upload()

void upload ( const std::string &  filename,
const std::string &  identifier,
int  exp1 = 0,
int  run1 = 0,
int  exp2 = -1,
int  run2 = -1 
)
static

Convenience function which uploads a given weightfile to the database.

Parameters
filenameof the weightfile
identifieridentifier in the database
exp1first valid experiment
run1first valid run
exp2last valid experiment
run2last valid run

Definition at line 46 of file Utility.cc.

◆ upload_array()

void upload_array ( const std::vector< std::string > &  filenames,
const std::string &  identifier,
int  exp1 = 0,
int  run1 = 0,
int  exp2 = -1,
int  run2 = -1 
)
static

Convenience function which uploads an array of weightfiles to the database.

Parameters
filenamesarray of names of the weightfiles
identifieridentifier in the database
exp1first valid experiment
run1first valid run
exp2last valid experiment
run2last valid run

Definition at line 61 of file Utility.cc.


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