1 #include <cuda_runtime.h>
36 using HitModuleStart = std::array<uint32_t, gpuClustering::maxNumModules + 1>;
55 clusterToken_{consumes<SiPixelClusterCollectionNew>(iConfig.getParameter<
edm::InputTag>(
"src"))},
56 tokenHit_{produces<TrackingRecHit2DCPU>()},
57 tokenModuleStart_{produces<HMSstorage>()},
58 convert2Legacy_(iConfig.getParameter<
bool>(
"convertToLegacy")) {
60 produces<SiPixelRecHitCollectionNew>();
69 desc.add<
bool>(
"convertToLegacy",
false);
77 throw cms::Exception(
"Configuration") <<
"SiPixelRecHitSoAFromLegacy can only use a CPE of type PixelCPEFast";
79 auto const& cpeView = fcpe->getCPUProduct();
90 auto const&
input = *hclusters;
95 auto hitsModuleStart = hmsp.get();
97 auto hms = std::make_unique<HMSstorage>(
std::move(hmsp));
102 auto legacyOutput = std::make_unique<SiPixelRecHitCollectionNew>();
105 std::vector<uint16_t>
xx;
106 std::vector<uint16_t>
yy;
107 std::vector<uint16_t>
adc;
108 std::vector<uint16_t> moduleInd;
109 std::vector<int32_t> clus;
111 std::vector<edm::Ref<edmNew::DetSetVector<SiPixelCluster>,
SiPixelCluster>> clusterRef;
124 moduleStart_.data(), clusInModule_.data(), &moduleId_, hitsModuleStart};
127 int numberOfClusters = 0;
128 for (
auto const& dsv :
input) {
129 unsigned int detid = dsv.detId();
130 DetId detIdObject(detid);
132 auto gind = genericDet->
index();
134 auto const nclus = dsv.size();
135 clusInModule_[gind] = nclus;
136 numberOfClusters += nclus;
138 hitsModuleStart[0] = 0;
139 for (
int i = 1,
n = clusInModule_.size();
i <
n; ++
i)
140 hitsModuleStart[
i] = hitsModuleStart[
i - 1] + clusInModule_[
i - 1];
144 auto output = std::make_unique<TrackingRecHit2DCPU>(numberOfClusters, &cpeView, hitsModuleStart,
nullptr);
146 if (0 == numberOfClusters) {
156 int numberOfDetUnits = 0;
157 int numberOfHits = 0;
158 for (
auto const& dsv :
input) {
160 unsigned int detid = dsv.detId();
161 DetId detIdObject(detid);
163 auto const gind = genericDet->
index();
165 const PixelGeomDetUnit* pixDet = dynamic_cast<const PixelGeomDetUnit*>(genericDet);
167 auto const nclus = dsv.size();
168 assert(clusInModule_[gind] == nclus);
172 auto const fc = hitsModuleStart[gind];
173 auto const lc = hitsModuleStart[gind + 1];
175 LogDebug(
"SiPixelRecHitSoAFromLegacy") <<
"in det " << gind <<
": conv " << nclus <<
" hits from " << dsv.size()
176 <<
" legacy clusters" <<
' ' <<
fc <<
',' << lc;
180 "WARNING: too many clusters %d in Module %d. Only first %d Hits converted\n", nclus, gind,
maxHitsInModule);
192 for (
auto const& clust : dsv) {
194 for (
int i = 0, nd = clust.size();
i < nd; ++
i) {
195 auto px = clust.pixel(
i);
198 adc.push_back(
px.adc);
199 moduleInd.push_back(gind);
203 assert(clust.originalId() == ic);
209 assert(clus.size() == ndigi);
210 numberOfHits += nclus;
213 assert(digiView.adc(0) != 0);
215 gpuPixelRecHits::getHits(&cpeView, &bsHost, &digiView, ndigi, &clusterView,
output->view());
216 for (
auto h =
fc;
h < lc; ++
h)
223 for (
auto h =
fc;
h < lc; ++
h) {
227 assert(ih < clusterRef.size());
236 assert(numberOfHits == numberOfClusters);
240 output->hitsLayerStart()[
i] = hitsModuleStart[cpeView.layerGeometry().layerStart[
i]];
242 cms::cuda::fillManyFromVector(
output->phiBinner(),
250 LogDebug(
"SiPixelRecHitSoAFromLegacy") <<
"created HitSoa for " << numberOfClusters <<
" clusters in "
251 << numberOfDetUnits <<
" Dets";