1 #include <cuda_runtime.h> 31 template <
typename TrackerTraits>
39 using HitModuleStart = std::array<uint32_t, TrackerTraits::numberOfModules + 1>;
55 template <
typename TrackerTraits>
60 clusterToken_{consumes<SiPixelClusterCollectionNew>(iConfig.getParameter<
edm::InputTag>(
"src"))},
61 tokenHit_{produces<HitsOnHost>()},
62 tokenModuleStart_{produces<HMSstorage>()},
63 convert2Legacy_(iConfig.getParameter<
bool>(
"convertToLegacy")) {
65 produces<SiPixelRecHitCollectionNew>();
68 template <
typename TrackerTraits>
75 cpeName += TrackerTraits::nameModifier;
77 desc.add<
bool>(
"convertToLegacy",
false);
82 template <
typename TrackerTraits>
89 throw cms::Exception(
"Configuration") <<
"SiPixelRecHitSoAFromLegacy can only use a CPE of type PixelCPEFast";
91 auto const& cpeView = fcpe->getCPUProduct();
101 iEvent.getByToken(clusterToken_, hclusters);
102 auto const&
input = *hclusters;
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;
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;
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();
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;
232 gpuPixelRecHits::getHits(&cpeView, &bsHost, digis_h.
view(), ndigi, clusters_h.
view(),
output.view());
233 for (
auto h = fc;
h < lc; ++
h)
239 if (convert2Legacy_) {
241 for (
auto h = fc;
h < lc; ++
h) {
247 assert(ih < clusterRef.size());
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";
272 output.view().hitsLayerStart().data(),
275 output.view().phiBinnerStorage());
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)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void push_back(data_type const &d)
T getParameter(std::string const &) const
std::array< uint32_t, TrackerTraits::numberOfModules+1 > HitModuleStart
~SiPixelRecHitSoAFromLegacyT() override=default
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
constexpr uint32_t numberOfLayers
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_
void produce(edm::StreamID streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
const edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > cpeToken_
#define DEFINE_FWK_MODULE(type)
const bool convert2Legacy_
constexpr uint16_t invalidModuleId
const edm::EDGetTokenT< reco::BeamSpot > bsGetToken_
Pixel cluster – collection of neighboring pixels above threshold.
unsigned int QualWordType
constexpr int32_t maxNumClustersPerModules
SiPixelRecHitSoAFromLegacyT(const edm::ParameterSet &iConfig)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
constexpr uint32_t maxHitsInModule()
const edm::EDGetTokenT< SiPixelClusterCollectionNew > clusterToken_