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>
76 auto begin = beginData<T>(column);
83 auto begin = beginData<T>(column);
91 throw cms::Exception(
"LogicError",
"columnValue works only for singleton tables");
92 return *beginData<T>(column);
114 template <
typename T,
typename C>
120 auto &vec = bigVector<T>();
126 template <
typename T,
typename C>
129 throw cms::Exception(
"LogicError",
"addColumnValue works only for singleton tables");
132 auto &vec = bigVector<T>();
141 template <
typename T>
143 if constexpr (std::is_same<T, uint8_t>())
145 else if constexpr (std::is_same<T, int16_t>())
147 else if constexpr (std::is_same<T, uint16_t>())
149 else if constexpr (std::is_same<T, int32_t>())
151 else if constexpr (std::is_same<T, uint32_t>())
153 else if constexpr (std::is_same<T, bool>())
155 else if constexpr (std::is_same<T, float>())
157 else if constexpr (std::is_same<T, double>())
174 template <
typename T>
176 return bigVector<T>().cbegin() +
columns_[column].firstIndex;
178 template <
typename T>
180 return bigVector<T>().begin() +
columns_[column].firstIndex;
183 template <
typename T>
185 return bigVectorImpl<T>(*this);
187 template <
typename T>
189 return bigVectorImpl<T>(*this);
192 template <
typename T,
class This>
195 if constexpr (std::is_same<T, uint8_t>())
196 return table.uint8s_;
197 else if constexpr (std::is_same<T, int16_t>())
198 return table.int16s_;
199 else if constexpr (std::is_same<T, uint16_t>())
200 return table.uint16s_;
201 else if constexpr (std::is_same<T, int32_t>())
202 return table.int32s_;
203 else if constexpr (std::is_same<T, uint32_t>())
204 return table.uint32s_;
205 else if constexpr (std::is_same<T, bool>())
206 return table.uint8s_;
207 else if constexpr (std::is_same<T, float>())
208 return table.floats_;
209 else if constexpr (std::is_same<T, double>())
210 return table.doubles_;
void addExtension(const FlatTable &extension)
double getAnyValue(const std::string &column) const
auto columnData(unsigned int column)
get a column by index (non-const)
RowView row(unsigned int row) const
const std::string & columnName(unsigned int col) const
void bulk(Span &&data) const
Column(const std::string &aname, const std::string &docString, ColumnType atype, unsigned int anIndex)
auto const & bigVector() const
std::vector< Column > columns_
std::vector< uint8_t > uint8s_
std::vector< int16_t > int16s_
static auto & bigVectorImpl(This &table)
std::vector< uint32_t > uint32s_
T one(const T &val) const
const std::string & name() const
void setDoc(const std::string &doc)
std::vector< float > floats_
double getAnyValue(unsigned int column) const
const FlatTable & table() const
MaybeMantissaReduce(int mantissaBits)
const std::string & doc() const
std::vector< int32_t > int32s_
int columnIndex(const std::string &name) const
unsigned int nRows() const
const auto & columValue(unsigned int column) const
get a column value for singleton (const)
std::vector< uint16_t > uint16s_
auto beginData(unsigned int column)
RowView(const FlatTable &table, unsigned int row)
auto columnData(unsigned int column) const
get a column by index (const)
double getAnyValue(unsigned int row, unsigned int column) const
float one(const float &val) const
void bulk(Span const &data) const
MaybeMantissaReduce(int mantissaBits)
FlatTable(unsigned int size, const std::string &name, bool singleton, bool extension=false)
static ColumnType defaultColumnType()
static float reduceMantissaToNbitsRounding(const float &f)
char data[epos_bytes_allocation]
ColumnType columnType(unsigned int col) const
void addColumn(const std::string &name, const C &values, const std::string &docString, int mantissaBits=-1)
void addColumnValue(const std::string &name, const C &value, const std::string &docString, int mantissaBits=-1)
unsigned int nColumns() const
const std::string & columnDoc(unsigned int col) const
auto beginData(unsigned int column) const
std::vector< double > doubles_
unsigned int size() const