Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-07-03 04:18:11

0001 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0002 
0003 #include "CondFormats/HcalObjects/interface/alpaka/HcalMahiPulseOffsetsDevice.h"
0004 #include "CondFormats/HcalObjects/interface/HcalMahiPulseOffsetsSoA.h"
0005 #include "HeterogeneousCore/CUDACore/interface/JobConfigurationGPURecord.h"
0006 
0007 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/ESProducer.h"
0008 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/ModuleFactory.h"
0009 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0010 #include "HeterogeneousCore/AlpakaInterface/interface/host.h"
0011 #include "HeterogeneousCore/AlpakaInterface/interface/memory.h"
0012 
0013 namespace ALPAKA_ACCELERATOR_NAMESPACE {
0014   class HcalMahiPulseOffsetsESProducer : public ESProducer {
0015   public:
0016     HcalMahiPulseOffsetsESProducer(edm::ParameterSet const& iConfig) : ESProducer(iConfig) {
0017       std::vector<int> offsets = iConfig.getParameter<std::vector<int>>("pulseOffsets");
0018 
0019       product = std::make_unique<hcal::HcalMahiPulseOffsetsPortableHost>(offsets.size(), cms::alpakatools::host());
0020 
0021       auto view = product->view();
0022 
0023       for (uint32_t i = 0; i < offsets.size(); i++) {
0024         view[i] = offsets[i];
0025       }
0026       setWhatProduced(this);
0027     }
0028 
0029     static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0030       edm::ParameterSetDescription desc;
0031       desc.add<std::vector<int>>("pulseOffsets", {-3, -2, -1, 0, 1, 2, 3, 4});
0032       descriptions.addWithDefaultLabel(desc);
0033     }
0034 
0035     std::shared_ptr<hcal::HcalMahiPulseOffsetsPortableHost> produce(JobConfigurationGPURecord const& iRecord) {
0036       return product;
0037     }
0038 
0039   private:
0040     std::shared_ptr<hcal::HcalMahiPulseOffsetsPortableHost> product;
0041   };
0042 }  // namespace ALPAKA_ACCELERATOR_NAMESPACE
0043 
0044 DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(HcalMahiPulseOffsetsESProducer);