CMS 3D CMS Logo

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
24 
25 // local includes
27 
28 class SiPixelPhase2DigiToClusterCUDA : public edm::stream::EDProducer<edm::ExternalWork> {
29 public:
30  explicit SiPixelPhase2DigiToClusterCUDA(const edm::ParameterSet& iConfig);
31  ~SiPixelPhase2DigiToClusterCUDA() override = default;
32 
33  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
35 
36 private:
37  void acquire(const edm::Event& iEvent,
38  const edm::EventSetup& iSetup,
39  edm::WaitingTaskWithArenaHolder waitingTaskHolder) override;
40  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
41 
44 
48 
50 
52 
53  const bool includeErrors_;
55  uint32_t nDigis_;
56 };
57 
59  : geomToken_(esConsumes()),
60  pixelDigiToken_(consumes<edm::DetSetVector<PixelDigi>>(iConfig.getParameter<edm::InputTag>("InputDigis"))),
61  digiPutToken_(produces<cms::cuda::Product<SiPixelDigisCUDA>>()),
62  clusterPutToken_(produces<cms::cuda::Product<SiPixelClustersCUDA>>()),
63  includeErrors_(iConfig.getParameter<bool>("IncludeErrors")),
64  clusterThresholds_{iConfig.getParameter<int32_t>("clusterThreshold_layer1"),
65  iConfig.getParameter<int32_t>("clusterThreshold_otherLayers"),
66  static_cast<float>(iConfig.getParameter<double>("ElectronPerADCGain")),
67  static_cast<int8_t>(iConfig.getParameter<int>("Phase2ReadoutMode")),
68  static_cast<uint16_t>(iConfig.getParameter<uint32_t>("Phase2DigiBaseline")),
69  static_cast<uint8_t>(iConfig.getParameter<uint32_t>("Phase2KinkADC"))} {
70  if (includeErrors_) {
71  digiErrorPutToken_ = produces<cms::cuda::Product<SiPixelDigiErrorsCUDA>>();
72  }
73 }
74 
77 
78  desc.add<bool>("IncludeErrors", true);
79  desc.add<int32_t>("clusterThreshold_layer1", 4000);
80  desc.add<int32_t>("clusterThreshold_otherLayers", 4000);
81  desc.add<double>("ElectronPerADCGain", 1500);
82  desc.add<int32_t>("Phase2ReadoutMode", 3);
83  desc.add<uint32_t>("Phase2DigiBaseline", 1000);
84  desc.add<uint32_t>("Phase2KinkADC", 8);
85  desc.add<edm::InputTag>("InputDigis", edm::InputTag("simSiPixelDigis:Pixel"));
86  descriptions.addWithDefaultLabel(desc);
87 }
88 
90  const edm::EventSetup& iSetup,
91  edm::WaitingTaskWithArenaHolder waitingTaskHolder) {
92  cms::cuda::ScopedContextAcquire ctx{iEvent.streamID(), std::move(waitingTaskHolder), ctxState_};
93 
94  auto const& input = iEvent.get(pixelDigiToken_);
95 
96  const TrackerGeometry* geom_ = &iSetup.getData(geomToken_);
97 
98  nDigis_ = 0;
99 
100  auto xDigis = cms::cuda::make_host_unique<uint16_t[]>(gpuClustering::maxNumDigis, ctx.stream());
101  auto yDigis = cms::cuda::make_host_unique<uint16_t[]>(gpuClustering::maxNumDigis, ctx.stream());
102  auto adcDigis = cms::cuda::make_host_unique<uint16_t[]>(gpuClustering::maxNumDigis, ctx.stream());
103  auto moduleIds = cms::cuda::make_host_unique<uint16_t[]>(gpuClustering::maxNumDigis, ctx.stream());
104  auto packedData = cms::cuda::make_host_unique<uint32_t[]>(gpuClustering::maxNumDigis, ctx.stream());
105  auto rawIds = cms::cuda::make_host_unique<uint32_t[]>(gpuClustering::maxNumDigis, ctx.stream());
106 
107  for (auto DSViter = input.begin(); DSViter != input.end(); DSViter++) {
108  unsigned int detid = DSViter->detId();
109  DetId detIdObject(detid);
110  const GeomDetUnit* genericDet = geom_->idToDetUnit(detIdObject);
111  auto const gind = genericDet->index();
112  for (auto const& px : *DSViter) {
113  moduleIds[nDigis_] = uint16_t(gind);
114 
115  xDigis[nDigis_] = uint16_t(px.row());
116  yDigis[nDigis_] = uint16_t(px.column());
117  adcDigis[nDigis_] = uint16_t(px.adc());
118 
119  packedData[nDigis_] = uint32_t(px.packedData());
120 
121  rawIds[nDigis_] = uint32_t(detid);
122 
123  nDigis_++;
124  }
125  }
126 
127  if (nDigis_ == 0)
128  return;
129 
131  moduleIds.get(),
132  xDigis.get(),
133  yDigis.get(),
134  adcDigis.get(),
135  packedData.get(),
136  rawIds.get(),
137  nDigis_,
138  ctx.stream());
139 }
140 
143 
144  if (nDigis_ == 0) {
145  ctx.emplace(iEvent, digiPutToken_, nDigis_, ctx.stream());
147  if (includeErrors_) {
149  }
150  return;
151  }
152 
153  auto tmp = gpuAlgo_.getResults();
154  ctx.emplace(iEvent, digiPutToken_, std::move(tmp.first));
155  ctx.emplace(iEvent, clusterPutToken_, std::move(tmp.second));
156  if (includeErrors_) {
157  ctx.emplace(iEvent, digiErrorPutToken_, gpuAlgo_.getErrors());
158  }
159 }
160 
161 // define as framework plugin
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDPutTokenT< cms::cuda::Product< SiPixelClustersCUDA > > clusterPutToken_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
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_
int index() const
Definition: GeomDet.h:83
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static constexpr uint16_t numberOfModules
edm::EDPutTokenT< cms::cuda::Product< SiPixelDigiErrorsCUDA > > digiErrorPutToken_
static std::string const input
Definition: EdmProvDump.cc:50
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)
int iEvent
Definition: GenABIO.cc:224
const SiPixelClusterThresholds clusterThresholds_
std::pair< SiPixelDigisCUDA, SiPixelClustersCUDA > getResults()
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SiPixelPhase2DigiToClusterCUDA(const edm::ParameterSet &iConfig)
Namespace of DDCMS conversion namespace.
Definition: DetId.h:17
edm::EDPutTokenT< cms::cuda::Product< SiPixelDigisCUDA > > digiPutToken_
HLT enums.
void acquire(const edm::Event &iEvent, const edm::EventSetup &iSetup, edm::WaitingTaskWithArenaHolder waitingTaskHolder) override
tmp
align.sh
Definition: createJobs.py:716
def move(src, dest)
Definition: eostools.py:511
~SiPixelPhase2DigiToClusterCUDA() override=default
constexpr uint32_t maxNumDigis