Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-11 23:28:10

0001 #include "DataFormats/BeamSpot/interface/BeamSpotPOD.h"
0002 #include "DataFormats/BeamSpot/interface/alpaka/BeamSpotDevice.h"
0003 #include "DataFormats/SiPixelClusterSoA/interface/SiPixelClustersDevice.h"
0004 #include "DataFormats/SiPixelClusterSoA/interface/alpaka/SiPixelClustersSoACollection.h"
0005 #include "DataFormats/SiPixelDigiSoA/interface/SiPixelDigisDevice.h"
0006 #include "DataFormats/SiPixelDigiSoA/interface/alpaka/SiPixelDigisSoACollection.h"
0007 #include "DataFormats/TrackingRecHitSoA/interface/TrackingRecHitsDevice.h"
0008 #include "DataFormats/TrackingRecHitSoA/interface/alpaka/TrackingRecHitsSoACollection.h"
0009 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0012 #include "FWCore/Utilities/interface/InputTag.h"
0013 #include "Geometry/CommonTopologies/interface/SimplePixelTopology.h"
0014 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0015 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0016 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/Event.h"
0017 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/EventSetup.h"
0018 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/global/EDProducer.h"
0019 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0020 #include "HeterogeneousCore/AlpakaInterface/interface/memory.h"
0021 
0022 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0024 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0025 #include "FWCore/Utilities/interface/InputTag.h"
0026 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0027 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0028 #include "RecoLocalTracker/Records/interface/PixelCPEFastParamsRecord.h"
0029 
0030 #include "RecoLocalTracker/SiPixelRecHits/interface/PixelCPEBase.h"
0031 #include "RecoLocalTracker/SiPixelRecHits/interface/pixelCPEforDevice.h"
0032 #include "RecoLocalTracker/SiPixelRecHits/interface/alpaka/PixelCPEFastParamsCollection.h"
0033 
0034 #include "PixelRecHitKernel.h"
0035 
0036 namespace ALPAKA_ACCELERATOR_NAMESPACE {
0037   template <typename TrackerTraits>
0038   class SiPixelRecHitAlpaka : public global::EDProducer<> {
0039   public:
0040     explicit SiPixelRecHitAlpaka(const edm::ParameterSet& iConfig);
0041     ~SiPixelRecHitAlpaka() override = default;
0042 
0043     static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0044 
0045   private:
0046     void produce(edm::StreamID streamID, device::Event& iEvent, const device::EventSetup& iSetup) const override;
0047 
0048     const device::ESGetToken<PixelCPEFastParams<TrackerTraits>, PixelCPEFastParamsRecord> cpeToken_;
0049     const device::EDGetToken<BeamSpotDevice> tBeamSpot;
0050     const device::EDGetToken<SiPixelClustersSoACollection> tokenClusters_;
0051     const device::EDGetToken<SiPixelDigisSoACollection> tokenDigi_;
0052     const device::EDPutToken<TrackingRecHitsSoACollection<TrackerTraits>> tokenHit_;
0053 
0054     const pixelgpudetails::PixelRecHitKernel<TrackerTraits> Algo_;
0055   };
0056 
0057   template <typename TrackerTraits>
0058   SiPixelRecHitAlpaka<TrackerTraits>::SiPixelRecHitAlpaka(const edm::ParameterSet& iConfig)
0059       : cpeToken_(esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("CPE")))),
0060         tBeamSpot(consumes(iConfig.getParameter<edm::InputTag>("beamSpot"))),
0061         tokenClusters_(consumes(iConfig.getParameter<edm::InputTag>("src"))),
0062         tokenDigi_(consumes(iConfig.getParameter<edm::InputTag>("src"))),
0063         tokenHit_(produces()) {
0064     // Workaround until the ProductID problem in issue https://github.com/cms-sw/cmssw/issues/44643 is fixed
0065 #ifdef ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED
0066     if constexpr (std::is_same_v<TrackerTraits, pixelTopology::Phase1>) {
0067       producesTemporarily("edm::DeviceProduct<alpaka_cuda_async::TrackingRecHitSoAPhase1>");
0068     }
0069 #endif
0070   }
0071 
0072   template <typename TrackerTraits>
0073   void SiPixelRecHitAlpaka<TrackerTraits>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0074     edm::ParameterSetDescription desc;
0075 
0076     desc.add<edm::InputTag>("beamSpot", edm::InputTag("offlineBeamSpotDevice"));
0077     desc.add<edm::InputTag>("src", edm::InputTag("siPixelClustersPreSplittingAlpaka"));
0078 
0079     std::string cpe = "PixelCPEFastParams";
0080     cpe += TrackerTraits::nameModifier;
0081     desc.add<std::string>("CPE", cpe);
0082 
0083     descriptions.addWithDefaultLabel(desc);
0084   }
0085 
0086   template <typename TrackerTraits>
0087   void SiPixelRecHitAlpaka<TrackerTraits>::produce(edm::StreamID streamID,
0088                                                    device::Event& iEvent,
0089                                                    const device::EventSetup& es) const {
0090     auto& fcpe = es.getData(cpeToken_);
0091 
0092     auto const& clusters = iEvent.get(tokenClusters_);
0093 
0094     auto const& digis = iEvent.get(tokenDigi_);
0095 
0096     auto const& bs = iEvent.get(tBeamSpot);
0097 
0098     iEvent.emplace(tokenHit_,
0099                    Algo_.makeHitsAsync(digis, clusters, bs.data(), fcpe.const_buffer().data(), iEvent.queue()));
0100   }
0101   using SiPixelRecHitAlpakaPhase1 = SiPixelRecHitAlpaka<pixelTopology::Phase1>;
0102   using SiPixelRecHitAlpakaPhase2 = SiPixelRecHitAlpaka<pixelTopology::Phase2>;
0103 }  // namespace ALPAKA_ACCELERATOR_NAMESPACE
0104 
0105 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/MakerMacros.h"
0106 DEFINE_FWK_ALPAKA_MODULE(SiPixelRecHitAlpakaPhase1);
0107 DEFINE_FWK_ALPAKA_MODULE(SiPixelRecHitAlpakaPhase2);