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::TopologyTypeDevice::ConstView
topology,
20 const typename CAL::CaloRecHitSoATypeDevice::ConstView
recHits,
22 uint32_t* __restrict__ denseId2pfRecHit,
23 uint32_t* __restrict__ num_pfRecHits)
const {
39 denseId2pfRecHit[CAL::detId2denseId(
pfRecHits.detId(
j))] =
j;
43 ALPAKA_FN_ACC
static bool applyCuts(
const typename CAL::CaloRecHitSoATypeDevice::ConstView::const_element rh,
44 const typename CAL::ParameterType::ConstView
params,
45 const typename CAL::TopologyTypeDevice::ConstView
topology);
47 ALPAKA_FN_ACC
static void constructPFRecHit(
48 reco::PFRecHitDeviceCollection::View::element pfrh,
49 const typename CAL::CaloRecHitSoATypeDevice::ConstView::const_element rh);
54 const typename HCAL::CaloRecHitSoATypeDevice::ConstView::const_element rh,
55 const HCAL::ParameterType::ConstView
params,
56 const HCAL::TopologyTypeDevice::ConstView
topology) {
59 const uint32_t
detId = rh.detId();
70 printf(
"Rechit with detId %u has invalid subdetector %u!\n",
detId, subdet);
79 const ECAL::CaloRecHitSoATypeDevice::ConstView::const_element rh,
80 const ECAL::ParameterType::ConstView
params,
81 const ECAL::TopologyTypeDevice::ConstView
topology) {
87 if ((
ECAL::checkFlag(rh.flags(), ECAL::Flags::kOutOfTime) && rh.energy() >
params.cleaningThreshold()) ||
97 reco::PFRecHitDeviceCollection::View::element pfrh,
98 const HCAL::CaloRecHitSoATypeDevice::ConstView::const_element rh) {
99 pfrh.detId() = rh.detId();
101 pfrh.energy() = rh.energy();
102 pfrh.time() = rh.time();
104 const uint32_t subdet =
getSubdet(pfrh.detId());
115 reco::PFRecHitDeviceCollection::View::element pfrh,
116 const ECAL::CaloRecHitSoATypeDevice::ConstView::const_element rh) {
117 pfrh.detId() = rh.detId();
119 pfrh.energy() = rh.energy();
120 pfrh.time() = rh.time();
122 const uint32_t subdet =
getSubdet(pfrh.detId());
132 template <
typename CAL>
134 template <
typename TAcc,
typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
136 const typename CAL::TopologyTypeDevice::ConstView
topology,
138 const uint32_t* __restrict__ denseId2pfRecHit,
139 uint32_t* __restrict__ num_pfRecHits)
const {
141 if (
const int32_t thread = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc)[0u]; thread == 0)
146 const uint32_t denseId = CAL::detId2denseId(
pfRecHits.detId(
i));
152 for (uint32_t
n = 0;
n < 8;
n++) {
154 const uint32_t denseId_neighbour =
topology.neighbours(denseId)(
n);
155 if (denseId_neighbour != 0xffffffff) {
156 const uint32_t pfRecHit_neighbour = denseId2pfRecHit[denseId_neighbour];
157 if (pfRecHit_neighbour != 0xffffffff)
158 pfRecHits.neighbours(
i)(
n) = (int32_t)pfRecHit_neighbour;
165 template <
typename CAL>
173 const uint32_t
items = 64;
178 template <
typename CAL>
180 const typename CAL::CaloRecHitSoATypeDevice&
recHits,
182 const typename CAL::TopologyTypeDevice&
topology,
184 alpaka::exec<Acc1D>(
queue,
191 denseId2pfRecHit_.data(),
192 num_pfRecHits_.data());
195 template <
typename CAL>
197 const typename CAL::TopologyTypeDevice&
topology,
199 alpaka::exec<Acc1D>(
queue,
204 denseId2pfRecHit_.data(),
205 num_pfRecHits_.data());
constexpr uint32_t getSubdet(uint32_t detId)
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)
static constexpr uint32_t detId2denseId(uint32_t detId)
PortableCollection<::reco::PFRecHitSoA > PFRecHitDeviceCollection
static constexpr bool checkFlag(uint32_t flagBits, int flag)
T1 atomicInc(T1 *a, T2 b)
std::vector< Block > Blocks
static constexpr uint32_t kMaxDepthHB
WorkDiv< Dim1D > work_div_
Namespace of DDCMS conversion namespace.
static constexpr uint32_t getDepth(uint32_t detId)
static ALPAKA_FN_ACC bool applyCuts(const typename CAL::CaloRecHitSoATypeDevice::ConstView::const_element rh, const typename CAL::ParameterType::ConstView params, const typename CAL::TopologyTypeDevice::ConstView topology)
void processRecHits(Queue &queue, const typename CAL::CaloRecHitSoATypeDevice &recHits, const typename CAL::ParameterType ¶ms, const typename CAL::TopologyTypeDevice &topology, reco::PFRecHitDeviceCollection &pfRecHits)
cms::alpakatools::device_buffer< Device, uint32_t[]> denseId2pfRecHit_
ALPAKA_FN_ACC void operator()(const TAcc &acc, const typename CAL::ParameterType::ConstView params, const typename CAL::TopologyTypeDevice::ConstView topology, const typename CAL::CaloRecHitSoATypeDevice::ConstView recHits, reco::PFRecHitDeviceCollection::View pfRecHits, uint32_t *__restrict__ denseId2pfRecHit, uint32_t *__restrict__ num_pfRecHits) const
static constexpr uint32_t detId2denseId(uint32_t detId)