Belle II Software light-2406-ragdoll
|
The Weightfile class serializes all information about a training into an xml tree. More...
#include <Weightfile.h>
Public Member Functions | |
Weightfile () | |
Construct an empty weightfile. | |
~Weightfile () | |
Destructor (removes temporary files associated with this weightfiles) | |
void | addFeatureImportance (const std::map< std::string, float > &importance) |
Add variable importance. | |
std::map< std::string, float > | getFeatureImportance () const |
Get feature importance. | |
void | addOptions (const Options &options) |
Add an Option object to the xml tree. | |
void | getOptions (Options &options) const |
Fills an Option object from the xml tree. | |
void | addSignalFraction (float signal_fraction) |
Saves the signal fraction in the xml tree. | |
float | getSignalFraction () const |
Loads the signal fraction frm the xml tree. | |
std::string | generateFileName (const std::string &suffix="") |
Returns a temporary filename with the given suffix. | |
void | addFile (const std::string &identifier, const std::string &custom_weightfile) |
Add a file (mostly a weightfile from a MVA library) to our Weightfile. | |
void | addStream (const std::string &identifier, std::istream &in) |
Add a stream to our weightfile. | |
template<class T > | |
void | addElement (const std::string &identifier, const T &element) |
Add an element to the xml tree. | |
template<class T > | |
void | addVector (const std::string &identifier, const std::vector< T > &vector) |
Add a vector to the xml tree. | |
void | getFile (const std::string &identifier, const std::string &custom_weightfile) |
Creates a file from our weightfile (mostly this will be a weightfile of an MVA library) | |
std::string | getStream (const std::string &identifier) const |
Returns the content of a stored stream as string. | |
template<class T > | |
T | getElement (const std::string &identifier) const |
Returns a stored element from the xml tree. | |
bool | containsElement (const std::string &identifier) const |
Returns true if given element is stored in the property tree. | |
template<class T > | |
T | getElement (const std::string &identifier, const T &default_value) const |
Returns a stored element from the xml tree. | |
template<class T > | |
std::vector< T > | getVector (const std::string &identifier) const |
Returns a stored vector from the xml tree. | |
void | setRemoveTemporaryDirectories (bool remove_temporary_directories) |
Set the deletion behaviour of the weightfile object for temporary directories For debugging it can be useful to not delete temporary directories. | |
const boost::property_tree::ptree & | getXMLTree () const |
Get xml tree. | |
Static Public Member Functions | |
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. | |
static void | saveToROOTFile (Weightfile &weightfile, const std::string &filename) |
Static function which saves a Weightfile to a ROOT file. | |
static void | saveToXMLFile (Weightfile &weightfile, const std::string &filename) |
Static function which saves a Weightfile to a XML file. | |
static void | saveToStream (Weightfile &weightfile, std::ostream &stream) |
Static function which serializes a Weightfile to a stream. | |
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. | |
static Weightfile | loadFromFile (const std::string &filename) |
Static function which loads a Weightfile from a file. | |
static Weightfile | loadFromROOTFile (const std::string &filename) |
Static function which loads a Weightfile from a ROOT file. | |
static Weightfile | loadFromXMLFile (const std::string &filename) |
Static function which loads a Weightfile from a XML file. | |
static Weightfile | loadFromStream (std::istream &stream) |
Static function which deserializes a Weightfile from a stream. | |
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. | |
static void | saveArrayToDatabase (const 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. | |
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. | |
Private Attributes | |
boost::property_tree::ptree | m_pt |
xml tree containing all the saved information of this weightfile | |
std::vector< std::string > | m_filenames |
generated temporary filenames, which will be removed in the destructor of this class | |
bool | m_remove_temporary_directories = true |
remove all temporary directories in the destructor of this class | |
The Weightfile class serializes all information about a training into an xml tree.
It can save and load this information from: a stream, a file, the database
Definition at line 38 of file Weightfile.h.
|
inline |
~Weightfile | ( | ) |
Destructor (removes temporary files associated with this weightfiles)
Definition at line 52 of file Weightfile.cc.
|
inline |
Add an element to the xml tree.
identifier | identifier of the element |
element | the value |
Definition at line 114 of file Weightfile.h.
void addFeatureImportance | ( | const std::map< std::string, float > & | importance | ) |
void addFile | ( | const std::string & | identifier, |
const std::string & | custom_weightfile | ||
) |
Add a file (mostly a weightfile from a MVA library) to our Weightfile.
identifier | of this weightfile |
custom_weightfile | the filename |
Definition at line 115 of file Weightfile.cc.
void addOptions | ( | const Options & | options | ) |
Add an Option object to the xml tree.
options | to add |
Definition at line 62 of file Weightfile.cc.
void addSignalFraction | ( | float | signal_fraction | ) |
Saves the signal fraction in the xml tree.
signal_fraction |
Definition at line 95 of file Weightfile.cc.
void addStream | ( | const std::string & | identifier, |
std::istream & | in | ||
) |
Add a stream to our weightfile.
identifier | of the stream |
in | the stream |
Definition at line 123 of file Weightfile.cc.
|
inline |
Add a vector to the xml tree.
identifier | identifier of the vector |
vector | the std::vector |
Definition at line 125 of file Weightfile.h.
|
inline |
Returns true if given element is stored in the property tree.
identifier | of the stored element |
Definition at line 160 of file Weightfile.h.
std::string generateFileName | ( | const std::string & | suffix = "" | ) |
Returns a temporary filename with the given suffix.
All temporary files are removed when the Weightfile class is destroyed
suffix | of the temporary filename |
Definition at line 105 of file Weightfile.cc.
|
inline |
Returns a stored element from the xml tree.
identifier | of the stored element |
Definition at line 151 of file Weightfile.h.
|
inline |
Returns a stored element from the xml tree.
identifier | of the stored element |
default_value | default value of the stored element |
Definition at line 171 of file Weightfile.h.
std::map< std::string, float > getFeatureImportance | ( | ) | const |
Get feature importance.
Definition at line 83 of file Weightfile.cc.
void getFile | ( | const std::string & | identifier, |
const std::string & | custom_weightfile | ||
) |
Creates a file from our weightfile (mostly this will be a weightfile of an MVA library)
identifier | of the file |
custom_weightfile | the filename which is created |
Definition at line 138 of file Weightfile.cc.
void getOptions | ( | Options & | options | ) | const |
Fills an Option object from the xml tree.
options |
Definition at line 67 of file Weightfile.cc.
float getSignalFraction | ( | ) | const |
std::string getStream | ( | const std::string & | identifier | ) | const |
Returns the content of a stored stream as string.
identifier | of the stored stream |
Definition at line 144 of file Weightfile.cc.
|
inline |
Returns a stored vector from the xml tree.
identifier | of the stored std::vector |
Definition at line 181 of file Weightfile.h.
|
inline |
|
static |
Static function which loads a Weightfile from a file or from the database.
filename | of the file containing our serialized Weightfile |
emd | EventMetaData |
Definition at line 195 of file Weightfile.cc.
|
static |
Static function which loads a Weightfile from the basf2 condition database.
identifier | in the database |
emd | event meta data containing the current valid event which is checked against the interval of validity of the stored weightfiles. |
Definition at line 281 of file Weightfile.cc.
|
static |
Static function which loads a Weightfile from a file.
filename | of the file containing our serialized Weightfile |
Definition at line 206 of file Weightfile.cc.
|
static |
Static function which loads a Weightfile from a ROOT file.
filename | of the file containing our serialized Weightfile |
Definition at line 217 of file Weightfile.cc.
|
static |
Static function which deserializes a Weightfile from a stream.
stream | containing our serialized Weightfile |
Definition at line 251 of file Weightfile.cc.
|
static |
Static function which loads a Weightfile from a XML file.
filename | of the file containing our serialized Weightfile |
Definition at line 240 of file Weightfile.cc.
|
static |
Static function which saves a Weightfile to a file.
weightfile | to store |
filename | of the file or identifier of the database |
iov | IntervalOfValidity of the Weightfile |
Definition at line 154 of file Weightfile.cc.
|
static |
Static function which saves an array of Weightfile objects in the basf2 condition database.
weightfiles | vector of weightfiles to save |
identifier | in the database |
iov | interval of validity of this weightfile |
Definition at line 267 of file Weightfile.cc.
|
static |
Static function which saves a Weightfile in the basf2 condition database.
weightfile | to save |
identifier | in the database |
iov | interval of validity of this weightfile |
Definition at line 258 of file Weightfile.cc.
|
static |
Static function which saves a Weightfile to a ROOT file.
weightfile | to store |
filename | of the file |
Definition at line 165 of file Weightfile.cc.
|
static |
Static function which serializes a Weightfile to a stream.
weightfile | to serialize |
stream |
Definition at line 185 of file Weightfile.cc.
|
static |
Static function which saves a Weightfile to a XML file.
weightfile | to store |
filename | of the file |
Definition at line 175 of file Weightfile.cc.
|
inline |
Set the deletion behaviour of the weightfile object for temporary directories For debugging it can be useful to not delete temporary directories.
Definition at line 282 of file Weightfile.h.
|
private |
generated temporary filenames, which will be removed in the destructor of this class
Definition at line 291 of file Weightfile.h.
|
private |
xml tree containing all the saved information of this weightfile
Definition at line 290 of file Weightfile.h.
|
private |
remove all temporary directories in the destructor of this class
Definition at line 292 of file Weightfile.h.