BCDataPoint Class Reference

A class representing a data point. More...

#include <BCDataPoint.h>

List of all members.

Public Member Functions

Constructors and destructors



 BCDataPoint (std::vector< double > x)
 BCDataPoint (int nvariables)
 ~BCDataPoint ()
Member functions (get)



const unsigned int GetNValues ()
double GetValue (int index)
std::vector< double > GetValues ()
Member functions (set)



void SetValue (int index, double value)
void SetValues (std::vector< double > values)

Private Attributes

std::vector< double > fData

Detailed Description

A class representing a data point.

Author:
Daniel Kollar
Kevin Kröninger
Version:
1.0
Date:
08.2008 This class represents a data point which is the basic unit of information. A data point can be an event, a bin content, etc. Each data point can store several variables of type double. The variables are organized in a vector.

Definition at line 30 of file BCDataPoint.h.


Constructor & Destructor Documentation

BCDataPoint::BCDataPoint ( int  nvariables  ) 

A constructor.

Parameters:
nvariables The number of variables stored in a data. object

Definition at line 18 of file BCDataPoint.cxx.

00019 {
00020    // assign the specified number of variables to the data
00021    // point and fill with zero
00022    fData.assign(nvariables, 0.);
00023 }

BCDataPoint::BCDataPoint ( std::vector< double >  x  ) 

A constructor.

Parameters:
x The vector containing the data.

Definition at line 27 of file BCDataPoint.cxx.

00028 {
00029    // copy all values of x to the data point
00030    for (std::vector<double>::const_iterator it = x.begin(); it != x.end(); ++it)
00031       fData.push_back(*it);
00032 }

BCDataPoint::~BCDataPoint (  ) 

A destructor.

Definition at line 36 of file BCDataPoint.cxx.

00037 {}


Member Function Documentation

const unsigned int BCDataPoint::GetNValues (  )  [inline]

Returns the number of values.

Definition at line 69 of file BCDataPoint.h.

00070          { return fData.size(); };

double BCDataPoint::GetValue ( int  index  ) 
Parameters:
index The index of the variable.
Returns:
The value of the variable.

Definition at line 41 of file BCDataPoint.cxx.

00042 {
00043 // this is not good at all
00044 // -1 can be ok value
00045 // and one can turn off warnings
00046 // so if index is out of range the program should stop
00047    double value = -1.0;
00048 
00049    // check if index is in range. return value if true ...
00050    if (index >= 0 && index < int(fData.size()))
00051       value = fData[index];
00052    // ... or give warning if not.
00053    else
00054       BCLog::Out(BCLog::warning, BCLog::warning,
00055             TString::Format("BCDataPoint::GetValue : Index %d out of range (%d to %d).",index,0,fData.size()));
00056 
00057    return value;
00058 }

std::vector<double> BCDataPoint::GetValues (  )  [inline]
Returns:
A vector of values.

Definition at line 64 of file BCDataPoint.h.

00065          { return fData; };

void BCDataPoint::SetValue ( int  index,
double  value 
)

Set the value of a variable.

Parameters:
index The index of the variable
value The value of the variable

Definition at line 62 of file BCDataPoint.cxx.

00063 {
00064 // this is not good at all
00065 // -1 can be ok value
00066 // and one can turn off warnings
00067 // so if index is out of range the program should stop
00068 
00069    // check if index is in range. set value if true ...
00070    if (index >= 0 && index < int(fData.size()))
00071       fData[index] = value;
00072    // ... or give warning if not.
00073    else
00074       BCLog::Out(BCLog::warning, BCLog::warning,
00075             TString::Format("BCDataPoint::SetValue : Index %d out of range (%d to %d).",index,0,fData.size()));
00076 }

void BCDataPoint::SetValues ( std::vector< double >  values  ) 

Set the values of all variables.

Parameters:
values A vector of values

Definition at line 80 of file BCDataPoint.cxx.

00081 {
00082    // check if sizes are the same. if true, clear the data point and copy from
00083    // the vector passed to the method ...
00084    if (values.size() == fData.size())
00085    {
00086       fData.clear();
00087       for (std::vector<double>::const_iterator it = values.begin(); it != values.end(); ++it)
00088          fData.push_back(*it);
00089    }
00090    // ... or give warning if the size if not the same.
00091    else
00092       BCLog::Out(BCLog::warning, BCLog::warning,"BCDataPoint::SetValues. vectors have different ranges.");
00093 }


Member Data Documentation

std::vector<double> BCDataPoint::fData [private]

The vector containing the values of the variables.

Definition at line 94 of file BCDataPoint.h.


The documentation for this class was generated from the following files:

Generated on Tue Oct 6 09:48:21 2009 for Bayesian Analysis Toolkit by  doxygen 1.6.1