CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SiPixelRecHitFromCUDAT< TrackerTraits > Class Template Reference
Inheritance diagram for SiPixelRecHitFromCUDAT< TrackerTraits >:
edm::stream::EDProducer< edm::ExternalWork >

Public Types

using HitsOnDevice = TrackingRecHitSoADevice< TrackerTraits >
 
using HMSstorage = HostProduct< uint32_t[]>
 
- Public Types inherited from edm::stream::EDProducer< edm::ExternalWork >
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Public Member Functions

 SiPixelRecHitFromCUDAT (const edm::ParameterSet &iConfig)
 
 ~SiPixelRecHitFromCUDAT () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::ExternalWork >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void acquire (edm::Event const &iEvent, edm::EventSetup const &iSetup, edm::WaitingTaskWithArenaHolder waitingTaskHolder) override
 
void produce (edm::Event &iEvent, edm::EventSetup const &iSetup) override
 

Private Attributes

const edm::EDGetTokenT< SiPixelClusterCollectionNewclusterToken_
 
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordgeomToken_
 
cms::cuda::host::unique_ptr< uint32_t[]> hitsModuleStart_
 
const edm::EDGetTokenT< cms::cuda::Product< HitsOnDevice > > hitsToken_
 
const edm::EDPutTokenT< HMSstoragehostPutToken_
 
uint32_t nHits_
 
const edm::EDPutTokenT< SiPixelRecHitCollectionrechitsPutToken_
 
cms::cuda::host::unique_ptr< float[]> store32_
 

Detailed Description

template<typename TrackerTraits>
class SiPixelRecHitFromCUDAT< TrackerTraits >

Definition at line 28 of file SiPixelRecHitFromCUDA.cc.

Member Typedef Documentation

◆ HitsOnDevice

template<typename TrackerTraits >
using SiPixelRecHitFromCUDAT< TrackerTraits >::HitsOnDevice = TrackingRecHitSoADevice<TrackerTraits>

Definition at line 36 of file SiPixelRecHitFromCUDA.cc.

◆ HMSstorage

template<typename TrackerTraits >
using SiPixelRecHitFromCUDAT< TrackerTraits >::HMSstorage = HostProduct<uint32_t[]>

Definition at line 35 of file SiPixelRecHitFromCUDA.cc.

Constructor & Destructor Documentation

◆ SiPixelRecHitFromCUDAT()

template<typename TrackerTraits >
SiPixelRecHitFromCUDAT< TrackerTraits >::SiPixelRecHitFromCUDAT ( const edm::ParameterSet iConfig)
explicit

Definition at line 56 of file SiPixelRecHitFromCUDA.cc.

58  hitsToken_(consumes<cms::cuda::Product<HitsOnDevice>>(iConfig.getParameter<edm::InputTag>("pixelRecHitSrc"))),
59  clusterToken_(consumes<SiPixelClusterCollectionNew>(iConfig.getParameter<edm::InputTag>("src"))),
60  rechitsPutToken_(produces<SiPixelRecHitCollection>()),
61  hostPutToken_(produces<HMSstorage>()) {}
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDPutTokenT< HMSstorage > hostPutToken_
const edm::EDGetTokenT< cms::cuda::Product< HitsOnDevice > > hitsToken_
const edm::EDPutTokenT< SiPixelRecHitCollection > rechitsPutToken_
const edm::EDGetTokenT< SiPixelClusterCollectionNew > clusterToken_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_

◆ ~SiPixelRecHitFromCUDAT()

template<typename TrackerTraits >
SiPixelRecHitFromCUDAT< TrackerTraits >::~SiPixelRecHitFromCUDAT ( )
overridedefault

Member Function Documentation

◆ acquire()

template<typename TrackerTraits >
void SiPixelRecHitFromCUDAT< TrackerTraits >::acquire ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup,
edm::WaitingTaskWithArenaHolder  waitingTaskHolder 
)
overrideprivate

Definition at line 73 of file SiPixelRecHitFromCUDA.cc.

References iEvent, LogDebug, and eostools::move().

75  {
76  cms::cuda::Product<HitsOnDevice> const& inputDataWrapped = iEvent.get(hitsToken_);
77 
78  cms::cuda::ScopedContextAcquire ctx{inputDataWrapped, std::move(waitingTaskHolder)};
79 
80  auto const& inputData = ctx.get(inputDataWrapped);
81 
82  nHits_ = inputData.nHits();
83  LogDebug("SiPixelRecHitFromCUDA") << "converting " << nHits_ << " Hits";
84 
85  if (0 == nHits_)
86  return;
87  store32_ = inputData.localCoordToHostAsync(ctx.stream());
88 
89  hitsModuleStart_ = inputData.hitsModuleStartToHostAsync(ctx.stream());
90 }
const edm::EDGetTokenT< cms::cuda::Product< HitsOnDevice > > hitsToken_
cms::cuda::host::unique_ptr< uint32_t[]> hitsModuleStart_
int iEvent
Definition: GenABIO.cc:224
cms::cuda::host::unique_ptr< float[]> store32_
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

