1 #include <cuda_runtime.h> 37 using HitModuleStart = std::array<uint32_t, gpuClustering::maxNumModules + 1>;
57 clusterToken_{consumes<SiPixelClusterCollectionNew>(iConfig.getParameter<
edm::InputTag>(
"src"))},
58 tokenHit_{produces<TrackingRecHit2DCPU>()},
59 tokenModuleStart_{produces<HMSstorage>()},
60 convert2Legacy_(iConfig.getParameter<
bool>(
"convertToLegacy")),
61 isPhase2_(iConfig.getParameter<
bool>(
"isPhase2")) {
63 produces<SiPixelRecHitCollectionNew>();
72 desc.add<
bool>(
"convertToLegacy",
false);
73 desc.add<
bool>(
"isPhase2",
false);
81 throw cms::Exception(
"Configuration") <<
"SiPixelRecHitSoAFromLegacy can only use a CPE of type PixelCPEFast";
83 auto const& cpeView = fcpe->getCPUProduct();
94 auto const&
input = *hclusters;
103 auto hmsp = std::make_unique<uint32_t[]>(
nMaxModules + 1);
105 auto hitsModuleStart = hmsp.get();
107 auto hms = std::make_unique<HMSstorage>(
std::move(hmsp));
112 auto legacyOutput = std::make_unique<SiPixelRecHitCollectionNew>();
115 std::vector<uint16_t>
xx;
116 std::vector<uint16_t>
yy;
117 std::vector<uint16_t>
adc;
118 std::vector<uint16_t> moduleInd;
119 std::vector<int32_t> clus;
121 std::vector<edm::Ref<edmNew::DetSetVector<SiPixelCluster>,
SiPixelCluster>> clusterRef;
135 moduleStart_.data(), clusInModule_.data(), &moduleId_, hitsModuleStart};
138 int numberOfClusters = 0;
139 for (
auto const& dsv :
input) {
140 unsigned int detid = dsv.detId();
141 DetId detIdObject(detid);
143 auto gind = genericDet->
index();
145 auto const nclus = dsv.size();
146 clusInModule_[gind] = nclus;
147 numberOfClusters += nclus;
149 hitsModuleStart[0] = 0;
152 hitsModuleStart[
i] = hitsModuleStart[
i - 1] + clusInModule_[
i - 1];
159 auto output = std::make_unique<TrackingRecHit2DCPU>(
160 numberOfClusters,
isPhase2_, hitsModuleStart[
startBPIX2], &cpeView, hitsModuleStart,
nullptr);
163 if (0 == numberOfClusters) {
171 legacyOutput->reserve(
nMaxModules, numberOfClusters);
173 int numberOfDetUnits = 0;
174 int numberOfHits = 0;
175 for (
auto const& dsv :
input) {
177 unsigned int detid = dsv.detId();
178 DetId detIdObject(detid);
180 auto const gind = genericDet->
index();
184 auto const nclus = dsv.size();
185 assert(clusInModule_[gind] == nclus);
189 auto const fc = hitsModuleStart[gind];
190 auto const lc = hitsModuleStart[gind + 1];
192 LogDebug(
"SiPixelRecHitSoAFromLegacy") <<
"in det " << gind <<
": conv " << nclus <<
" hits from " << dsv.size()
193 <<
" legacy clusters" <<
' ' << fc <<
',' << lc;
194 assert((lc - fc) == nclus);
197 "WARNING: too many clusters %d in Module %d. Only first %d Hits converted\n", nclus, gind,
maxHitsInModule);
209 for (
auto const& clust : dsv) {
211 for (
int i = 0, nd = clust.size();
i < nd; ++
i) {
212 auto px = clust.pixel(
i);
215 adc.push_back(
px.adc);
216 moduleInd.push_back(gind);
226 assert(clus.size() == ndigi);
227 numberOfHits += nclus;
230 digiView.
xx_ =
xx.data();
231 digiView.
yy_ =
yy.data();
234 digiView.
clus_ = clus.data();
235 digiView.
pdigi_ =
nullptr;
239 gpuPixelRecHits::getHits(&cpeView, &bsHost, digiView, ndigi, &clusterView,
output->view());
240 for (
auto h = fc;
h < lc; ++
h)
247 for (
auto h = fc;
h < lc; ++
h) {
252 assert(ih < clusterRef.size());
262 assert(numberOfHits == numberOfClusters);
267 output->hitsLayerStart()[
i] = hitsModuleStart[cpeView.layerGeometry().layerStart[
i]];
268 LogDebug(
"SiPixelRecHitSoAFromLegacy")
269 <<
"Layer n." <<
i <<
" - starting at module: " << cpeView.layerGeometry().layerStart[
i]
270 <<
" - starts ad cluster: " <<
output->hitsLayerStart()[
i] <<
"\n";
273 cms::cuda::fillManyFromVector(
output->phiBinner(),
279 output->phiBinnerStorage());
281 LogDebug(
"SiPixelRecHitSoAFromLegacy") <<
"created HitSoa for " << numberOfClusters <<
" clusters in " 282 << numberOfDetUnits <<
" Dets";
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)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void push_back(data_type const &d)
constexpr int nMaxModules
T getParameter(std::string const &) const
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
constexpr uint32_t numberOfLayers
#define DEFINE_FWK_MODULE(type)
constexpr uint32_t layerStart[numberOfLayers+1]
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
constexpr uint32_t maxHitsInModule()
const edm::EDGetTokenT< reco::BeamSpot > bsGetToken_
constexpr uint32_t numberOfModules
~SiPixelRecHitSoAFromLegacy() override=default
static std::string const input
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
constexpr uint16_t maxNumModules
bool getData(T &iHolder) const
const uint16_t * adc() const
constexpr uint16_t invalidModuleId
constexpr uint32_t numberOfModules
std::array< uint32_t, gpuClustering::maxNumModules+1 > HitModuleStart
const edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > cpeToken_
constexpr uint8_t numberOfLayers
Pixel cluster – collection of neighboring pixels above threshold.
unsigned int QualWordType
const edm::EDPutTokenT< HMSstorage > tokenModuleStart_
constexpr uint32_t layerStart[numberOfLayers+1]
const edm::EDPutTokenT< TrackingRecHit2DCPU > tokenHit_
const edm::EDGetTokenT< SiPixelClusterCollectionNew > clusterToken_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
void produce(edm::StreamID streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
SiPixelRecHitSoAFromLegacy(const edm::ParameterSet &iConfig)
const bool convert2Legacy_
uint16_t *__restrict__ uint16_t const *__restrict__ adc