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) return i;
6  }
7  return -1;
8 }
9 
11  if (extension() || !other.extension() || name() != other.name() || size() != other.size()) throw cms::Exception("LogicError", "Mismatch in adding extension");
12  for (unsigned int i = 0, n = other.nColumns(); i < n; ++i) {
13  switch(other.columnType(i)) {
14  case FloatColumn:
15  addColumn<float>(other.columnName(i), other.columnData<float>(i), other.columnDoc(i), other.columnType(i));
16  break;
17  case IntColumn:
18  addColumn<int>(other.columnName(i), other.columnData<int>(i), other.columnDoc(i), other.columnType(i));
19  break;
20  case BoolColumn: // as UInt8
21  case UInt8Column:
22  addColumn<uint8_t>(other.columnName(i), other.columnData<uint8_t>(i), other.columnDoc(i), other.columnType(i));
23  break;
24  }
25  }
26 }
27 
28 double nanoaod::FlatTable::getAnyValue(unsigned int row, unsigned int column) const {
29  if (column >= nColumns()) throw cms::Exception("LogicError","Invalid column");
30  switch(columnType(column)) {
31  case FloatColumn: return *(beginData<float>(column)+row);
32  case IntColumn: return *(beginData<int>(column)+row);
33  case BoolColumn: return *(beginData<uint8_t>(column)+row);
34  case UInt8Column: return *(beginData<uint8_t>(column)+row);
35  }
36  throw cms::Exception("LogicError", "Unsupported type");
37 }
boost::sub_range< const std::vector< T > > columnData(unsigned int column) const
get a column by index (const)
Definition: FlatTable.h:53
void addExtension(const FlatTable &extension)
Definition: FlatTable.cc:10
RowView row(unsigned int row) const
Definition: FlatTable.h:86
int columnIndex(const std::string &name) const
Definition: FlatTable.cc:3
bool extension() const
Definition: FlatTable.h:39
std::vector< Column > columns_
Definition: FlatTable.h:151
ColumnType columnType(unsigned int col) const
Definition: FlatTable.h:45
const std::string & name() const
Definition: FlatTable.h:40
const std::string & columnName(unsigned int col) const
Definition: FlatTable.h:42
unsigned int nColumns() const
Definition: FlatTable.h:35
unsigned int size() const
Definition: FlatTable.h:37
double getAnyValue(unsigned int row, unsigned int column) const
Definition: FlatTable.cc:28
const std::string & columnDoc(unsigned int col) const
Definition: FlatTable.h:49