89 throw cms::Exception(
"Configuration") <<
"SiPixelRecHitSoAFromLegacy can only use a CPE of type PixelCPEFast";
91 auto const& cpeView = fcpe->getCPUProduct();
102 auto const&
input = *hclusters;
105 constexpr
int startBPIX2 = pixelTopology::layerStart<TrackerTraits>(1);
108 auto hmsp = std::make_unique<uint32_t[]>(nModules + 1);
109 auto hitsModuleStart = hmsp.get();
111 auto hms = std::make_unique<HMSstorage>(
std::move(hmsp));
116 auto legacyOutput = std::make_unique<SiPixelRecHitCollectionNew>();
118 std::vector<edm::Ref<edmNew::DetSetVector<SiPixelCluster>,
SiPixelCluster>> clusterRef;
124 memset(clusters_h.view().clusInModule(), 0, (nModules + 1) *
sizeof(uint32_t));
125 memset(clusters_h.view().moduleStart(), 0, (nModules + 1) *
sizeof(uint32_t));
126 memset(clusters_h.view().moduleId(), 0, (nModules + 1) *
sizeof(uint32_t));
127 memset(clusters_h.view().clusModuleStart(), 0, (nModules + 1) *
sizeof(uint32_t));
129 assert(0 == clusters_h.view()[nModules].clusInModule());
130 clusters_h.view()[1].moduleStart() = 0;
133 int numberOfClusters = 0;
134 for (
auto const& dsv :
input) {
135 unsigned int detid = dsv.detId();
136 DetId detIdObject(detid);
138 auto gind = genericDet->
index();
140 auto const nclus = dsv.size();
141 clusters_h.view()[gind].clusInModule() = nclus;
142 numberOfClusters += nclus;
144 clusters_h.view()[0].clusModuleStart() = 0;
146 for (
int i = 1;
i < nModules + 1; ++
i) {
147 clusters_h.view()[
i].clusModuleStart() =
148 clusters_h.view()[
i - 1].clusModuleStart() + clusters_h.view()[
i - 1].clusInModule();
151 assert((uint32_t)numberOfClusters == clusters_h.view()[nModules].clusModuleStart());
155 numberOfClusters, clusters_h.view()[
startBPIX2].clusModuleStart(), &cpeView, clusters_h.view().clusModuleStart());
157 if (0 == numberOfClusters) {
165 legacyOutput->reserve(nModules, numberOfClusters);
167 int numberOfDetUnits = 0;
168 int numberOfHits = 0;
169 for (
auto const& dsv :
input) {
171 unsigned int detid = dsv.detId();
172 DetId detIdObject(detid);
174 auto const gind = genericDet->
index();
178 auto const nclus = dsv.size();
180 assert(clusters_h.view()[gind].clusInModule() == nclus);
184 auto const fc = clusters_h.view()[gind].clusModuleStart();
185 auto const lc = clusters_h.view()[gind + 1].clusModuleStart();
187 LogDebug(
"SiPixelRecHitSoAFromLegacy") <<
"in det " << gind <<
": conv " << nclus <<
" hits from " << dsv.size()
188 <<
" legacy clusters" <<
' ' << fc <<
',' << lc;
189 assert((lc - fc) == nclus);
192 "WARNING: too many clusters %d in Module %d. Only first %d Hits converted\n", nclus, gind,
maxHitsInModule);
196 for (
auto const& clust : dsv) {
198 ndigi += clust.size();
204 clusters_h.view()[0].moduleId() = gind;
209 for (
auto const& clust : dsv) {
211 for (
int i = 0, nd = clust.size();
i < nd; ++
i) {
212 auto px = clust.pixel(
i);
213 digis_h.view()[ndigi].xx() =
px.x;
214 digis_h.view()[ndigi].yy() =
px.y;
215 digis_h.view()[ndigi].adc() =
px.adc;
216 digis_h.view()[ndigi].moduleId() = gind;
217 digis_h.view()[ndigi].clus() = ic;
227 numberOfHits += nclus;
229 assert(digis_h.view()[0].adc() != 0);
232 gpuPixelRecHits::getHits(&cpeView, &bsHost, digis_h.view(), ndigi, clusters_h.view(),
output.view());
233 for (
auto h = fc;
h < lc; ++
h)
241 for (
auto h = fc;
h < lc; ++
h) {
247 assert(ih < clusterRef.size());
253 recHitsOnDetUnit.push_back(
hit);
258 assert(numberOfHits == numberOfClusters);
263 output.view().hitsLayerStart()[
i] = clusters_h.view()[cpeView.layerGeometry().layerStart[
i]].clusModuleStart();
264 LogDebug(
"SiPixelRecHitSoAFromLegacy")
265 <<
"Layer n." <<
i <<
" - starting at module: " << cpeView.layerGeometry().layerStart[
i]
266 <<
" - starts ad cluster: " <<
output->hitsLayerStart()[
i] <<
"\n";
269 cms::cuda::fillManyFromVector(&(
output.view().phiBinner()),
272 output.view().hitsLayerStart().data(),
275 output.view().phiBinnerStorage());
277 LogDebug(
"SiPixelRecHitSoAFromLegacy") <<
"created HitSoa for " << numberOfClusters <<
" clusters in " 278 << numberOfDetUnits <<
" Dets" 282 memcpy(hitsModuleStart, clusters_h.view().clusModuleStart(), nModules *
sizeof(uint32_t));
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
TrackingRecHitSoAHost< TrackerTraits > HitsOnHost
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
constexpr uint32_t numberOfLayers
constexpr uint32_t maxHitsInModule()
const edm::EDPutTokenT< HMSstorage > tokenModuleStart_
constexpr uint16_t numberOfModules
static std::string const input
const edm::EDPutTokenT< HitsOnHost > tokenHit_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
const edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > cpeToken_
const bool convert2Legacy_
constexpr uint16_t invalidModuleId
const edm::EDGetTokenT< reco::BeamSpot > bsGetToken_
Pixel cluster – collection of neighboring pixels above threshold.
unsigned int QualWordType
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
const edm::EDGetTokenT< SiPixelClusterCollectionNew > clusterToken_