Project
Loading...
Searching...
No Matches
SurfaceIndexMap.h
Go to the documentation of this file.
1// Copyright 2019-2026 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
17
18#ifndef ALICEO2_ACTS_SURFACEINDEXMAP_H
19#define ALICEO2_ACTS_SURFACEINDEXMAP_H
20
21#include <cstddef>
22#include <functional>
23#include <string>
24#include <unordered_map>
25#include <vector>
26
27#include "Acts/Geometry/GeometryIdentifier.hpp"
28
29namespace Acts
30{
31class Surface;
32class TrackingGeometry;
33class GeometryContext;
34} // namespace Acts
35
36namespace o2::detectors
37{
38class DetMatrixCache;
39}
40
41namespace o2::acts
42{
43
57{
58 public:
59 static constexpr int InvalidSensorID = -1;
60
62 void add(int sensorID, const Acts::Surface& surface);
63
65 const Acts::Surface* getSurface(int sensorID) const;
67 Acts::GeometryIdentifier getGeometryId(int sensorID) const;
68
71 const std::vector<int>& getSensorIDs(Acts::GeometryIdentifier geoId) const;
72
73 bool empty() const { return mBySensor.empty(); }
75 std::size_t size() const { return mBySensor.size(); }
77 std::size_t getNSurfaces() const { return mByGeoId.size(); }
78 void clear();
79
80 private:
81 struct Entry {
82 const Acts::Surface* surface = nullptr;
83 Acts::GeometryIdentifier geoId{};
84 };
85
86 std::unordered_map<int, Entry> mBySensor;
87 std::unordered_map<Acts::GeometryIdentifier, std::vector<int>> mByGeoId;
88};
89
91using SensorPathProvider = std::function<std::string(int sensorID)>;
92
122SurfaceIndexMap makeSurfaceIndex(const Acts::TrackingGeometry& geometry,
123 const Acts::GeometryContext& gctx,
125 double toleranceCm = 1e-3,
126 SensorPathProvider pathProvider = {});
127
128} // namespace o2::acts
129
130#endif // ALICEO2_ACTS_SURFACEINDEXMAP_H
const Acts::Surface * surface
std::size_t size() const
Number of mapped sensors.
const Acts::Surface * getSurface(int sensorID) const
const std::vector< int > & getSensorIDs(Acts::GeometryIdentifier geoId) const
std::size_t getNSurfaces() const
Number of distinct surfaces the sensors map onto.
void add(int sensorID, const Acts::Surface &surface)
static constexpr int InvalidSensorID
Acts::GeometryIdentifier getGeometryId(int sensorID) const
SurfaceIndexMap makeSurfaceIndex(const Acts::TrackingGeometry &geometry, const Acts::GeometryContext &gctx, const o2::detectors::DetMatrixCache &cache, double toleranceCm=1e-3, SensorPathProvider pathProvider={})
std::function< std::string(int sensorID)> SensorPathProvider
Full TGeo node path of one sensor, e.g. o2::trk::GeometryTGeo::getMatrixPath().