Back to home page

EIC code displayed by LXR

 
 

    


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

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/Definitions/Algebra.hpp"
0012 #include "Acts/Utilities/BinUtility.hpp"
0013 
0014 #include <array>
0015 #include <vector>
0016 
0017 namespace Acts {
0018 
0019 ///  @class BinnedArray
0020 ///
0021 /// Pure virtual base class for Binned Array to avoid map searches
0022 /// - there is only one restriction:
0023 ///   T must be of pointer type in order to be initialized with nullptr
0024 ///   and to allow for nullptr return type
0025 ///
0026 /// - the BinnedArray is designed for 0D, 1D, 2D, and 3D binning
0027 template <class T>
0028 class BinnedArray {
0029  public:
0030   /// Default Constructor - needed for inherited classes
0031   BinnedArray() = default;
0032   /// Virtual Destructor
0033   virtual ~BinnedArray() = default;
0034   /// Returns the object in the associated bin according the local position
0035   ///
0036   /// @param lposition is the local position for the object retrieval
0037   /// @param bins is the bin triple to filled
0038   ///
0039   /// @return the object according to the estimated bin
0040   virtual T object(const Vector2& lposition,
0041                    std::array<std::size_t, 3>& bins) const = 0;
0042 
0043   /// Same method without bins for backward compatibility
0044   ///
0045   /// @param lposition is the local position for finding the object
0046   ///
0047   /// @return the object according to the estimated bin
0048   virtual T object(const Vector2& lposition) const {
0049     std::array<std::size_t, 3> bins{};
0050     return object(lposition, bins);
0051   }
0052 
0053   /// Returns the object in the associated bin according the local position
0054   ///
0055   /// @param position is the global position for the object retrieval
0056   /// @param bin is the bin triple filled
0057   ///
0058   /// @return the object according to the estimated bin
0059   virtual T object(const Vector3& position,
0060                    std::array<std::size_t, 3>& bin) const = 0;
0061 
0062   /// Same method without bins for backward compatibility
0063   ///
0064   /// @param position is the global position for the object finding
0065   ///
0066   /// @return the object according to the estimated bin
0067   virtual T object(const Vector3& position) const {
0068     std::array<std::size_t, 3> bins{};
0069     return object(position, bins);
0070   }
0071 
0072   /// Return all unique object
0073   /// @note this is the accessor to the
0074   /// @return the vector of all array objects
0075   virtual const std::vector<T>& arrayObjects() const = 0;
0076 
0077   /// Return the object grid multiple entries are allowed
0078   /// @return the object grid
0079   virtual const std::vector<std::vector<std::vector<T>>>& objectGrid()
0080       const = 0;
0081 
0082   /// Return the BinUtility
0083   /// - if returned 0 it is a 0D array
0084   /// @return plain pointer to the bin utility
0085   virtual const BinUtility* binUtility() const = 0;
0086 };
0087 
0088 }  // namespace Acts