10#include <tracking/trackFindingCDC/varsets/NamedFloatTuple.h>
20 namespace TrackFindingCDC {
30 bool strequal(
char const* s1,
char const* s2)
32 return (not * s1 and not * s2) or (*s1 and * s2 and * s1 == *s2 and strequal(s1 + 1, s2 + 1));
45 template <
size_t nVars>
46 constexpr int index(
const char*
const(&names)[nVars],
const char* name,
size_t iName = 0)
48 return ((nVars == iName) ?
50 strequal(names[iName], name) ? iName : index(names, name, iName + 1));
63 template<
size_t nVars>
65 int index(
const char* (
getName(
int)),
66 const char*
const name,
67 const size_t iName = 0)
69 return ((nVars == iName) ?
71 strequal(
getName(iName), name) ? iName : index<nVars>(getName, name, iName + 1));
82 template <
class T,
size_t N>
83 constexpr size_t size(T (&array)[N] __attribute__((unused)))
97 template<
class ANames>
102 static const size_t nVars = ANames::nVars;
115 constexpr static int named(
const char* name)
117 return index<nVars>(ANames::getName, name);
124 return ANames::nVars;
143 assert(iValue < (
int)
nVars);
145 return ANames::getName(iValue);
153 static_assert(
nVars != I,
"Requested name not found in names.");
154 assert(I < (
int)
nVars);
160 void set(
int iValue, Float_t value)
final
162 assert(iValue < (
int)
nVars);
168 void set(
const char* name, Float_t value)
177 static_assert(
nVars != I,
"Requested name not found in names.");
178 assert(I < (
int)
nVars);
184 Float_t
get(
int iValue)
const final
186 assert(iValue < (
int)
nVars);
192 Float_t
get(
const char* name)
const
201 static_assert(
nVars != I,
"Requested name not found in names.");
202 assert(I < (
int)
nVars);
210 assert(iValue < (
int)
nVars);
Generic class that contains a fixed number of named float values.
std::string getName(int iValue) const final
Getter for the ith name.
Float_t & operator[](int iValue) final
Reference getter for the ith value.
static constexpr int named(const char *name)
Static getter for the index from the name.
Float_t & var()
Reference getter for the ith value. Static index version.
Float_t & operator[](const char *name)
Reference getter for the value with the given name.
Float_t get(const char *name) const
Getter for the value with the given name.
Float_t m_values[nVars]
Memory for nVars floating point values.
static const size_t nVars
Number of floating point values represented by this class.
Float_t get() const
Getter for the ith value. Static index version.
Float_t get(int iValue) const final
Getter for the ith value.
void set(Float_t value)
Setter for the ith values. Static index version.
void set(int iValue, Float_t value) final
Setter for the ith value.
size_t size() const final
Getter for number of floating point values represented by this class.
int getNameIndex(const char *name) const final
Getter for the index from a name.
void set(const char *name, Float_t value)
Setter for the value with the given name.
An abstract tuple of float value where each value has an associated name.
TString getName(const TObject *obj)
human-readable name (e.g.
Abstract base class for different kinds of events.