Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:10

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Utilities/Axis.hpp"
0012 #include "Acts/Utilities/Grid.hpp"
0013 #include "Acts/Utilities/TypeList.hpp"
0014 
0015 #include <array>
0016 #include <tuple>
0017 #include <vector>
0018 
0019 /// Axis generators are used to allow defining different grid types
0020 /// for indexed geometry objects.
0021 ///
0022 /// The call operator() API allows to plug axis generators into
0023 /// dedicated code snippets and create fitting axis types on the fly
0024 /// which then turn into concrete Grid types.
0025 namespace Acts::GridAxisGenerators {
0026 
0027 /// @brief  Templated base generator for equidistant axis as a tuple - 1D
0028 ///
0029 /// @tparam aType the type of the axis (Bound, Closed, Open)
0030 template <Acts::AxisBoundaryType aType>
0031 struct Eq {
0032   /// Broadcast the return_type
0033   using return_type =
0034       std::tuple<Acts::Axis<Acts::AxisType::Equidistant, aType>>;
0035 
0036   /// Broadcast the grid type
0037   template <typename T>
0038   using grid_type =
0039       Acts::Grid<T, Acts::Axis<Acts::AxisType::Equidistant, aType>>;
0040 
0041   std::array<double, 2u> range = {};
0042   std::size_t nBins = 0u;
0043 
0044   /// Call operator that generates the Axis
0045   return_type operator()() const {
0046     Acts::Axis<Acts::AxisType::Equidistant, aType> eAxis(range[0u], range[1u],
0047                                                          nBins);
0048     return {eAxis};
0049   }
0050 };
0051 
0052 // All 1D equidistant options
0053 using EqBound = Eq<Acts::AxisBoundaryType::Bound>;
0054 using EqOpen = Eq<Acts::AxisBoundaryType::Open>;
0055 using EqClosed = Eq<Acts::AxisBoundaryType::Closed>;
0056 
0057 /// @brief  Templated base generator for variable axis as a tuple - 1D
0058 ///
0059 /// @tparam aType the type of the axis (Bound, Closed, Open)
0060 template <Acts::AxisBoundaryType aType>
0061 struct Var {
0062   /// Broadcast the return_type
0063   using return_type = std::tuple<Acts::Axis<Acts::AxisType::Variable, aType>>;
0064 
0065   /// Broadcast the grid type
0066   template <typename T>
0067   using grid_type = Acts::Grid<T, Acts::Axis<Acts::AxisType::Variable, aType>>;
0068 
0069   std::vector<double> edges = {};
0070 
0071   /// Call operator that generates the Axis
0072   return_type operator()() const {
0073     Acts::Axis<Acts::AxisType::Variable, aType> vAxis(edges);
0074     return {vAxis};
0075   }
0076 };
0077 
0078 // All 1D variable options
0079 using VarBound = Var<Acts::AxisBoundaryType::Bound>;
0080 using VarOpen = Var<Acts::AxisBoundaryType::Open>;
0081 using VarClosed = Var<Acts::AxisBoundaryType::Closed>;
0082 
0083 /// @brief  Templated base generator for two equidistant axes as a tuple - 2D
0084 ///
0085 /// @tparam aType the type of the first axis (Bound, Closed, Open)
0086 /// @tparam bType the type of the second axis (Bound, Closed, Open)
0087 ///
0088 template <Acts::AxisBoundaryType aType, Acts::AxisBoundaryType bType>
0089 struct EqEq {
0090   /// Broadcast the return_type
0091   using return_type =
0092       std::tuple<Acts::Axis<Acts::AxisType::Equidistant, aType>,
0093                  Acts::Axis<Acts::AxisType::Equidistant, bType>>;
0094 
0095   /// Broadcast the grid type
0096   template <typename T>
0097   using grid_type =
0098       Acts::Grid<T, Acts::Axis<Acts::AxisType::Equidistant, aType>,
0099                  Acts::Axis<Acts::AxisType::Equidistant, bType>>;
0100 
0101   std::array<double, 2u> range0 = {};
0102   std::size_t nBins0 = 0u;
0103   std::array<double, 2u> range1 = {};
0104   std::size_t nBins1 = 1u;
0105 
0106   /// Call operator that generates the Axis
0107   return_type operator()() const {
0108     // Create the two axis
0109     Acts::Axis<Acts::AxisType::Equidistant, aType> aEq(range0[0u], range0[1u],
0110                                                        nBins0);
0111     Acts::Axis<Acts::AxisType::Equidistant, bType> bEq(range1[0u], range1[1u],
0112                                                        nBins1);
0113     return {aEq, bEq};
0114   }
0115 };
0116 
0117 // All 2D EqEq options
0118 using EqBoundEqBound =
0119     EqEq<Acts::AxisBoundaryType::Bound, Acts::AxisBoundaryType::Bound>;
0120 using EqBoundEqOpen =
0121     EqEq<Acts::AxisBoundaryType::Bound, Acts::AxisBoundaryType::Open>;
0122 using EqBoundEqClosed =
0123     EqEq<Acts::AxisBoundaryType::Bound, Acts::AxisBoundaryType::Closed>;
0124 using EqOpenEqBound =
0125     EqEq<Acts::AxisBoundaryType::Open, Acts::AxisBoundaryType::Bound>;
0126 using EqOpenEqOpen =
0127     EqEq<Acts::AxisBoundaryType::Open, Acts::AxisBoundaryType::Open>;
0128 using EqOpenEqClosed =
0129     EqEq<Acts::AxisBoundaryType::Open, Acts::AxisBoundaryType::Closed>;
0130 using EqClosedEqBound =
0131     EqEq<Acts::AxisBoundaryType::Closed, Acts::AxisBoundaryType::Bound>;
0132 using EqClosedEqOpen =
0133     EqEq<Acts::AxisBoundaryType::Closed, Acts::AxisBoundaryType::Open>;
0134 using EqClosedEqClosed =
0135     EqEq<Acts::AxisBoundaryType::Closed, Acts::AxisBoundaryType::Closed>;
0136 
0137 /// @brief  Templated base generator for equidistant / variable axes as a tuple - 2D
0138 ///
0139 /// @tparam aType the type of the first axis (Bound, Closed, Open)
0140 /// @tparam bType the type of the second axis (Bound, Closed, Open)
0141 ///
0142 template <Acts::AxisBoundaryType aType, Acts::AxisBoundaryType bType>
0143 struct EqVar {
0144   /// Broadcast the return_type
0145   using return_type = std::tuple<Acts::Axis<Acts::AxisType::Equidistant, aType>,
0146                                  Acts::Axis<Acts::AxisType::Variable, bType>>;
0147 
0148   /// Broadcast the grid type
0149   template <typename T>
0150   using grid_type =
0151       Acts::Grid<T, Acts::Axis<Acts::AxisType::Equidistant, aType>,
0152                  Acts::Axis<Acts::AxisType::Variable, bType>>;
0153 
0154   std::array<double, 2u> range = {};
0155   std::size_t nBins = 0u;
0156   std::vector<double> edges = {};
0157 
0158   /// Call operator that generates the Axis
0159   return_type operator()() const {
0160     Acts::Axis<Acts::AxisType::Equidistant, aType> eqA(range[0u], range[1u],
0161                                                        nBins);
0162     Acts::Axis<Acts::AxisType::Variable, bType> varB(edges);
0163     return {eqA, varB};
0164   }
0165 };
0166 
0167 // All 2D EqVar options
0168 using EqBoundVarBound =
0169     EqVar<Acts::AxisBoundaryType::Bound, Acts::AxisBoundaryType::Bound>;
0170 using EqBoundVarOpen =
0171     EqVar<Acts::AxisBoundaryType::Bound, Acts::AxisBoundaryType::Open>;
0172 using EqBoundVarClosed =
0173     EqVar<Acts::AxisBoundaryType::Bound, Acts::AxisBoundaryType::Closed>;
0174 using EqOpenVarBound =
0175     EqVar<Acts::AxisBoundaryType::Open, Acts::AxisBoundaryType::Bound>;
0176 using EqOpenVarOpen =
0177     EqVar<Acts::AxisBoundaryType::Open, Acts::AxisBoundaryType::Open>;
0178 using EqOpenVarClosed =
0179     EqVar<Acts::AxisBoundaryType::Open, Acts::AxisBoundaryType::Closed>;
0180 using EqClosedVarBound =
0181     EqVar<Acts::AxisBoundaryType::Closed, Acts::AxisBoundaryType::Bound>;
0182 using EqClosedVarOpen =
0183     EqVar<Acts::AxisBoundaryType::Closed, Acts::AxisBoundaryType::Open>;
0184 using EqClosedVarClosed =
0185     EqVar<Acts::AxisBoundaryType::Closed, Acts::AxisBoundaryType::Closed>;
0186 
0187 /// @brief  Templated base generator for a variable, equidistant axes tuple - 2D
0188 ///
0189 /// @tparam aType the type of the first axis (Bound, Closed, Open)
0190 /// @tparam bType the type of the second axis (Bound, Closed, Open)
0191 ///
0192 template <Acts::AxisBoundaryType aType, Acts::AxisBoundaryType bType>
0193 struct VarEq {
0194   /// Broadcast the return_type
0195   using return_type =
0196       std::tuple<Acts::Axis<Acts::AxisType::Variable, aType>,
0197                  Acts::Axis<Acts::AxisType::Equidistant, bType>>;
0198 
0199   /// Broadcast the grid type
0200   template <typename T>
0201   using grid_type = Acts::Grid<T, Acts::Axis<Acts::AxisType::Variable, aType>,
0202                                Acts::Axis<Acts::AxisType::Equidistant, bType>>;
0203 
0204   std::vector<double> edges = {};
0205   std::array<double, 2u> range = {};
0206   std::size_t nBins = 0u;
0207 
0208   /// Call operator that generates the Axis
0209   return_type operator()() const {
0210     Acts::Axis<Acts::AxisType::Variable, aType> varA(edges);
0211     Acts::Axis<Acts::AxisType::Equidistant, bType> eqB(range[0u], range[1u],
0212                                                        nBins);
0213     return {varA, eqB};
0214   }
0215 };
0216 
0217 // All 2D VarEq options
0218 using VarBoundEqBound =
0219     VarEq<Acts::AxisBoundaryType::Bound, Acts::AxisBoundaryType::Bound>;
0220 using VarBoundEqOpen =
0221     VarEq<Acts::AxisBoundaryType::Bound, Acts::AxisBoundaryType::Open>;
0222 using VarBoundEqClosed =
0223     VarEq<Acts::AxisBoundaryType::Bound, Acts::AxisBoundaryType::Closed>;
0224 using VarOpenEqBound =
0225     VarEq<Acts::AxisBoundaryType::Open, Acts::AxisBoundaryType::Bound>;
0226 using VarOpenEqOpen =
0227     VarEq<Acts::AxisBoundaryType::Open, Acts::AxisBoundaryType::Open>;
0228 using VarOpenEqClosed =
0229     VarEq<Acts::AxisBoundaryType::Open, Acts::AxisBoundaryType::Closed>;
0230 using VarClosedEqBound =
0231     VarEq<Acts::AxisBoundaryType::Closed, Acts::AxisBoundaryType::Bound>;
0232 using VarClosedEqOpen =
0233     VarEq<Acts::AxisBoundaryType::Closed, Acts::AxisBoundaryType::Open>;
0234 using VarClosedEqClosed =
0235     VarEq<Acts::AxisBoundaryType::Closed, Acts::AxisBoundaryType::Closed>;
0236 
0237 /// @brief  Templated base generator for a two variable axes tuple - 2D
0238 ///
0239 /// @tparam aType the type of the first axis (Bound, Closed, Open)
0240 /// @tparam bType the type of the second axis (Bound, Closed, Open)
0241 ///
0242 template <Acts::AxisBoundaryType aType, Acts::AxisBoundaryType bType>
0243 struct VarVar {
0244   /// Broadcast the return_type
0245   using return_type = std::tuple<Acts::Axis<Acts::AxisType::Variable, aType>,
0246                                  Acts::Axis<Acts::AxisType::Variable, bType>>;
0247 
0248   /// Broadcast the grid type
0249   template <typename T>
0250   using grid_type = Acts::Grid<T, Acts::Axis<Acts::AxisType::Variable, aType>,
0251                                Acts::Axis<Acts::AxisType::Variable, bType>>;
0252 
0253   std::vector<double> edges0 = {};
0254   std::vector<double> edges1 = {};
0255 
0256   /// Call operator that generates the Axis
0257   return_type operator()() const {
0258     Acts::Axis<Acts::AxisType::Variable, aType> varA(edges0);
0259     Acts::Axis<Acts::AxisType::Variable, bType> varB(edges1);
0260     return {varA, varB};
0261   }
0262 };
0263 
0264 // All 2D VarVar options
0265 using VarBoundVarBound =
0266     VarVar<Acts::AxisBoundaryType::Bound, Acts::AxisBoundaryType::Bound>;
0267 using VarBoundVarOpen =
0268     VarVar<Acts::AxisBoundaryType::Bound, Acts::AxisBoundaryType::Open>;
0269 using VarBoundVarClosed =
0270     VarVar<Acts::AxisBoundaryType::Bound, Acts::AxisBoundaryType::Closed>;
0271 using VarOpenVarBound =
0272     VarVar<Acts::AxisBoundaryType::Open, Acts::AxisBoundaryType::Bound>;
0273 using VarOpenVarOpen =
0274     VarVar<Acts::AxisBoundaryType::Open, Acts::AxisBoundaryType::Open>;
0275 using VarOpenVarClosed =
0276     VarVar<Acts::AxisBoundaryType::Open, Acts::AxisBoundaryType::Closed>;
0277 using VarClosedVarBound =
0278     VarVar<Acts::AxisBoundaryType::Closed, Acts::AxisBoundaryType::Bound>;
0279 using VarClosedVarOpen =
0280     VarVar<Acts::AxisBoundaryType::Closed, Acts::AxisBoundaryType::Open>;
0281 using VarClosedVarClosed =
0282     VarVar<Acts::AxisBoundaryType::Closed, Acts::AxisBoundaryType::Closed>;
0283 
0284 // Generate the possible axes in this case
0285 using PossibleAxes =
0286     TypeList<EqBound, EqOpen, EqClosed,
0287              // All 1D Var  options
0288              VarBound, VarOpen, VarClosed,
0289              // All 2D EqEq options
0290              EqBoundEqBound, EqBoundEqOpen, EqBoundEqClosed, EqOpenEqBound,
0291              EqOpenEqOpen, EqOpenEqClosed, EqClosedEqBound, EqClosedEqOpen,
0292              EqClosedEqClosed,
0293              // All 2D EqVar options
0294              EqBoundVarBound, EqBoundVarOpen, EqBoundVarClosed, EqOpenVarBound,
0295              EqOpenVarOpen, EqOpenVarClosed, EqClosedVarBound, EqClosedVarOpen,
0296              EqClosedVarClosed,
0297              // All 2D VarEq options
0298              VarBoundEqBound, VarBoundEqOpen, VarBoundEqClosed, VarOpenEqBound,
0299              VarOpenEqOpen, VarOpenEqClosed, VarClosedEqBound, VarClosedEqOpen,
0300              VarClosedEqClosed,
0301              // All 2D VarEq options
0302              VarBoundVarBound, VarBoundVarOpen, VarBoundVarClosed,
0303              VarOpenVarBound, VarOpenVarOpen, VarOpenVarClosed,
0304              VarClosedVarBound, VarClosedVarOpen, VarClosedVarClosed>;
0305 
0306 }  // namespace Acts::GridAxisGenerators