◆ fillDescriptions()

template<typename TrackerTraits >
void SiPixelRecHitFromCUDAT< TrackerTraits >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 64 of file SiPixelRecHitFromCUDA.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

64  {
66  desc.add<edm::InputTag>("pixelRecHitSrc", edm::InputTag("siPixelRecHitsPreSplittingCUDA"));
67  desc.add<edm::InputTag>("src", edm::InputTag("siPixelClustersPreSplitting"));
68 
69  descriptions.addWithDefaultLabel(desc);
70 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ produce()

template<typename TrackerTraits >
void SiPixelRecHitFromCUDAT< TrackerTraits >::produce ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
overrideprivate

Definition at line 93 of file SiPixelRecHitFromCUDA.cc.

References cms::cuda::assert(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), filterCSVwithJSON::copy, edmNew::DetSetVector< T >::FastFiller::emplace_back(), relativeConstraints::geom, edm::EventSetup::getData(), iEvent, GeomDet::index(), input, dqmdumpme::k, LogDebug, edmNew::makeRefTo(), pixelClustering::maxHitsInModule(), SiStripPI::min, eostools::move(), nhits, gpuClustering::nMaxModules, electrons_cff::numberOfClusters, phase1PixelTopology::numberOfModules, convertSQLitetoXML_cfg::output, and edmNew::DetSetVector< T >::FastFiller::size().

93  {
94  // allocate a buffer for the indices of the clusters
96  auto hmsp = std::make_unique<uint32_t[]>(nMaxModules + 1);
97 
99  output.reserve(nMaxModules, nHits_);
100 
101  if (0 == nHits_) {
103  iEvent.emplace(hostPutToken_, std::move(hmsp));
104  return;
105  }
106  output.reserve(nMaxModules, nHits_);
107 
108  std::copy(hitsModuleStart_.get(), hitsModuleStart_.get() + nMaxModules + 1, hmsp.get());
109  // wrap the buffer in a HostProduct, and move it to the Event, without reallocating the buffer or affecting hitsModuleStart
110  iEvent.emplace(hostPutToken_, std::move(hmsp));
111 
112  auto xl = store32_.get();
113  auto yl = xl + nHits_;
114  auto xe = yl + nHits_;
115  auto ye = xe + nHits_;
116 
117  const TrackerGeometry* geom = &es.getData(geomToken_);
118 
120  auto const& input = *hclusters;
121 
123 
124  int numberOfDetUnits = 0;
125  int numberOfClusters = 0;
126  for (auto const& dsv : input) {
127  numberOfDetUnits++;
128  unsigned int detid = dsv.detId();
129  DetId detIdObject(detid);
130  const GeomDetUnit* genericDet = geom->idToDetUnit(detIdObject);
131  auto gind = genericDet->index();
132  const PixelGeomDetUnit* pixDet = dynamic_cast<const PixelGeomDetUnit*>(genericDet);
133  assert(pixDet);
134  SiPixelRecHitCollection::FastFiller recHitsOnDetUnit(output, detid);
135  auto fc = hitsModuleStart_[gind];
136  auto lc = hitsModuleStart_[gind + 1];
137  auto nhits = lc - fc;
138 
139  assert(lc > fc);
140  LogDebug("SiPixelRecHitFromCUDA") << "in det " << gind << ": conv " << nhits << " hits from " << dsv.size()
141  << " legacy clusters" << ' ' << fc << ',' << lc << "\n";
142  if (nhits > maxHitsInModule)
143  edm::LogWarning("SiPixelRecHitFromCUDA") << fmt::sprintf(
144  "Too many clusters %d in module %d. Only the first %d hits will be converted", nhits, gind, maxHitsInModule);
146 
147  LogDebug("SiPixelRecHitFromCUDA") << "in det " << gind << "conv " << nhits << " hits from " << dsv.size()
148  << " legacy clusters" << ' ' << lc << ',' << fc;
149 
150  if (0 == nhits)
151  continue;
152  auto jnd = [&](int k) { return fc + k; };
153  assert(nhits <= dsv.size());
154  if (nhits != dsv.size()) {
155  edm::LogWarning("GPUHits2CPU") << "nhits!= nclus " << nhits << ' ' << dsv.size();
156  }
157  for (auto const& clust : dsv) {
158  assert(clust.originalId() >= 0);
159  assert(clust.originalId() < dsv.size());
160  if (clust.originalId() >= nhits)
161  continue;
162  auto ij = jnd(clust.originalId());
163  LocalPoint lp(xl[ij], yl[ij]);
164  LocalError le(xe[ij], 0, ye[ij]);
166 
168 
169  /* cpu version.... (for reference)
170  std::tuple<LocalPoint, LocalError, SiPixelRecHitQuality::QualWordType> tuple = cpe_->getParameters( clust, *genericDet );
171  LocalPoint lp( std::get<0>(tuple) );
172  LocalError le( std::get<1>(tuple) );
173  SiPixelRecHitQuality::QualWordType rqw( std::get<2>(tuple) );
174  */
175 
176  // Create a persistent edm::Ref to the cluster
178  // Make a RecHit and add it to the DetSet
179  recHitsOnDetUnit.emplace_back(lp, le, rqw, *genericDet, cluster);
180  // =============================
181 
182  LogDebug("SiPixelRecHitFromCUDA") << "cluster " << numberOfClusters << " at " << lp << ' ' << le;
183 
184  } // <-- End loop on Clusters
185 
186  // LogDebug("SiPixelRecHitGPU")
187  LogDebug("SiPixelRecHitFromCUDA") << "found " << recHitsOnDetUnit.size() << " RecHits on " << detid;
188 
189  } // <-- End loop on DetUnits
190 
191  LogDebug("SiPixelRecHitFromCUDA") << "found " << numberOfDetUnits << " dets, " << numberOfClusters << " clusters";
192 
194 }
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)
constexpr int nMaxModules
Definition: gpuClustering.h:77
int index() const
Definition: GeomDet.h:83
const edm::EDPutTokenT< HMSstorage > hostPutToken_
assert(be >=bs)
constexpr uint16_t numberOfModules
static std::string const input
Definition: EdmProvDump.cc:50
const edm::EDPutTokenT< SiPixelRecHitCollection > rechitsPutToken_
const edm::EDGetTokenT< SiPixelClusterCollectionNew > clusterToken_
cms::cuda::host::unique_ptr< uint32_t[]> hitsModuleStart_
int iEvent
Definition: GenABIO.cc:224
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
cms::cuda::host::unique_ptr< float[]> store32_
Definition: DetId.h:17
Pixel cluster – collection of neighboring pixels above threshold.
Definition: output.py:1
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511
constexpr uint32_t maxHitsInModule()
#define LogDebug(id)

