Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ProtoBinning.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ProtoBinning.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 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 
15 
16 #include <stdexcept>
17 #include <vector>
18 
19 namespace Acts {
20 
21 namespace Experimental {
22 
28 struct ProtoBinning {
32  Acts::detail::AxisType axisType = Acts::detail::AxisType::Equidistant;
35  Acts::detail::AxisBoundaryType::Bound;
37  std::vector<ActsScalar> edges = {};
39  std::size_t expansion = 0u;
40 
48  const std::vector<ActsScalar>& e, std::size_t exp = 0u)
49  : binValue(bValue),
50  axisType(Acts::detail::AxisType::Variable),
51  boundaryType(bType),
52  edges(e),
53  expansion(exp) {
54  if (edges.size() < 2u) {
55  throw std::invalid_argument(
56  "ProtoBinning: Invalid binning, at least two edges are needed.");
57  }
58  }
59 
69  ActsScalar minE, ActsScalar maxE, std::size_t nbins,
70  std::size_t exp = 0u)
71  : binValue(bValue), boundaryType(bType), expansion(exp) {
72  if (minE >= maxE) {
73  throw std::invalid_argument(
74  "ProtoBinning: Invalid binning, min edge needs to be smaller than "
75  "max edge.");
76  }
77  if (nbins < 1u) {
78  throw std::invalid_argument(
79  "ProtoBinning: Invalid binning, at least one bin is needed.");
80  }
81 
82  ActsScalar stepE = (maxE - minE) / nbins;
83  edges.reserve(nbins + 1);
84  for (std::size_t i = 0; i <= nbins; i++) {
85  edges.push_back(minE + i * stepE);
86  }
87  }
88 
89  std::size_t bins() const { return edges.size() - 1u; }
90 };
91 
92 } // namespace Experimental
93 } // namespace Acts