Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Extent.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Extent.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2022 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
12 
18 
19 #include <array>
20 #include <bitset>
21 #include <ostream>
22 #include <string>
23 #include <vector>
24 
25 namespace Acts {
26 
27 using Envelope = std::array<ActsScalar, 2>;
28 using ExtentEnvelope = std::array<Envelope, binValues>;
29 
30 constexpr Envelope zeroEnvelope = {0, 0};
33  zeroEnvelope, zeroEnvelope, zeroEnvelope, zeroEnvelope};
34 
41 class Extent {
42  public:
45 
47  bool operator==(const Extent& e) const;
48 
50  bool operator!=(const Extent& e) const { return (not operator==(e)); }
51 
59  void extend(const Vector3& vtx,
60  const std::vector<BinningValue>& bValues = s_binningValues,
61  bool applyEnv = true, bool fillHistograms = false);
62 
71  template <typename vector_iterator_t>
72  void extend(const vector_iterator_t& start, const vector_iterator_t& end,
73  const std::vector<BinningValue>& bValues = s_binningValues,
74  bool applyEnv = true, bool fillHistograms = false) {
75  for (vector_iterator_t vIt = start; vIt < end; ++vIt) {
76  extend(*vIt, bValues, applyEnv, fillHistograms);
77  }
78  }
79 
94  void extend(const Extent& rhs,
95  const std::vector<BinningValue>& bValues = s_binningValues,
96  bool applyEnv = true);
97 
105  void addConstrain(const Extent& rhs,
107 
113  void set(BinningValue bValue, ActsScalar min, ActsScalar max);
114 
119 
126 
132  const Range1D<ActsScalar>& range(BinningValue bValue) const;
133 
136 
139  template <unsigned int kSUBDIM>
141  const std::array<BinningValue, kSUBDIM>& binValues) const {
143  for (auto [i, v] : enumerate(binValues)) {
144  rRange[i] = range(v);
145  }
146  return rRange;
147  }
148 
151 
153  const ExtentEnvelope& envelope() const;
154 
158  const std::array<std::vector<ActsScalar>, binValues>& valueHistograms() const;
159 
163  ActsScalar min(BinningValue bValue) const { return m_range[bValue].min(); }
164 
168  ActsScalar max(BinningValue bValue) const { return m_range[bValue].max(); }
169 
174  return 0.5 * (m_range[bValue].min() + m_range[bValue].max());
175  }
176 
181  return m_range[bValue].size();
182  }
183 
191  bool contains(const Extent& rhs, BinningValue bValue = binValues) const;
192 
200  bool intersects(const Extent& rhs, BinningValue bValue = binValues) const;
201 
205  bool constrains(BinningValue bValue = binValues) const;
206 
210  std::string toString(const std::string& indent = "") const;
211 
212  private:
214  std::bitset<binValues> m_constrains{0};
220  std::array<std::vector<ActsScalar>, binValues> m_valueHistograms;
221 };
222 
224  return m_range[bValue];
225 }
226 
228  BinningValue bValue) const {
229  return m_range[bValue];
230 }
231 
233  return m_range;
234 }
235 
237  return m_envelope;
238 }
239 
240 inline const ExtentEnvelope& Extent::envelope() const {
241  return m_envelope;
242 }
243 
244 inline const std::array<std::vector<ActsScalar>, binValues>&
246  return m_valueHistograms;
247 }
248 
250 std::ostream& operator<<(std::ostream& sl, const Extent& rhs);
251 
252 } // namespace Acts