Member Data Documentation

◆ clusterToken_

template<typename TrackerTraits >
const edm::EDGetTokenT<SiPixelClusterCollectionNew> SiPixelRecHitFromCUDAT< TrackerTraits >::clusterToken_
private

Definition at line 46 of file SiPixelRecHitFromCUDA.cc.

◆ geomToken_

template<typename TrackerTraits >
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SiPixelRecHitFromCUDAT< TrackerTraits >::geomToken_
private

Definition at line 44 of file SiPixelRecHitFromCUDA.cc.

◆ hitsModuleStart_

template<typename TrackerTraits >
cms::cuda::host::unique_ptr<uint32_t[]> SiPixelRecHitFromCUDAT< TrackerTraits >::hitsModuleStart_
private

Definition at line 52 of file SiPixelRecHitFromCUDA.cc.

◆ hitsToken_

template<typename TrackerTraits >
const edm::EDGetTokenT<cms::cuda::Product<HitsOnDevice> > SiPixelRecHitFromCUDAT< TrackerTraits >::hitsToken_
private

Definition at line 45 of file SiPixelRecHitFromCUDA.cc.

◆ hostPutToken_

template<typename TrackerTraits >
const edm::EDPutTokenT<HMSstorage> SiPixelRecHitFromCUDAT< TrackerTraits >::hostPutToken_
private

Definition at line 48 of file SiPixelRecHitFromCUDA.cc.

◆ nHits_

template<typename TrackerTraits >
uint32_t SiPixelRecHitFromCUDAT< TrackerTraits >::nHits_
private

Definition at line 50 of file SiPixelRecHitFromCUDA.cc.

◆ rechitsPutToken_

template<typename TrackerTraits >
const edm::EDPutTokenT<SiPixelRecHitCollection> SiPixelRecHitFromCUDAT< TrackerTraits >::rechitsPutToken_
private

Definition at line 47 of file SiPixelRecHitFromCUDA.cc.

◆ store32_

template<typename TrackerTraits >
cms::cuda::host::unique_ptr<float[]> SiPixelRecHitFromCUDAT< TrackerTraits >::store32_
private

Definition at line 51 of file SiPixelRecHitFromCUDA.cc.