ATLAS Offline Software
Loading...
Searching...
No Matches
RootAuxDynDefs.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef ROOTAUXDYN_DEFS_H
5#define ROOTAUXDYN_DEFS_H
6
7#include <format>
8
9namespace RootAuxDynIO
10{
12 constexpr char AUX_POSTFIX[] = "Aux.";
13 constexpr size_t AUX_POSTFIX_LEN = sizeof(AUX_POSTFIX)-1;
14 constexpr char AUXDYN_POSTFIX[] = "Dyn.";
15 constexpr size_t AUXDYN_POSTFIX_LEN = sizeof(AUXDYN_POSTFIX)-1;
16
21 inline bool endsWithAuxPostfix(std::string_view str) {
22 return str.ends_with(AUX_POSTFIX);
23 }
24
29 bool removeAuxPostfix(std::string& str);
30
36 std::string auxBranchName(const std::string& attr_name, const std::string& baseBranchName);
37
43 std::string auxFieldName(const std::string& attr_name, const std::string& baseName);
44
45} // namespace
46
47
48inline bool
50{
51 if( endsWithAuxPostfix(str) ) {
52 str.resize( str.size() - AUX_POSTFIX_LEN );
53 return true;
54 }
55 return false;
56}
57
58
59inline std::string
60RootAuxDynIO::auxBranchName(const std::string& attr_name, const std::string& baseBranchName)
61{
62 std::string branch_name = baseBranchName;
63 if( !branch_name.empty() and branch_name.back() == '.' ) branch_name.pop_back();
64 branch_name += RootAuxDynIO::AUXDYN_POSTFIX + attr_name;
65 return branch_name;
66}
67
68inline std::string
69RootAuxDynIO::auxFieldName(const std::string& attr_name, const std::string& baseName)
70{
71 // RNTuple field names cannot contain dot characters '.'
72 // Therefore, for now, we're using a colon instead ':'
73 // This can be changed in the future
74 std::string field_name = baseName;
75 if (field_name.ends_with(':')) {
76 field_name.pop_back();
77 }
78 field_name = std::format("{}Dyn:{}", field_name, attr_name);
79 return field_name;
80}
81
82#endif
Specialization of RootAuxDynStore for reading Aux Dynamic attributes from RNTuple.
bool endsWithAuxPostfix(std::string_view str)
Check if a string ends with AUX_POSTFIX.
std::string auxFieldName(const std::string &attr_name, const std::string &baseName)
Construct field name for a given dynamic attribute.
constexpr size_t AUX_POSTFIX_LEN
constexpr char AUX_POSTFIX[]
Common post-fix for the names of auxiliary containers in StoreGate.
constexpr size_t AUXDYN_POSTFIX_LEN
bool removeAuxPostfix(std::string &str)
if a string ends with AUX_POSTFIX then remove it
std::string auxBranchName(const std::string &attr_name, const std::string &baseBranchName)
Construct branch name for a given dynamic attribute.
constexpr char AUXDYN_POSTFIX[]