Project
Loading...
Searching...
No Matches
IndexTableConfigurationSet.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef ALICEO2_ITSMFT_TRACKING_INDEXTABLECONFIGURATIONSET_H_
13#define ALICEO2_ITSMFT_TRACKING_INDEXTABLECONFIGURATIONSET_H_
14
15#include <array>
16#include <cassert>
19
21{
22// Owning cache: one all-layer lookup configuration for each coordinate kind,
23// plus a compact surface-to-kind mapping. Copies never borrow another owner.
25{
26 public:
27 bool reset(SurfaceCatalogView catalog) noexcept
28 {
29 *this = {};
30 if (catalog.nSurfaces > MaxLayoutSurfaces || (catalog.nSurfaces && !catalog.surfaces)) {
31 return false;
32 }
33 for (uint32_t layer = 0; layer < catalog.nSurfaces; ++layer) {
34 const auto kind = catalog.surfaces[layer].kind;
36 *this = {};
37 return false;
38 }
39 const auto slot = kind == SurfaceKind::Cylinder ? 0 : 1;
40 mKindByLayer[layer] = slot;
41 mPresent[slot] = true;
42 }
43 mLayers = catalog.nSurfaces;
44 return true;
45 }
46 void clear() noexcept { *this = {}; }
47 size_t size() const noexcept { return mLayers; }
48 size_t configurationCount() const noexcept { return size_t(mPresent[0]) + size_t(mPresent[1]); }
49 bool hasKind(SurfaceKind kind) const noexcept { return (kind == SurfaceKind::Cylinder || kind == SurfaceKind::Disk) && mPresent[kind == SurfaceKind::Cylinder ? 0 : 1]; }
51 {
52 assert(hasKind(kind));
53 return mByKind[kind == SurfaceKind::Cylinder ? 0 : 1];
54 }
55 const IndexTableUtilsCore& operator[](size_t layer) const noexcept
56 {
57 assert(layer < mLayers);
58 return mByKind[mKindByLayer[layer]];
59 }
60
61 private:
62 std::array<IndexTableUtilsCore, 2> mByKind;
63 std::array<uint8_t, MaxLayoutSurfaces> mKindByLayer{};
64 std::array<bool, 2> mPresent{};
65 uint32_t mLayers = 0;
66};
67} // namespace o2::itsmft::tracking
68#endif
Shared index-table utilities for periodic-phi surface charts.
const IndexTableUtilsCore & operator[](size_t layer) const noexcept
IndexTableUtilsCore & forKind(SurfaceKind kind) noexcept
bool reset(SurfaceCatalogView catalog) noexcept
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
uint32_t trackClusterIndicesSize noexcept
constexpr uint32_t MaxLayoutSurfaces
Definition IdTypes.h:70