|
|
|||
File indexing completed on 2026-07-26 08:22:01
0001 /** TRACCC library, part of the ACTS project (R&D line) 0002 * 0003 * (c) 2020-2026 CERN for the benefit of the ACTS project 0004 * 0005 * Mozilla Public License Version 2.0 0006 */ 0007 0008 #pragma once 0009 0010 #include <algorithm> 0011 0012 #include "traccc/definitions/qualifiers.hpp" 0013 0014 namespace traccc { 0015 0016 /** Struct that helps taking a two-dimensional binning into 0017 * a serial binning for data storage. 0018 * 0019 * Serializers allow to create a memory local environment if 0020 * advantegeous. 0021 * 0022 **/ 0023 struct serializer2 { 0024 /** Create a serial bin from two individual bins 0025 * 0026 * @tparam faxis_t is the type of the first axis 0027 * @tparam saxis_t is the type of the second axis 0028 * 0029 * @param faxis the first axis 0030 * @param saxis the second axis, unused here 0031 * @param fbin first bin 0032 * @param sbin second bin 0033 * 0034 * @return a unsigned int for the memory storage 0035 */ 0036 template <typename faxis_t, typename saxis_t> 0037 DETRAY_HOST_DEVICE unsigned int serialize(const faxis_t &faxis, 0038 const saxis_t & /*saxis*/, 0039 unsigned int fbin, 0040 unsigned int sbin) const { 0041 unsigned int offset = sbin * faxis.bins(); 0042 return offset + fbin; 0043 } 0044 0045 /** Create a bin tuple from a serialized bin 0046 * 0047 * @tparam faxis_t is the type of the first axis 0048 * @tparam saxis_t is the type of the second axis 0049 * 0050 * @param faxis the first axis 0051 * @param saxis the second axis, unused here 0052 * @param serialbin the serial bin 0053 * 0054 * @return a 2-dim array of unsigned int 0055 */ 0056 template <typename faxis_t, typename saxis_t, 0057 template <typename, std::size_t> class array_t = std::array> 0058 DETRAY_HOST_DEVICE array_t<unsigned int, 2> deserialize( 0059 const faxis_t &faxis, const saxis_t & /*saxis*/, 0060 unsigned int serialbin) const { 0061 auto sbin = static_cast<unsigned int>(serialbin / faxis.bins()); 0062 unsigned int fbin = serialbin - sbin * faxis.bins(); 0063 return {fbin, sbin}; 0064 } 0065 }; 0066 0067 } // namespace traccc
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|