CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CAHitNtupletCUDA.cc
Go to the documentation of this file.
1 #include <cuda_runtime.h>
2 
21 
25 
27 public:
29  ~CAHitNtupletCUDA() override = default;
30 
31  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
32 
33 private:
34  void produce(edm::StreamID streamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
35 
36  bool onGPU_;
37 
43 
45 };
46 
48  : onGPU_(iConfig.getParameter<bool>("onGPU")), tokenField_(esConsumes()), gpuAlgo_(iConfig, consumesCollector()) {
49  if (onGPU_) {
50  tokenHitGPU_ =
51  consumes<cms::cuda::Product<TrackingRecHit2DGPU>>(iConfig.getParameter<edm::InputTag>("pixelRecHitSrc"));
52  tokenTrackGPU_ = produces<cms::cuda::Product<PixelTrackHeterogeneous>>();
53  } else {
54  tokenHitCPU_ = consumes<TrackingRecHit2DCPU>(iConfig.getParameter<edm::InputTag>("pixelRecHitSrc"));
55  tokenTrackCPU_ = produces<PixelTrackHeterogeneous>();
56  }
57 }
58 
61 
62  desc.add<bool>("onGPU", true);
63  desc.add<edm::InputTag>("pixelRecHitSrc", edm::InputTag("siPixelRecHitsPreSplittingCUDA"));
64 
66  descriptions.add("pixelTracksCUDA", desc);
67 }
68 
70  auto bf = 1. / es.getData(tokenField_).inverseBzAtOriginInGeV();
71 
72  if (onGPU_) {
73  auto hHits = iEvent.getHandle(tokenHitGPU_);
74 
76  auto const& hits = ctx.get(*hHits);
77 
78  ctx.emplace(iEvent, tokenTrackGPU_, gpuAlgo_.makeTuplesAsync(hits, bf, ctx.stream()));
79  } else {
80  auto const& hits = iEvent.get(tokenHitCPU_);
81  iEvent.emplace(tokenTrackCPU_, gpuAlgo_.makeTuples(hits, bf));
82  }
83 }
84 
~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
bool getData(T &iHolder) const
Definition: EventSetup.h:122
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:563
int iEvent
Definition: GenABIO.cc:224
edm::EDPutTokenT< PixelTrackHeterogeneous > tokenTrackCPU_
static void fillDescriptions(edm::ParameterSetDescription &desc)
CAHitNtupletGeneratorOnGPU gpuAlgo_
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > tokenField_
edm::EDGetTokenT< cms::cuda::Product< TrackingRecHit2DGPU > > tokenHitGPU_
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:433
CAHitNtupletCUDA(const edm::ParameterSet &iConfig)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void add(std::string const &label, ParameterSetDescription const &psetDescription)
PixelTrackHeterogeneous makeTuples(TrackingRecHit2DCPU const &hits_d, float bfield) const
edm::EDPutTokenT< cms::cuda::Product< PixelTrackHeterogeneous > > tokenTrackGPU_
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
PixelTrackHeterogeneous makeTuplesAsync(TrackingRecHit2DGPU const &hits_d, float bfield, cudaStream_t stream) const