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 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 }
size
Write out results.
void addExtension(const FlatTable &extension)
Definition: FlatTable.cc:11
std::vector< Column > columns_
Definition: FlatTable.h:212
int Bool
Definition: Types.h:100
const std::string & name() const
Definition: FlatTable.h:60
int columnIndex(const std::string &name) const
Definition: FlatTable.cc:3
unsigned int UInt32
Definition: Types.h:69
double getAnyValue(unsigned int row, unsigned int column) const
Definition: FlatTable.cc:43
int Int
Definition: forwards.h:16