npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
npstat::AbsNtuple< T > Class Template Referenceabstract

#include <AbsNtuple.hh>

Inheritance diagram for npstat::AbsNtuple< T >:
npstat::ArchivedNtuple< T > npstat::InMemoryNtuple< T >

Classes

class  column_iterator
 
class  row_iterator
 

Public Types

typedef T value_type
 

Public Member Functions

 AbsNtuple (const std::vector< std::string > &columnNames, const char *ntTitle)
 
const std::string & title () const
 
virtual void setTitle (const char *newtitle)
 
unsigned long nColumns () const
 
const std::string & columnName (const unsigned long i) const
 
const std::vector< std::string > & columnNames () const
 
virtual bool setColumnName (unsigned long i, const char *newname)
 
unsigned long columnNumber (const char *columnName) const
 
unsigned long validColumn (const char *columnName) const
 
virtual unsigned long nRows () const =0
 
unsigned long length () const
 
virtual void fill (const T *values, unsigned long lenValues)=0
 
virtual void fill (const T &v0)=0
 
virtual void fill (const T &v0, const T &v1)=0
 
virtual void fill (const T &v0, const T &v1, const T &v2)=0
 
virtual void fill (const T &v0, const T &v1, const T &v2, const T &v3)=0
 
virtual void fill (const T &v0, const T &v1, const T &v2, const T &v3, const T &v4)=0
 
virtual void fill (const T &v0, const T &v1, const T &v2, const T &v3, const T &v4, const T &v5)=0
 
virtual void fill (const T &v0, const T &v1, const T &v2, const T &v3, const T &v4, const T &v5, const T &v6)=0
 
virtual void fill (const T &v0, const T &v1, const T &v2, const T &v3, const T &v4, const T &v5, const T &v6, const T &v7)=0
 
virtual void fill (const T &v0, const T &v1, const T &v2, const T &v3, const T &v4, const T &v5, const T &v6, const T &v7, const T &v8)=0
 
virtual void fill (const T &v0, const T &v1, const T &v2, const T &v3, const T &v4, const T &v5, const T &v6, const T &v7, const T &v8, const T &v9)=0
 
template<typename T2 >
void append (const AbsNtuple< T2 > &another)
 
virtual T operator() (unsigned long r, unsigned long c) const =0
 
virtual T at (unsigned long r, unsigned long c) const =0
 
element (unsigned long r, const Column &c) const
 
elementAt (unsigned long r, const Column &c) const
 
virtual void rowContents (unsigned long row, T *buf, unsigned long lenBuf) const =0
 
virtual void columnContents (const Column &c, T *buf, unsigned long lenBuf) const =0
 
virtual void clear ()=0
 
row_iterator row_begin (unsigned long rowNumber) const
 
row_iterator row_end () const
 
column_iterator column_begin (const Column &column) const
 
column_iterator column_end () const
 
template<class Accumulator >
void cycleOverRows (Accumulator &acc) const
 
template<class Filter , class Accumulator >
unsigned long conditionalCycleOverRows (const Filter &f, Accumulator &acc) const
 
template<class Filter >
unsigned long conditionalRowCount (const Filter &f) const
 
template<class Accumulator , class WeightCalc >
void weightedCycleOverRows (Accumulator &acc, const WeightCalc &wcalc, bool skipZeroWeights=false) const
 
template<class Filter , class Accumulator , class WeightCalc >
double weightedConditionalCycleOverRows (const Filter &f, Accumulator &acc, const WeightCalc &wcalc, bool skipZeroWeights=false) const
 
template<class Filter , class WeightCalc >
double weightedConditionalRowCount (const Filter &f, const WeightCalc &wcalc) const
 
std::vector< unsigned long > columnIndices (const Column &c0) const
 
std::vector< unsigned long > columnIndices (const Column &c0, const Column &c1) const
 
std::vector< unsigned long > columnIndices (const Column &c0, const Column &c1, const Column &c2) const
 
std::vector< unsigned long > columnIndices (const Column &c0, const Column &c1, const Column &c2, const Column &c3) const
 
std::vector< unsigned long > columnIndices (const Column &c0, const Column &c1, const Column &c2, const Column &c3, const Column &c4) const
 
std::vector< unsigned long > columnIndices (const Column &c0, const Column &c1, const Column &c2, const Column &c3, const Column &c4, const Column &c5) const
 
std::vector< unsigned long > columnIndices (const Column &c0, const Column &c1, const Column &c2, const Column &c3, const Column &c4, const Column &c5, const Column &c6) const
 
std::vector< unsigned long > columnIndices (const Column &c0, const Column &c1, const Column &c2, const Column &c3, const Column &c4, const Column &c5, const Column &c6, const Column &c7) const
 
std::vector< unsigned long > columnIndices (const Column &c0, const Column &c1, const Column &c2, const Column &c3, const Column &c4, const Column &c5, const Column &c6, const Column &c7, const Column &c8) const
 
std::vector< unsigned long > columnIndices (const Column &c0, const Column &c1, const Column &c2, const Column &c3, const Column &c4, const Column &c5, const Column &c6, const Column &c7, const Column &c8, const Column &c9) const
 
