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
40 
41 // local includes
44 
45 class SiPixelPhase2DigiToClusterCUDA : public edm::stream::EDProducer<edm::ExternalWork> {
46 public:
47  explicit SiPixelPhase2DigiToClusterCUDA(const edm::ParameterSet& iConfig);
48  ~SiPixelPhase2DigiToClusterCUDA() override = default;
49 
50  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
52 
53 private:
54  void acquire(const edm::Event& iEvent,
55  const edm::EventSetup& iSetup,
56  edm::WaitingTaskWithArenaHolder waitingTaskHolder) override;
57  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
58 
61 
65 
67 
69 
70  const bool includeErrors_;
72 };
73 
75  : geomToken_(esConsumes()),
76  pixelDigiToken_(consumes<edm::DetSetVector<PixelDigi>>(iConfig.getParameter<edm::InputTag>("InputDigis"))),
77  digiPutToken_(produces<cms::cuda::Product<SiPixelDigisCUDA>>()),
78  clusterPutToken_(produces<cms::cuda::Product<SiPixelClustersCUDA>>()),
79  includeErrors_(iConfig.getParameter<bool>("IncludeErrors")),
80  clusterThresholds_{iConfig.getParameter<int32_t>("clusterThreshold_layer1"),
81  iConfig.getParameter<int32_t>("clusterThreshold_otherLayers"),
82  static_cast<float>(iConfig.getParameter<double>("ElectronPerADCGain")),
83  static_cast<int8_t>(iConfig.getParameter<int>("Phase2ReadoutMode")),
84  static_cast<uint16_t>(iConfig.getParameter<uint32_t>("Phase2DigiBaseline")),
85  static_cast<uint8_t>(iConfig.getParameter<uint32_t>("Phase2KinkADC"))} {
86  if (includeErrors_) {
87  digiErrorPutToken_ = produces<cms::cuda::Product<SiPixelDigiErrorsCUDA>>();
88  }
89 }
90 
93 
94  desc.add<bool>("IncludeErrors", true);
95  desc.add<int32_t>("clusterThreshold_layer1", 4000);
96  desc.add<int32_t>("clusterThreshold_otherLayers", 4000);
97  desc.add<double>("ElectronPerADCGain", 1500);
98  desc.add<int32_t>("Phase2ReadoutMode", 3);
99  desc.add<uint32_t>("Phase2DigiBaseline", 1000);
100  desc.add<uint32_t>("Phase2KinkADC", 8);
101  desc.add<edm::InputTag>("InputDigis", edm::InputTag("simSiPixelDigis:Pixel"));
102  descriptions.addWithDefaultLabel(desc);
103 }
104 
106  const edm::EventSetup& iSetup,
107  edm::WaitingTaskWithArenaHolder waitingTaskHolder) {
108  cms::cuda::ScopedContextAcquire ctx{iEvent.streamID(), std::move(waitingTaskHolder), ctxState_};
109 
110  auto const& input = iEvent.get(pixelDigiToken_);
111 
112  const TrackerGeometry* geom_ = &iSetup.getData(geomToken_);
113 
114  uint32_t nDigis = 0;
115 
116  auto xDigis = cms::cuda::make_host_unique<uint16_t[]>(gpuClustering::maxNumDigis, ctx.stream());
117  auto yDigis = cms::cuda::make_host_unique<uint16_t[]>(gpuClustering::maxNumDigis, ctx.stream());
118  auto adcDigis = cms::cuda::make_host_unique<uint16_t[]>(gpuClustering::maxNumDigis, ctx.stream());
119  auto moduleIds = cms::cuda::make_host_unique<uint16_t[]>(gpuClustering::maxNumDigis, ctx.stream());
120  auto packedData = cms::cuda::make_host_unique<uint32_t[]>(gpuClustering::maxNumDigis, ctx.stream());
121  auto rawIds = cms::cuda::make_host_unique<uint32_t[]>(gpuClustering::maxNumDigis, ctx.stream());
122 
123  for (auto DSViter = input.begin(); DSViter != input.end(); DSViter++) {
124  unsigned int detid = DSViter->detId();
125  DetId detIdObject(detid);
126  const GeomDetUnit* genericDet = geom_->idToDetUnit(detIdObject);
127  auto const gind = genericDet->index();
128  for (auto const& px : *DSViter) {
129  moduleIds[nDigis] = uint16_t(gind);
130 
131  xDigis[nDigis] = uint16_t(px.row());
132  yDigis[nDigis] = uint16_t(px.column());
133  adcDigis[nDigis] = uint16_t(px.adc());
134 
135  packedData[nDigis] = uint32_t(px.packedData());
136 
137  rawIds[nDigis] = uint32_t(detid);
138 
139  nDigis++;
140  }
141  }
142 
144  moduleIds.get(),
145  xDigis.get(),
146  yDigis.get(),
147  adcDigis.get(),
148  packedData.get(),
149  rawIds.get(),
150  nDigis,
151  ctx.stream());
152 }
153 
156 
157  auto tmp = gpuAlgo_.getResults();
158  ctx.emplace(iEvent, digiPutToken_, std::move(tmp.first));
159  ctx.emplace(iEvent, clusterPutToken_, std::move(tmp.second));
160  if (includeErrors_) {
161  ctx.emplace(iEvent, digiErrorPutToken_, gpuAlgo_.getErrors());
162  }
163 }
164 
165 // 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)
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