Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-21 07:49:44

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 <iosfwd>
0012 #include <string>
0013 #include <vector>
0014 
0015 namespace Acts {
0016 
0017 /// @enum AxisDirection to specify a local axis direction
0018 enum class AxisDirection : int {
0019   /// AxisX, AxisY, AxisZ are the cartesian directions in the local frame
0020   AxisX = 0,
0021   AxisY = 1,
0022   AxisZ = 2,
0023   /// AxisR is a radial direction
0024   AxisR = 3,
0025   /// AxisPhi is the azimuthal direction
0026   AxisPhi = 4,
0027   /// AxisRPhi is the radial-azimuthal direction
0028   AxisRPhi = 5,
0029   /// AxisTheta is the polar angle direction
0030   AxisTheta = 6,
0031   /// AxisEta is the pseudorapidity direction
0032   AxisEta = 7,
0033   /// AxisMag is the magnitude of the vector
0034   AxisMag = 8
0035 };
0036 
0037 /// Get all possible axis directions
0038 /// @return a vector of all possible axis directions
0039 const std::vector<AxisDirection>& allAxisDirections();
0040 
0041 /// Returns the total number of axis directions
0042 /// @return the number of axis directions
0043 constexpr std::size_t numAxisDirections() {
0044   return 9;
0045 }
0046 
0047 /// Get an axis direction from its string name
0048 ///
0049 /// @param name is the name of the axis direction
0050 /// @return the axis direction
0051 AxisDirection axisDirectionFromName(const std::string& name);
0052 
0053 /// Get the name of a binning value as a string
0054 /// @param aDir is the binning value
0055 /// @return the name of the binning value
0056 const std::string& axisDirectionName(AxisDirection aDir);
0057 
0058 /// Output stream operator for @c AxisDirection
0059 /// @param os is the output stream
0060 /// @param aDir is the axis direction
0061 /// @return the output stream
0062 std::ostream& operator<<(std::ostream& os, AxisDirection aDir);
0063 
0064 /// Get the name of a vector of binning values as a string
0065 /// @param manyDir is the vector of binning values
0066 /// @return the name of the binning value
0067 std::string axesDirectionName(const std::vector<AxisDirection>& manyDir);
0068 
0069 /// Output stream operator for a vector of @c AxisDirection
0070 /// @param os is the output stream
0071 /// @param manyDir is the vector of axis directions
0072 /// @return the output stream
0073 std::ostream& operator<<(std::ostream& os,
0074                          const std::vector<AxisDirection>& manyDir);
0075 
0076 /// Enum which determines how the axis handle its outer boundaries
0077 /// possible values values
0078 enum class AxisBoundaryType {
0079   /// Default behaviour: out of bounds
0080   /// positions are filled into the over or underflow bins
0081   Open,
0082   /// Out-of-bounds positions resolve to first/last bin
0083   /// respectively
0084   Bound,
0085   /// Out-of-bounds positions resolve to the outermost
0086   /// bin on the opposite side
0087   Closed,
0088 };
0089 
0090 /// Tag helper type for Axis constructors with class template deduction
0091 /// @tparam bdt the boundary type
0092 template <AxisBoundaryType bdt>
0093 struct AxisBoundaryTypeTag {};
0094 
0095 /// Convenience typedefs for AxisBoundaryTypeTag
0096 /// Constant for open boundary type axis
0097 constexpr auto AxisOpen = AxisBoundaryTypeTag<AxisBoundaryType::Open>{};
0098 /// Constant for bound boundary type axis
0099 constexpr auto AxisBound = AxisBoundaryTypeTag<AxisBoundaryType::Bound>{};
0100 /// Constant for closed boundary type axis
0101 constexpr auto AxisClosed = AxisBoundaryTypeTag<AxisBoundaryType::Closed>{};
0102 
0103 /// Stream operator for AxisBoundaryType
0104 /// @param os Output stream
0105 /// @param bdt AxisBoundaryType to output
0106 /// @return Reference to output stream
0107 std::ostream& operator<<(std::ostream& os, AxisBoundaryType bdt);
0108 
0109 /// Enum which determines the binning type of the axis
0110 enum class AxisType {
0111   /// An axis where all bins have the same size
0112   Equidistant,
0113   /// An axis where bins can have different sizes
0114   Variable,
0115 };
0116 
0117 /// Stream operator for AxisType
0118 /// @param os Output stream
0119 /// @param type AxisType to output
0120 /// @return Reference to output stream
0121 std::ostream& operator<<(std::ostream& os, AxisType type);
0122 
0123 /// @brief calculate bin indices from a given binning structure
0124 ///
0125 /// This class provides some basic functionality for calculating bin indices
0126 /// for a given binning configuration. Both equidistant as well as variable
0127 /// binning structures are supported.
0128 ///
0129 /// Bin intervals are defined such that the lower bound is closed and the
0130 /// upper bound is open.
0131 ///
0132 /// @tparam equidistant flag whether binning is equidistant (@c true)
0133 ///                     or not (@c false)
0134 template <AxisType type, AxisBoundaryType bdt = AxisBoundaryType::Open>
0135 class Axis;
0136 
0137 /// Deduction guide for equidistant axis with open boundaries
0138 /// @param min Minimum value
0139 /// @param max Maximum value
0140 /// @param bins Number of bins
0141 Axis(double min, double max, std::size_t bins)
0142     -> Axis<AxisType::Equidistant, AxisBoundaryType::Open>;
0143 
0144 /// Deduction guide for equidistant axis with specified boundary type
0145 /// @param min Minimum value
0146 /// @param max Maximum value
0147 /// @param bins Number of bins
0148 template <AxisBoundaryType bdt>
0149 Axis(AxisBoundaryTypeTag<bdt> /*bdt*/, double min, double max, std::size_t bins)
0150     -> Axis<AxisType::Equidistant, bdt>;
0151 
0152 /// Deduction guide for variable axis with open boundaries
0153 /// @param bins Vector of bin edges
0154 Axis(std::vector<double> bins)
0155     -> Axis<AxisType::Variable, AxisBoundaryType::Open>;
0156 
0157 /// Deduction guide for variable axis with specified boundary type
0158 /// @param bins Vector of bin edges
0159 template <AxisBoundaryType bdt>
0160 Axis(AxisBoundaryTypeTag<bdt> /*bdt*/, std::vector<double> bins)
0161     -> Axis<AxisType::Variable, bdt>;
0162 
0163 }  // namespace Acts