Belle II Software development
|
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. | |
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. | |
virtual std::vector< float > | getFeature (unsigned int iFeature) override |
Returns all values of one feature in a std::vector<float> | |
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> | |
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. | |
virtual unsigned int | getSpectatorIndex (const std::string &spectator) |
Return index of spectator with the given name. | |
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 Types | |
typedef std::variant< double, float, int, bool > | RootDatasetVarVariant |
Typedef for variable types supported by the mva ROOTDataset, can be one of double, float, int or bool in std::variant. | |
Protected Attributes | |
TChain * | m_tree = nullptr |
Pointer to the TChain containing the data. | |
std::vector< RootDatasetVarVariant > | m_input_variant |
Contains all feature values of the currently loaded event. | |
std::vector< RootDatasetVarVariant > | m_spectators_variant |
Contains all spectators values of the currently loaded event. | |
RootDatasetVarVariant | m_weight_variant |
Contains the weight of the currently loaded event. | |
RootDatasetVarVariant | m_target_variant |
Contains the target value of the currently loaded event. | |
Private Member Functions | |
template<class T > | |
std::vector< float > | getVectorFromTTree (const std::string &variableType, const std::string &branchName, T &memberVariableTarget) |
Returns all values for a specified variableType and branchName. | |
std::vector< float > | getVectorFromTTreeVariant (const std::string &variableType, const std::string &branchName, RootDatasetVarVariant &memberVariableTarget) |
Returns all values for a specified variableType and branchName. | |
void | setRootInputType () |
Tries to infer the data-type of the spectator and feature variables in a root file. | |
template<class T > | |
void | setScalarVariableAddress (const std::string &variableType, const std::string &variableName, T &variableTarget) |
sets the branch address for a scalar variable to a given target | |
void | setScalarVariableAddressVariant (const std::string &variableType, const std::string &variableName, RootDatasetVarVariant &variableTarget) |
sets the branch address for a scalar variable to a given target | |
template<class T > | |
void | setVectorVariableAddress (const std::string &variableType, const std::vector< std::string > &variableName, T &variableTargets) |
sets the branch address for a vector variable to a given target | |
void | setVectorVariableAddressVariant (const std::string &variableType, const std::vector< std::string > &variableName, std::vector< RootDatasetVarVariant > &varVariantTargets) |
sets the branch address for a vector of VarVariant to a given target | |
void | setTargetRootInputType () |
Determines the data type of the target variable and sets it to m_target_data_type. | |
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. | |
float | castVarVariantToFloat (RootDatasetVarVariant &) const |
Casts a VarVariant which can contain <double,int,bool,float> to float. | |
void | initialiseVarVariantType (const std::string, RootDatasetVarVariant &) |
Initialises the VarVariant. | |
void | initialiseVarVariantForBranch (const std::string, RootDatasetVarVariant &) |
Infers the type (double,float,int,bool) from the TTree and initialises the VarVariant with the correct type. | |
Proivdes a dataset from a ROOT file This is the usually used dataset providing training data to the mva methods.
|
protected |
Typedef for variable types supported by the mva ROOTDataset, can be one of double, float, int or bool in std::variant.
|
explicit |
Creates a new ROOTDataset.
_general_options | defines the rootfile, treename, branches, ... |
Definition at line 316 of file Dataset.cc.
|
virtual |
Virtual destructor.
Definition at line 452 of file Dataset.cc.
|
private |
Casts a VarVariant which can contain <double,int,bool,float> to float.
variant | the VarVariant to cast |
Definition at line 376 of file Dataset.cc.
|
private |
Checks if the given branchname exists in the TTree.
tree | |
branchname |
Definition at line 507 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 429 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.
|
inlineoverridevirtual |
Returns the number of events in this dataset.
Implements Dataset.
Definition at line 371 of file Dataset.h.
|
inlineoverridevirtual |
Returns the number of features in this dataset.
Implements Dataset.
Definition at line 361 of file Dataset.h.
|
inlineoverridevirtual |
Returns the number of features in this dataset.
Implements Dataset.
Definition at line 366 of file Dataset.h.
|
virtualinherited |
Returns the signal fraction of the whole sample.
Reimplemented in SPlotDataset.
Definition at line 35 of file Dataset.cc.
|
virtualinherited |
Returns all is Signals.
Reimplemented in ReweightingDataset.
Definition at line 122 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 440 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.
|
virtualinherited |
Returns all targets.
Reimplemented in RegressionDataSet, and ReweightingDataset.
Definition at line 110 of file Dataset.cc.
|
private |
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 474 of file Dataset.cc.
|
private |
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.
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 458 of file Dataset.cc.
|
overridevirtual |
Returns all values of of the weights in a std::vector<float>
Reimplemented from Dataset.
Definition at line 408 of file Dataset.cc.
|
private |
Infers the type (double,float,int,bool) from the TTree and initialises the VarVariant with the correct type.
branch_name | branch name in the datafile |
varVariantTarget | variant to initialise |
Definition at line 615 of file Dataset.cc.
|
private |
Initialises the VarVariant.
type | defines which alternative to use for the variant {Double_t, Float_t, Int_t, Bool_t} |
varVariantTarget | variant to initialise. |
Definition at line 598 of file Dataset.cc.
|
overridevirtual |
Load the event number iEvent from the TTree.
event | event number to load |
Implements Dataset.
Definition at line 391 of file Dataset.cc.
|
private |
Sets the branch addresses of all features, weight and target again.
Definition at line 568 of file Dataset.cc.
|
private |
Tries to infer the data-type of the spectator and feature variables in a root file.
Definition at line 632 of file Dataset.cc.
|
private |
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 515 of file Dataset.cc.
|
private |
sets the branch address for a scalar variable to a given target
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 536 of file Dataset.cc.
|
private |
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 552 of file Dataset.cc.
|
private |
sets the branch address for a vector of VarVariant to a given target
variableType | defines {feature, weights, spectator, target} |
variableName | names of the variable, usually defined in general_options |
varVariantTargets | variables, the address is set to |
Definition at line 560 of file Dataset.cc.
|
inherited |
GeneralOptions passed to this dataset.
|
inherited |
|
protected |
|
inherited |
|
inherited |
|
protected |
|
inherited |
|
protected |
|
protected |
|
inherited |
|
protected |