3 #include <alpaka/alpaka.hpp> 11 using namespace particleFlowRecHitProducer;
14 template <
typename CAL>
16 template <
typename TAcc,
typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
18 const typename CAL::ParameterType::ConstView
params,
19 const typename CAL::CaloRecHitSoATypeDevice::ConstView
recHits,
21 uint32_t* __restrict__ denseId2pfRecHit,
22 uint32_t* __restrict__ num_pfRecHits)
const {
35 constructPFRecHit(pfRecHits[
j],
recHits[
i]);
38 denseId2pfRecHit[CAL::detId2denseId(pfRecHits.detId(
j))] =
j;
42 ALPAKA_FN_ACC
static bool applyCuts(
const typename CAL::CaloRecHitSoATypeDevice::ConstView::const_element rh,
43 const typename CAL::ParameterType::ConstView
params);
45 ALPAKA_FN_ACC
static void constructPFRecHit(
46 reco::PFRecHitDeviceCollection::View::element pfrh,
47 const typename CAL::CaloRecHitSoATypeDevice::ConstView::const_element rh);
52 const typename HCAL::CaloRecHitSoATypeDevice::ConstView::const_element rh,
56 const uint32_t
detId = rh.detId();
64 printf(
"Rechit with detId %u has invalid subdetector %u!\n",
detId, subdet);
78 if ((
ECAL::checkFlag(rh.flags(), ECAL::Flags::kOutOfTime) && rh.energy() >
params.cleaningThreshold()) ||
88 reco::PFRecHitDeviceCollection::View::element pfrh,
89 const HCAL::CaloRecHitSoATypeDevice::ConstView::const_element rh) {
90 pfrh.detId() = rh.detId();
91 pfrh.energy() = rh.energy();
92 pfrh.time() = rh.time();
94 const uint32_t subdet =
getSubdet(pfrh.detId());
105 reco::PFRecHitDeviceCollection::View::element pfrh,
106 const ECAL::CaloRecHitSoATypeDevice::ConstView::const_element rh) {
107 pfrh.detId() = rh.detId();
108 pfrh.energy() = rh.energy();
109 pfrh.time() = rh.time();
111 const uint32_t subdet =
getSubdet(pfrh.detId());
121 template <
typename CAL>
123 template <
typename TAcc,
typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
125 const typename CAL::TopologyTypeDevice::ConstView topology,
127 const uint32_t* __restrict__ denseId2pfRecHit,
128 uint32_t* __restrict__ num_pfRecHits)
const {
130 if (
const int32_t thread = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc)[0u]; thread == 0)
131 pfRecHits.size() = *num_pfRecHits;
135 const uint32_t denseId = CAL::detId2denseId(pfRecHits.detId(
i));
137 pfRecHits.x(
i) = topology.positionX(denseId);
138 pfRecHits.y(
i) = topology.positionY(denseId);
139 pfRecHits.z(
i) = topology.positionZ(denseId);
141 for (uint32_t
n = 0;
n < 8;
n++) {
142 pfRecHits.neighbours(
i)(
n) = -1;
143 const uint32_t denseId_neighbour = topology.neighbours(denseId)(
n);
144 if (denseId_neighbour != 0xffffffff) {
145 const uint32_t pfRecHit_neighbour = denseId2pfRecHit[denseId_neighbour];
146 if (pfRecHit_neighbour != 0xffffffff)
147 pfRecHits.neighbours(
i)(
n) = (int32_t)pfRecHit_neighbour;
154 template <
typename CAL>
162 const uint32_t
items = 64;
167 template <
typename CAL>
169 const typename CAL::CaloRecHitSoATypeDevice&
recHits,
172 alpaka::exec<Acc1D>(
queue,
178 denseId2pfRecHit_.data(),
179 num_pfRecHits_.data());
182 template <
typename CAL>
184 const typename CAL::TopologyTypeDevice& topology,
186 alpaka::exec<Acc1D>(
queue,
191 denseId2pfRecHit_.data(),
192 num_pfRecHits_.data());
constexpr uint32_t getSubdet(uint32_t detId)
void processRecHits(Queue &queue, const typename CAL::CaloRecHitSoATypeDevice &recHits, const typename CAL::ParameterType ¶ms, reco::PFRecHitDeviceCollection &pfRecHits)
cms::alpakatools::device_buffer< Device, uint32_t > num_pfRecHits_
void associateTopologyInfo(Queue &queue, const typename CAL::TopologyTypeDevice &topology, reco::PFRecHitDeviceCollection &pfRecHits)
PFRecHitProducerKernel(Queue &queue, const uint32_t num_recHits)
ALPAKA_FN_ACC void operator()(const TAcc &acc, const typename CAL::TopologyTypeDevice::ConstView topology, reco::PFRecHitDeviceCollection::View pfRecHits, const uint32_t *__restrict__ denseId2pfRecHit, uint32_t *__restrict__ num_pfRecHits) const
static ALPAKA_FN_ACC void constructPFRecHit(reco::PFRecHitDeviceCollection::View::element pfrh, const typename CAL::CaloRecHitSoATypeDevice::ConstView::const_element rh)
typename Layout::ConstView ConstView
static constexpr uint32_t detId2denseId(uint32_t detId)
typename Layout::View View
ALPAKA_FN_ACC void operator()(const TAcc &acc, const typename CAL::ParameterType::ConstView params, const typename CAL::CaloRecHitSoATypeDevice::ConstView recHits, reco::PFRecHitDeviceCollection::View pfRecHits, uint32_t *__restrict__ denseId2pfRecHit, uint32_t *__restrict__ num_pfRecHits) const
static constexpr bool checkFlag(uint32_t flagBits, int flag)
T1 atomicInc(T1 *a, T2 b)
std::vector< Block > Blocks
static constexpr uint32_t kMaxDepthHB
static ALPAKA_FN_ACC bool applyCuts(const typename CAL::CaloRecHitSoATypeDevice::ConstView::const_element rh, const typename CAL::ParameterType::ConstView params)
WorkDiv< Dim1D > work_div_
Namespace of DDCMS conversion namespace.
static constexpr uint32_t getDepth(uint32_t detId)
cms::alpakatools::device_buffer< Device, uint32_t[]> denseId2pfRecHit_