Skip to content
Snippets Groups Projects
Commit 528948c0 authored by Gerhard Raven's avatar Gerhard Raven
Browse files

support putting any enum into FunTuple

parent cfc82398
No related branches found
No related tags found
1 merge request!973support more enum types in FunTuple
Pipeline #5392332 passed
......@@ -14,8 +14,12 @@
// Gaudi
#include "GaudiAlg/GaudiTupleAlg.h"
// Event
// Event -- to support various 'enum' classes
#include "Event/MCVertex.h"
#include "Event/ODIN.h"
#include "Event/TrackEnums.h"
#include "MCInterfaces/IMCReconstructed.h"
#include "MCInterfaces/IMCReconstructible.h"
// custom classes
#include "InvalidValue.h"
......@@ -25,6 +29,7 @@
// Custom error code
#include "ErrorCode.h"
#include <type_traits>
namespace LHCb::FTuple {
// max buffer size for storing array
......@@ -65,8 +70,13 @@ namespace LHCb::FTuple {
// default fill: just forward to column
template <typename T>
inline StatusCode fill_( const Tuples::Tuple& ntuple, const std::string& colname, const T& val ) {
return ntuple->column( colname, val );
StatusCode fill_( const Tuples::Tuple& ntuple, const std::string& colname, const T& val ) {
if constexpr ( std::is_enum_v<T> ) {
// FIXME/TODO: this should really be done in NTuple::column instead...
return fill_( ntuple, colname, static_cast<std::underlying_type_t<T>>( val ) );
} else {
return ntuple->column( colname, val );
}
}
// fill for scalar SIMD types (float_v)
......@@ -81,13 +91,6 @@ namespace LHCb::FTuple {
return ntuple->column( colname, val.cast() );
}
// fill for BXTypes (enum class of uint32_t see:
// https://gitlab.cern.ch/lhcb/LHCb/-/blob/master/Event/DAQEvent/include/Event/ODIN.h#L149)
using BXTypes = LHCb::ODIN::BXTypes;
inline StatusCode fill_( const Tuples::Tuple& ntuple, const std::string& colname, const BXTypes& val ) {
return ntuple->column( colname, static_cast<std::uint8_t>( val ) );
}
// fill for uint64_t (unsigned long): Special since we cast it to unsigned long long
// as done in TupleObj.h in Gaudi. This is to side step a platform specific warning flagged by TupleObj.cpp in
// Gaudi. (see issue): https://gitlab.cern.ch/lhcb/DaVinci/-/issues/48 (Particularly see suggestion by Marco about
......@@ -222,15 +225,17 @@ namespace LHCb::FTuple {
// list the supported types
inline const auto map_valtype_callcolfun =
make_map<bool, short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int,
unsigned long long int, SIMDWrapper::scalar::int_v, float, double, std::uint64_t, BXTypes,
SIMDWrapper::scalar::float_v, Gaudi::LorentzVector, Gaudi::XYZVector, Gaudi::XYZPoint,
Gaudi::SymMatrix3x3, Gaudi::SymMatrix4x4, Gaudi::SymMatrix5x5, std::vector<double>, std::vector<float>,
std::vector<int>, std::vector<bool>, std::vector<unsigned int>, std::vector<unsigned long int>,
std::vector<long long int>, std::vector<long int>, std::vector<SIMDWrapper::scalar::float_v>,
LHCb::LinAlg::Vec<double, 3>, LHCb::LinAlg::Vec<double, 4>, LHCb::LinAlg::Vec<float, 3>,
LHCb::LinAlg::Vec<float, 4>, LHCb::LinAlg::Vec<SIMDWrapper::scalar::float_v, 3>,
LHCb::LinAlg::Vec<SIMDWrapper::scalar::float_v, 4>, LHCb::LinAlg::Vec3<double>,
LHCb::LinAlg::Vec3<float>, LHCb::LinAlg::Vec3<SIMDWrapper::scalar::float_v>,
unsigned long long int, SIMDWrapper::scalar::int_v, float, double, std::uint64_t, LHCb::ODIN::BXTypes,
LHCb::MCVertex::MCVertexType, IMCReconstructible::RecCategory, IMCReconstructed::RecCategory,
LHCb::Event::Enum::Track::History, LHCb::Event::Enum::Track::FitHistory, LHCb::Event::Enum::Track::Type,
LHCb::Event::Enum::Track::FitStatus, LHCb::Event::Enum::Track::Flag, SIMDWrapper::scalar::float_v,
Gaudi::LorentzVector, Gaudi::XYZVector, Gaudi::XYZPoint, Gaudi::SymMatrix3x3, Gaudi::SymMatrix4x4,
Gaudi::SymMatrix5x5, std::vector<double>, std::vector<float>, std::vector<int>, std::vector<bool>,
std::vector<unsigned int>, std::vector<unsigned long int>, std::vector<long long int>,
std::vector<long int>, std::vector<SIMDWrapper::scalar::float_v>, LHCb::LinAlg::Vec<double, 3>,
LHCb::LinAlg::Vec<double, 4>, LHCb::LinAlg::Vec<float, 3>, LHCb::LinAlg::Vec<float, 4>,
LHCb::LinAlg::Vec<SIMDWrapper::scalar::float_v, 3>, LHCb::LinAlg::Vec<SIMDWrapper::scalar::float_v, 4>,
LHCb::LinAlg::Vec3<double>, LHCb::LinAlg::Vec3<float>, LHCb::LinAlg::Vec3<SIMDWrapper::scalar::float_v>,
std::map<std::string, std::any>>();
// fill function to loop through supported types invoking function that calls fill function
......@@ -239,4 +244,4 @@ namespace LHCb::FTuple {
if ( f == map_valtype_callcolfun.end() ) { return StatusCode{EC::ErrorCode::TypeNotSupported}; }
return std::invoke( f->second, ntuple, colname, val );
}
} // namespace LHCb::FTuple
\ No newline at end of file
} // namespace LHCb::FTuple
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment