A class representing a set of data points. More...
#include <BCDataSet.h>
Public Member Functions | |
Constructors and destructor | |
BCDataSet (unsigned n=0) | |
Default constructor. More... | |
virtual | ~BCDataSet () |
Destructor. | |
operators | |
BCDataPoint & | operator[] (unsigned index) |
Raw and fast access. More... | |
const BCDataPoint & | operator[] (unsigned index) const |
Raw and fast access. More... | |
Member functions (get) | |
unsigned | GetNDataPoints () const |
unsigned | GetNValuesPerPoint () const |
BCDataPoint & | GetDataPoint (unsigned index) |
Safer, but slower, access to data points. More... | |
const BCDataPoint & | GetDataPoint (unsigned index) const |
Safer, but slower, access to data points. More... | |
BCDataPoint & | Back () |
Access to last added data point. More... | |
std::vector< double > | GetDataComponents (unsigned index) const |
Viewing the data set as a table with one row per point, this method returns a specified column. More... | |
bool | BoundsExist () const |
const BCDataPoint & | GetLowerBounds () const |
const BCDataPoint & | GetUpperBounds () const |
BCDataPoint & | GetUserLowerBounds () |
BCDataPoint & | GetUserUpperBounds () |
double | GetLowerBound (unsigned index) const |
Return user-set lower bound on data, if set, otherwise actual lower bound. More... | |
double | GetUpperBound (unsigned index) const |
Return user-set upper bound on data, if set, otherwise actual upper bound. More... | |
double | GetRangeWidth (unsigned index) const |
Return upper-bound minus lower-bound for data axis, using user-set bounds, if provided, other actual bounds. More... | |
bool | IsFixed (unsigned index) const |
Return wether data axis is fixed. More... | |
Setters | |
void | SetNValuesPerPoint (unsigned n) |
Set number of values inside each data point. More... | |
void | SetBounds (unsigned index, double lower_bound, double upper_bound, bool fixed=false) |
Set bounds for data values. More... | |
void | Fix (unsigned i, bool b=true) |
Set fixed flag of a data axis. More... | |
Member functions (miscellaneous methods) | |
bool | ReadDataFromFile (const std::string &filename, const std::string &treename, const std::string &branchnames, char delim= ',') |
Reads data from a TTree in file. More... | |
bool | ReadDataFromFile (const std::string &filename, int nvariables) |
Reads data from a file. More... | |
bool | ReadDataFromFileTree (const std::string &filename, const std::string &treename, const std::string &branchnames, char delim= ',') |
Reads a TTree from a .root file. More... | |
bool | ReadDataFromFileTxt (const std::string &filename, int nvariables) |
Reads data from a .txt file. More... | |
bool | AddDataPoint (const BCDataPoint &datapoint) |
Adds a data point to the data set. More... | |
void | AdjustBoundForUncertainties (unsigned i, double nSigma, unsigned i_err1, int i_err2=-1) |
Recalculate a data axis bound accounting for uncertainties specified by other data axes. More... | |
void | Reset () |
Resets the content of the data set. | |
void | PrintSummary (void(*output)(const std::string &)=BCLog::OutSummary) const |
Print summary to string handler. More... | |
TGraph * | GetGraph (unsigned x, unsigned y) const |
Get data set as ROOT TGraph object,. More... | |
TGraphErrors * | GetGraph (unsigned x, unsigned y, int ex, int ey) const |
Get data set as ROOT TGraphErrors object. More... | |
TGraphAsymmErrors * | GetGraph (unsigned x, unsigned y, int ex_below, int ex_above, int ey_below, int ey_above) const |
Get data set as ROOT TGraphAsymmErrors object. More... | |
TH2 * | CreateH2 (const char *name, const char *title, unsigned x, unsigned y, unsigned nbins_x=100, unsigned nbins_y=100, double x_padding=0.10, double y_padding=0.10) const |
Get ROOT TH2 with ranges set to data bounds. More... | |
Detailed Description
A class representing a set of data points.
- Version
- 1.0
- Date
- 08.2008
This class represents a data set containing a set of data points. The data points are organized in a vector. The class provides functions to read in data from a file.
Definition at line 39 of file BCDataSet.h.
Constructor & Destructor Documentation
BCDataSet::BCDataSet | ( | unsigned | n = 0 | ) |
Default constructor.
- Parameters
-
n Dimensionality (Number of values inside) of data points.
Definition at line 31 of file BCDataSet.cxx.
Member Function Documentation
bool BCDataSet::AddDataPoint | ( | const BCDataPoint & | datapoint | ) |
Adds a data point to the data set.
- Parameters
-
datapoint The data point to be added
Definition at line 209 of file BCDataSet.cxx.
void BCDataSet::AdjustBoundForUncertainties | ( | unsigned | i, |
double | nSigma, | ||
unsigned | i_err1, | ||
int | i_err2 = -1 |
||
) |
Recalculate a data axis bound accounting for uncertainties specified by other data axes.
If a second error index is provided, the first is taken as error below the value, and the second as error above the value.
- Parameters
-
i Index of the data axis to be recalculated nSigma Multiples of the stored uncertainty to account for i_err1 Index of the data axis containing uncertainty (below point, if next i_err2 also specified) i_err2 Index of the data axis containing uncertainty above point
Definition at line 232 of file BCDataSet.cxx.
|
inline |
Access to last added data point.
Definition at line 99 of file BCDataSet.h.
bool BCDataSet::BoundsExist | ( | ) | const |
- Returns
- Whether bounds for the data set exist.
Definition at line 55 of file BCDataSet.cxx.
TH2 * BCDataSet::CreateH2 | ( | const char * | name, |
const char * | title, | ||
unsigned | x, | ||
unsigned | y, | ||
unsigned | nbins_x = 100 , |
||
unsigned | nbins_y = 100 , |
||
double | x_padding = 0.10 , |
||
double | y_padding = 0.10 |
||
) | const |
Get ROOT TH2 with ranges set to data bounds.
Padding is specified as fraction of boundary range.
- Note
- The caller is responsible for deletion of the returned object.
- Parameters
-
name Name of histogram title Title of histogram x Index of data axis for abscissa y Index of data axis for ordinate nbins_x number of bins on abscissa (default 100) nbins_y number of bins on ordinate (default 100) x_padding Amount to pad on either side of abscissa boundaries (default = 0.10) y_padding Amount to pad on either side of ordinate boundaries (default = 0.10)
- Returns
- pointer to empty ROOT TH2
Definition at line 353 of file BCDataSet.cxx.
|
inline |
Set fixed flag of a data axis.
- Parameters
-
i index of axis to fix b whether to fix (true) or unfix (false)
Definition at line 182 of file BCDataSet.h.
std::vector< double > BCDataSet::GetDataComponents | ( | unsigned | index | ) | const |
Viewing the data set as a table with one row per point, this method returns a specified column.
- Parameters
-
index The index of the component to be returned.
- Returns
- The (index)th component of all data points
Definition at line 37 of file BCDataSet.cxx.
|
inline |
Safer, but slower, access to data points.
- Parameters
-
index The index of the data point to be returned.
- Returns
- The data point at the index.
Definition at line 87 of file BCDataSet.h.
|
inline |
Safer, but slower, access to data points.
- Parameters
-
index The index of the data point to be returned.
- Returns
- The data point at the index.
Definition at line 94 of file BCDataSet.h.
TGraph * BCDataSet::GetGraph | ( | unsigned | x, |
unsigned | y | ||
) | const |
Get data set as ROOT TGraph object,.
- Note
- The caller is responsible for deletion of the returned object.
- Parameters
-
x Index of data axis plotted as abscissa y Index of data axis plotted as ordinate
- Returns
- pointer to filled ROOT TGraph
Definition at line 295 of file BCDataSet.cxx.
TGraphErrors * BCDataSet::GetGraph | ( | unsigned | x, |
unsigned | y, | ||
int | ex, | ||
int | ey | ||
) | const |
Get data set as ROOT TGraphErrors object.
Set error indices negative to leave errors unset.
- Note
- The caller is responsible for deletion of the returned object.
- Parameters
-
x Index of data axis plotted as abscissa y Index of data axis plotted as ordinate ex Index of data axis for error on abscissa ey Index of data axis for error on ordinate
- Returns
- pointer to filled ROOT TGraphErrors
Definition at line 310 of file BCDataSet.cxx.
TGraphAsymmErrors * BCDataSet::GetGraph | ( | unsigned | x, |
unsigned | y, | ||
int | ex_below, | ||
int | ex_above, | ||
int | ey_below, | ||
int | ey_above | ||
) | const |
Get data set as ROOT TGraphAsymmErrors object.
Set error indices negative to leave errors unset.
- Note
- The caller is responsible for deletion of the returned object.
- Parameters
-
x Index of data axis plotted as abscissa y Index of data axis plotted as ordinate ex_below Index of data axis for error on abscissa below data points ex_above Index of data axis for error on abscissa below data points ey_below Index of data axis for error on ordinate below data points ey_above Index of data axis for error on ordinate below data points
- Returns
- pointer to filled ROOT TGraphAsymmErrors
Definition at line 330 of file BCDataSet.cxx.
double BCDataSet::GetLowerBound | ( | unsigned | index | ) | const |
Return user-set lower bound on data, if set, otherwise actual lower bound.
- Parameters
-
index Index of data value to return lower bound of.
- Returns
- Lower bound on data values.
Definition at line 64 of file BCDataSet.cxx.
|
inline |
- Returns
- BCDataPoint with values set to actual lower bounds of data.
Definition at line 115 of file BCDataSet.h.
|
inline |
- Returns
- The number of data points.
Definition at line 75 of file BCDataSet.h.
|
inline |
- Returns
- number of values per data point (dimension of data).
Definition at line 80 of file BCDataSet.h.
|
inline |
Return upper-bound minus lower-bound for data axis, using user-set bounds, if provided, other actual bounds.
- Returns
- range width.
Definition at line 149 of file BCDataSet.h.
double BCDataSet::GetUpperBound | ( | unsigned | index | ) | const |
Return user-set upper bound on data, if set, otherwise actual upper bound.
- Parameters
-
index Index of data value to return upper bound of.
- Returns
- Upper bound on data values.
Definition at line 76 of file BCDataSet.cxx.
|
inline |
- Returns
- BCDataPoint with values set to actual upper bounds of data.
Definition at line 120 of file BCDataSet.h.
|
inline |
- Returns
- BCDataPoint with values set to user-set lower bounds of data.
Definition at line 125 of file BCDataSet.h.
|
inline |
- Returns
- BCDataPoint with values set to user-set upper bounds of data.
Definition at line 130 of file BCDataSet.h.
|
inline |
Return wether data axis is fixed.
- Parameters
-
index Index of axis to query
- Returns
- Whether data axis is fixed.
Definition at line 156 of file BCDataSet.h.
|
inline |
Raw and fast access.
Definition at line 61 of file BCDataSet.h.
|
inline |
Raw and fast access.
Definition at line 66 of file BCDataSet.h.
void BCDataSet::PrintSummary | ( | void(*)(const std::string &) | output = BCLog::OutSummary | ) | const |
Print summary to string handler.
- Parameters
-
output String handler (default = BCLog::OutSummary).
Definition at line 283 of file BCDataSet.cxx.
|
inline |
Reads data from a TTree in file.
- Parameters
-
filename Path to file containing TTree object. treename Name of TTree inside file. branchnames List of names of branches to be read from TTree delim Character deliminating branch names (default: comma).
- Returns
- Success of action.
Definition at line 197 of file BCDataSet.h.
|
inline |
Reads data from a file.
- Parameters
-
filename Path to file containing data. nvariables Number of variables (columns) in data file.
- Returns
- Success of action.
Definition at line 205 of file BCDataSet.h.
bool BCDataSet::ReadDataFromFileTree | ( | const std::string & | filename, |
const std::string & | treename, | ||
const std::string & | branchnames, | ||
char | delim = ',' |
||
) |
Reads a TTree from a .root file.
Opens a .root file and gets a TTree. It creates data points containing the values read from the file.
- Parameters
-
filename The name of the .root file. treename The name of the TTree. branchnames A list of the names of the branches delim Character deliminating between branch names (default: comma)
- Returns
- Success of action.
Definition at line 88 of file BCDataSet.cxx.
bool BCDataSet::ReadDataFromFileTxt | ( | const std::string & | filename, |
int | nvariables | ||
) |
Reads data from a .txt file.
Opens a .txt file and creates data objects containing the values read from the file.
- Parameters
-
filename The name of the .txt file. nvariables The number of variables (columns) in file.
- Returns
- Success of action.
Definition at line 157 of file BCDataSet.cxx.
void BCDataSet::SetBounds | ( | unsigned | index, |
double | lower_bound, | ||
double | upper_bound, | ||
bool | fixed = false |
||
) |
Set bounds for data values.
- Parameters
-
index Index of data axis to provide bounds for. lower_bound The lower bound of the data value. upper_bound The upper bound of the data value. fixed If the data value can vary or not.
Definition at line 267 of file BCDataSet.cxx.
void BCDataSet::SetNValuesPerPoint | ( | unsigned | n | ) |
Set number of values inside each data point.
If set to zero, then this will be set by first added data point.
- Parameters
-
n Size of data point.
Definition at line 256 of file BCDataSet.cxx.
The documentation for this class was generated from the following files:
- /root/bat/BAT/BCDataSet.h
- /root/bat/src/BCDataSet.cxx