![]() |
Belle II Software
release-06-01-15
|
Proivdes a dataset from a ROOT file This is the usually used dataset providing training data to the mva methods. More...
#include <Dataset.h>
Public Member Functions | |
ROOTDataset (const GeneralOptions &_general_options) | |
Creates a new ROOTDataset. More... | |
virtual unsigned int | getNumberOfFeatures () const override |
Returns the number of features in this dataset. | |
virtual unsigned int | getNumberOfSpectators () const override |
Returns the number of features in this dataset. | |
virtual unsigned int | getNumberOfEvents () const override |
Returns the number of events in this dataset. | |
virtual void | loadEvent (unsigned int event) override |
Load the event number iEvent from the TTree. More... | |
virtual std::vector< float > | getFeature (unsigned int iFeature) override |
Returns all values of one feature in a std::vector<float> More... | |
virtual std::vector< float > | getWeights () override |
Returns all values of of the weights in a std::vector<float> | |
virtual std::vector< float > | getSpectator (unsigned int iSpectator) override |
Returns all values of one spectator in a std::vector<float> More... | |
template<class T > | |
std::vector< float > | getVectorFromTTree (std::string &variableType, std::string &branchName, T &memberVariableTarget) |
Returns all values for a specified variableType and branchName. More... | |
void | setRootInputType () |
Tries to infer the data-type of a root file and sets m_isDoubleInputType. | |
template<class T > | |
void | setScalarVariableAddress (std::string &variableType, std::string &variableName, T &variableTarget) |
sets the branch address for a scalar variable to a given target More... | |
template<class T > | |
void | setVectorVariableAddress (std::string &variableType, std::vector< std::string > &variableName, T &variableTargets) |
sets the branch address for a vector variable to a given target More... | |
virtual | ~ROOTDataset () |
Virtual destructor. | |
virtual float | getSignalFraction () |
Returns the signal fraction of the whole sample. | |
virtual unsigned int | getFeatureIndex (const std::string &feature) |
Return index of feature with the given name. More... | |
virtual unsigned int | getSpectatorIndex (const std::string &spectator) |
Return index of spectator with the given name. More... | |
virtual std::vector< float > | getTargets () |
Returns all targets. | |
virtual std::vector< bool > | getSignals () |
Returns all is Signals. | |
Public Attributes | |
GeneralOptions | m_general_options |
GeneralOptions passed to this dataset. | |
std::vector< float > | m_input |
Contains all feature values of the currently loaded event. | |
std::vector< float > | m_spectators |
Contains all spectators values of the currently loaded event. | |
float | m_weight |
Contains the weight of the currently loaded event. | |
float | m_target |
Contains the target value of the currently loaded event. | |
bool | m_isSignal |
Defines if the currently loaded event is signal or background. | |
Protected Attributes | |
TChain * | m_tree = nullptr |
Pointer to the TChain containing the data. | |
bool | m_isDoubleInputType = true |
Defines the expected datatype in the ROOT file. | |
std::vector< double > | m_input_double |
Contains all feature values of the currently loaded event. | |
std::vector< double > | m_spectators_double |
Contains all spectators values of the currently loaded event. | |
double | m_weight_double |
Contains the weight of the currently loaded event. | |
double | m_target_double |
Contains the target value of the currently loaded event. | |
Private Member Functions | |
void | setBranchAddresses () |
Sets the branch addresses of all features, weight and target again. | |
bool | checkForBranch (TTree *, const std::string &) const |
Checks if the given branchname exists in the TTree. More... | |
Proivdes a dataset from a ROOT file This is the usually used dataset providing training data to the mva methods.
|
explicit |
Creates a new ROOTDataset.
_general_options | defines the rootfile, treename, branches, ... |
Definition at line 316 of file Dataset.cc.
|
private |
Checks if the given branchname exists in the TTree.
tree | |
branchname |
Definition at line 490 of file Dataset.cc.
|
overridevirtual |
Returns all values of one feature in a std::vector<float>
iFeature | the position of the feature to return |
Reimplemented from Dataset.
Definition at line 418 of file Dataset.cc.
|
virtualinherited |
Return index of feature with the given name.
feature | name of the feature |
Definition at line 50 of file Dataset.cc.
|
overridevirtual |
Returns all values of one spectator in a std::vector<float>
iSpectator | the position of the spectator to return |
Reimplemented from Dataset.
Definition at line 434 of file Dataset.cc.
|
virtualinherited |
Return index of spectator with the given name.
spectator | name of the spectator |
Definition at line 62 of file Dataset.cc.
std::vector< float > getVectorFromTTree | ( | std::string & | variableType, |
std::string & | branchName, | ||
T & | memberVariableTarget | ||
) |
Returns all values for a specified variableType and branchName.
The values are read from a root file. The type is inferred from the given memberVariableTarget name.
T | type memberVariable of this class which has to be updated (float, double) |
variableType | defines {feature, weights, spectator, target} |
branchName | name of the branch to read |
memberVariableTarget | variable the branch address from the root file is set to |
Definition at line 457 of file Dataset.cc.
|
overridevirtual |
Load the event number iEvent from the TTree.
event | event number to load |
Implements Dataset.
Definition at line 375 of file Dataset.cc.
void setScalarVariableAddress | ( | std::string & | variableType, |
std::string & | variableName, | ||
T & | variableTarget | ||
) |
sets the branch address for a scalar variable to a given target
T | target type (float, double) |
variableType | defines {feature, weights, spectator, target} |
variableName | name of the variable, usually defined in general_options |
variableTarget | variable, the address is set to |
Definition at line 498 of file Dataset.cc.
void setVectorVariableAddress | ( | std::string & | variableType, |
std::vector< std::string > & | variableName, | ||
T & | variableTargets | ||
) |
sets the branch address for a vector variable to a given target
T | target type (std::vector<float>, std::vector<double>) |
variableType | defines {feature, weights, spectator, target} |
variableName | names of the variable, usually defined in general_options |
variableTargets | variables, the address is set to |
Definition at line 520 of file Dataset.cc.