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();
133 assert(gind < gpuClustering::maxNumModules);
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];
141 assert(numberOfClusters ==
int(hitsModuleStart[gpuClustering::maxNumModules]));
146 std::make_unique<TrackingRecHit2DCPU>(numberOfClusters, hitsModuleStart[96], &cpeView, hitsModuleStart,
nullptr);
148 if (0 == numberOfClusters) {
156 legacyOutput->reserve(gpuClustering::maxNumModules, numberOfClusters);
158 int numberOfDetUnits = 0;
159 int numberOfHits = 0;
160 for (
auto const& dsv : input) {
162 unsigned int detid = dsv.detId();
163 DetId detIdObject(detid);
165 auto const gind = genericDet->
index();
166 assert(gind < gpuClustering::maxNumModules);
169 auto const nclus = dsv.size();
170 assert(clusInModule_[gind] == nclus);
174 auto const fc = hitsModuleStart[gind];
175 auto const lc = hitsModuleStart[gind + 1];
177 LogDebug(
"SiPixelRecHitSoAFromLegacy") <<
"in det " << gind <<
": conv " << nclus <<
" hits from " << dsv.size()
178 <<
" legacy clusters" <<
' ' << fc <<
',' << lc;
179 assert((lc - fc) == nclus);
180 if (nclus > maxHitsInModule)
182 "WARNING: too many clusters %d in Module %d. Only first %d Hits converted\n", nclus, gind, maxHitsInModule);
194 for (
auto const& clust : dsv) {
196 for (
int i = 0, nd = clust.size();
i < nd; ++
i) {
197 auto px = clust.pixel(
i);
200 adc.push_back(px.adc);
201 moduleInd.push_back(gind);
205 assert(clust.originalId() == ic);
211 assert(clus.size() == ndigi);
212 numberOfHits += nclus;
215 assert(digiView.adc(0) != 0);
217 gpuPixelRecHits::getHits(&cpeView, &bsHost, &digiView, ndigi, &clusterView,
output->view());
218 for (
auto h = fc;
h < lc; ++
h)
219 if (
h - fc < maxHitsInModule)
225 for (
auto h = fc;
h < lc; ++
h) {
227 if (ih >= maxHitsInModule)
229 assert(ih < clusterRef.size());
238 assert(numberOfHits == numberOfClusters);
242 output->hitsLayerStart()[
i] = hitsModuleStart[cpeView.layerGeometry().layerStart[
i]];
244 cms::cuda::fillManyFromVector(
output->phiBinner(),
250 output->phiBinnerStorage());
252 LogDebug(
"SiPixelRecHitSoAFromLegacy") <<
"created HitSoa for " << numberOfClusters <<
" clusters in "
253 << 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)
double z0() const
z coordinate
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void push_back(data_type const &d)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
constexpr uint32_t numberOfLayers
#define DEFINE_FWK_MODULE(type)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
constexpr uint32_t maxHitsInModule()
const edm::EDGetTokenT< reco::BeamSpot > bsGetToken_
~SiPixelRecHitSoAFromLegacy() override=default
static std::string const input
bool getData(T &iHolder) const
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
bool get(ProductID const &oid, Handle< PROD > &result) const
constexpr uint16_t maxNumModules
ParameterDescriptionBase * add(U const &iLabel, T const &value)
constexpr uint16_t invalidModuleId
T getParameter(std::string const &) const
std::array< uint32_t, gpuClustering::maxNumModules+1 > HitModuleStart
const edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > cpeToken_
Pixel cluster – collection of neighboring pixels above threshold.
unsigned int QualWordType
const edm::EDPutTokenT< HMSstorage > tokenModuleStart_
double y0() const
y coordinate
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
double x0() const
x coordinate