From bcbae482c6174e740062ac6f4a982a74c2e0707d Mon Sep 17 00:00:00 2001 From: jsamudio Date: Sun, 16 Jun 2024 06:32:15 -0500 Subject: [PATCH] Produce HCAL rechit SoA in CaloRecHitSoAProducer Revert column name to detId Code checks and formatting --- .../plugins/alpaka/CaloRecHitSoAProducer.cc | 41 +++++++++++-------- .../plugins/alpaka/CalorimeterDefinitions.h | 7 +++- .../alpaka/PFRecHitProducerKernel.dev.cc | 2 +- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/CaloRecHitSoAProducer.cc b/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/CaloRecHitSoAProducer.cc index c9e7646f519b9..9a912d65e9954 100644 --- a/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/CaloRecHitSoAProducer.cc +++ b/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/CaloRecHitSoAProducer.cc @@ -14,6 +14,9 @@ #include "HeterogeneousCore/AlpakaCore/interface/alpaka/global/EDProducer.h" #include "CalorimeterDefinitions.h" +#include "DataFormats/HcalRecHit/interface/HcalRecHitHostCollection.h" +#include "DataFormats/HcalRecHit/interface/alpaka/HcalRecHitDeviceCollection.h" + #define DEBUG false namespace ALPAKA_ACCELERATOR_NAMESPACE { @@ -25,12 +28,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { CaloRecHitSoAProducer(edm::ParameterSet const& config) : recHitsToken_(consumes(config.getParameter("src"))), deviceToken_(produces()), - synchronise_(config.getUntrackedParameter("synchronise")) { - // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed -#ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED - producesTemporarily("edm::DeviceProduct"); -#endif - } + synchronise_(config.getUntrackedParameter("synchronise")) {} void produce(edm::StreamID sid, device::Event& event, device::EventSetup const&) const override { const edm::SortedCollection& recHits = event.get(recHitsToken_); @@ -38,17 +36,17 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { if (DEBUG) printf("Found %d recHits\n", num_recHits); - reco::CaloRecHitHostCollection hostProduct{num_recHits, event.queue()}; + hcal::RecHitHostCollection hostProduct{num_recHits, event.queue()}; auto& view = hostProduct.view(); for (int i = 0; i < num_recHits; i++) { convertRecHit(view[i], recHits[i]); if (DEBUG && i < 10) - printf("recHit %4d %u %f %f %08x\n", i, view.detId(i), view.energy(i), view.time(i), view.flags(i)); + printf("recHit %4d %u %f %f\n", i, view.detId(i), view.energy(i), view.timeM0(i)); } - reco::CaloRecHitDeviceCollection deviceProduct{num_recHits, event.queue()}; + hcal::RecHitDeviceCollection deviceProduct{num_recHits, event.queue()}; alpaka::memcpy(event.queue(), deviceProduct.buffer(), hostProduct.buffer()); if (synchronise_) alpaka::wait(event.queue()); @@ -65,23 +63,29 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { private: const edm::EDGetTokenT> recHitsToken_; - const device::EDPutToken deviceToken_; + const device::EDPutToken deviceToken_; const bool synchronise_; - static void convertRecHit(reco::CaloRecHitHostCollection::View::element to, - const typename CAL::CaloRecHitType& from); + static void convertRecHit(hcal::RecHitHostCollection::View::element to, const typename CAL::CaloRecHitType& from); }; template <> - void CaloRecHitSoAProducer::convertRecHit(reco::CaloRecHitHostCollection::View::element to, + void CaloRecHitSoAProducer::convertRecHit(hcal::RecHitHostCollection::View::element to, const HCAL::CaloRecHitType& from) { // Fill SoA from HCAL rec hit to.detId() = from.id().rawId(); to.energy() = from.energy(); - to.time() = from.time(); - to.flags() = from.flags(); + to.timeM0() = from.time(); } + /* + The ECALRecHitSoAProducer currently has no use, but is available via this + module. In the case where ECAL PF Clustering is moved to Alpaka, we can then + decide to use this converted solely for ECAL, or if the SoA is available + we can switch to using just the ECAL RecHit SoA. + */ + + /* template <> void CaloRecHitSoAProducer::convertRecHit(reco::CaloRecHitHostCollection::View::element to, const ECAL::CaloRecHitType& from) { @@ -91,11 +95,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { to.time() = from.time(); to.flags() = from.flagsBits(); } + */ using HCALRecHitSoAProducer = CaloRecHitSoAProducer; - using ECALRecHitSoAProducer = CaloRecHitSoAProducer; + + // Purposely commented out; see above. + //using ECALRecHitSoAProducer = CaloRecHitSoAProducer; } // namespace ALPAKA_ACCELERATOR_NAMESPACE #include "HeterogeneousCore/AlpakaCore/interface/alpaka/MakerMacros.h" DEFINE_FWK_ALPAKA_MODULE(HCALRecHitSoAProducer); -DEFINE_FWK_ALPAKA_MODULE(ECALRecHitSoAProducer); +//DEFINE_FWK_ALPAKA_MODULE(ECALRecHitSoAProducer); diff --git a/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/CalorimeterDefinitions.h b/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/CalorimeterDefinitions.h index 26b8838c46c62..39f8559abb811 100644 --- a/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/CalorimeterDefinitions.h +++ b/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/CalorimeterDefinitions.h @@ -15,6 +15,9 @@ #include "RecoParticleFlow/PFRecHitProducer/interface/alpaka/PFRecHitParamsDeviceCollection.h" #include "RecoParticleFlow/PFRecHitProducer/interface/alpaka/PFRecHitTopologyDeviceCollection.h" +#include "DataFormats/HcalRecHit/interface/HcalRecHitHostCollection.h" +#include "DataFormats/HcalRecHit/interface/alpaka/HcalRecHitDeviceCollection.h" + // Forward declaration of EventSetup records, to avoid propagating the dependency on framework headers to device code class PFRecHitHCALParamsRecord; class PFRecHitHCALTopologyRecord; @@ -34,8 +37,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::particleFlowRecHitProducer { struct HCAL { using CaloRecHitType = HBHERecHit; - using CaloRecHitSoATypeHost = reco::CaloRecHitHostCollection; - using CaloRecHitSoATypeDevice = reco::CaloRecHitDeviceCollection; + using CaloRecHitSoATypeHost = hcal::RecHitHostCollection; + using CaloRecHitSoATypeDevice = hcal::RecHitDeviceCollection; using ParameterType = reco::PFRecHitHCALParamsDeviceCollection; using ParameterRecordType = PFRecHitHCALParamsRecord; using TopologyTypeHost = reco::PFRecHitHCALTopologyHostCollection; diff --git a/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/PFRecHitProducerKernel.dev.cc b/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/PFRecHitProducerKernel.dev.cc index 48230571b7d54..40d7b2315c818 100644 --- a/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/PFRecHitProducerKernel.dev.cc +++ b/RecoParticleFlow/PFRecHitProducer/plugins/alpaka/PFRecHitProducerKernel.dev.cc @@ -99,7 +99,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { pfrh.detId() = rh.detId(); pfrh.denseId() = HCAL::detId2denseId(rh.detId()); pfrh.energy() = rh.energy(); - pfrh.time() = rh.time(); + pfrh.time() = rh.timeM0(); pfrh.depth() = HCAL::getDepth(pfrh.detId()); const uint32_t subdet = getSubdet(pfrh.detId()); if (subdet == HcalBarrel)