File indexing completed on 2024-07-03 04:17:36
0001 #ifndef CondFormats_HcalObjects_interface_HcalRecoParamWithPulseShapeHostT_h
0002 #define CondFormats_HcalObjects_interface_HcalRecoParamWithPulseShapeHostT_h
0003
0004 #include "CondFormats/HcalObjects/interface/HcalRecoParamWithPulseShapeSoA.h"
0005 #include "DataFormats/Portable/interface/PortableCollection.h"
0006 #include "DataFormats/Portable/interface/PortableHostCollection.h"
0007
0008 namespace hcal {
0009 template <typename TDev>
0010 class HcalRecoParamWithPulseShapeT {
0011 public:
0012 using RecoParamCollection = PortableCollection<HcalRecoParamSoA, TDev>;
0013 using PulseShapeCollection = PortableCollection<HcalPulseShapeSoA, TDev>;
0014
0015 using PulseShapeConstElement = typename PulseShapeCollection::ConstView::const_element;
0016
0017 class ConstView {
0018 public:
0019 using RecoParamConstView = typename RecoParamCollection::ConstView;
0020 using PulseShapeConstView = typename PulseShapeCollection::ConstView;
0021 constexpr ConstView(RecoParamConstView recoView, PulseShapeConstView psView)
0022 : recoParamView_{recoView}, pulseShapeView_{psView} {};
0023
0024 ALPAKA_FN_ACC PulseShapeConstElement getPulseShape(uint32_t const hashedId) const {
0025 auto const recoPulseShapeId = recoParamView_.ids()[hashedId];
0026 return pulseShapeView_[recoPulseShapeId];
0027 }
0028
0029 constexpr typename RecoParamCollection::ConstView recoParamView() { return recoParamView_; }
0030
0031 private:
0032 typename RecoParamCollection::ConstView recoParamView_;
0033 typename PulseShapeCollection::ConstView pulseShapeView_;
0034 };
0035
0036 HcalRecoParamWithPulseShapeT(size_t recoSize, size_t pulseSize, TDev const& dev)
0037 : recoParam_(recoSize, dev), pulseShape_(pulseSize, dev) {}
0038 template <typename TQueue, typename = std::enable_if_t<alpaka::isQueue<TQueue>>>
0039 HcalRecoParamWithPulseShapeT(size_t recoSize, size_t pulseSize, TQueue const& queue)
0040 : recoParam_(recoSize, queue), pulseShape_(pulseSize, queue) {}
0041 HcalRecoParamWithPulseShapeT(RecoParamCollection reco, PulseShapeCollection pulse)
0042 : recoParam_(std::move(reco)), pulseShape_(std::move(pulse)) {}
0043
0044 const RecoParamCollection& recoParam() const { return recoParam_; }
0045 const PulseShapeCollection& pulseShape() const { return pulseShape_; }
0046
0047 typename RecoParamCollection::View recoParamView() { return recoParam_.view(); }
0048 typename PulseShapeCollection::View pulseShapeView() { return pulseShape_.view(); }
0049
0050 ConstView const_view() const { return ConstView(recoParam_.view(), pulseShape_.view()); }
0051
0052 private:
0053 RecoParamCollection recoParam_;
0054 PulseShapeCollection pulseShape_;
0055 };
0056 }
0057 #endif