Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-03-08 03:06:48

0001 #include "DataFormats/HGCalReco/interface/HGCalSoARecHitsHostCollection.h"
0002 #include "DataFormats/HGCalReco/interface/alpaka/HGCalSoARecHitsDeviceCollection.h"
0003 #include "DataFormats/HGCalReco/interface/alpaka/HGCalSoARecHitsExtraDeviceCollection.h"
0004 #include "FWCore/Framework/interface/ConsumesCollector.h"
0005 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0008 #include "FWCore/Utilities/interface/InputTag.h"
0009 #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
0010 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/EDPutToken.h"
0011 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/ESGetToken.h"
0012 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/stream/EDProducer.h"
0013 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0014 #include "RecoLocalCalo/HGCalRecProducers/interface/HGCalTilesConstants.h"
0015 
0016 #include "HGCalLayerClustersAlgoWrapper.h"
0017 
0018 // Processes the input RecHit SoA collection and generates an output SoA
0019 // containing all the necessary information to build the clusters.
0020 // Specifically, this producer does not create the clusters in any format.
0021 // Instead, it fills a SoA (HGCalSoARecHitsExtra) with the same size as the input
0022 // RecHit SoA. This output SoA includes all the data needed to assemble the
0023 // clusters and assigns a clusterId to each cell that belongs to a cluster.
0024 // Consequently, this producer must be used by another downstream producer to
0025 // either build traditional clusters or to create a SoA representing the
0026 // clusters, complete with all required information (e.g., energy, position).
0027 namespace ALPAKA_ACCELERATOR_NAMESPACE {
0028 
0029   class HGCalSoARecHitsLayerClustersProducer : public stream::EDProducer<> {
0030   public:
0031     HGCalSoARecHitsLayerClustersProducer(edm::ParameterSet const& config)
0032         : EDProducer(config),
0033           getTokenDevice_{consumes(config.getParameter<edm::InputTag>("hgcalRecHitsSoA"))},
0034           deviceToken_{produces()},
0035           deltac_((float)config.getParameter<double>("deltac")),
0036           kappa_((float)config.getParameter<double>("kappa")),
0037           outlierDeltaFactor_((float)config.getParameter<double>("outlierDeltaFactor")) {}
0038 
0039     ~HGCalSoARecHitsLayerClustersProducer() override = default;
0040 
0041     void produce(device::Event& iEvent, device::EventSetup const& iSetup) override {
0042       auto const& deviceInput = iEvent.get(getTokenDevice_);
0043       //std::cout << "Size of device collection: " << deviceInput->metadata().size() << std::endl;
0044       auto const input_v = deviceInput.view();
0045       // Allocate output SoA
0046       HGCalSoARecHitsExtraDeviceCollection output(deviceInput->metadata().size(), iEvent.queue());
0047       auto output_v = output.view();
0048 
0049       algo_.run(
0050           iEvent.queue(), deviceInput->metadata().size(), deltac_, kappa_, outlierDeltaFactor_, input_v, output_v);
0051       iEvent.emplace(deviceToken_, std::move(output));
0052     }
0053 
0054     static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0055       edm::ParameterSetDescription desc;
0056       desc.add<edm::InputTag>("hgcalRecHitsSoA", edm::InputTag("TO BE DEFINED"));
0057       desc.add<double>("deltac", 1.3);
0058       desc.add<double>("kappa", 9.);
0059       desc.add<double>("outlierDeltaFactor", 2.);
0060       descriptions.addWithDefaultLabel(desc);
0061     }
0062 
0063   private:
0064     // use device::EDGetToken<T> to read from device memory space
0065     device::EDGetToken<HGCalSoARecHitsDeviceCollection> const getTokenDevice_;
0066     device::EDPutToken<HGCalSoARecHitsExtraDeviceCollection> const deviceToken_;
0067     HGCalLayerClustersAlgoWrapper algo_;
0068     const float deltac_;
0069     const float kappa_;
0070     const float outlierDeltaFactor_;
0071   };
0072 
0073 }  // namespace ALPAKA_ACCELERATOR_NAMESPACE
0074 
0075 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/MakerMacros.h"
0076 DEFINE_FWK_ALPAKA_MODULE(HGCalSoARecHitsLayerClustersProducer);