forked from cms-patatrack/pixeltrack-standalone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSiPixelRecHitCUDA.cc
61 lines (47 loc) · 2.26 KB
/
SiPixelRecHitCUDA.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <cuda_runtime.h>
#include "CUDADataFormats/BeamSpotCUDA.h"
#include "CUDACore/Product.h"
#include "CUDADataFormats/SiPixelClustersCUDA.h"
#include "CUDADataFormats/SiPixelDigisCUDA.h"
#include "CUDADataFormats/TrackingRecHit2DCUDA.h"
#include "Framework/EventSetup.h"
#include "Framework/Event.h"
#include "Framework/PluginFactory.h"
#include "Framework/EDProducer.h"
#include "CUDACore/ScopedContext.h"
#include "CondFormats/PixelCPEFast.h"
#include "PixelRecHits.h" // TODO : spit product from kernel
class SiPixelRecHitCUDA : public edm::EDProducer {
public:
explicit SiPixelRecHitCUDA(edm::ProductRegistry& reg);
~SiPixelRecHitCUDA() override = default;
private:
void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
// The mess with inputs will be cleaned up when migrating to the new framework
edm::EDGetTokenT<cms::cuda::Product<BeamSpotCUDA>> tBeamSpot;
edm::EDGetTokenT<cms::cuda::Product<SiPixelClustersCUDA>> token_;
edm::EDGetTokenT<cms::cuda::Product<SiPixelDigisCUDA>> tokenDigi_;
edm::EDPutTokenT<cms::cuda::Product<TrackingRecHit2DCUDA>> tokenHit_;
pixelgpudetails::PixelRecHitGPUKernel gpuAlgo_;
};
SiPixelRecHitCUDA::SiPixelRecHitCUDA(edm::ProductRegistry& reg)
: tBeamSpot(reg.consumes<cms::cuda::Product<BeamSpotCUDA>>()),
token_(reg.consumes<cms::cuda::Product<SiPixelClustersCUDA>>()),
tokenDigi_(reg.consumes<cms::cuda::Product<SiPixelDigisCUDA>>()),
tokenHit_(reg.produces<cms::cuda::Product<TrackingRecHit2DCUDA>>()) {}
void SiPixelRecHitCUDA::produce(edm::Event& iEvent, const edm::EventSetup& es) {
PixelCPEFast const& fcpe = es.get<PixelCPEFast>();
auto const& pclusters = iEvent.get(token_);
cms::cuda::ScopedContextProduce ctx{pclusters};
auto const& clusters = ctx.get(pclusters);
auto const& digis = ctx.get(iEvent, tokenDigi_);
auto const& bs = ctx.get(iEvent, tBeamSpot);
auto nHits = clusters.nClusters();
if (nHits >= TrackingRecHit2DSOAView::maxHits()) {
std::cout << "Clusters/Hits Overflow " << nHits << " >= " << TrackingRecHit2DSOAView::maxHits() << std::endl;
}
ctx.emplace(iEvent,
tokenHit_,
gpuAlgo_.makeHitsAsync(digis, clusters, bs, fcpe.getGPUProductAsync(ctx.stream()), ctx.stream()));
}
DEFINE_FWK_MODULE(SiPixelRecHitCUDA);