Private Attributes

BCDataPoint Class Reference

A class representing a data point. More...

#include <BCDataPoint.h>

List of all members.

Public Member Functions

Constructors and destructors

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

double GetValue (int index)
std::vector< double > GetValues ()
unsigned int GetNValues ()
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.

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

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

A constructor.

Parameters:
x The vector containing the data.

Definition at line 27 of file BCDataPoint.cxx.

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

BCDataPoint::~BCDataPoint (  ) 

A destructor.

Definition at line 36 of file BCDataPoint.cxx.

{}


Member Function Documentation

unsigned int BCDataPoint::GetNValues (  )  [inline]

Returns the number of values.

Definition at line 69 of file BCDataPoint.h.

         { 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.

{
// this is not good at all
// -1 can be ok value
// and one can turn off warnings
// so if index is out of range the program should stop
   double value = -1.0;

   // check if index is in range. return value if true ...
   if (index >= 0 && index < int(fData.size()))
      value = fData[index];
   // ... or give warning if not.
   else
      BCLog::Out(BCLog::warning, BCLog::warning, TString::Format(
            "BCDataPoint::GetValue : Index %d out of range (%d to %d).", index,
            0, fData.size()-1));

   return value;
}

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

Definition at line 64 of file BCDataPoint.h.

         { 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 63 of file BCDataPoint.cxx.

{
// this is not good at all
// -1 can be ok value
// and one can turn off warnings
// so if index is out of range the program should stop

   // check if index is in range. set value if true ...
   if (index >= 0 && index < int(fData.size()))
      fData[index] = value;
   // ... or give warning if not.
   else
      BCLog::Out(BCLog::warning, BCLog::warning,TString::Format(
            "BCDataPoint::SetValue : Index %d out of range (%d to %d).",
            index, 0 ,fData.size()-1));
}

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

Set the values of all variables.

Parameters:
values A vector of values

Definition at line 82 of file BCDataPoint.cxx.

{
   // check if sizes are the same. if true, clear the data point and copy from
   // the vector passed to the method ...
   if (values.size() == fData.size())
   {
      fData.clear();
      for (std::vector<double>::const_iterator it = values.begin(); it != values.end(); ++it)
         fData.push_back(*it);
   }
   // ... or give warning if the size if not the same.
   else
      BCLog::Out(BCLog::warning, BCLog::warning,"BCDataPoint::SetValues : Vectors have different ranges.");
}


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: