CbmRoot
Loading...
Searching...
No Matches
CbmDefs.cxx
Go to the documentation of this file.
1/* Copyright (C) 2020-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer] */
4
5#include "CbmDefs.h"
6
7#include <algorithm>
8#include <array>
9#include <cctype>
10#include <ostream>
11#include <stdexcept> // for out_of_range
12
13// operator ++ for ECbmModuleId for convenient usage in loops
14// This operator is tuned for ECbmModuleID. It takes into account non
15// continuous values for the enum. Since the detectorID which is stored
16// in the generated output has only 4 bit the maximum number of detectors
17// can be 16 (0-15). To avoid that the enum class has to be changed again
18// the values 11-15 are reserved for future detectors.
19// The ids of the passive modules are only relevant at run time so they can
20// be shifted easily
21// The operator takes care about the non continuous values for the enum
22// When it reaches the last detector it automatically continuous with the
23// first passive module
25{
27 throw std::out_of_range("for ECbmModuleId& operator ++ (ECbmModuleId&)");
28 }
29 else if (e == ECbmModuleId::kNofSystems) { // jump over gap between end of detectors and begin of passives
31 }
32 else {
33 e = ECbmModuleId(static_cast<std::underlying_type<ECbmModuleId>::type>(e) + 1);
34 }
35 return e;
36}
37
38// operator << for convenient output to std::ostream.
39// Converts the enum value to a string which is put in the stream
40std::ostream& operator<<(std::ostream& strm, const ECbmDataType& dataType)
41{
42 strm << std::to_string(ToIntegralType(dataType));
43 return strm;
44}
45
46
47//namespace cbm::algo::ca
48//{
49// ECbmModuleId ToCbmModuleId(EDetectorID detID)
50// {
51// switch (detID) {
52// case EDetectorID::kMvd: return ECbmModuleId::kMvd;
53// case EDetectorID::kSts: return ECbmModuleId::kSts;
54// case EDetectorID::kMuch: return ECbmModuleId::kMuch;
55// case EDetectorID::kTrd: return ECbmModuleId::kTrd;
56// case EDetectorID::kTof: return ECbmModuleId::kTof;
57// default: return ECbmModuleId::kNotExist;
58// }
59// }
60//
61// EDetectorID ToCaDetectorID(ECbmModuleId modId)
62// {
63// switch (modId) {
64// case ECbmModuleId::kMvd: return EDetectorID::kMvd;
65// case ECbmModuleId::kSts: return EDetectorID::kSts;
66// case ECbmModuleId::kMuch: return EDetectorID::kMuch;
67// case ECbmModuleId::kTrd: return EDetectorID::kTrd;
68// case ECbmModuleId::kTof: return EDetectorID::kTof;
69// default: return EDetectorID::END;
70// }
71// }
72//
73//} // namespace cbm::algo::ca
std::ostream & operator<<(std::ostream &strm, const ECbmDataType &dataType)
operator << for convenient output to std::ostream.
Definition CbmDefs.cxx:40
ECbmModuleId & operator++(ECbmModuleId &e)
operator ++ for ECbmModuleId for convenient usage in loops
Definition CbmDefs.cxx:24
XPU_D constexpr auto ToIntegralType(T enumerator) -> typename std::underlying_type< T >::type
Converts an element of enum class to its underlying integral type.
Definition CbmDefs.h:33
ECbmDataType
Enumerator for CBM data types.
Definition CbmDefs.h:122
ECbmModuleId
Enumerator for module Identifiers.
Definition CbmDefs.h:45
@ kMagnet
Magnet.
Definition CbmDefs.h:61
@ kLastModule
For loops over all modules.
Definition CbmDefs.h:67
@ kNofSystems
For loops over active systems.
Definition CbmDefs.h:60