Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GridAxisGenerators.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GridAxisGenerators.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 
13 
14 #include <array>
15 #include <tuple>
16 #include <vector>
17 
18 namespace Acts {
19 namespace Experimental {
20 namespace detail {
21 
29 namespace GridAxisGenerators {
30 
34 template <Acts::detail::AxisBoundaryType aType>
35 struct Eq {
37  using return_type = std::tuple<
38  Acts::detail::Axis<Acts::detail::AxisType::Equidistant, aType>>;
39 
41  template <typename T>
43  T, Acts::detail::Axis<Acts::detail::AxisType::Equidistant, aType>>;
44 
45  std::array<ActsScalar, 2u> range = {};
46  std::size_t nBins = 0u;
47 
50  Acts::detail::Axis<Acts::detail::AxisType::Equidistant, aType> eAxis(
51  range[0u], range[1u], nBins);
52  return {eAxis};
53  }
54 };
55 
56 // All 1D equidistant options
60 
64 template <Acts::detail::AxisBoundaryType aType>
65 struct Var {
67  using return_type =
68  std::tuple<Acts::detail::Axis<Acts::detail::AxisType::Variable, aType>>;
69 
71  template <typename T>
73  T, Acts::detail::Axis<Acts::detail::AxisType::Variable, aType>>;
74 
75  std::vector<ActsScalar> edges = {};
76 
79  Acts::detail::Axis<Acts::detail::AxisType::Variable, aType> vAxis(edges);
80  return {vAxis};
81  }
82 };
83 
84 // All 1D variable options
88 
94 template <Acts::detail::AxisBoundaryType aType,
96 struct EqEq {
98  using return_type = std::tuple<
99  Acts::detail::Axis<Acts::detail::AxisType::Equidistant, aType>,
100  Acts::detail::Axis<Acts::detail::AxisType::Equidistant, bType>>;
101 
103  template <typename T>
105  T, Acts::detail::Axis<Acts::detail::AxisType::Equidistant, aType>,
106  Acts::detail::Axis<Acts::detail::AxisType::Equidistant, bType>>;
107 
108  std::array<ActsScalar, 2u> range0 = {};
109  std::size_t nBins0 = 0u;
110  std::array<ActsScalar, 2u> range1 = {};
111  std::size_t nBins1 = 1u;
112 
115  // Create the two axis
116  Acts::detail::Axis<Acts::detail::AxisType::Equidistant, aType> aEq(
117  range0[0u], range0[1u], nBins0);
118  Acts::detail::Axis<Acts::detail::AxisType::Equidistant, bType> bEq(
119  range1[0u], range1[1u], nBins1);
120  return std::tie(aEq, bEq);
121  }
122 };
123 
124 // All 2D EqEq options
125 using EqBoundEqBound = EqEq<Acts::detail::AxisBoundaryType::Bound,
126  Acts::detail::AxisBoundaryType::Bound>;
127 using EqBoundEqOpen = EqEq<Acts::detail::AxisBoundaryType::Bound,
128  Acts::detail::AxisBoundaryType::Open>;
129 using EqBoundEqClosed = EqEq<Acts::detail::AxisBoundaryType::Bound,
130  Acts::detail::AxisBoundaryType::Closed>;
131 using EqOpenEqBound = EqEq<Acts::detail::AxisBoundaryType::Open,
132  Acts::detail::AxisBoundaryType::Bound>;
133 using EqOpenEqOpen = EqEq<Acts::detail::AxisBoundaryType::Open,
134  Acts::detail::AxisBoundaryType::Open>;
135 using EqOpenEqClosed = EqEq<Acts::detail::AxisBoundaryType::Open,
136  Acts::detail::AxisBoundaryType::Closed>;
137 using EqClosedEqBound = EqEq<Acts::detail::AxisBoundaryType::Closed,
138  Acts::detail::AxisBoundaryType::Bound>;
139 using EqClosedEqOpen = EqEq<Acts::detail::AxisBoundaryType::Closed,
140  Acts::detail::AxisBoundaryType::Open>;
141 using EqClosedEqClosed = EqEq<Acts::detail::AxisBoundaryType::Closed,
142  Acts::detail::AxisBoundaryType::Closed>;
143 
149 template <Acts::detail::AxisBoundaryType aType,
151 struct EqVar {
153  using return_type =
154  std::tuple<Acts::detail::Axis<Acts::detail::AxisType::Equidistant, aType>,
155  Acts::detail::Axis<Acts::detail::AxisType::Variable, bType>>;
156 
158  template <typename T>
160  T, Acts::detail::Axis<Acts::detail::AxisType::Equidistant, aType>,
161  Acts::detail::Axis<Acts::detail::AxisType::Variable, bType>>;
162 
163  std::array<ActsScalar, 2u> range = {};
164  std::size_t nBins = 0u;
165  std::vector<ActsScalar> edges = {};
166 
169  Acts::detail::Axis<Acts::detail::AxisType::Equidistant, aType> eqA(
170  range[0u], range[1u], nBins);
171  Acts::detail::Axis<Acts::detail::AxisType::Variable, bType> varB(edges);
172  return std::tie(eqA, varB);
173  }
174 };
175 
176 // All 2D EqVar options
177 using EqBoundVarBound = EqVar<Acts::detail::AxisBoundaryType::Bound,
178  Acts::detail::AxisBoundaryType::Bound>;
179 using EqBoundVarOpen = EqVar<Acts::detail::AxisBoundaryType::Bound,
180  Acts::detail::AxisBoundaryType::Open>;
181 using EqBoundVarClosed = EqVar<Acts::detail::AxisBoundaryType::Bound,
182  Acts::detail::AxisBoundaryType::Closed>;
183 using EqOpenVarBound = EqVar<Acts::detail::AxisBoundaryType::Open,
184  Acts::detail::AxisBoundaryType::Bound>;
185 using EqOpenVarOpen = EqVar<Acts::detail::AxisBoundaryType::Open,
186  Acts::detail::AxisBoundaryType::Open>;
187 using EqOpenVarClosed = EqVar<Acts::detail::AxisBoundaryType::Open,
188  Acts::detail::AxisBoundaryType::Closed>;
189 using EqClosedVarBound = EqVar<Acts::detail::AxisBoundaryType::Closed,
190  Acts::detail::AxisBoundaryType::Bound>;
191 using EqClosedVarOpen = EqVar<Acts::detail::AxisBoundaryType::Closed,
192  Acts::detail::AxisBoundaryType::Open>;
193 using EqClosedVarClosed = EqVar<Acts::detail::AxisBoundaryType::Closed,
194  Acts::detail::AxisBoundaryType::Closed>;
195 
201 template <Acts::detail::AxisBoundaryType aType,
203 struct VarEq {
205  using return_type = std::tuple<
206  Acts::detail::Axis<Acts::detail::AxisType::Variable, aType>,
207  Acts::detail::Axis<Acts::detail::AxisType::Equidistant, bType>>;
208 
210  template <typename T>
212  T, Acts::detail::Axis<Acts::detail::AxisType::Variable, aType>,
213  Acts::detail::Axis<Acts::detail::AxisType::Equidistant, bType>>;
214 
215  std::vector<ActsScalar> edges = {};
216  std::array<ActsScalar, 2u> range = {};
217  std::size_t nBins = 0u;
218 
221  Acts::detail::Axis<Acts::detail::AxisType::Variable, aType> varA(edges);
222  Acts::detail::Axis<Acts::detail::AxisType::Equidistant, bType> eqB(
223  range[0u], range[1u], nBins);
224  return std::tie(varA, eqB);
225  }
226 };
227 
228 // All 2D VarEq options
229 using VarBoundEqBound = VarEq<Acts::detail::AxisBoundaryType::Bound,
230  Acts::detail::AxisBoundaryType::Bound>;
231 using VarBoundEqOpen = VarEq<Acts::detail::AxisBoundaryType::Bound,
232  Acts::detail::AxisBoundaryType::Open>;
233 using VarBoundEqClosed = VarEq<Acts::detail::AxisBoundaryType::Bound,
234  Acts::detail::AxisBoundaryType::Closed>;
235 using VarOpenEqBound = VarEq<Acts::detail::AxisBoundaryType::Open,
236  Acts::detail::AxisBoundaryType::Bound>;
237 using VarOpenEqOpen = VarEq<Acts::detail::AxisBoundaryType::Open,
238  Acts::detail::AxisBoundaryType::Open>;
239 using VarOpenEqClosed = VarEq<Acts::detail::AxisBoundaryType::Open,
240  Acts::detail::AxisBoundaryType::Closed>;
241 using VarClosedEqBound = VarEq<Acts::detail::AxisBoundaryType::Closed,
242  Acts::detail::AxisBoundaryType::Bound>;
243 using VarClosedEqOpen = VarEq<Acts::detail::AxisBoundaryType::Closed,
244  Acts::detail::AxisBoundaryType::Open>;
245 using VarClosedEqClosed = VarEq<Acts::detail::AxisBoundaryType::Closed,
246  Acts::detail::AxisBoundaryType::Closed>;
247 
253 template <Acts::detail::AxisBoundaryType aType,
255 struct VarVar {
257  using return_type =
258  std::tuple<Acts::detail::Axis<Acts::detail::AxisType::Variable, aType>,
259  Acts::detail::Axis<Acts::detail::AxisType::Variable, bType>>;
260 
262  template <typename T>
264  T, Acts::detail::Axis<Acts::detail::AxisType::Variable, aType>,
265  Acts::detail::Axis<Acts::detail::AxisType::Variable, bType>>;
266 
267  std::vector<ActsScalar> edges0 = {};
268  std::vector<ActsScalar> edges1 = {};
269 
272  Acts::detail::Axis<Acts::detail::AxisType::Variable, aType> varA(edges0);
273  Acts::detail::Axis<Acts::detail::AxisType::Variable, bType> varB(edges1);
274  return std::tie(varA, varB);
275  }
276 };
277 
278 // All 2D VarVar options
279 using VarBoundVarBound = VarVar<Acts::detail::AxisBoundaryType::Bound,
280  Acts::detail::AxisBoundaryType::Bound>;
281 using VarBoundVarOpen = VarVar<Acts::detail::AxisBoundaryType::Bound,
282  Acts::detail::AxisBoundaryType::Open>;
283 using VarBoundVarClosed = VarVar<Acts::detail::AxisBoundaryType::Bound,
284  Acts::detail::AxisBoundaryType::Closed>;
285 using VarOpenVarBound = VarVar<Acts::detail::AxisBoundaryType::Open,
286  Acts::detail::AxisBoundaryType::Bound>;
287 using VarOpenVarOpen = VarVar<Acts::detail::AxisBoundaryType::Open,
288  Acts::detail::AxisBoundaryType::Open>;
289 using VarOpenVarClosed = VarVar<Acts::detail::AxisBoundaryType::Open,
290  Acts::detail::AxisBoundaryType::Closed>;
291 using VarClosedVarBound = VarVar<Acts::detail::AxisBoundaryType::Closed,
292  Acts::detail::AxisBoundaryType::Bound>;
293 using VarClosedVarOpen = VarVar<Acts::detail::AxisBoundaryType::Closed,
294  Acts::detail::AxisBoundaryType::Open>;
295 using VarClosedVarClosed = VarVar<Acts::detail::AxisBoundaryType::Closed,
296  Acts::detail::AxisBoundaryType::Closed>;
297 
298 } // namespace GridAxisGenerators
299 } // namespace detail
300 } // namespace Experimental
301 } // namespace Acts