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