File indexing completed on 2024-07-03 04:18:12
0001 #include "DataFormats/PortableTestObjects/interface/alpaka/TestDeviceCollection.h"
0002 #include "FWCore/Framework/interface/ConsumesCollector.h"
0003 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0006 #include "FWCore/Utilities/interface/InputTag.h"
0007 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/stream/SynchronizingEDProducer.h"
0008 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/EDPutToken.h"
0009 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/ESGetToken.h"
0010 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0011 #include "HeterogeneousCore/AlpakaTest/interface/AlpakaESTestRecords.h"
0012 #include "HeterogeneousCore/AlpakaTest/interface/alpaka/AlpakaESTestData.h"
0013 #include "RecoLocalCalo/HGCalRecProducers/interface/HGCalTilesConstants.h"
0014 #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
0015 #include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h"
0016
0017 #include "DataFormats/HGCalReco/interface/HGCalSoARecHitsHostCollection.h"
0018 #include "DataFormats/HGCalReco/interface/alpaka/HGCalSoAClustersDeviceCollection.h"
0019 #include "DataFormats/HGCalReco/interface/alpaka/HGCalSoARecHitsExtraDeviceCollection.h"
0020 #include "DataFormats/HGCalReco/interface/HGCalSoAClusters.h"
0021 #include "RecoLocalCalo/HGCalRecProducers/interface/HGCalSoAClustersExtra.h"
0022 #include "HGCalLayerClustersSoAAlgoWrapper.h"
0023
0024 namespace ALPAKA_ACCELERATOR_NAMESPACE {
0025
0026 class HGCalSoALayerClustersProducer : public stream::SynchronizingEDProducer<> {
0027 public:
0028 HGCalSoALayerClustersProducer(edm::ParameterSet const& config)
0029 : getTokenDeviceRecHits_{consumes(config.getParameter<edm::InputTag>("hgcalRecHitsSoA"))},
0030 getTokenDeviceClusters_{consumes(config.getParameter<edm::InputTag>("hgcalRecHitsLayerClustersSoA"))},
0031 deviceTokenSoAClusters_{produces()},
0032 thresholdW0_(config.getParameter<double>("thresholdW0")),
0033 positionDeltaRho2_(config.getParameter<double>("positionDeltaRho2")) {}
0034
0035 ~HGCalSoALayerClustersProducer() override = default;
0036
0037 void acquire(device::Event const& iEvent, device::EventSetup const& iSetup) override {
0038
0039
0040
0041
0042 auto const& deviceInputClusters = iEvent.get(getTokenDeviceClusters_);
0043 auto const inputClusters_v = deviceInputClusters.view();
0044
0045
0046 auto device_numclusters = cms::alpakatools::make_device_view<const unsigned int>(
0047 alpaka::getDev(iEvent.queue()), inputClusters_v.numberOfClustersScalar());
0048 auto host_numclusters = cms::alpakatools::make_host_view<unsigned int>(num_clusters_);
0049 alpaka::memcpy(iEvent.queue(), host_numclusters, device_numclusters);
0050 }
0051
0052 void produce(device::Event& iEvent, device::EventSetup const& iSetup) override {
0053
0054 auto const& deviceInputRecHits = iEvent.get(getTokenDeviceRecHits_);
0055 auto const inputRechits_v = deviceInputRecHits.view();
0056
0057
0058
0059
0060
0061 auto const& deviceInputClusters = iEvent.get(getTokenDeviceClusters_);
0062 auto const inputClusters_v = deviceInputClusters.view();
0063
0064 HGCalSoAClustersDeviceCollection output(num_clusters_, iEvent.queue());
0065 auto output_v = output.view();
0066
0067 HGCalSoAClustersExtraDeviceCollection outputWorkspace(num_clusters_, iEvent.queue());
0068 auto output_workspace_v = outputWorkspace.view();
0069
0070 algo_.run(iEvent.queue(),
0071 num_clusters_,
0072 thresholdW0_,
0073 positionDeltaRho2_,
0074 inputRechits_v,
0075 inputClusters_v,
0076 output_v,
0077 output_workspace_v);
0078 iEvent.emplace(deviceTokenSoAClusters_, std::move(output));
0079 }
0080
0081 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0082 edm::ParameterSetDescription desc;
0083 desc.add<edm::InputTag>("hgcalRecHitsLayerClustersSoA", edm::InputTag("TO BE DEFINED"));
0084 desc.add<edm::InputTag>("hgcalRecHitsSoA", edm::InputTag("TO BE DEFINED"));
0085 desc.add<double>("thresholdW0", 2.9);
0086 desc.add<double>("positionDeltaRho2", 1.69);
0087 descriptions.addWithDefaultLabel(desc);
0088 }
0089
0090 private:
0091 device::EDGetToken<HGCalSoARecHitsDeviceCollection> const getTokenDeviceRecHits_;
0092 device::EDGetToken<HGCalSoARecHitsExtraDeviceCollection> const getTokenDeviceClusters_;
0093 device::EDPutToken<HGCalSoAClustersDeviceCollection> const deviceTokenSoAClusters_;
0094 HGCalLayerClustersSoAAlgoWrapper algo_;
0095 unsigned int num_clusters_;
0096 float thresholdW0_;
0097 float positionDeltaRho2_;
0098 };
0099
0100 }
0101
0102 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/MakerMacros.h"
0103 DEFINE_FWK_ALPAKA_MODULE(HGCalSoALayerClustersProducer);