CMS 3D CMS Logo

FlatTable.cc
Go to the documentation of this file.
2 
4  for (unsigned int i = 0, n = columns_.size(); i < n; ++i) {
5  if (columns_[i].name == name)
6  return i;
7  }
8  return -1;
9 }
10 
12  if (extension() || !other.extension() || name() != other.name() || size() != other.size())
13  throw cms::Exception("LogicError", "Mismatch in adding extension");
14  for (unsigned int i = 0, n = other.nColumns(); i < n; ++i) {
15  switch (other.columnType(i)) {
16  case FloatColumn:
17  addColumn<float>(other.columnName(i), other.columnData<float>(i), other.columnDoc(i), other.columnType(i));
18  break;
19  case IntColumn:
20  addColumn<int>(other.columnName(i), other.columnData<int>(i), other.columnDoc(i), other.columnType(i));
21  break;
22  case BoolColumn: // as UInt8
23  case UInt8Column:
24  addColumn<uint8_t>(other.columnName(i), other.columnData<uint8_t>(i), other.columnDoc(i), other.columnType(i));
25  break;
26  }
27  }
28 }
29 
30 double nanoaod::FlatTable::getAnyValue(unsigned int row, unsigned int column) const {
31  if (column >= nColumns())
32  throw cms::Exception("LogicError", "Invalid column");
33  switch (columnType(column)) {
34  case FloatColumn:
35  return *(beginData<float>(column) + row);
36  case IntColumn:
37  return *(beginData<int>(column) + row);
38  case BoolColumn:
39  return *(beginData<uint8_t>(column) + row);
40  case UInt8Column:
41  return *(beginData<uint8_t>(column) + row);
42  }
43  throw cms::Exception("LogicError", "Unsupported type");
44 }
boost::sub_range< const std::vector< T > > columnData(unsigned int column) const
get a column by index (const)
Definition: FlatTable.h:66
void addExtension(const FlatTable &extension)
Definition: FlatTable.cc:11
RowView row(unsigned int row) const
Definition: FlatTable.h:103
int columnIndex(const std::string &name) const
Definition: FlatTable.cc:3
bool extension() const
Definition: FlatTable.h:52
std::vector< Column > columns_
Definition: FlatTable.h:186
ColumnType columnType(unsigned int col) const
Definition: FlatTable.h:58
const std::string & name() const
Definition: FlatTable.h:53
const std::string & columnName(unsigned int col) const
Definition: FlatTable.h:55
unsigned int nColumns() const
Definition: FlatTable.h:48
unsigned int size() const
Definition: FlatTable.h:50
double getAnyValue(unsigned int row, unsigned int column) const
Definition: FlatTable.cc:30
const std::string & columnDoc(unsigned int col) const
Definition: FlatTable.h:62