|
|
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>
71 auto begin = beginData<T>(column);
78 auto begin = beginData<T>(column);
86 throw cms::Exception(
"LogicError",
"columnValue works only for singleton tables");
87 return *beginData<T>(column);
109 template <
typename T,
typename C>
115 auto &vec = bigVector<T>();
121 template <
typename T,
typename C>
124 throw cms::Exception(
"LogicError",
"addColumnValue works only for singleton tables");
127 auto &vec = bigVector<T>();
136 template <
typename T>
138 if constexpr (std::is_same<T, float>())
140 else if constexpr (std::is_same<T, int>())
142 else if constexpr (std::is_same<T, uint8_t>())
144 else if constexpr (std::is_same<T, bool>())
161 template <
typename T>
163 return bigVector<T>().cbegin() +
columns_[column].firstIndex;
165 template <
typename T>
167 return bigVector<T>().begin() +
columns_[column].firstIndex;
170 template <
typename T>
172 return bigVectorImpl<T>(*
this);
174 template <
typename T>
176 return bigVectorImpl<T>(*
this);
179 template <
typename T,
class This>
182 if constexpr (std::is_same<T, float>())
183 return table.floats_;
184 else if constexpr (std::is_same<T, int>())
186 else if constexpr (std::is_same<T, uint8_t>())
187 return table.uint8s_;
188 else if constexpr (std::is_same<T, bool>())
189 return table.uint8s_;
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)
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
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