CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
nanoaod::MergeableCounterTable Class Reference

#include <MergeableCounterTable.h>

Classes

struct  SingleColumn
 
struct  VectorColumn
 

Public Types

typedef double float_accumulator
 
typedef SingleColumn< float_accumulatorFloatColumn
 
typedef long long int_accumulator
 
typedef SingleColumn< int_accumulatorIntColumn
 
typedef VectorColumn< float_accumulatorVFloatColumn
 
typedef VectorColumn< int_accumulatorVIntColumn
 

Public Member Functions

template<typename F >
void addFloat (const std::string &name, const std::string &doc, F value)
 
template<typename I >
void addInt (const std::string &name, const std::string &doc, I value)
 
template<typename F >
void addVFloat (const std::string &name, const std::string &doc, const std::vector< F > values)
 
template<typename I >
void addVInt (const std::string &name, const std::string &doc, const std::vector< I > values)
 
const std::vector< FloatColumn > & floatCols () const
 
const std::vector< IntColumn > & intCols () const
 
 MergeableCounterTable ()
 
bool mergeProduct (const MergeableCounterTable &other)
 
void swap (MergeableCounterTable &iOther)
 
const std::vector< VFloatColumn > & vfloatCols () const
 
const std::vector< VIntColumn > & vintCols () const
 

Private Member Functions

template<typename T >
bool tryMerge (std::vector< T > &one, const std::vector< T > &two)
 

Private Attributes

std::vector< FloatColumnfloatCols_
 
std::vector< IntColumnintCols_
 
std::vector< VFloatColumnvfloatCols_
 
std::vector< VIntColumnvintCols_
 

Detailed Description

Definition at line 10 of file MergeableCounterTable.h.

Member Typedef Documentation

Definition at line 14 of file MergeableCounterTable.h.

Definition at line 34 of file MergeableCounterTable.h.

Definition at line 13 of file MergeableCounterTable.h.

Definition at line 35 of file MergeableCounterTable.h.

Definition at line 60 of file MergeableCounterTable.h.

Definition at line 61 of file MergeableCounterTable.h.

Constructor & Destructor Documentation

nanoaod::MergeableCounterTable::MergeableCounterTable ( )
inline

Definition at line 12 of file MergeableCounterTable.h.

12 {}

Member Function Documentation

template<typename F >
void nanoaod::MergeableCounterTable::addFloat ( const std::string &  name,
const std::string &  doc,
F  value 
)
inline

Definition at line 69 of file MergeableCounterTable.h.

References floatCols_.

69  {
70  floatCols_.push_back(FloatColumn(name, doc, value));
71  }
SingleColumn< float_accumulator > FloatColumn
Definition: value.py:1
std::vector< FloatColumn > floatCols_
template<typename I >
void nanoaod::MergeableCounterTable::addInt ( const std::string &  name,
const std::string &  doc,
value 
)
inline

Definition at line 74 of file MergeableCounterTable.h.

References intCols_.

74  {
75  intCols_.push_back(IntColumn(name, doc, value));
76  }
std::vector< IntColumn > intCols_
Definition: value.py:1
SingleColumn< int_accumulator > IntColumn
template<typename F >
void nanoaod::MergeableCounterTable::addVFloat ( const std::string &  name,
const std::string &  doc,
const std::vector< F values 
)
inline

Definition at line 79 of file MergeableCounterTable.h.

References filterCSVwithJSON::copy, and vfloatCols_.

79  {
80  vfloatCols_.push_back(VFloatColumn(name, doc, values.size()));
81  std::copy(values.begin(), values.end(), vfloatCols_.back().values.begin());
82  }
std::vector< VFloatColumn > vfloatCols_
VectorColumn< float_accumulator > VFloatColumn
template<typename I >
void nanoaod::MergeableCounterTable::addVInt ( const std::string &  name,
const std::string &  doc,
const std::vector< I >  values 
)
inline