std::vector< unsigned long > columnIndices (const std::vector< std::string > &colNames) const
 
virtual gs::ClassId classId () const =0
 
bool operator== (const AbsNtuple &r) const
 
bool operator!= (const AbsNtuple &r) const
 

Protected Member Functions

virtual bool isEqual (const AbsNtuple &r) const
 

Detailed Description

template<typename T>
class npstat::AbsNtuple< T >

Interface class for ntuples. Here, ntuples are homogeneous 2-d tables in which the number of columns is fixed while the number of rows can grow dynamically.

Constructor & Destructor Documentation

◆ AbsNtuple()

template<typename T >
npstat::AbsNtuple< T >::AbsNtuple ( const std::vector< std::string > &  columnNames,
const char *  ntTitle 
)
inline

The constructor arguments are a vector of column names and an ntuple title c-string (which can be NULL)

Member Function Documentation

◆ append()

template<typename T >
template<typename T2 >
void npstat::AbsNtuple< T >::append ( const AbsNtuple< T2 > &  another)

Append contents of another ntuple. That ntuple must have the same number of columns. The copy constructor must exist which builds elements of this ntuple from the elements of another ntuple.

◆ at()

template<typename T >
virtual T npstat::AbsNtuple< T >::at ( unsigned long  r,
unsigned long  c 
) const
pure virtual

Access individual elements with bounds checking

Implemented in npstat::ArchivedNtuple< T >, and npstat::InMemoryNtuple< T >.

◆ classId()

template<typename T >
virtual gs::ClassId npstat::AbsNtuple< T >::classId ( ) const
pure virtual

Prototype needed for I/O

Implemented in npstat::InMemoryNtuple< T >, and npstat::ArchivedNtuple< T >.

◆ clear()

template<typename T >
virtual void npstat::AbsNtuple< T >::clear ( )
pure virtual

Clear the data (if possible). Note that certain disk-based implementations may ignore this. Check the number of rows to make sure that the data was indeed cleared.

Implemented in npstat::InMemoryNtuple< T >, and npstat::ArchivedNtuple< T >.

◆ columnIndices() [1/2]

template<typename T >
std::vector<unsigned long> npstat::AbsNtuple< T >::columnIndices ( const Column c0) const

Convenience method which returns a collection of column indices using a set of inhomogeneous column descriptions as an argument. Exception will be thrown if the column does not exist.

◆ columnIndices() [2/2]

template<typename T >
std::vector<unsigned long> npstat::AbsNtuple< T >::columnIndices ( const std::vector< std::string > &  colNames) const

Convenience method which returns a collection of column indices using a vector of column names as an argument.

◆ columnName()

template<typename T >
const std::string& npstat::AbsNtuple< T >::columnName ( const unsigned long  i) const
inline

Retrieve the name for the given column

◆ columnNames()

template<typename T >
const std::vector<std::string>& npstat::AbsNtuple< T >::columnNames ( ) const
inline

Retrieve all column names

◆ columnNumber()

template<typename T >
unsigned long npstat::AbsNtuple< T >::columnNumber ( const char *  columnName) const

This method returns nColumns() in case the given column name is not valid

◆ conditionalCycleOverRows()

template<typename T >
template<class Filter , class Accumulator >
unsigned long npstat::AbsNtuple< T >::conditionalCycleOverRows ( const Filter &  f,
Accumulator &  acc 
) const

Same as cycleOverRows, but the accumulator will be called only if the filter returns "true". The filter must be a functor which implements

bool operator()(unsigned long rowNumber, const T* rowContents, unsigned long nColumns) const

The function returns the number of rows passing the filter.

◆ conditionalRowCount()

template<typename T >
template<class Filter >
unsigned long npstat::AbsNtuple< T >::conditionalRowCount ( const Filter &  f) const

Cycle over rows counting how many rows pass the filter

◆ cycleOverRows()

template<typename T >
template<class Accumulator >
void npstat::AbsNtuple< T >::cycleOverRows ( Accumulator &  acc) const

Function for cycling over all rows. The accumulator class must implement the following function:

void accumulate(T* rowContents, unsigned long nColumns)

◆ element()

template<typename T >
T npstat::AbsNtuple< T >::element ( unsigned long  r,
const Column c 
) const

Access with flexible column argument. The "Column" class has converting constructors from unsigned long, const char*, and std::string&. All these can now be used as the second argument. Note that this type of access will be slower than access by simple indices, so don't use this method in tight loops.

◆ elementAt()

template<typename T >
T npstat::AbsNtuple< T >::elementAt ( unsigned long  r,
const Column c 
) const

Similar method with bounds checking

◆ fill() [1/2]

template<typename T >
virtual void npstat::AbsNtuple< T >::fill ( const T &  v0)
pure virtual

Convenience method which works if the number of arguments equals the number if colums (otherwise an exception will be thrown)

Implemented in npstat::InMemoryNtuple< T >, and npstat::ArchivedNtuple< T >.

