File indexing completed on 2024-10-10 23:05:29
0001 #ifndef RecoTracker_MkFitCore_src_MatriplexPackers_h
0002 #define RecoTracker_MkFitCore_src_MatriplexPackers_h
0003
0004 #include "Matrix.h"
0005
0006 #include "RecoTracker/MkFitCore/interface/Hit.h"
0007 #include "RecoTracker/MkFitCore/interface/Track.h"
0008
0009 namespace mkfit {
0010
0011
0012
0013
0014
0015 template <typename D>
0016 class MatriplexPackerSlurpIn {
0017 protected:
0018 alignas(64) int m_idx[NN];
0019
0020 const D* m_base;
0021 int m_pos;
0022
0023 public:
0024 MatriplexPackerSlurpIn(const D* base) : m_base(base), m_pos(0) {}
0025
0026 void reset() { m_pos = 0; }
0027
0028 int size() const { return m_pos; }
0029
0030 void addNullInput() { m_idx[m_pos++] = 0; }
0031
0032 void addInput(const D& item) {
0033
0034
0035 m_idx[m_pos] = &item - m_base;
0036
0037 ++m_pos;
0038 }
0039
0040 void addInputAt(int pos, const D& item) {
0041 while (m_pos < pos) {
0042
0043
0044 m_idx[m_pos++] = 0;
0045 }
0046
0047 addInput(item);
0048 }
0049
0050 template <typename TM>
0051 void pack(TM& mplex, int base_offset) {
0052 assert(m_pos > 0 && m_pos <= NN);
0053
0054 #if defined(GATHER_INTRINSICS)
0055 GATHER_IDX_LOAD(vi, m_idx);
0056 mplex.slurpIn(m_base + base_offset, vi, D(), m_pos);
0057 #else
0058 mplex.slurpIn(m_base + base_offset, m_idx, m_pos);
0059 #endif
0060 }
0061 };
0062
0063
0064
0065
0066
0067
0068
0069 template <typename T, typename D>
0070 class MatriplexErrParPackerSlurpIn : public MatriplexPackerSlurpIn<D> {
0071 int m_off_param;
0072
0073 public:
0074 MatriplexErrParPackerSlurpIn(const T* t)
0075 : MatriplexPackerSlurpIn<D>(t ? t->errArray() : nullptr), m_off_param(t ? (t->posArray() - this->m_base) : 0) {}
0076
0077 void addInput(const T& item) {
0078
0079
0080 this->m_idx[this->m_pos] = item.errArray() - this->m_base;
0081
0082 ++this->m_pos;
0083 }
0084
0085 void addInputAt(int pos, const T& item) {
0086 while (this->m_pos < pos) {
0087
0088
0089 this->m_idx[this->m_pos++] = 0;
0090 }
0091
0092 addInput(item);
0093 }
0094
0095 template <typename TMerr, typename TMpar>
0096 void pack(TMerr& err, TMpar& par) {
0097 assert(this->m_base);
0098 assert(this->m_pos > 0 && this->m_pos <= NN);
0099
0100 #if defined(GATHER_INTRINSICS)
0101 GATHER_IDX_LOAD(vi, this->m_idx);
0102 err.slurpIn(this->m_base, vi, D(), this->m_pos);
0103 par.slurpIn(this->m_base + m_off_param, vi, D(), this->m_pos);
0104 #else
0105 err.slurpIn(this->m_base, this->m_idx, this->m_pos);
0106 par.slurpIn(this->m_base + m_off_param, this->m_idx, this->m_pos);
0107 #endif
0108 }
0109 };
0110
0111
0112
0113
0114
0115 template <typename T, typename D>
0116 class MatriplexTrackPackerPlexify
0117 {
0118 public:
0119 MatriplexTrackPackerPlexify(const T& t) {}
0120
0121 void reset() {}
0122
0123 void addNullInput() {}
0124
0125 void addInput(const T& item) {}
0126
0127 void addInputAt(int pos, const T& item) {}
0128
0129 template <typename TMerr, typename TMpar>
0130 void pack(TMerr& err, TMpar& par) {}
0131 };
0132
0133
0134
0135
0136
0137
0138
0139 using MatriplexHitPacker = MatriplexErrParPackerSlurpIn<Hit, float>;
0140 using MatriplexTrackPacker = MatriplexErrParPackerSlurpIn<TrackBase, float>;
0141
0142 using MatriplexHoTPacker = MatriplexPackerSlurpIn<HitOnTrack>;
0143 }
0144
0145 #endif