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 (const BCDataPoint &datapoint)
 ~BCDataPoint ()
Assignment operators

BCDataPointoperator= (const BCDataPoint &datapoint)
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.

Copyright (C) 2008-2012, Daniel Kollar and Kevin Kroeninger. All rights reserved.

For the licensing terms see doc/COPYING.

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 26 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 ( const BCDataPoint datapoint  ) 

The copy constructor.

Definition at line 34 of file BCDataPoint.cxx.

{
   // debugKK
   fData = datapoint.fData;
}

BCDataPoint::~BCDataPoint (  ) 

A destructor.

Definition at line 41 of file BCDataPoint.cxx.

{}


Member Function Documentation

unsigned int BCDataPoint::GetNValues (  )  [inline]

Returns the number of values.

Definition at line 81 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 54 of file BCDataPoint.cxx.

{
   double value;

   // check if index is in range. return value if true ...
   if (index >= 0 && index < int(fData.size()))
      value = fData[index];
   // ... or give error if not.
   else {
      // exit on error
      BCLog::OutError(
            Form("BCDataPoint::GetValue : Index %d out of range (%d to %d).",
                 index,0, (int)fData.size()-1));
      exit(1);
   }

   return value;
}

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

Definition at line 76 of file BCDataPoint.h.

         { return fData; };

BCDataPoint & BCDataPoint::operator= ( const BCDataPoint datapoint  ) 

Defaut assignment operator

Definition at line 45 of file BCDataPoint.cxx.

{
   fData = datapoint.fData;

   // return this
   return *this;
}

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

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

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

Set the values of all variables.

Parameters:
values A vector of values

Definition at line 90 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 error if the size if not the same.
   else {
      BCLog::OutError("BCDataPoint::SetValues : Vectors have different ranges.");
      exit(1);
   }
}


Member Data Documentation

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

The vector containing the values of the variables.

Definition at line 106 of file BCDataPoint.h.


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