|
|
Go to the documentation of this file. 1 #ifndef DataFormats_NanoAOD_FlatTable_h
2 #define DataFormats_NanoAOD_FlatTable_h
11 #include <type_traits>
15 namespace flatTableHelper {
20 template <
typename Span>
27 inline float one(
const float &
val)
const {
30 template <
typename Span>
73 auto begin = beginData<T>(column);
80 auto begin = beginData<T>(column);
88 throw cms::Exception(
"LogicError",
"columnValue works only for singleton tables");
89 return *beginData<T>(column);
111 template <
typename T,
typename C>
117 auto &vec = bigVector<T>();
123 template <
typename T,
typename C>
126 throw cms::Exception(
"LogicError",
"addColumnValue works only for singleton tables");
129 auto &vec = bigVector<T>();
138 template <
typename T>
140 if constexpr (std::is_same<T, float>())
142 else if constexpr (std::is_same<T, int>())
144 else if constexpr (std::is_same<T, uint8_t>())
146 else if constexpr (std::is_same<T, bool>())
148 else if constexpr (std::is_same<T, uint32_t>())
150 else if constexpr (std::is_same<T, double>())
167 template <
typename T>
169 return bigVector<T>().cbegin() +
columns_[column].firstIndex;
171 template <
typename T>
173 return bigVector<T>().begin() +
columns_[column].firstIndex;
176 template <
typename T>
178 return bigVectorImpl<T>(*
this);
180 template <
typename T>
182 return bigVectorImpl<T>(*
this);
185 template <
typename T,
class This>
188 if constexpr (std::is_same<T, float>())
189 return table.floats_;
190 else if constexpr (std::is_same<T, int>())
192 else if constexpr (std::is_same<T, uint8_t>())
193 return table.uint8s_;
194 else if constexpr (std::is_same<T, bool>())
195 return table.uint8s_;
196 else if constexpr (std::is_same<T, uint32_t>())
197 return table.uint32s_;
198 else if constexpr (std::is_same<T, double>())
199 return table.doubles_;
Column(const std::string &aname, const std::string &docString, ColumnType atype, unsigned int anIndex)
void bulk(Span &&data) const
RowView(const FlatTable &table, unsigned int row)
void addColumn(const std::string &name, const C &values, const std::string &docString, int mantissaBits=-1)
static auto & bigVectorImpl(This &table)
std::vector< uint32_t > uint32s_
void setDoc(const std::string &doc)
MaybeMantissaReduce(int mantissaBits)
RowView row(unsigned int row) const
const std::string & doc() const
void bulk(Span const &data) const
T one(const T &val) const
auto columnData(unsigned int column) const
get a column by index (const)
const std::string & columnDoc(unsigned int col) const
MaybeMantissaReduce(int mantissaBits)
ColumnType columnType(unsigned int col) const
const FlatTable & table() const
const auto & bigVector() const
void addExtension(const FlatTable &extension)
int columnIndex(const std::string &name) const
std::vector< double > doubles_
auto beginData(unsigned int column)
static float reduceMantissaToNbitsRounding(const float &f)
std::vector< uint8_t > uint8s_
float one(const float &val) const
unsigned int nRows() const
void addColumnValue(const std::string &name, const C &value, const std::string &docString, int mantissaBits=-1)
std::vector< Column > columns_
const std::string & name() const
static ColumnType defaultColumnType()
std::vector< float > floats_
double getAnyValue(const std::string &column) const
const std::string & columnName(unsigned int col) const
const auto & columValue(unsigned int column) const
get a column value for singleton (const)
unsigned int nColumns() const
double getAnyValue(unsigned int row, unsigned int column) const
auto columnData(unsigned int column)
get a column by index (non-const)
char data[epos_bytes_allocation]
double getAnyValue(unsigned int column) const
FlatTable(unsigned int size, const std::string &name, bool singleton, bool extension=false)
auto beginData(unsigned int column) const
unsigned int size() const