ATLAS Offline Software
ColumnarDef.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef COLUMNAR_CORE_COLUMNAR_DEF_H
6 #define COLUMNAR_CORE_COLUMNAR_DEF_H
7 
8 #include <cstdint>
9 #include <stdexcept>
10 
11 namespace columnar
12 {
13  // This checks that COLUMNAR_DEFAULT_ACCESS_MODE is indeed defined, plus makes it
14  // available for use with `if constexpr`.
15  constexpr unsigned columnarAccessMode = COLUMNAR_DEFAULT_ACCESS_MODE;
16 
18  {
20  static constexpr bool isXAOD = true;
21 
27  static constexpr bool inPlaceReplace = true;
28  };
29 
30 
31 
33  {
35  static constexpr bool isXAOD = false;
36 
42  static constexpr bool inPlaceReplace = false;
43 
44 
66 
68  using LinkIndexType = std::size_t;
69 
71  static constexpr LinkIndexType invalidLinkValue = static_cast<LinkIndexType>(-1);
72 
74  static constexpr unsigned linkKeyBits = 8;
75 
78 
80  static_assert (linkKeyBits <= 8 * sizeof(LinkKeyType), "Link key bits exceed key type size");
81  static_assert (linkKeyBits < 8 * sizeof(LinkIndexType), "Link key bits exceed link type size");
82  static constexpr unsigned linkIndexBits = 8 * sizeof(LinkIndexType) - linkKeyBits;
83  static constexpr LinkIndexType linkIndexMask = (static_cast<LinkIndexType>(1) << linkIndexBits) - 1;
84 
86  static inline LinkKeyType getLinkKey (LinkIndexType link) {
87  return link >> linkIndexBits;
88  }
89 
91  static inline LinkIndexType getLinkIndex (LinkIndexType link) {
92  return link & linkIndexMask;
93  }
94 
97  if (key >= (static_cast<LinkIndexType>(1) << linkKeyBits))
98  throw std::runtime_error ("link key too large to fit in link: " + std::to_string(key));
99  if (index & ~linkIndexMask)
100  throw std::runtime_error ("index too large to fit in link: " + std::to_string(index));
101  return index | (key << linkIndexBits);
102  }
103  };
104 
105 
106 
107 #if COLUMNAR_DEFAULT_ACCESS_MODE == 0
109 #elif COLUMNAR_DEFAULT_ACCESS_MODE == 2
111 #else
112  #error "COLUMNAR_DEFAULT_ACCESS_MODE must be 0 or 2"
113 #endif
114 }
115 
116 #endif
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:558
index
Definition: index.py:1
columnar::ColumnarModeArray::getLinkIndex
static LinkIndexType getLinkIndex(LinkIndexType link)
get the index value from a link value
Definition: ColumnarDef.h:91
columnar::ColumnarModeArray::getLinkKey
static LinkKeyType getLinkKey(LinkIndexType link)
get the key value from a link value
Definition: ColumnarDef.h:86
columnar::ColumnarModeArray::linkIndexMask
static constexpr LinkIndexType linkIndexMask
Definition: ColumnarDef.h:83
MuonR4::to_string
std::string to_string(const SectorProjector proj)
Definition: MsTrackSeeder.cxx:66
columnar::ColumnarModeArray::linkIndexBits
static constexpr unsigned linkIndexBits
various helper definitions
Definition: ColumnarDef.h:82
columnar::columnarAccessMode
constexpr unsigned columnarAccessMode
Definition: ColumnarDef.h:15
columnar::ColumnarModeArray::LinkIndexType
std::size_t LinkIndexType
the type used for columns that represent element links
Definition: ColumnarDef.h:68
columnar::ColumnarModeArray::inPlaceReplace
static constexpr bool inPlaceReplace
Whether for this columnar mode decorators that replace the original column will also refer to the inp...
Definition: ColumnarDef.h:42
columnar::ColumnarModeXAOD::isXAOD
static constexpr bool isXAOD
Whether this is the xAOD mode.
Definition: ColumnarDef.h:20
columnar::ColumnarModeArray::isXAOD
static constexpr bool isXAOD
Whether this is the xAOD mode.
Definition: ColumnarDef.h:35
columnar::ColumnarModeArray::LinkKeyType
std::uint8_t LinkKeyType
the type used for the key column
Definition: ColumnarDef.h:77
columnar::ColumnarModeArray
Definition: ColumnarDef.h:33
columnar::ColumnarModeArray::mergeLinkKeyIndex
static LinkIndexType mergeLinkKeyIndex(LinkIndexType key, LinkIndexType index)
merge a key and index value into a link value
Definition: ColumnarDef.h:96
columnar
Definition: ClusterDef.h:16
columnar::ColumnarModeXAOD
Definition: ColumnarDef.h:18
columnar::ColumnarModeXAOD::inPlaceReplace
static constexpr bool inPlaceReplace
Whether for this columnar mode decorators that replace the original column will also refer to the inp...
Definition: ColumnarDef.h:27
columnar::ColumnarModeArray::invalidLinkValue
static constexpr LinkIndexType invalidLinkValue
the value used for an invalid link (a.k.a. empty/null link)
Definition: ColumnarDef.h:71
columnar::ColumnarModeArray::linkKeyBits
static constexpr unsigned linkKeyBits
the number of bits used for the key inside the link
Definition: ColumnarDef.h:74
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37