Skip to content

Commit 5a5ce89

Browse files
committed
DetID: add nameToID method
1 parent a72d560 commit 5a5ce89

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

  • DataFormats/Detectors/Common/include/DetectorsCommonDataFormats

DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ class DetID
131131
static mask_t getMask(const std::string_view detList);
132132

133133
static std::string getNames(mask_t mask, char delimiter = ',');
134+
135+
inline static constexpr int nameToID(char const* name, int id)
136+
{
137+
return id > Last ? -1 : sameStr(name, sDetNames[id]) ? id
138+
: nameToID(name, id + 1);
139+
}
140+
134141
#endif // GPUCA_GPUCODE_DEVICE
135142

136143
private:
@@ -143,11 +150,6 @@ class DetID
143150
ID mID = First; ///< detector ID
144151

145152
#ifndef GPUCA_GPUCODE_DEVICE
146-
inline static constexpr int nameToID(char const* name, int id)
147-
{
148-
return id > Last ? id : sameStr(name, sDetNames[id]) ? id : nameToID(name, id + 1);
149-
}
150-
151153
// detector names, will be defined in DataSources
152154
static constexpr const char* sDetNames[nDetectors + 1] = ///< defined detector names
153155
#ifdef ENABLE_UPGRADES

0 commit comments

Comments
 (0)