File indexing completed on 2025-08-05 08:09:14
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011
0012
0013 #include "Acts/Definitions/Algebra.hpp"
0014 #include "Acts/Utilities/BinningType.hpp"
0015 #include "Acts/Utilities/Enumerate.hpp"
0016 #include "Acts/Utilities/RangeXD.hpp"
0017
0018 #include <array>
0019 #include <bitset>
0020 #include <ostream>
0021 #include <string>
0022 #include <vector>
0023
0024 namespace Acts {
0025
0026 using Envelope = std::array<ActsScalar, 2>;
0027 using ExtentEnvelope = std::array<Envelope, binValues>;
0028
0029 constexpr Envelope zeroEnvelope = {0, 0};
0030 constexpr ExtentEnvelope zeroEnvelopes = {
0031 zeroEnvelope, zeroEnvelope, zeroEnvelope, zeroEnvelope,
0032 zeroEnvelope, zeroEnvelope, zeroEnvelope, zeroEnvelope};
0033
0034
0035
0036
0037
0038
0039
0040 class Extent {
0041 public:
0042
0043 Extent(const ExtentEnvelope& envelope = zeroEnvelopes);
0044
0045
0046 bool operator==(const Extent& e) const;
0047
0048
0049 bool operator!=(const Extent& e) const { return (!operator==(e)); }
0050
0051
0052
0053
0054
0055
0056
0057
0058 void extend(const Vector3& vtx,
0059 const std::vector<BinningValue>& bValues = s_binningValues,
0060 bool applyEnv = true, bool fillHistograms = false);
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 template <typename vector_iterator_t>
0071 void extend(const vector_iterator_t& start, const vector_iterator_t& end,
0072 const std::vector<BinningValue>& bValues = s_binningValues,
0073 bool applyEnv = true, bool fillHistograms = false) {
0074 for (vector_iterator_t vIt = start; vIt < end; ++vIt) {
0075 extend(*vIt, bValues, applyEnv, fillHistograms);
0076 }
0077 }
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093 void extend(const Extent& rhs,
0094 const std::vector<BinningValue>& bValues = s_binningValues,
0095 bool applyEnv = true);
0096
0097
0098
0099
0100
0101
0102
0103
0104 void addConstrain(const Extent& rhs,
0105 const ExtentEnvelope& envelope = zeroEnvelopes);
0106
0107
0108
0109
0110
0111
0112 void set(BinningValue bValue, ActsScalar min, ActsScalar max);
0113
0114
0115
0116
0117 void setEnvelope(const ExtentEnvelope& envelope = zeroEnvelopes);
0118
0119
0120
0121
0122
0123
0124 auto range(BinningValue bValue) { return m_range[bValue]; }
0125
0126
0127
0128
0129
0130
0131 Range1D<ActsScalar> range(BinningValue bValue) const;
0132
0133
0134 const RangeXD<binValues, ActsScalar>& range() const;
0135
0136
0137
0138 template <unsigned int kSUBDIM>
0139 RangeXD<kSUBDIM, ActsScalar> range(
0140 const std::array<BinningValue, kSUBDIM>& binValues) const {
0141 RangeXD<kSUBDIM, ActsScalar> rRange;
0142 for (auto [i, v] : enumerate(binValues)) {
0143 rRange[i] = range(v);
0144 }
0145 return rRange;
0146 }
0147
0148
0149 ExtentEnvelope& envelope();
0150
0151
0152 const ExtentEnvelope& envelope() const;
0153
0154
0155
0156
0157 const std::array<std::vector<ActsScalar>, binValues>& valueHistograms() const;
0158
0159
0160
0161
0162 ActsScalar min(BinningValue bValue) const { return m_range[bValue].min(); }
0163
0164
0165
0166
0167 ActsScalar max(BinningValue bValue) const { return m_range[bValue].max(); }
0168
0169
0170
0171
0172 ActsScalar medium(BinningValue bValue) const {
0173 return 0.5 * (m_range[bValue].min() + m_range[bValue].max());
0174 }
0175
0176
0177
0178
0179 ActsScalar interval(BinningValue bValue) const {
0180 return m_range[bValue].size();
0181 }
0182
0183
0184
0185
0186
0187
0188
0189
0190 bool contains(const Extent& rhs, BinningValue bValue = binValues) const;
0191
0192
0193
0194
0195
0196
0197 bool contains(const Vector3& vtx) const;
0198
0199
0200
0201
0202
0203
0204
0205
0206 bool intersects(const Extent& rhs, BinningValue bValue = binValues) const;
0207
0208
0209
0210
0211 bool constrains(BinningValue bValue = binValues) const;
0212
0213
0214
0215
0216 std::string toString(const std::string& indent = "") const;
0217
0218 private:
0219
0220 std::bitset<binValues> m_constrains{0};
0221
0222 RangeXD<binValues, ActsScalar> m_range;
0223
0224 ExtentEnvelope m_envelope = zeroEnvelopes;
0225
0226 std::array<std::vector<ActsScalar>, binValues> m_valueHistograms;
0227 };
0228
0229 inline Range1D<ActsScalar> Acts::Extent::range(BinningValue bValue) const {
0230 return m_range[bValue];
0231 }
0232
0233 inline const RangeXD<binValues, ActsScalar>& Extent::range() const {
0234 return m_range;
0235 }
0236
0237 inline ExtentEnvelope& Extent::envelope() {
0238 return m_envelope;
0239 }
0240
0241 inline const ExtentEnvelope& Extent::envelope() const {
0242 return m_envelope;
0243 }
0244
0245 inline const std::array<std::vector<ActsScalar>, binValues>&
0246 Extent::valueHistograms() const {
0247 return m_valueHistograms;
0248 }
0249
0250
0251 std::ostream& operator<<(std::ostream& sl, const Extent& rhs);
0252
0253 }