Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce kInvalidDenseId for ECAL and HCAL [14.0.x] #45239

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef RecoParticleFlow_PFRecHitProducer_interface_alpaka_CalorimeterDefinitions_h
#define RecoParticleFlow_PFRecHitProducer_interface_alpaka_CalorimeterDefinitions_h

#include <limits>

#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
Expand Down Expand Up @@ -97,6 +99,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::particleFlowRecHitProducer {
return retval + kSizeBarrel;
}

static constexpr uint32_t kInvalidDenseId = std::numeric_limits<uint32_t>::max();

static constexpr uint32_t detId2denseId(uint32_t detId) {
const uint32_t subdet = getSubdet(detId);
if (subdet == HcalBarrel)
Expand All @@ -105,7 +109,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::particleFlowRecHitProducer {
return detId2denseIdHE(detId);

printf("invalid detId: %u\n", detId);
return -1;
return kInvalidDenseId;
}
};

Expand Down Expand Up @@ -181,6 +185,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::particleFlowRecHitProducer {

static constexpr bool checkFlag(uint32_t flagBits, int flag) { return flagBits & (0x1 << flag); }

static constexpr uint32_t kInvalidDenseId = std::numeric_limits<uint32_t>::max();

static constexpr uint32_t detId2denseId(uint32_t detId) {
const uint32_t subdet = getSubdet(detId);
if (subdet == EcalBarrel)
Expand All @@ -189,7 +195,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::particleFlowRecHitProducer {
return Barrel::kSize + Endcap::denseIndex(detId);

printf("invalid detId: %u\n", detId);
return 0;
return kInvalidDenseId;
}

static constexpr bool detIdInRange(uint32_t detId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
for (uint32_t n = 0; n < 8; n++) {
pfRecHits.neighbours(i)(n) = -1;
const uint32_t denseId_neighbour = topology.neighbours(denseId)(n);
if (denseId_neighbour != 0xffffffff) {
if (denseId_neighbour != CAL::kInvalidDenseId) {
const uint32_t pfRecHit_neighbour = denseId2pfRecHit[denseId_neighbour];
if (pfRecHit_neighbour != 0xffffffff)
pfRecHits.neighbours(i)(n) = (int32_t)pfRecHit_neighbour;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
if (CAL::detIdInRange(neighDetId))
view.neighbours(denseId)(n) = CAL::detId2denseId(neighDetId);
else
view.neighbours(denseId)(n) = 0xffffffff;
view.neighbours(denseId)(n) = CAL::kInvalidDenseId;
}
}
}
Expand All @@ -107,13 +107,13 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
for (auto const detId : geom.getValidDetIds(CAL::kDetectorId, subdet)) {
const uint32_t denseId = CAL::detId2denseId(detId);
for (uint32_t n = 0; n < 8; n++) {
if (view.neighbours(denseId)[n] == 0xffffffff)
if (view.neighbours(denseId)[n] == CAL::kInvalidDenseId)
continue;
const ::reco::PFRecHitsTopologyNeighbours& neighboursOfNeighbour =
view.neighbours(view.neighbours(denseId)[n]);
if (std::find(neighboursOfNeighbour.begin(), neighboursOfNeighbour.end(), denseId) ==
neighboursOfNeighbour.end())
view.neighbours(denseId)[n] = 0xffffffff;
view.neighbours(denseId)[n] = CAL::kInvalidDenseId;
}
}
}
Expand Down