Definition at line 85 of file MergeableCounterTable.h.

References filterCSVwithJSON::copy, and vintCols_.

85  {
86  vintCols_.push_back(VIntColumn(name, doc, values.size()));
87  std::copy(values.begin(), values.end(), vintCols_.back().values.begin());
88  }
std::vector< VIntColumn > vintCols_
VectorColumn< int_accumulator > VIntColumn
const std::vector<FloatColumn>& nanoaod::MergeableCounterTable::floatCols ( ) const
inline
const std::vector<IntColumn>& nanoaod::MergeableCounterTable::intCols ( ) const
inline
bool nanoaod::MergeableCounterTable::mergeProduct ( const MergeableCounterTable other)
inline

Definition at line 90 of file MergeableCounterTable.h.

References floatCols_, intCols_, tryMerge(), vfloatCols_, and vintCols_.

90  {
91  if (!tryMerge(intCols_, other.intCols_))
92  return false;
93  if (!tryMerge(vintCols_, other.vintCols_))
94  return false;
95  if (!tryMerge(floatCols_, other.floatCols_))
96  return false;
97  if (!tryMerge(vfloatCols_, other.vfloatCols_))
98  return false;
99  return true;
100  }
std::vector< IntColumn > intCols_
bool tryMerge(std::vector< T > &one, const std::vector< T > &two)
std::vector< VIntColumn > vintCols_
std::vector< VFloatColumn > vfloatCols_
std::vector< FloatColumn > floatCols_
void nanoaod::MergeableCounterTable::swap ( MergeableCounterTable iOther)
inline

Definition at line 102 of file MergeableCounterTable.h.

References floatCols_, intCols_, vfloatCols_, and vintCols_.

102  {
103  floatCols_.swap(iOther.floatCols_);
104  vfloatCols_.swap(iOther.vfloatCols_);
105  intCols_.swap(iOther.intCols_);
106  vintCols_.swap(iOther.vintCols_);
107  }
std::vector< IntColumn > intCols_
std::vector< VIntColumn > vintCols_
std::vector< VFloatColumn > vfloatCols_
std::vector< FloatColumn > floatCols_
template<typename T >
bool nanoaod::MergeableCounterTable::tryMerge ( std::vector< T > &  one,
const std::vector< T > &  two 
)
inlineprivate

Definition at line 116 of file MergeableCounterTable.h.

References nanoaod::MergeableCounterTable::SingleColumn< T >::compatible(), mps_fire::i, and dqmiodumpmetadata::n.

Referenced by mergeProduct().

116  {
117  if (one.size() != two.size())
118  return false;
119  for (unsigned int i = 0, n = one.size(); i < n; ++i) {
120  if (!one[i].compatible(two[i]))
121  return false;
122  one[i] += two[i];
123  }
124  return true;
125  }
const std::vector<VFloatColumn>& nanoaod::MergeableCounterTable::vfloatCols ( ) const
inline
const std::vector<VIntColumn>& nanoaod::MergeableCounterTable::vintCols ( ) const
inline

Member Data Documentation

std::vector<FloatColumn> nanoaod::MergeableCounterTable::floatCols_
private

Definition at line 110 of file MergeableCounterTable.h.

Referenced by addFloat(), floatCols(), mergeProduct(), and swap().

std::vector<IntColumn> nanoaod::MergeableCounterTable::intCols_
private

Definition at line 112 of file MergeableCounterTable.h.

Referenced by addInt(), intCols(), mergeProduct(), and swap().

std::vector<VFloatColumn> nanoaod::MergeableCounterTable::vfloatCols_
private

Definition at line 111 of file MergeableCounterTable.h.

Referenced by addVFloat(), mergeProduct(), swap(), and vfloatCols().

std::vector<VIntColumn> nanoaod::MergeableCounterTable::vintCols_
private

Definition at line 113 of file MergeableCounterTable.h.

Referenced by addVInt(), mergeProduct(), swap(), and vintCols().