Dataset for sPlot Wraps a dataset and provides each data-point twice, once as signal and once as background.
More...
#include <DataDriven.h>
|
| SPlotDataset (const GeneralOptions &general_options, Dataset &dataset, const std::vector< float > &weights, float signalFraction) |
| Constructs a new SPlotDataset.
|
|
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.
|
|
virtual float | getSignalFraction () override |
| 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 > | getFeature (unsigned int iFeature) |
| Returns all values of one feature in a std::vector<float>
|
|
virtual std::vector< float > | getSpectator (unsigned int iSpectator) |
| Returns all values of one spectator in a std::vector<float>
|
|
virtual std::vector< float > | getWeights () |
| Returns all weights.
|
|
virtual std::vector< float > | getTargets () |
| Returns all targets.
|
|
virtual std::vector< bool > | getSignals () |
| Returns all is Signals.
|
|
|
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.
|
|
Dataset for sPlot Wraps a dataset and provides each data-point twice, once as signal and once as background.
Definition at line 161 of file DataDriven.h.
◆ SPlotDataset()
Constructs a new SPlotDataset.
- Parameters
-
general_options | shared options defining the dataset (variables, ...) |
dataset | containing the data-points |
weights | sPlot weights |
signalFraction | original signal fraction |
Definition at line 153 of file DataDriven.cc.
154 : Dataset(general_options), m_dataset(dataset), m_weights(weights), m_signalFraction(signalFraction) { }
◆ getFeature()
std::vector< float > getFeature |
( |
unsigned int | iFeature | ) |
|
|
virtualinherited |
◆ getFeatureIndex()
unsigned int getFeatureIndex |
( |
const std::string & | feature | ) |
|
|
virtualinherited |
Return index of feature with the given name.
- Parameters
-
feature | name of the feature |
Definition at line 50 of file Dataset.cc.
51 {
52
53 auto it = std::find(m_general_options.m_variables.begin(), m_general_options.m_variables.end(), feature);
54 if (it == m_general_options.m_variables.end()) {
55 B2ERROR("Unknown feature named " << feature);
56 return 0;
57 }
58 return std::distance(m_general_options.m_variables.begin(), it);
59
60 }
◆ getNumberOfEvents()
virtual unsigned int getNumberOfEvents |
( |
| ) |
const |
|
inlineoverridevirtual |
Returns the number of events in this dataset.
Implements Dataset.
Definition at line 186 of file DataDriven.h.
186{ return 2 * m_dataset.getNumberOfEvents(); };
◆ getNumberOfFeatures()
virtual unsigned int getNumberOfFeatures |
( |
| ) |
const |
|
inlineoverridevirtual |
Returns the number of features in this dataset.
Implements Dataset.
Definition at line 176 of file DataDriven.h.
176{ return m_dataset.getNumberOfFeatures(); }
◆ getNumberOfSpectators()
virtual unsigned int getNumberOfSpectators |
( |
| ) |
const |
|
inlineoverridevirtual |
Returns the number of features in this dataset.
Implements Dataset.
Definition at line 181 of file DataDriven.h.
181{ return m_dataset.getNumberOfSpectators(); }
◆ getSignalFraction()
float getSignalFraction |
( |
| ) |
|
|
overridevirtual |
Returns the signal fraction of the whole sample.
Reimplemented from Dataset.
Definition at line 157 of file DataDriven.cc.
158 {
159 return m_signalFraction;
160 }
◆ getSignals()
std::vector< bool > getSignals |
( |
| ) |
|
|
virtualinherited |
Returns all is Signals.
Reimplemented in ReweightingDataset.
Definition at line 122 of file Dataset.cc.
123 {
124
125 std::vector<bool> result(getNumberOfEvents());
126 for (unsigned int iEvent = 0; iEvent < getNumberOfEvents(); ++iEvent) {
127 loadEvent(iEvent);
128 result[iEvent] = m_isSignal;
129 }
130 return result;
131
132 }
◆ getSpectator()
std::vector< float > getSpectator |
( |
unsigned int | iSpectator | ) |
|
|
virtualinherited |
◆ getSpectatorIndex()
unsigned int getSpectatorIndex |
( |
const std::string & | spectator | ) |
|
|
virtualinherited |
Return index of spectator with the given name.
- Parameters
-
spectator | name of the spectator |
Definition at line 62 of file Dataset.cc.
63 {
64
65 auto it = std::find(m_general_options.m_spectators.begin(), m_general_options.m_spectators.end(), spectator);
66 if (it == m_general_options.m_spectators.end()) {
67 B2ERROR("Unknown spectator named " << spectator);
68 return 0;
69 }
70 return std::distance(m_general_options.m_spectators.begin(), it);
71
72 }
◆ getTargets()
std::vector< float > getTargets |
( |
| ) |
|
|
virtualinherited |
Returns all targets.
Reimplemented in RegressionDataSet, and ReweightingDataset.
Definition at line 110 of file Dataset.cc.
111 {
112
113 std::vector<float> result(getNumberOfEvents());
114 for (unsigned int iEvent = 0; iEvent < getNumberOfEvents(); ++iEvent) {
115 loadEvent(iEvent);
116 result[iEvent] = m_target;
117 }
118 return result;
119
120 }
◆ getWeights()
std::vector< float > getWeights |
( |
| ) |
|
|
virtualinherited |
Returns all weights.
Reimplemented in RegressionDataSet, ReweightingDataset, and ROOTDataset.
Definition at line 98 of file Dataset.cc.
99 {
100
101 std::vector<float> result(getNumberOfEvents());
102 for (unsigned int iEvent = 0; iEvent < getNumberOfEvents(); ++iEvent) {
103 loadEvent(iEvent);
104 result[iEvent] = m_weight;
105 }
106 return result;
107
108 }
◆ loadEvent()
void loadEvent |
( |
unsigned int | event | ) |
|
|
overridevirtual |
Load the event number iEvent.
- Parameters
-
event | event number to load |
Implements Dataset.
Definition at line 162 of file DataDriven.cc.
163 {
164 m_dataset.loadEvent(event / 2);
165 for (unsigned int iFeature = 0; iFeature < getNumberOfFeatures(); ++iFeature) {
166 m_input[iFeature] = m_dataset.m_input[iFeature];
167 }
168
169 if (event % 2 == 1) {
170 m_isSignal = false;
171 m_target = 0.0;
172 m_weight = m_weights[event] * m_dataset.m_weight;
173 } else {
174 m_isSignal = true;
175 m_target = 1.0;
176 m_weight = m_weights[event] * m_dataset.m_weight;
177 }
178 }
◆ m_dataset
◆ m_general_options
◆ m_input
std::vector<float> m_input |
|
inherited |
Contains all feature values of the currently loaded event.
Definition at line 123 of file Dataset.h.
◆ m_isSignal
Defines if the currently loaded event is signal or background.
Definition at line 127 of file Dataset.h.
◆ m_signalFraction
◆ m_spectators
std::vector<float> m_spectators |
|
inherited |
Contains all spectators values of the currently loaded event.
Definition at line 124 of file Dataset.h.
◆ m_target
Contains the target value of the currently loaded event.
Definition at line 126 of file Dataset.h.
◆ m_weight
Contains the weight of the currently loaded event.
Definition at line 125 of file Dataset.h.
◆ m_weights
std::vector<float> m_weights |
|
private |
The documentation for this class was generated from the following files: