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::UInt8:
17  addColumn<uint8_t>(other.columnName(i), other.columnData<uint8_t>(i), other.columnDoc(i));
18  break;
19  case ColumnType::Int16:
20  addColumn<int16_t>(other.columnName(i), other.columnData<int16_t>(i), other.columnDoc(i));
21  break;
22  case ColumnType::UInt16:
23  addColumn<uint16_t>(other.columnName(i), other.columnData<uint16_t>(i), other.columnDoc(i));
24  break;
25  case ColumnType::Int32:
26  addColumn<int32_t>(other.columnName(i), other.columnData<int32_t>(i), other.columnDoc(i));
27  break;
28  case ColumnType::UInt32:
29  addColumn<uint32_t>(other.columnName(i), other.columnData<uint32_t>(i), other.columnDoc(i));
30  break;
31  case ColumnType::Bool:
32  addColumn<bool>(other.columnName(i), other.columnData<bool>(i), other.columnDoc(i));
33  break;
34  case ColumnType::Float:
35  addColumn<float>(other.columnName(i), other.columnData<float>(i), other.columnDoc(i));
36  break;
37  case ColumnType::Double:
38  addColumn<double>(other.columnName(i), other.columnData<double>(i), other.columnDoc(i));
39  break;
40  default:
41  throw cms::Exception("LogicError", "Unsupported type");
42  }
43  }
44 }
45 
46 double nanoaod::FlatTable::getAnyValue(unsigned int row, unsigned int column) const {
47  if (column >= nColumns())
48  throw cms::Exception("LogicError", "Invalid column");
49  switch (columnType(column)) {
50  case ColumnType::UInt8:
51  return *(beginData<uint8_t>(column) + row);
52  case ColumnType::Int16:
53  return *(beginData<int16_t>(column) + row);
54  case ColumnType::UInt16:
55  return *(beginData<uint16_t>(column) + row);
56  case ColumnType::Int32:
57  return *(beginData<int32_t>(column) + row);
58  case ColumnType::UInt32:
59  return *(beginData<uint32_t>(column) + row);
60  case ColumnType::Bool:
61  return *(beginData<bool>(column) + row);
62  case ColumnType::Float:
63  return *(beginData<float>(column) + row);
64  case ColumnType::Double:
65  return *(beginData<double>(column) + row);
66  }
67  throw cms::Exception("LogicError", "Unsupported type");
68 }
void addExtension(const FlatTable &extension)
Definition: FlatTable.cc:11
std::vector< Column > columns_
Definition: FlatTable.h:218
int Bool
Definition: Types.h:100
const std::string & name() const
Definition: FlatTable.h:62
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:46
unsigned short UInt16
Definition: Types.h:62
short Int16
Definition: Types.h:61
int Int32
Definition: Types.h:68