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, int8_t>())
145 else if constexpr (std::is_same<T, uint8_t>())
147 else if constexpr (std::is_same<T, int16_t>())
149 else if constexpr (std::is_same<T, uint16_t>())
151 else if constexpr (std::is_same<T, int32_t>())
153 else if constexpr (std::is_same<T, uint32_t>())
155 else if constexpr (std::is_same<T, bool>())
157 else if constexpr (std::is_same<T, float>())
159 else if constexpr (std::is_same<T, double>())
176 template <
typename T>
178 return bigVector<T>().cbegin() +
columns_[column].firstIndex;
180 template <
typename T>
182 return bigVector<T>().begin() +
columns_[column].firstIndex;
185 template <
typename T>
187 return bigVectorImpl<T>(*this);
189 template <
typename T>
191 return bigVectorImpl<T>(*this);
194 template <
typename T,
class This>
197 if constexpr (std::is_same<T, int8_t>())
199 else if constexpr (std::is_same<T, uint8_t>())
200 return table.uint8s_;
201 else if constexpr (std::is_same<T, int16_t>())
202 return table.int16s_;
203 else if constexpr (std::is_same<T, uint16_t>())
204 return table.uint16s_;
205 else if constexpr (std::is_same<T, int32_t>())
206 return table.int32s_;
207 else if constexpr (std::is_same<T, uint32_t>())
208 return table.uint32s_;
209 else if constexpr (std::is_same<T, bool>())
210 return table.uint8s_;
211 else if constexpr (std::is_same<T, float>())
212 return table.floats_;
213 else if constexpr (std::is_same<T, double>())
214 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
std::vector< int8_t > int8s_
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