CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 ColumnType::Float:
17  addColumn<float>(other.columnName(i), other.columnData<float>(i), other.columnDoc(i));
18  break;
19  case ColumnType::Int:
20  addColumn<int>(other.columnName(i), other.columnData<int>(i), other.columnDoc(i));
21  break;
22  case ColumnType::Int8:
23  addColumn<int8_t>(other.columnName(i), other.columnData<int>(i), other.columnDoc(i));
24  break;
25  case ColumnType::Bool:
26  addColumn<bool>(other.columnName(i), other.columnData<bool>(i), other.columnDoc(i));
27  break;
28  case ColumnType::UInt8:
29  addColumn<uint8_t>(other.columnName(i), other.columnData<uint8_t>(i), other.columnDoc(i));
30  break;
31  case ColumnType::UInt32:
32  addColumn<uint32_t>(other.columnName(i), other.columnData<uint32_t>(i), other.columnDoc(i));
33  break;
34  case ColumnType::Double:
35  addColumn<double>(other.columnName(i), other.columnData<double>(i), other.columnDoc(i));
36  break;
37  default:
38  throw cms::Exception("LogicError", "Unsupported type");
39  }
40  }
41 }
42 
43 double nanoaod::FlatTable::getAnyValue(unsigned int row, unsigned int column) const {
44  if (column >= nColumns())
45  throw cms::Exception("LogicError", "Invalid column");
46  switch (columnType(column)) {
47  case ColumnType::Float:
48  return *(beginData<float>(column) + row);
49  case ColumnType::Int:
50  return *(beginData<int>(column) + row);
51  case ColumnType::Int8:
52  return *(beginData<int8_t>(column) + row);
53  case ColumnType::Bool:
54  return *(beginData<bool>(column) + row);
55  case ColumnType::UInt8:
56  return *(beginData<uint8_t>(column) + row);
57  case ColumnType::UInt32:
58  return *(beginData<uint32_t>(column) + row);
59  case ColumnType::Double:
60  return *(beginData<double>(column) + row);
61  }
62  throw cms::Exception("LogicError", "Unsupported type");
63 }
void addExtension(const FlatTable &extension)
Definition: FlatTable.cc:11
int columnIndex(const std::string &name) const
Definition: FlatTable.cc:3
bool extension() const
Definition: FlatTable.h:59
std::vector< Column > columns_
Definition: FlatTable.h:212
ColumnType columnType(unsigned int col) const
Definition: FlatTable.h:65
int Bool
Definition: Types.h:100
auto columnData(unsigned int column) const
get a column by index (const)
Definition: FlatTable.h:73
unsigned int UInt32
Definition: Types.h:69
const std::string & name() const
Definition: FlatTable.h:60
int Int
Definition: forwards.h:16
const std::string & columnName(unsigned int col) const
Definition: FlatTable.h:62
unsigned int nColumns() const
Definition: FlatTable.h:55
unsigned int size() const
Definition: FlatTable.h:57
double getAnyValue(unsigned int row, unsigned int column) const
Definition: FlatTable.cc:43
tuple size
Write out results.
const std::string & columnDoc(unsigned int col) const
Definition: FlatTable.h:69