◆ fill() [2/2]

template<typename T >
virtual void npstat::AbsNtuple< T >::fill ( const T *  values,
unsigned long  lenValues 
)
pure virtual

The number of values provided, "lenValues", should be divisible by the number of columns. If it is not, the function should throw "std::invalid_argument" exception.

Implemented in npstat::InMemoryNtuple< T >, and npstat::ArchivedNtuple< T >.

◆ isEqual()

template<typename T >
virtual bool npstat::AbsNtuple< T >::isEqual ( const AbsNtuple< T > &  r) const
protectedvirtual

Comparison for equality to be overriden by the derived classes. Don't forget to call "isEqual" method of the base class.

Reimplemented in npstat::ArchivedNtuple< T >, and npstat::InMemoryNtuple< T >.

◆ length()

template<typename T >
unsigned long npstat::AbsNtuple< T >::length ( ) const
inline

Retrieve the total number of ntuple elements

◆ nColumns()

template<typename T >
unsigned long npstat::AbsNtuple< T >::nColumns ( ) const
inline

Retrieve the number of columns

◆ nRows()

template<typename T >
virtual unsigned long npstat::AbsNtuple< T >::nRows ( ) const
pure virtual

Retrieve the number of rows

Implemented in npstat::InMemoryNtuple< T >, and npstat::ArchivedNtuple< T >.

◆ operator!=()

template<typename T >
bool npstat::AbsNtuple< T >::operator!= ( const AbsNtuple< T > &  r) const
inline

Logical negation of operator==

◆ operator()()

template<typename T >
virtual T npstat::AbsNtuple< T >::operator() ( unsigned long  r,
unsigned long  c 
) const
pure virtual

Access individual elements (no bounds checking). Note that access is by value, so it involves a fair amount of copying. The other alternative, return by reference, could lead to subtle bugs with references invalidated by fill operations and buffer swapping.

Implemented in npstat::ArchivedNtuple< T >, and npstat::InMemoryNtuple< T >.

◆ operator==()

template<typename T >
bool npstat::AbsNtuple< T >::operator== ( const AbsNtuple< T > &  r) const
inline

Comparison for equality. Do not override in derived classes (override "isEqual" method instead)

◆ row_begin()

template<typename T >
row_iterator npstat::AbsNtuple< T >::row_begin ( unsigned long  rowNumber) const

Methods which return begin/end positions for the row/column iterators

◆ rowContents()

template<typename T >
virtual void npstat::AbsNtuple< T >::rowContents ( unsigned long  row,
T *  buf,
unsigned long  lenBuf 
) const
pure virtual

Fetch copies of rows/columns. The buffer should be at least as large as the number of elements expected in return.

Implemented in npstat::InMemoryNtuple< T >, and npstat::ArchivedNtuple< T >.

◆ setColumnName()

template<typename T >
virtual bool npstat::AbsNtuple< T >::setColumnName ( unsigned long  i,
const char *  newname 
)
virtual

The code will refuse to set the column name (and false will be returned in this case) if the provided name duplicates an existing column name. False will also be returned if the column index is out of range. Derived classes can also refuse to change the column name if their implementation relies in some way on the permanence of these names.

◆ setTitle()

template<typename T >
virtual void npstat::AbsNtuple< T >::setTitle ( const char *  newtitle)
inlinevirtual

Set the ntuple title

◆ title()

template<typename T >
const std::string& npstat::AbsNtuple< T >::title ( ) const
inline

Retrieve the ntuple title

◆ validColumn()

template<typename T >
unsigned long npstat::AbsNtuple< T >::validColumn ( const char *  columnName) const

This method works just like columnNumber but generates a dynamic fault in case the given column name is invalid

◆ weightedConditionalCycleOverRows()

template<typename T >
template<class Filter , class Accumulator , class WeightCalc >
double npstat::AbsNtuple< T >::weightedConditionalCycleOverRows ( const Filter &  f,
Accumulator &  acc,
const WeightCalc &  wcalc,
bool  skipZeroWeights = false 
) const

This method returns the sum of weights for rows that pass the filter and call the accumulator as appropriate

◆ weightedConditionalRowCount()

template<typename T >
template<class Filter , class WeightCalc >
double npstat::AbsNtuple< T >::weightedConditionalRowCount ( const Filter &  f,
const WeightCalc &  wcalc 
) const

This method just returns the sum of weights for rows that pass the filter

◆ weightedCycleOverRows()

template<typename T >
template<class Accumulator , class WeightCalc >
void npstat::AbsNtuple< T >::weightedCycleOverRows ( Accumulator &  acc,
const WeightCalc &  wcalc,
bool  skipZeroWeights = false 
) const

Another row cycling function which employs a functor that calculates a weight. The weight functor must implement

double operator()(unsigned long rowNumber, const T* rowContents, unsigned long nCols) const

The returned weights must be non-negative. The accumulator must implement

void accumulate(T* rowContents, unsigned long nColumns, double w)

The option "skipZeroWeights" allows the user not to call the accumulator if the calculated weight is 0.


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