/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
DataFormats/NanoAOD/src/FlatTable.cc
82 строки
3 KB
Huilin Qu
Add support for 64b integers in NANO.
13 мар 2025, 17:57
13 мар 2025, 17:57
27a7eb0
Код
Авторство
О чём код?
#include "DataFormats/NanoAOD/interface/FlatTable.h" int nanoaod::FlatTable::columnIndex(const std::string& name) const { for (unsigned int i = 0, n = columns_.size(); i < n; ++i) { if (columns_[i].name == name) return i; } return -1; } void nanoaod::FlatTable::addExtension(const nanoaod::FlatTable& other) { if (extension() || !other.extension() || name() != other.name() || size() != other.size()) throw cms::Exception("LogicError", "Mismatch in adding extension"); for (unsigned int i = 0, n = other.nColumns(); i < n; ++i) { switch (other.columnType(i)) { case ColumnType::UInt8: addColumn<uint8_t>(other.columnName(i), other.columnData<uint8_t>(i), other.columnDoc(i)); break; case ColumnType::Int16: addColumn<int16_t>(other.columnName(i), other.columnData<int16_t>(i), other.columnDoc(i)); break; case ColumnType::UInt16: addColumn<uint16_t>(other.columnName(i), other.columnData<uint16_t>(i), other.columnDoc(i)); break; case ColumnType::Int32: addColumn<int32_t>(other.columnName(i), other.columnData<int32_t>(i), other.columnDoc(i)); break; case ColumnType::UInt32: addColumn<uint32_t>(other.columnName(i), other.columnData<uint32_t>(i), other.columnDoc(i)); break; case ColumnType::Int64: addColumn<int64_t>(other.columnName(i), other.columnData<int64_t>(i), other.columnDoc(i)); break; case ColumnType::UInt64: addColumn<uint64_t>(other.columnName(i), other.columnData<uint64_t>(i), other.columnDoc(i)); break; case ColumnType::Bool: addColumn<bool>(other.columnName(i), other.columnData<bool>(i), other.columnDoc(i)); break; case ColumnType::Float: addColumn<float>(other.columnName(i), other.columnData<float>(i), other.columnDoc(i)); break; case ColumnType::Double: addColumn<double>(other.columnName(i), other.columnData<double>(i), other.columnDoc(i)); break; default: throw cms::Exception("LogicError", "Unsupported type"); } } } double nanoaod::FlatTable::getAnyValue(unsigned int row, unsigned int column) const { if (column >= nColumns()) throw cms::Exception("LogicError", "Invalid column"); switch (columnType(column)) { case ColumnType::UInt8: return *(beginData<uint8_t>(column) + row); case ColumnType::Int16: return *(beginData<int16_t>(column) + row); case ColumnType::UInt16: return *(beginData<uint16_t>(column) + row); case ColumnType::Int32: return *(beginData<int32_t>(column) + row); case ColumnType::UInt32: return *(beginData<uint32_t>(column) + row); case ColumnType::Int64: return *(beginData<int64_t>(column) + row); case ColumnType::UInt64: return *(beginData<uint64_t>(column) + row); case ColumnType::Bool: return *(beginData<bool>(column) + row); case ColumnType::Float: return *(beginData<float>(column) + row); case ColumnType::Double: return *(beginData<double>(column) + row); } throw cms::Exception("LogicError", "Unsupported type"); } void nanoaod::FlatTable::RowView::throwUnknownColumn(const std::string& column) { throw cms::Exception("LogicError") << "Invalid column name '" << column << "'"; }