CMS 3D CMS Logo

CAHitNtupletCUDA.cc
Go to the documentation of this file.
1 #include <cuda_runtime.h>
2 
21 
25 
27 public:
28  explicit CAHitNtupletCUDA(const edm::ParameterSet& iConfig);
29  ~CAHitNtupletCUDA() override = default;
30 
31  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
32 
33 private:
34  void beginJob() override;
35  void endJob() override;
36 
37  void produce(edm::StreamID streamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
38 
39  bool onGPU_;
40 
46 
48 };
49 
51  : onGPU_(iConfig.getParameter<bool>("onGPU")), tokenField_(esConsumes()), gpuAlgo_(iConfig, consumesCollector()) {
52  if (onGPU_) {
53  tokenHitGPU_ =
54  consumes<cms::cuda::Product<TrackingRecHit2DGPU>>(iConfig.getParameter<edm::InputTag>("pixelRecHitSrc"));
55  tokenTrackGPU_ = produces<cms::cuda::Product<PixelTrackHeterogeneous>>();
56  } else {
57  tokenHitCPU_ = consumes<TrackingRecHit2DCPU>(iConfig.getParameter<edm::InputTag>("pixelRecHitSrc"));
58  tokenTrackCPU_ = produces<PixelTrackHeterogeneous>();
59  }
60 }
61 
64 
65  desc.add<bool>("onGPU", true);
66  desc.add<edm::InputTag>("pixelRecHitSrc", edm::InputTag("siPixelRecHitsPreSplittingCUDA"));
67 
69  descriptions.add("pixelTracksCUDA", desc);
70 }
71 
73 
75 
77  auto bf = 1. / es.getData(tokenField_).inverseBzAtOriginInGeV();
78 
79  if (onGPU_) {
80  auto hHits = iEvent.getHandle(tokenHitGPU_);
81 
83  auto const& hits = ctx.get(*hHits);
84 
85  ctx.emplace(iEvent, tokenTrackGPU_, gpuAlgo_.makeTuplesAsync(hits, bf, ctx.stream()));
86  } else {
87  auto const& hits = iEvent.get(tokenHitCPU_);
89  }
90 }
91 
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
~CAHitNtupletCUDA() override=default
edm::EDGetTokenT< TrackingRecHit2DCPU > tokenHitCPU_
void produce(edm::StreamID streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void endJob() override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iEvent
Definition: GenABIO.cc:224
edm::EDPutTokenT< PixelTrackHeterogeneous > tokenTrackCPU_
static void fillDescriptions(edm::ParameterSetDescription &desc)
CAHitNtupletGeneratorOnGPU gpuAlgo_
bool getData(T &iHolder) const
Definition: EventSetup.h:122
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > tokenField_
edm::EDGetTokenT< cms::cuda::Product< TrackingRecHit2DGPU > > tokenHitGPU_
PixelTrackHeterogeneous makeTuplesAsync(TrackingRecHit2DGPU const &hits_d, float bfield, cudaStream_t stream) const
CAHitNtupletCUDA(const edm::ParameterSet &iConfig)
PixelTrackHeterogeneous makeTuples(TrackingRecHit2DCPU const &hits_d, float bfield) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void beginJob() override
edm::EDPutTokenT< cms::cuda::Product< PixelTrackHeterogeneous > > tokenTrackGPU_