CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiPixelPhase2DigiToClusterCUDA.cc
Go to the documentation of this file.
1 // C++ includes
2 #include <memory>
3 #include <string>
4 #include <vector>
5 
6 // CMSSW includes
39 
40 // local includes
43 
44 class SiPixelPhase2DigiToClusterCUDA : public edm::stream::EDProducer<edm::ExternalWork> {
45 public:
47  ~SiPixelPhase2DigiToClusterCUDA() override = default;
48 
49  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
50 
51 private:
52  void acquire(const edm::Event& iEvent,
53  const edm::EventSetup& iSetup,
54  edm::WaitingTaskWithArenaHolder waitingTaskHolder) override;
55  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
56 
59 
63 
65 
67  std::unique_ptr<pixelgpudetails::SiPixelRawToClusterGPUKernel::WordFedAppender> wordFedAppender_;
68 
69  const bool includeErrors_;
71 };
72 
74  : geomToken_(esConsumes()),
75  pixelDigiToken_(consumes<edm::DetSetVector<PixelDigi>>(iConfig.getParameter<edm::InputTag>("InputDigis"))),
76  digiPutToken_(produces<cms::cuda::Product<SiPixelDigisCUDA>>()),
77  clusterPutToken_(produces<cms::cuda::Product<SiPixelClustersCUDA>>()),
78  includeErrors_(iConfig.getParameter<bool>("IncludeErrors")),
79  clusterThresholds_{iConfig.getParameter<int32_t>("clusterThreshold_layer1"),
80  iConfig.getParameter<int32_t>("clusterThreshold_otherLayers")} {
81  if (includeErrors_) {
82  digiErrorPutToken_ = produces<cms::cuda::Product<SiPixelDigiErrorsCUDA>>();
83  }
84 }
85 
88 
89  desc.add<bool>("IncludeErrors", true);
90  desc.add<int32_t>("clusterThreshold_layer1", kSiPixelClusterThresholdsDefaultPhase2.layer1);
91  desc.add<int32_t>("clusterThreshold_otherLayers", kSiPixelClusterThresholdsDefaultPhase2.otherLayers);
92  desc.add<edm::InputTag>("InputDigis", edm::InputTag("simSiPixelDigis:Pixel"));
93  descriptions.addWithDefaultLabel(desc);
94 }
95 
97  const edm::EventSetup& iSetup,
98  edm::WaitingTaskWithArenaHolder waitingTaskHolder) {
99  cms::cuda::ScopedContextAcquire ctx{iEvent.streamID(), std::move(waitingTaskHolder), ctxState_};
100 
101  auto const& input = iEvent.get(pixelDigiToken_);
102 
103  const TrackerGeometry* geom_ = &iSetup.getData(geomToken_);
104 
105  uint32_t nDigis = 0;
106 
107  auto xDigis = cms::cuda::make_host_unique<uint16_t[]>(gpuClustering::maxNumDigis, ctx.stream());
108  auto yDigis = cms::cuda::make_host_unique<uint16_t[]>(gpuClustering::maxNumDigis, ctx.stream());
109  auto adcDigis = cms::cuda::make_host_unique<uint16_t[]>(gpuClustering::maxNumDigis, ctx.stream());
110  auto moduleIds = cms::cuda::make_host_unique<uint16_t[]>(gpuClustering::maxNumDigis, ctx.stream());
111  auto packedData = cms::cuda::make_host_unique<uint32_t[]>(gpuClustering::maxNumDigis, ctx.stream());
112  auto rawIds = cms::cuda::make_host_unique<uint32_t[]>(gpuClustering::maxNumDigis, ctx.stream());
113 
114  for (auto DSViter = input.begin(); DSViter != input.end(); DSViter++) {
115  unsigned int detid = DSViter->detId();
116  DetId detIdObject(detid);
117  const GeomDetUnit* genericDet = geom_->idToDetUnit(detIdObject);
118  auto const gind = genericDet->index();
119  for (auto const& px : *DSViter) {
120  moduleIds[nDigis] = uint16_t(gind);
121 
122  xDigis[nDigis] = uint16_t(px.row());
123  yDigis[nDigis] = uint16_t(px.column());
124  adcDigis[nDigis] = uint16_t(px.adc());
125 
126  packedData[nDigis] = uint32_t(px.packedData());
127 
128  rawIds[nDigis] = uint32_t(detid);
129 
130  nDigis++;
131  }
132  }
133 
135  moduleIds.get(),
136  xDigis.get(),
137  yDigis.get(),
138  adcDigis.get(),
139  packedData.get(),
140  rawIds.get(),
141  nDigis,
142  ctx.stream());
143 }
144 
147 
148  auto tmp = gpuAlgo_.getResults();
149  ctx.emplace(iEvent, digiPutToken_, std::move(tmp.first));
150  ctx.emplace(iEvent, clusterPutToken_, std::move(tmp.second));
151  if (includeErrors_) {
152  ctx.emplace(iEvent, digiErrorPutToken_, gpuAlgo_.getErrors());
153  }
154 }
155 
156 // define as framework plugin
std::unique_ptr< pixelgpudetails::SiPixelRawToClusterGPUKernel::WordFedAppender > wordFedAppender_
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
edm::EDPutTokenT< cms::cuda::Product< SiPixelClustersCUDA > > clusterPutToken_
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
const edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > pixelDigiToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::pair< SiPixelDigisCUDA, SiPixelClustersCUDA > getResults()
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDPutTokenT< cms::cuda::Product< SiPixelDigiErrorsCUDA > > digiErrorPutToken_
static std::string const input
Definition: EdmProvDump.cc:47
constexpr SiPixelClusterThresholds kSiPixelClusterThresholdsDefaultPhase2
bool getData(T &iHolder) const
Definition: EventSetup.h:122
int iEvent
Definition: GenABIO.cc:224
const SiPixelClusterThresholds clusterThresholds_
pixelgpudetails::SiPixelRawToClusterGPUKernel gpuAlgo_
def move
Definition: eostools.py:511
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
SiPixelPhase2DigiToClusterCUDA(const edm::ParameterSet &iConfig)
int index() const
Definition: GeomDet.h:83
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: DetId.h:17
void makePhase2ClustersAsync(const SiPixelClusterThresholds clusterThresholds, const uint16_t *moduleIds, const uint16_t *xDigis, const uint16_t *yDigis, const uint16_t *adcDigis, const uint32_t *packedData, const uint32_t *rawIds, const uint32_t numDigis, cudaStream_t stream)
edm::EDPutTokenT< cms::cuda::Product< SiPixelDigisCUDA > > digiPutToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
StreamID streamID() const
Definition: Event.h:98
void acquire(const edm::Event &iEvent, const edm::EventSetup &iSetup, edm::WaitingTaskWithArenaHolder waitingTaskHolder) override
tmp
align.sh
Definition: createJobs.py:716
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
~SiPixelPhase2DigiToClusterCUDA() override=default
constexpr uint32_t maxNumDigis