14#include <fmt/format.h>
20 const std::map<std::string, std::string, std::less<>> typeMap = {
21 {
"char",
"B" }, {
"unsigned char",
"b" }, {
"short",
"S" }, {
"unsigned short",
"s" },
22 {
"int",
"I" }, {
"unsigned int",
"i" }, {
"float",
"F" }, {
"double",
"D" },
23 {
"long long",
"L" }, {
"unsigned long long",
"l" }, {
"long",
"G" }, {
"unsigned long",
"g" },
27 std::optional<std::string> getLeafListForType(
const std::string_view& typeName ) {
28 auto it = typeMap.find( typeName );
29 return ( it != typeMap.end() ) ? std::optional<std::string>{ it->second } : std::nullopt;
36 const std::string& branchName,
const std::string& location,
const std::string& algName )
38 auto leafListTag = getLeafListForType(
m_className );
42 ( fmt::format(
"{}/{}",
m_className, leafListTag.value() ) ).c_str() );
43 setBranchAddress = []( gsl::not_null<TBranch*> br,
const void** wrappedDataPtr ) {
44 br->SetAddress(
const_cast<void*
>( *wrappedDataPtr ) );
47 }
else if ( TClass::GetClass(
m_className.c_str() ) ) {
50 setBranchAddress = []( gsl::not_null<TBranch*> br,
const void** wrappedDataPtr ) {
51 br->SetAddress( wrappedDataPtr );
55 throw GaudiException( fmt::format(
"Cannot create branch {} for unknown class: {}. Provide a dictionary please.",
77 m_dataBuffer = baseWrapper ? baseWrapper->payload() : pObj.get();
Define general base for Gaudi exception.
constexpr static const auto FAILURE
BranchWrapper(const gsl::not_null< TTree * > tree, const std::string &className, const std::string &branchName, const std::string &location, const std::string &algName)
void(* setBranchAddress)(gsl::not_null< TBranch * >, const void **)
const std::string & getClassName() const
void setDataPtr(void const *dataPtr)
const std::string & getLocation() const
void setBranchData(const gsl::not_null< DataObject * > pObj)
void const * m_dataBuffer