Project
Loading...
Searching...
No Matches
DetectorConfiguration.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_DETECTORCONFIGURATION_H_
13#define ALICEO2_ITSMFT_TRACKING_DETECTORCONFIGURATION_H_
14
15#include <algorithm>
16#include <cstdint>
17#include <utility>
18#include <vector>
19
20#include <gsl/span>
21
25
27{
28
36
37// TimeFrame-owned detector geometry and prepared settings, shared by every
38// iteration. LayerId is the dense descriptor position. SurfaceCatalogView
39// borrows only the geometry; iteration topology and event state live elsewhere.
41{
42 public:
44 DetectorConfiguration(gsl::span<const SurfaceDescriptor> layers, std::vector<uint16_t> componentOffsets = {0}, LayerMask holeLayers = {})
45 : mLayers{layers.begin(), layers.end()}, mComponentOffsets{std::move(componentOffsets)}, mHoleLayers{holeLayers}
46 {
47 validate();
48 }
49
50 bool valid() const noexcept { return mError == DetectorConfigurationError::None; }
51 DetectorConfigurationError getError() const noexcept { return mError; }
52 bool empty() const noexcept { return mLayers.empty(); }
53 std::size_t size() const noexcept { return mLayers.size(); }
54 gsl::span<const SurfaceDescriptor> getLayers() const noexcept { return mLayers; }
55 const SurfaceDescriptor& operator[](LayerId id) const { return mLayers.at(id.value()); }
56 gsl::span<const uint16_t> getComponentOffsets() const noexcept { return mComponentOffsets; }
57 LayerMask getHoleLayers() const noexcept { return mHoleLayers; }
58 SurfaceCatalogView getSurfaceCatalog() const noexcept { return {mLayers.data(), static_cast<uint32_t>(mLayers.size())}; }
59
60 // Cylinders have one radius; disks use the midpoint of their radial chart.
62 {
63 const auto& surface = (*this)[id];
64 return surface.kind == SurfaceKind::Cylinder ? surface.referenceCoordinate
65 : 0.5f * (surface.chartRange.min + surface.chartRange.max);
66 }
67
68 bool sameComponent(uint16_t first, uint16_t second) const noexcept
69 {
70 if (first >= mLayers.size() || second >= mLayers.size()) {
71 return false;
72 }
73 const auto component = [this](uint16_t position) {
74 return std::upper_bound(mComponentOffsets.begin(), mComponentOffsets.end(), position) - mComponentOffsets.begin();
75 };
76 return component(first) == component(second);
77 }
78
79 // Prepared once by Tracker before the configuration is installed in a frame.
81 std::vector<float> positionResolutions;
82 std::vector<uint32_t> addTimeError;
83 std::vector<float> layerResolution;
84 std::vector<float> systError2Row;
85 std::vector<float> systError2Col;
86
87 private:
88 void validate() noexcept
89 {
90 if (mLayers.empty()) {
92 return;
93 }
94 if (mLayers.size() > MaxLayoutSurfaces) {
96 return;
97 }
98 if (mComponentOffsets.empty() || mComponentOffsets.front() != 0 || mComponentOffsets.back() >= mLayers.size() ||
99 !std::is_sorted(mComponentOffsets.begin(), mComponentOffsets.end()) ||
100 std::adjacent_find(mComponentOffsets.begin(), mComponentOffsets.end()) != mComponentOffsets.end()) {
102 return;
103 }
104 if (!mHoleLayers.isSubsetOf(LayerMask::span(0, static_cast<int>(mLayers.size()) - 1))) {
106 return;
107 }
109 }
110
111 std::vector<SurfaceDescriptor> mLayers;
112 std::vector<uint16_t> mComponentOffsets;
113 LayerMask mHoleLayers{};
115};
116
117} // namespace o2::itsmft::tracking
118
119#endif
const SurfaceDescriptor & operator[](LayerId id) const
DetectorConfigurationError getError() const noexcept
gsl::span< const uint16_t > getComponentOffsets() const noexcept
gsl::span< const SurfaceDescriptor > getLayers() const noexcept
SurfaceCatalogView getSurfaceCatalog() const noexcept
DetectorConfiguration(gsl::span< const SurfaceDescriptor > layers, std::vector< uint16_t > componentOffsets={0}, LayerMask holeLayers={})
bool sameComponent(uint16_t first, uint16_t second) const noexcept
GLuint GLuint end
Definition glcorearb.h:469
GLint first
Definition glcorearb.h:399
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLuint id
Definition glcorearb.h:650
uint32_t trackClusterIndicesSize noexcept
constexpr uint32_t MaxLayoutSurfaces
Definition IdTypes.h:70