File indexing completed on 2025-12-11 09:39:49
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/EventData/SourceLink.hpp"
0012 #include "Acts/EventData/SpacePointColumnProxy2.hpp"
0013 #include "Acts/EventData/Types.hpp"
0014 #include "Acts/EventData/detail/SpacePointContainer2Column.hpp"
0015 #include "Acts/Utilities/EnumBitwiseOperators.hpp"
0016 #include "Acts/Utilities/Zip.hpp"
0017 #include "Acts/Utilities/detail/ContainerIterator.hpp"
0018 #include "Acts/Utilities/detail/ContainerRange.hpp"
0019 #include "Acts/Utilities/detail/ContainerSubset.hpp"
0020
0021 #include <cassert>
0022 #include <limits>
0023 #include <memory>
0024 #include <optional>
0025 #include <ranges>
0026 #include <span>
0027 #include <stdexcept>
0028 #include <string>
0029 #include <type_traits>
0030 #include <unordered_map>
0031 #include <vector>
0032
0033 namespace Acts {
0034
0035 static constexpr float NoTime = std::numeric_limits<float>::quiet_NaN();
0036
0037 class SpacePointContainer2;
0038 template <bool read_only>
0039 class SpacePointProxy2;
0040 using MutableSpacePointProxy2 = SpacePointProxy2<false>;
0041 using ConstSpacePointProxy2 = SpacePointProxy2<true>;
0042
0043 enum class SpacePointColumns : std::uint32_t {
0044 None = 0,
0045
0046 SourceLinks = 1 << 0,
0047 X = 1 << 1,
0048 Y = 1 << 2,
0049 Z = 1 << 3,
0050 R = 1 << 4,
0051 Phi = 1 << 5,
0052 Time = 1 << 6,
0053 VarianceZ = 1 << 7,
0054 VarianceR = 1 << 8,
0055 TopStripVector = 1 << 9,
0056 BottomStripVector = 1 << 10,
0057 StripCenterDistance = 1 << 11,
0058 TopStripCenter = 1 << 12,
0059 CopyFromIndex = 1 << 13,
0060
0061
0062 XY = 1 << 14,
0063 ZR = 1 << 15,
0064 XYZ = 1 << 16,
0065 XYZR = 1 << 17,
0066 VarianceZR = 1 << 18,
0067
0068
0069 Strip =
0070 TopStripVector | BottomStripVector | StripCenterDistance | TopStripCenter,
0071 };
0072
0073 ACTS_DEFINE_ENUM_BITWISE_OPERATORS(SpacePointColumns);
0074
0075
0076
0077
0078
0079 class SpacePointContainer2 {
0080 public:
0081
0082 using Index = SpacePointIndex2;
0083
0084 using IndexRange = SpacePointIndexRange2;
0085
0086 using IndexSubset = SpacePointIndexSubset2;
0087
0088 using MutableProxy = MutableSpacePointProxy2;
0089
0090 using ConstProxy = ConstSpacePointProxy2;
0091
0092
0093
0094 explicit SpacePointContainer2(
0095 SpacePointColumns columns = SpacePointColumns::None) noexcept;
0096
0097
0098
0099 SpacePointContainer2(const SpacePointContainer2 &other) noexcept;
0100
0101
0102
0103 SpacePointContainer2(SpacePointContainer2 &&other) noexcept;
0104
0105
0106 ~SpacePointContainer2() noexcept = default;
0107
0108
0109
0110
0111 SpacePointContainer2 &operator=(const SpacePointContainer2 &other) noexcept;
0112
0113
0114
0115
0116 SpacePointContainer2 &operator=(SpacePointContainer2 &&other) noexcept;
0117
0118
0119
0120 std::uint32_t size() const noexcept { return m_size; }
0121
0122
0123 [[nodiscard]] bool empty() const noexcept { return size() == 0; }
0124
0125
0126
0127
0128
0129 void reserve(std::uint32_t size, float averageSourceLinks = 1) noexcept;
0130
0131
0132 void clear() noexcept;
0133
0134
0135
0136 MutableProxy createSpacePoint() noexcept;
0137
0138
0139
0140
0141 void createColumns(SpacePointColumns columns) noexcept;
0142
0143
0144
0145
0146 void dropColumns(SpacePointColumns columns) noexcept;
0147
0148
0149
0150
0151
0152 bool hasColumns(SpacePointColumns columns) const noexcept {
0153 return (m_knownColumns & columns) == columns;
0154 }
0155
0156
0157
0158
0159
0160
0161
0162 template <typename T>
0163 MutableSpacePointColumnProxy<T> createColumn(const std::string &name) {
0164 return createColumnImpl<ColumnHolder<T>>(name);
0165 }
0166
0167
0168
0169
0170
0171
0172 void dropColumn(const std::string &name);
0173
0174
0175
0176
0177 bool hasColumn(const std::string &name) const noexcept {
0178 return m_namedColumns.contains(name);
0179 }
0180
0181
0182
0183
0184
0185
0186 template <typename T>
0187 ConstSpacePointColumnProxy<T> column(const std::string &name) const {
0188 return columnImpl<ColumnHolder<T>>(name);
0189 }
0190
0191
0192
0193 MutableSpacePointColumnProxy<float> xColumn() noexcept {
0194 assert(m_xColumn.has_value() && "Column 'x' does not exist");
0195 return m_xColumn->proxy(*this);
0196 }
0197
0198
0199 MutableSpacePointColumnProxy<float> yColumn() noexcept {
0200 assert(m_yColumn.has_value() && "Column 'y' does not exist");
0201 return m_yColumn->proxy(*this);
0202 }
0203
0204
0205 MutableSpacePointColumnProxy<float> zColumn() noexcept {
0206 assert(m_zColumn.has_value() && "Column 'z' does not exist");
0207 return m_zColumn->proxy(*this);
0208 }
0209
0210
0211 MutableSpacePointColumnProxy<float> rColumn() noexcept {
0212 assert(m_rColumn.has_value() && "Column 'r' does not exist");
0213 return m_rColumn->proxy(*this);
0214 }
0215
0216
0217 MutableSpacePointColumnProxy<float> phiColumn() noexcept {
0218 assert(m_phiColumn.has_value() && "Column 'phi' does not exist");
0219 return m_phiColumn->proxy(*this);
0220 }
0221
0222
0223 MutableSpacePointColumnProxy<float> timeColumn() noexcept {
0224 assert(m_timeColumn.has_value() && "Column 'time' does not exist");
0225 return m_timeColumn->proxy(*this);
0226 }
0227
0228
0229 MutableSpacePointColumnProxy<float> varianceZColumn() noexcept {
0230 assert(m_varianceZColumn.has_value() &&
0231 "Column 'varianceZ' does not exist");
0232 return m_varianceZColumn->proxy(*this);
0233 }
0234
0235
0236 MutableSpacePointColumnProxy<float> varianceRColumn() noexcept {
0237 assert(m_varianceRColumn.has_value() &&
0238 "Column 'varianceR' does not exist");
0239 return m_varianceRColumn->proxy(*this);
0240 }
0241
0242
0243 MutableSpacePointColumnProxy<std::array<float, 3>>
0244 topStripVectorColumn() noexcept {
0245 assert(m_topStripVectorColumn.has_value() &&
0246 "Column 'topStripVector' does not exist");
0247 return m_topStripVectorColumn->proxy(*this);
0248 }
0249
0250
0251 MutableSpacePointColumnProxy<std::array<float, 3>>
0252 bottomStripVectorColumn() noexcept {
0253 assert(m_bottomStripVectorColumn.has_value() &&
0254 "Column 'bottomStripVector' does not exist");
0255 return m_bottomStripVectorColumn->proxy(*this);
0256 }
0257
0258
0259 MutableSpacePointColumnProxy<std::array<float, 3>>
0260 stripCenterDistanceColumn() noexcept {
0261 assert(m_stripCenterDistanceColumn.has_value() &&
0262 "Column 'stripCenterDistance' does not exist");
0263 return m_stripCenterDistanceColumn->proxy(*this);
0264 }
0265
0266
0267 MutableSpacePointColumnProxy<std::array<float, 3>>
0268 topStripCenterColumn() noexcept {
0269 assert(m_topStripCenterColumn.has_value() &&
0270 "Column 'topStripCenter' does not exist");
0271 return m_topStripCenterColumn->proxy(*this);
0272 }
0273
0274
0275 MutableSpacePointColumnProxy<SpacePointIndex2>
0276 copyFromIndexColumn() noexcept {
0277 assert(m_copyFromIndexColumn.has_value() &&
0278 "Column 'copyFromIndex' does not exist");
0279 return m_copyFromIndexColumn->proxy(*this);
0280 }
0281
0282
0283 MutableSpacePointColumnProxy<std::array<float, 2>> xyColumn() noexcept {
0284 assert(m_xyColumn.has_value() && "Column 'xy' does not exist");
0285 return m_xyColumn->proxy(*this);
0286 }
0287
0288
0289 MutableSpacePointColumnProxy<std::array<float, 2>> zrColumn() noexcept {
0290 assert(m_zrColumn.has_value() && "Column 'zr' does not exist");
0291 return m_zrColumn->proxy(*this);
0292 }
0293
0294
0295 MutableSpacePointColumnProxy<std::array<float, 3>> xyzColumn() noexcept {
0296 assert(m_xyzColumn.has_value() && "Column 'xyz' does not exist");
0297 return m_xyzColumn->proxy(*this);
0298 }
0299
0300
0301 MutableSpacePointColumnProxy<std::array<float, 4>> xyzrColumn() noexcept {
0302 assert(m_xyzrColumn.has_value() && "Column 'xyzr' does not exist");
0303 return m_xyzrColumn->proxy(*this);
0304 }
0305
0306
0307 MutableSpacePointColumnProxy<std::array<float, 2>>
0308 varianceZRColumn() noexcept {
0309 assert(m_varianceZRColumn.has_value() &&
0310 "Column 'varianceZR' does not exist");
0311 return m_varianceZRColumn->proxy(*this);
0312 }
0313
0314
0315
0316 ConstSpacePointColumnProxy<float> xColumn() const noexcept {
0317 assert(m_xColumn.has_value() && "Column 'x' does not exist");
0318 return m_xColumn->proxy(*this);
0319 }
0320
0321
0322 ConstSpacePointColumnProxy<float> yColumn() const noexcept {
0323 assert(m_yColumn.has_value() && "Column 'y' does not exist");
0324 return m_yColumn->proxy(*this);
0325 }
0326
0327
0328 ConstSpacePointColumnProxy<float> zColumn() const noexcept {
0329 assert(m_zColumn.has_value() && "Column 'z' does not exist");
0330 return m_zColumn->proxy(*this);
0331 }
0332
0333
0334 ConstSpacePointColumnProxy<float> rColumn() const noexcept {
0335 assert(m_rColumn.has_value() && "Column 'r' does not exist");
0336 return m_rColumn->proxy(*this);
0337 }
0338
0339
0340 ConstSpacePointColumnProxy<float> phiColumn() const noexcept {
0341 assert(m_phiColumn.has_value() && "Column 'phi' does not exist");
0342 return m_phiColumn->proxy(*this);
0343 }
0344
0345
0346 ConstSpacePointColumnProxy<float> timeColumn() const noexcept {
0347 assert(m_timeColumn.has_value() && "Column 'time' does not exist");
0348 return m_timeColumn->proxy(*this);
0349 }
0350
0351
0352 ConstSpacePointColumnProxy<float> varianceZColumn() const noexcept {
0353 assert(m_varianceZColumn.has_value() &&
0354 "Column 'varianceZ' does not exist");
0355 return m_varianceZColumn->proxy(*this);
0356 }
0357
0358
0359 ConstSpacePointColumnProxy<float> varianceRColumn() const noexcept {
0360 assert(m_varianceRColumn.has_value() &&
0361 "Column 'varianceR' does not exist");
0362 return m_varianceRColumn->proxy(*this);
0363 }
0364
0365
0366 ConstSpacePointColumnProxy<std::array<float, 3>> topStripVectorColumn()
0367 const noexcept {
0368 assert(m_topStripVectorColumn.has_value() &&
0369 "Column 'topStripVector' does not exist");
0370 return m_topStripVectorColumn->proxy(*this);
0371 }
0372
0373
0374 ConstSpacePointColumnProxy<std::array<float, 3>> bottomStripVectorColumn()
0375 const noexcept {
0376 assert(m_bottomStripVectorColumn.has_value() &&
0377 "Column 'bottomStripVector' does not exist");
0378 return m_bottomStripVectorColumn->proxy(*this);
0379 }
0380
0381
0382 ConstSpacePointColumnProxy<std::array<float, 3>> stripCenterDistanceColumn()
0383 const noexcept {
0384 assert(m_stripCenterDistanceColumn.has_value() &&
0385 "Column 'stripCenterDistance' does not exist");
0386 return m_stripCenterDistanceColumn->proxy(*this);
0387 }
0388
0389
0390 ConstSpacePointColumnProxy<std::array<float, 3>> topStripCenterColumn()
0391 const noexcept {
0392 assert(m_topStripCenterColumn.has_value() &&
0393 "Column 'topStripCenter' does not exist");
0394 return m_topStripCenterColumn->proxy(*this);
0395 }
0396
0397
0398 ConstSpacePointColumnProxy<SpacePointIndex2> copyFromIndexColumn()
0399 const noexcept {
0400 assert(m_copyFromIndexColumn.has_value() &&
0401 "Column 'copyFromIndex' does not exist");
0402 return m_copyFromIndexColumn->proxy(*this);
0403 }
0404
0405
0406 ConstSpacePointColumnProxy<std::array<float, 2>> xyColumn() const noexcept {
0407 assert(m_xyColumn.has_value() && "Column 'xy' does not exist");
0408 return m_xyColumn->proxy(*this);
0409 }
0410
0411
0412 ConstSpacePointColumnProxy<std::array<float, 2>> zrColumn() const noexcept {
0413 assert(m_zrColumn.has_value() && "Column 'zr' does not exist");
0414 return m_zrColumn->proxy(*this);
0415 }
0416
0417
0418 ConstSpacePointColumnProxy<std::array<float, 3>> xyzColumn() const noexcept {
0419 assert(m_xyzColumn.has_value() && "Column 'xyz' does not exist");
0420 return m_xyzColumn->proxy(*this);
0421 }
0422
0423
0424 ConstSpacePointColumnProxy<std::array<float, 4>> xyzrColumn() const noexcept {
0425 assert(m_xyzrColumn.has_value() && "Column 'xyzr' does not exist");
0426 return m_xyzrColumn->proxy(*this);
0427 }
0428
0429
0430 ConstSpacePointColumnProxy<std::array<float, 2>> varianceZRColumn()
0431 const noexcept {
0432 assert(m_varianceZRColumn.has_value() &&
0433 "Column 'varianceZR' does not exist");
0434 return m_varianceZRColumn->proxy(*this);
0435 }
0436
0437
0438
0439
0440
0441
0442 MutableProxy at(Index index);
0443
0444
0445
0446
0447
0448 ConstProxy at(Index index) const;
0449
0450
0451
0452
0453 MutableProxy operator[](Index index) noexcept;
0454
0455
0456
0457 ConstProxy operator[](Index index) const noexcept;
0458
0459
0460
0461
0462
0463
0464
0465 void assignSourceLinks(Index index, std::span<const SourceLink> sourceLinks);
0466
0467
0468
0469
0470 std::span<SourceLink> sourceLinks(Index index) {
0471 assert(m_sourceLinkOffsetColumn.has_value() &&
0472 m_sourceLinkCountColumn.has_value() &&
0473 "Column 'sourceLinks' does not exist");
0474 assert(index < m_sourceLinkOffsetColumn->size() &&
0475 index < m_sourceLinkCountColumn->size() && "Index out of bounds");
0476 return std::span<SourceLink>(
0477 m_sourceLinks.data() + m_sourceLinkOffsetColumn->proxy(*this)[index],
0478 m_sourceLinkCountColumn->proxy(*this)[index]);
0479 }
0480
0481
0482
0483 float &x(Index index) noexcept {
0484 assert(m_xColumn.has_value() && "Column 'x' does not exist");
0485 assert(index < m_xColumn->size() && "Index out of bounds");
0486 return m_xColumn->proxy(*this)[index];
0487 }
0488
0489
0490
0491 float &y(Index index) noexcept {
0492 assert(m_yColumn.has_value() && "Column 'y' does not exist");
0493 assert(index < m_yColumn->size() && "Index out of bounds");
0494 return m_yColumn->proxy(*this)[index];
0495 }
0496
0497
0498
0499 float &z(Index index) noexcept {
0500 assert(m_zColumn.has_value() && "Column 'z' does not exist");
0501 assert(index < m_zColumn->size() && "Index out of bounds");
0502 return m_zColumn->proxy(*this)[index];
0503 }
0504
0505
0506
0507
0508 float &r(Index index) noexcept {
0509 assert(m_rColumn.has_value() && "Column 'r' does not exist");
0510 assert(index < m_rColumn->size() && "Index out of bounds");
0511 return m_rColumn->proxy(*this)[index];
0512 }
0513
0514
0515
0516
0517 float &phi(Index index) noexcept {
0518 assert(m_phiColumn.has_value() && "Column 'phi' does not exist");
0519 assert(index < m_phiColumn->size() && "Index out of bounds");
0520 return m_phiColumn->proxy(*this)[index];
0521 }
0522
0523
0524
0525
0526 float &time(Index index) noexcept {
0527 assert(m_timeColumn.has_value() && "Column 'time' does not exist");
0528 assert(index < m_timeColumn->size() && "Index out of bounds");
0529 return m_timeColumn->proxy(*this)[index];
0530 }
0531
0532
0533
0534
0535 float &varianceZ(Index index) noexcept {
0536 assert(m_varianceZColumn.has_value() &&
0537 "Column 'varianceZ' does not exist");
0538 assert(index < m_varianceZColumn->size() && "Index out of bounds");
0539 return m_varianceZColumn->proxy(*this)[index];
0540 }
0541
0542
0543
0544
0545 float &varianceR(Index index) noexcept {
0546 assert(m_varianceRColumn.has_value() &&
0547 "Column 'varianceR' does not exist");
0548 assert(index < m_varianceRColumn->size() && "Index out of bounds");
0549 return m_varianceRColumn->proxy(*this)[index];
0550 }
0551
0552
0553
0554
0555 std::array<float, 3> &topStripVector(Index index) noexcept {
0556 assert(m_topStripVectorColumn.has_value() &&
0557 "Column 'topStripVector' does not exist");
0558 assert(index < m_topStripVectorColumn->size() && "Index out of bounds");
0559 return m_topStripVectorColumn->proxy(*this)[index];
0560 }
0561
0562
0563
0564
0565 std::array<float, 3> &bottomStripVector(Index index) noexcept {
0566 assert(m_bottomStripVectorColumn.has_value() &&
0567 "Column 'bottomStripVector' does not exist");
0568 assert(index < m_bottomStripVectorColumn->size() && "Index out of bounds");
0569 return m_bottomStripVectorColumn->proxy(*this)[index];
0570 }
0571
0572
0573
0574
0575 std::array<float, 3> &stripCenterDistance(Index index) noexcept {
0576 assert(m_stripCenterDistanceColumn.has_value() &&
0577 "Column 'stripCenterDistance' does not exist");
0578 assert(index < m_stripCenterDistanceColumn->size() &&
0579 "Index out of bounds");
0580 return m_stripCenterDistanceColumn->proxy(*this)[index];
0581 }
0582
0583
0584
0585
0586 std::array<float, 3> &topStripCenter(Index index) noexcept {
0587 assert(m_topStripCenterColumn.has_value() &&
0588 "Column 'topStripCenter' does not exist");
0589 assert(index < m_topStripCenterColumn->size() && "Index out of bounds");
0590 return m_topStripCenterColumn->proxy(*this)[index];
0591 }
0592
0593
0594
0595
0596 SpacePointIndex2 ©FromIndex(Index index) noexcept {
0597 assert(m_copyFromIndexColumn.has_value() &&
0598 "Column 'copyFromIndex' does not exist");
0599 assert(index < m_copyFromIndexColumn->size() && "Index out of bounds");
0600 return m_copyFromIndexColumn->proxy(*this)[index];
0601 }
0602
0603
0604
0605
0606 std::array<float, 2> &xy(Index index) noexcept {
0607 assert(m_xyColumn.has_value() && "Column 'xy' does not exist");
0608 assert(index < m_xyColumn->size() && "Index out of bounds");
0609 return m_xyColumn->proxy(*this)[index];
0610 }
0611
0612
0613
0614
0615 std::array<float, 2> &zr(Index index) noexcept {
0616 assert(m_zrColumn.has_value() && "Column 'zr' does not exist");
0617 assert(index < m_zrColumn->size() && "Index out of bounds");
0618 return m_zrColumn->proxy(*this)[index];
0619 }
0620
0621
0622
0623
0624 std::array<float, 3> &xyz(Index index) noexcept {
0625 assert(m_xyzColumn.has_value() && "Column 'xyz' does not exist");
0626 assert(index < m_xyzColumn->size() && "Index out of bounds");
0627 return m_xyzColumn->proxy(*this)[index];
0628 }
0629
0630
0631
0632
0633 std::array<float, 4> &xyzr(Index index) noexcept {
0634 assert(m_xyzrColumn.has_value() && "Column 'xyzr' does not exist");
0635 assert(index < m_xyzrColumn->size() && "Index out of bounds");
0636 return m_xyzrColumn->proxy(*this)[index];
0637 }
0638
0639
0640
0641
0642 std::array<float, 2> &varianceZR(Index index) noexcept {
0643 assert(m_varianceZRColumn.has_value() &&
0644 "Column 'varianceZR' does not exist");
0645 assert(index < m_varianceZRColumn->size() && "Index out of bounds");
0646 return m_varianceZRColumn->proxy(*this)[index];
0647 }
0648
0649
0650
0651
0652 std::span<const SourceLink> sourceLinks(Index index) const noexcept {
0653 assert(m_sourceLinkOffsetColumn.has_value() &&
0654 m_sourceLinkCountColumn.has_value() &&
0655 "Column 'sourceLinks' does not exist");
0656 assert(index < m_sourceLinkOffsetColumn->size() &&
0657 index < m_sourceLinkCountColumn->size() && "Index out of bounds");
0658 return std::span<const SourceLink>(
0659 m_sourceLinks.data() + m_sourceLinkOffsetColumn->proxy(*this)[index],
0660 m_sourceLinkCountColumn->proxy(*this)[index]);
0661 }
0662
0663
0664
0665 float x(Index index) const noexcept {
0666 assert(m_xColumn.has_value() && "Column 'x' does not exist");
0667 assert(index < m_xColumn->size() && "Index out of bounds");
0668 return m_xColumn->proxy(*this)[index];
0669 }
0670
0671
0672
0673 float y(Index index) const noexcept {
0674 assert(m_yColumn.has_value() && "Column 'y' does not exist");
0675 assert(index < m_yColumn->size() && "Index out of bounds");
0676 return m_yColumn->proxy(*this)[index];
0677 }
0678
0679
0680
0681 float z(Index index) const noexcept {
0682 assert(m_zColumn.has_value() && "Column 'z' does not exist");
0683 assert(index < m_zColumn->size() && "Index out of bounds");
0684 return m_zColumn->proxy(*this)[index];
0685 }
0686
0687
0688
0689
0690 float r(Index index) const noexcept {
0691 assert(m_rColumn.has_value() && "Column 'r' does not exist");
0692 assert(index < m_rColumn->size() && "Index out of bounds");
0693 return m_rColumn->proxy(*this)[index];
0694 }
0695
0696
0697
0698
0699 float phi(Index index) const noexcept {
0700 assert(m_phiColumn.has_value() && "Column 'phi' does not exist");
0701 assert(index < m_phiColumn->size() && "Index out of bounds");
0702 return m_phiColumn->proxy(*this)[index];
0703 }
0704
0705
0706
0707
0708 float time(Index index) const noexcept {
0709 assert(m_timeColumn.has_value() && "Column 'time' does not exist");
0710 assert(index < m_timeColumn->size() && "Index out of bounds");
0711 return m_timeColumn->proxy(*this)[index];
0712 }
0713
0714
0715
0716
0717 float varianceZ(Index index) const noexcept {
0718 assert(m_varianceZColumn.has_value() &&
0719 "Column 'varianceZ' does not exist");
0720 assert(index < m_varianceZColumn->size() && "Index out of bounds");
0721 return m_varianceZColumn->proxy(*this)[index];
0722 }
0723
0724
0725
0726
0727 float varianceR(Index index) const noexcept {
0728 assert(m_varianceRColumn.has_value() &&
0729 "Column 'varianceR' does not exist");
0730 assert(index < m_varianceRColumn->size() && "Index out of bounds");
0731 return m_varianceRColumn->proxy(*this)[index];
0732 }
0733
0734
0735
0736
0737 const std::array<float, 3> &topStripVector(Index index) const noexcept {
0738 assert(m_topStripVectorColumn.has_value() &&
0739 "Column 'topStripVector' does not exist");
0740 assert(index < m_topStripVectorColumn->size() && "Index out of bounds");
0741 return m_topStripVectorColumn->proxy(*this)[index];
0742 }
0743
0744
0745
0746
0747 const std::array<float, 3> &bottomStripVector(Index index) const noexcept {
0748 assert(m_bottomStripVectorColumn.has_value() &&
0749 "Column 'bottomStripVector' does not exist");
0750 assert(index < m_bottomStripVectorColumn->size() && "Index out of bounds");
0751 return m_bottomStripVectorColumn->proxy(*this)[index];
0752 }
0753
0754
0755
0756
0757 const std::array<float, 3> &stripCenterDistance(Index index) const noexcept {
0758 assert(m_stripCenterDistanceColumn.has_value() &&
0759 "Column 'stripCenterDistance' does not exist");
0760 assert(index < m_stripCenterDistanceColumn->size() &&
0761 "Index out of bounds");
0762 return m_stripCenterDistanceColumn->proxy(*this)[index];
0763 }
0764
0765
0766
0767
0768 const std::array<float, 3> &topStripCenter(Index index) const noexcept {
0769 assert(m_topStripCenterColumn.has_value() &&
0770 "Column 'topStripCenter' does not exist");
0771 assert(index < m_topStripCenterColumn->size() && "Index out of bounds");
0772 return m_topStripCenterColumn->proxy(*this)[index];
0773 }
0774
0775
0776
0777
0778 SpacePointIndex2 copyFromIndex(Index index) const noexcept {
0779 assert(m_copyFromIndexColumn.has_value() &&
0780 "Column 'copyFromIndex' does not exist");
0781 assert(index < m_copyFromIndexColumn->size() && "Index out of bounds");
0782 return m_copyFromIndexColumn->proxy(*this)[index];
0783 }
0784
0785
0786
0787 const std::array<float, 2> &xy(Index index) const noexcept {
0788 assert(m_xyColumn.has_value() && "Column 'xy' does not exist");
0789 assert(index < m_xyColumn->size() && "Index out of bounds");
0790 return m_xyColumn->proxy(*this)[index];
0791 }
0792
0793
0794
0795 const std::array<float, 2> &zr(Index index) const noexcept {
0796 assert(m_zrColumn.has_value() && "Column 'zr' does not exist");
0797 assert(index < m_zrColumn->size() && "Index out of bounds");
0798 return m_zrColumn->proxy(*this)[index];
0799 }
0800
0801
0802
0803
0804 const std::array<float, 3> &xyz(Index index) const noexcept {
0805 assert(m_xyzColumn.has_value() && "Column 'xyz' does not exist");
0806 assert(index < m_xyzColumn->size() && "Index out of bounds");
0807 return m_xyzColumn->proxy(*this)[index];
0808 }
0809
0810
0811
0812
0813 const std::array<float, 4> &xyzr(Index index) const noexcept {
0814 assert(m_xyzrColumn.has_value() && "Column 'xyzr' does not exist");
0815 assert(index < m_xyzrColumn->size() && "Index out of bounds");
0816 return m_xyzrColumn->proxy(*this)[index];
0817 }
0818
0819
0820
0821 const std::array<float, 2> &varianceZR(Index index) const noexcept {
0822 assert(m_varianceZRColumn.has_value() &&
0823 "Column 'varianceZR' does not exist");
0824 assert(index < m_varianceZRColumn->size() && "Index out of bounds");
0825 return m_varianceZRColumn->proxy(*this)[index];
0826 }
0827
0828
0829
0830
0831
0832
0833 SpacePointIndex2 resolvedIndex(Index index) const noexcept {
0834 if (m_copyFromIndexColumn.has_value()) {
0835 return this->copyFromIndex(index);
0836 }
0837 return index;
0838 }
0839
0840
0841 template <bool read_only>
0842 using Iterator = Acts::detail::ContainerIterator<
0843 SpacePointContainer2,
0844 std::conditional_t<read_only, ConstSpacePointProxy2,
0845 MutableSpacePointProxy2>,
0846 Index, read_only>;
0847
0848
0849 using iterator = Iterator<false>;
0850
0851 using const_iterator = Iterator<true>;
0852
0853
0854
0855 iterator begin() noexcept { return iterator(*this, 0); }
0856
0857
0858 iterator end() noexcept { return iterator(*this, size()); }
0859
0860
0861
0862 const_iterator begin() const noexcept { return const_iterator(*this, 0); }
0863
0864
0865 const_iterator end() const noexcept { return const_iterator(*this, size()); }
0866
0867 template <bool read_only>
0868 class Range
0869 : public Acts::detail::ContainerRange<Range<read_only>, Range<true>,
0870 SpacePointContainer2, Index,
0871 read_only> {
0872 public:
0873 using Base =
0874 Acts::detail::ContainerRange<Range<read_only>, Range<true>,
0875 SpacePointContainer2, Index, read_only>;
0876
0877 using Base::Base;
0878
0879 template <typename... Ts>
0880 auto zip(const ConstSpacePointColumnProxy<Ts> &...columns) const noexcept {
0881 return Base::container().zip(Base::range(), columns...);
0882 }
0883 };
0884
0885 using MutableRange = Range<false>;
0886
0887 using ConstRange = Range<true>;
0888
0889
0890
0891
0892 MutableRange range(const IndexRange &range) noexcept {
0893 return MutableRange(*this, range);
0894 }
0895
0896
0897
0898 ConstRange range(const IndexRange &range) const noexcept {
0899 return ConstRange(*this, range);
0900 }
0901
0902 template <bool read_only>
0903 class Subset : public Acts::detail::ContainerSubset<
0904 Subset<read_only>, Subset<true>, SpacePointContainer2,
0905 std::conditional_t<read_only, ConstSpacePointProxy2,
0906 MutableSpacePointProxy2>,
0907 SpacePointIndex2, read_only> {
0908 public:
0909 using Base = Acts::detail::ContainerSubset<
0910 Subset<read_only>, Subset<true>, SpacePointContainer2,
0911 std::conditional_t<read_only, ConstSpacePointProxy2,
0912 MutableSpacePointProxy2>,
0913 SpacePointIndex2, read_only>;
0914
0915 using Base::Base;
0916
0917 template <typename... Ts>
0918 auto zip(const ConstSpacePointColumnProxy<Ts> &...columns) const noexcept {
0919 return Base::container().zip(Base::subset(), columns...);
0920 }
0921 };
0922
0923 using MutableSubset = Subset<false>;
0924
0925 using ConstSubset = Subset<true>;
0926
0927
0928
0929
0930 MutableSubset subset(const IndexSubset &subset) noexcept {
0931 return MutableSubset(*this, subset);
0932 }
0933
0934
0935
0936 ConstSubset subset(const IndexSubset &subset) const noexcept {
0937 return ConstSubset(*this, subset);
0938 }
0939
0940
0941
0942
0943 template <typename... Ts>
0944 auto zip(const MutableSpacePointColumnProxy<Ts> &...columns) noexcept {
0945 return Acts::zip(std::ranges::iota_view<Index, Index>(0, size()),
0946 columns.data()...);
0947 }
0948
0949
0950
0951 template <typename... Ts>
0952 auto zip(const ConstSpacePointColumnProxy<Ts> &...columns) const noexcept {
0953 return Acts::zip(std::ranges::iota_view<Index, Index>(0, size()),
0954 columns.data()...);
0955 }
0956
0957
0958
0959
0960
0961 template <typename... Ts>
0962 auto zip(const IndexRange &range,
0963 const MutableSpacePointColumnProxy<Ts> &...columns) noexcept {
0964 return Acts::zip(
0965 std::ranges::iota_view<Index, Index>(range.first, range.second),
0966 columns.data().subspan(range.first, range.second - range.first)...);
0967 }
0968
0969
0970
0971
0972 template <typename... Ts>
0973 auto zip(const IndexRange &range,
0974 const ConstSpacePointColumnProxy<Ts> &...columns) const noexcept {
0975 return Acts::zip(
0976 std::ranges::iota_view<Index, Index>(range.first, range.second),
0977 columns.data().subspan(range.first, range.second - range.first)...);
0978 }
0979
0980
0981
0982
0983
0984
0985 template <typename... Ts>
0986 auto zip(const IndexSubset &subset,
0987 const MutableSpacePointColumnProxy<Ts> &...columns) noexcept {
0988 return Acts::zip(subset, columns.subset(subset)...);
0989 }
0990
0991
0992
0993
0994
0995
0996 template <typename... Ts>
0997 auto zip(const IndexSubset &subset,
0998 const ConstSpacePointColumnProxy<Ts> &...columns) const noexcept {
0999 return Acts::zip(subset, columns.subset(subset)...);
1000 }
1001
1002 private:
1003 using ColumnHolderBase = detail::sp::ColumnHolderBase;
1004 template <typename T>
1005 using ColumnHolder = detail::sp::ColumnHolder<T>;
1006
1007 std::uint32_t m_size{0};
1008
1009 std::unordered_map<
1010 std::string,
1011 std::pair<ColumnHolderBase *, std::unique_ptr<ColumnHolderBase>>,
1012 std::hash<std::string_view>, std::equal_to<>>
1013 m_namedColumns;
1014 SpacePointColumns m_knownColumns{SpacePointColumns::None};
1015
1016 std::vector<SourceLink> m_sourceLinks;
1017
1018 std::optional<ColumnHolder<SpacePointIndex2>> m_sourceLinkOffsetColumn;
1019 std::optional<ColumnHolder<std::uint8_t>> m_sourceLinkCountColumn;
1020
1021 std::optional<ColumnHolder<float>> m_xColumn;
1022 std::optional<ColumnHolder<float>> m_yColumn;
1023 std::optional<ColumnHolder<float>> m_zColumn;
1024
1025
1026 std::optional<ColumnHolder<float>> m_rColumn;
1027 std::optional<ColumnHolder<float>> m_phiColumn;
1028
1029 std::optional<ColumnHolder<float>> m_timeColumn;
1030
1031 std::optional<ColumnHolder<float>> m_varianceZColumn;
1032 std::optional<ColumnHolder<float>> m_varianceRColumn;
1033
1034 std::optional<ColumnHolder<std::array<float, 3>>> m_topStripVectorColumn;
1035 std::optional<ColumnHolder<std::array<float, 3>>> m_bottomStripVectorColumn;
1036 std::optional<ColumnHolder<std::array<float, 3>>> m_stripCenterDistanceColumn;
1037 std::optional<ColumnHolder<std::array<float, 3>>> m_topStripCenterColumn;
1038
1039 std::optional<ColumnHolder<SpacePointIndex2>> m_copyFromIndexColumn;
1040
1041 std::optional<ColumnHolder<std::array<float, 2>>> m_xyColumn;
1042 std::optional<ColumnHolder<std::array<float, 2>>> m_zrColumn;
1043 std::optional<ColumnHolder<std::array<float, 3>>> m_xyzColumn;
1044 std::optional<ColumnHolder<std::array<float, 4>>> m_xyzrColumn;
1045 std::optional<ColumnHolder<std::array<float, 2>>> m_varianceZRColumn;
1046
1047 static auto knownColumnMasks() noexcept {
1048 using enum SpacePointColumns;
1049 return std::tuple(SourceLinks, SourceLinks, X, Y, Z, R, Phi, Time,
1050 VarianceZ, VarianceR, TopStripVector, BottomStripVector,
1051 StripCenterDistance, TopStripCenter, CopyFromIndex, XY,
1052 ZR, XYZ, XYZR, VarianceZR);
1053 }
1054
1055 static auto knownColumnNames() noexcept {
1056 return std::tuple("sourceLinkOffset", "sourceLinkCount", "x", "y", "z", "r",
1057 "phi", "time", "varianceZ", "varianceR", "topStripVector",
1058 "bottomStripVector", "stripCenterDistance",
1059 "topStripCenter", "copyFromIndex", "xy", "zr", "xyz",
1060 "xyzr", "varianceZR");
1061 }
1062
1063 static auto knownColumnDefaults() noexcept {
1064 return std::tuple(
1065 SpacePointIndex2{0}, std::uint8_t{0}, float{0}, float{0}, float{0},
1066 float{0}, float{0}, float{NoTime}, float{0}, float{0},
1067 std::array<float, 3>{0, 0, 0}, std::array<float, 3>{0, 0, 0},
1068 std::array<float, 3>{0, 0, 0}, std::array<float, 3>{0, 0, 0},
1069 SpacePointIndex2{0}, std::array<float, 2>{0, 0},
1070 std::array<float, 2>{0, 0}, std::array<float, 3>{0, 0, 0},
1071 std::array<float, 4>{0, 0, 0, 0}, std::array<float, 2>{0, 0});
1072 }
1073
1074 auto knownColumns() & noexcept {
1075 return std::tie(m_sourceLinkOffsetColumn, m_sourceLinkCountColumn,
1076 m_xColumn, m_yColumn, m_zColumn, m_rColumn, m_phiColumn,
1077 m_timeColumn, m_varianceZColumn, m_varianceRColumn,
1078 m_topStripVectorColumn, m_bottomStripVectorColumn,
1079 m_stripCenterDistanceColumn, m_topStripCenterColumn,
1080 m_copyFromIndexColumn, m_xyColumn, m_zrColumn, m_xyzColumn,
1081 m_xyzrColumn, m_varianceZRColumn);
1082 }
1083 auto knownColumns() const & noexcept {
1084 return std::tie(m_sourceLinkOffsetColumn, m_sourceLinkCountColumn,
1085 m_xColumn, m_yColumn, m_zColumn, m_rColumn, m_phiColumn,
1086 m_timeColumn, m_varianceZColumn, m_varianceRColumn,
1087 m_topStripVectorColumn, m_bottomStripVectorColumn,
1088 m_stripCenterDistanceColumn, m_topStripCenterColumn,
1089 m_copyFromIndexColumn, m_xyColumn, m_zrColumn, m_xyzColumn,
1090 m_xyzrColumn, m_varianceZRColumn);
1091 }
1092 auto knownColumns() && noexcept {
1093 return std::tuple(
1094 std::move(m_sourceLinkOffsetColumn), std::move(m_sourceLinkCountColumn),
1095 std::move(m_xColumn), std::move(m_yColumn), std::move(m_zColumn),
1096 std::move(m_rColumn), std::move(m_phiColumn), std::move(m_timeColumn),
1097 std::move(m_varianceZColumn), std::move(m_varianceRColumn),
1098 std::move(m_topStripVectorColumn), std::move(m_bottomStripVectorColumn),
1099 std::move(m_stripCenterDistanceColumn),
1100 std::move(m_topStripCenterColumn), std::move(m_copyFromIndexColumn),
1101 std::move(m_xyColumn), std::move(m_zrColumn), std::move(m_xyzColumn),
1102 std::move(m_xyzrColumn), std::move(m_varianceZRColumn));
1103 }
1104
1105 void copyColumns(const SpacePointContainer2 &other);
1106 void moveColumns(SpacePointContainer2 &other) noexcept;
1107
1108 static bool reservedColumn(const std::string &name) noexcept;
1109
1110 template <typename Holder>
1111 auto createColumnImpl(const std::string &name) {
1112 if (reservedColumn(name)) {
1113 throw std::runtime_error("Column name is reserved: " + name);
1114 }
1115 if (hasColumn(name)) {
1116 throw std::runtime_error("Column already exists: " + name);
1117 }
1118 auto holder = std::make_unique<Holder>();
1119 holder->resize(size());
1120 auto proxy = holder->proxy(*this);
1121 m_namedColumns.try_emplace(name,
1122 std::pair{holder.get(), std::move(holder)});
1123 return proxy;
1124 }
1125
1126 template <typename Holder>
1127 auto columnImpl(const std::string &name) const {
1128 auto it = m_namedColumns.find(name);
1129 if (it == m_namedColumns.end()) {
1130 throw std::runtime_error("Column not found: " + name);
1131 }
1132 auto &holder = dynamic_cast<Holder &>(*it->second.first);
1133 return holder.proxy();
1134 }
1135 };
1136
1137 }
1138
1139 #include "Acts/EventData/SpacePointContainer2.ipp"