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();
72 printf(
"Encountered invalid denseId for detId %u (subdetector %u)!",
detId, subdet);
81 printf(
"Rechit with detId %u has invalid subdetector %u!\n",
detId, subdet);
90 const ECAL::CaloRecHitSoATypeDevice::ConstView::const_element rh,
91 const ECAL::ParameterType::ConstView
params,
92 const ECAL::TopologyTypeDevice::ConstView
topology) {
98 if ((
ECAL::checkFlag(rh.flags(), ECAL::Flags::kOutOfTime) && rh.energy() >
params.cleaningThreshold()) ||
108 reco::PFRecHitDeviceCollection::View::element pfrh,
109 const HCAL::CaloRecHitSoATypeDevice::ConstView::const_element rh) {
110 pfrh.detId() = rh.detId();
112 pfrh.energy() = rh.energy();
113 pfrh.time() = rh.timeM0();
115 const uint32_t subdet =
getSubdet(pfrh.detId());
126 reco::PFRecHitDeviceCollection::View::element pfrh,
127 const ECAL::CaloRecHitSoATypeDevice::ConstView::const_element rh) {
128 pfrh.detId() = rh.detId();
130 pfrh.energy() = rh.energy();
131 pfrh.time() = rh.time();
133 const uint32_t subdet =
getSubdet(pfrh.detId());
143 template <
typename CAL>
145 template <
typename TAcc,
typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
147 const typename CAL::TopologyTypeDevice::ConstView
topology,
149 const uint32_t* __restrict__ denseId2pfRecHit,
150 uint32_t* __restrict__ num_pfRecHits)
const {
152 if (
const int32_t thread = alpaka::getIdx<alpaka::Grid, alpaka::Threads>(acc)[0u]; thread == 0)
157 const uint32_t denseId = CAL::detId2denseId(
pfRecHits.detId(
i));
163 for (uint32_t
n = 0;
n < 8;
n++) {
165 const uint32_t denseId_neighbour =
topology.neighbours(denseId)(
n);
166 if (denseId_neighbour != CAL::kInvalidDenseId) {
167 const uint32_t pfRecHit_neighbour = denseId2pfRecHit[denseId_neighbour];
168 if (pfRecHit_neighbour != 0xffffffff)
169 pfRecHits.neighbours(
i)(
n) = (int32_t)pfRecHit_neighbour;
176 template <
typename CAL>
184 const uint32_t
items = 64;
189 template <
typename CAL>
191 const typename CAL::CaloRecHitSoATypeDevice&
recHits,
193 const typename CAL::TopologyTypeDevice&
topology,
195 alpaka::exec<Acc1D>(
queue,
202 denseId2pfRecHit_.data(),
203 num_pfRecHits_.data());
206 template <
typename CAL>
208 const typename CAL::TopologyTypeDevice&
topology,
210 alpaka::exec<Acc1D>(
queue,
215 denseId2pfRecHit_.data(),
216 num_pfRecHits_.data());
constexpr uint32_t getSubdet(uint32_t detId)
static constexpr uint32_t kInvalidDenseId
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)