CMS 3D CMS Logo

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

Public Types

using HMSstorage = HostProduct< uint32_t[]>
 
- Public Types inherited from edm::stream::EDProducer< edm::ExternalWork >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Public Member Functions

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

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< TrackingRecHit2DCUDA > > hitsToken_
 
const edm::EDPutTokenT< HMSstoragehostPutToken_
 
uint32_t nHits_
 
const edm::EDPutTokenT< SiPixelRecHitCollectionrechitsPutToken_
 
cms::cuda::host::unique_ptr< float[]> store32_
 

Detailed Description

Definition at line 27 of file SiPixelRecHitFromCUDA.cc.

Member Typedef Documentation

◆ HMSstorage

Definition at line 34 of file SiPixelRecHitFromCUDA.cc.

Constructor & Destructor Documentation

◆ SiPixelRecHitFromCUDA()

SiPixelRecHitFromCUDA::SiPixelRecHitFromCUDA ( const edm::ParameterSet iConfig)
explicit

Definition at line 53 of file SiPixelRecHitFromCUDA.cc.

55  hitsToken_(
56  consumes<cms::cuda::Product<TrackingRecHit2DCUDA>>(iConfig.getParameter<edm::InputTag>("pixelRecHitSrc"))),
57  clusterToken_(consumes<SiPixelClusterCollectionNew>(iConfig.getParameter<edm::InputTag>("src"))),
58  rechitsPutToken_(produces<SiPixelRecHitCollection>()),
59  hostPutToken_(produces<HMSstorage>()) {}

◆ ~SiPixelRecHitFromCUDA()

SiPixelRecHitFromCUDA::~SiPixelRecHitFromCUDA ( )
overridedefault

Member Function Documentation

◆ acquire()

void SiPixelRecHitFromCUDA::acquire ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup,
edm::WaitingTaskWithArenaHolder  waitingTaskHolder 
)
overrideprivate

Definition at line 68 of file SiPixelRecHitFromCUDA.cc.

70  {
71  cms::cuda::Product<TrackingRecHit2DCUDA> const& inputDataWrapped = iEvent.get(hitsToken_);
72  cms::cuda::ScopedContextAcquire ctx{inputDataWrapped, std::move(waitingTaskHolder)};
73  auto const& inputData = ctx.get(inputDataWrapped);
74 
75  nHits_ = inputData.nHits();
76 
77  LogDebug("SiPixelRecHitFromCUDA") << "converting " << nHits_ << " Hits";
78 
79  if (0 == nHits_)
80  return;
81  store32_ = inputData.localCoordToHostAsync(ctx.stream());
82  hitsModuleStart_ = inputData.hitsModuleStartToHostAsync(ctx.stream());
83 }

References hitsModuleStart_, hitsToken_, iEvent, LogDebug, eostools::move(), nHits_, and store32_.

◆ fillDescriptions()

void SiPixelRecHitFromCUDA::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 61 of file SiPixelRecHitFromCUDA.cc.

61  {
63  desc.add<edm::InputTag>("pixelRecHitSrc", edm::InputTag("siPixelRecHitsPreSplittingCUDA"));
64  desc.add<edm::InputTag>("src", edm::InputTag("siPixelClustersPreSplitting"));
65  descriptions.addWithDefaultLabel(desc);
66 }

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

◆ produce()

void SiPixelRecHitFromCUDA::produce ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
overrideprivate

Definition at line 85 of file SiPixelRecHitFromCUDA.cc.

85  {
86  // allocate a buffer for the indices of the clusters
87  auto hmsp = std::make_unique<uint32_t[]>(gpuClustering::maxNumModules + 1);
89  // wrap the buffer in a HostProduct, and move it to the Event, without reallocating the buffer or affecting hitsModuleStart
90  iEvent.emplace(hostPutToken_, std::move(hmsp));
91 
93  if (0 == nHits_) {
95  return;
96  }
97 
98  auto xl = store32_.get();
99  auto yl = xl + nHits_;
100  auto xe = yl + nHits_;
101  auto ye = xe + nHits_;
102 
103  const TrackerGeometry* geom = &es.getData(geomToken_);
104 
106  auto const& input = *hclusters;
107 
108  constexpr uint32_t maxHitsInModule = gpuClustering::maxHitsInModule();
109 
110  int numberOfDetUnits = 0;
111  int numberOfClusters = 0;
112  for (auto const& dsv : input) {
113  numberOfDetUnits++;
114  unsigned int detid = dsv.detId();
115  DetId detIdObject(detid);
116  const GeomDetUnit* genericDet = geom->idToDetUnit(detIdObject);
117  auto gind = genericDet->index();
118  const PixelGeomDetUnit* pixDet = dynamic_cast<const PixelGeomDetUnit*>(genericDet);
119  assert(pixDet);
120  SiPixelRecHitCollection::FastFiller recHitsOnDetUnit(output, detid);
121  auto fc = hitsModuleStart_[gind];
122  auto lc = hitsModuleStart_[gind + 1];
123  auto nhits = lc - fc;
124 
125  assert(lc > fc);
126  LogDebug("SiPixelRecHitFromCUDA") << "in det " << gind << ": conv " << nhits << " hits from " << dsv.size()
127  << " legacy clusters" << ' ' << fc << ',' << lc;
128  if (nhits > maxHitsInModule)
129  edm::LogWarning("SiPixelRecHitFromCUDA") << fmt::sprintf(
130  "Too many clusters %d in module %d. Only the first %d hits will be converted", nhits, gind, maxHitsInModule);
132 
133  LogDebug("SiPixelRecHitFromCUDA") << "in det " << gind << "conv " << nhits << " hits from " << dsv.size()
134  << " legacy clusters" << ' ' << lc << ',' << fc;
135 
136  if (0 == nhits)
137  continue;
138  auto jnd = [&](int k) { return fc + k; };
139  assert(nhits <= dsv.size());
140  if (nhits != dsv.size()) {
141  edm::LogWarning("GPUHits2CPU") << "nhits!= nclus " << nhits << ' ' << dsv.size();
142  }
143  for (auto const& clust : dsv) {
144  assert(clust.originalId() >= 0);
145  assert(clust.originalId() < dsv.size());
146  if (clust.originalId() >= nhits)
147  continue;
148  auto ij = jnd(clust.originalId());
150  continue; // overflow...
151  LocalPoint lp(xl[ij], yl[ij]);
152  LocalError le(xe[ij], 0, ye[ij]);
154 
155  numberOfClusters++;
156 
157  /* cpu version.... (for reference)
158  std::tuple<LocalPoint, LocalError, SiPixelRecHitQuality::QualWordType> tuple = cpe_->getParameters( clust, *genericDet );
159  LocalPoint lp( std::get<0>(tuple) );
160  LocalError le( std::get<1>(tuple) );
161  SiPixelRecHitQuality::QualWordType rqw( std::get<2>(tuple) );
162  */
163 
164  // Create a persistent edm::Ref to the cluster
166  // Make a RecHit and add it to the DetSet
167  SiPixelRecHit hit(lp, le, rqw, *genericDet, cluster);
168  //
169  // Now save it =================
170  recHitsOnDetUnit.push_back(hit);
171  // =============================
172 
173  LogDebug("SiPixelRecHitFromCUDA") << "cluster " << numberOfClusters << " at " << lp << ' ' << le;
174 
175  } // <-- End loop on Clusters
176 
177  // LogDebug("SiPixelRecHitGPU")
178  LogDebug("SiPixelRecHitFromCUDA") << "found " << recHitsOnDetUnit.size() << " RecHits on " << detid;
179 
180  } // <-- End loop on DetUnits
181 
182  LogDebug("SiPixelRecHitFromCUDA") << "found " << numberOfDetUnits << " dets, " << numberOfClusters << " clusters";
183 
185 }

References cms::cuda::assert(), clusterToken_, filterCSVwithJSON::copy, benchmark_cfg::fc, relativeConstraints::geom, geomToken_, edm::EventSetup::getData(), hitsModuleStart_, hostPutToken_, iEvent, GeomDet::index(), input, dqmdumpme::k, LogDebug, edmNew::makeRefTo(), TrackingRecHit2DSOAView::maxHits(), gpuClustering::maxHitsInModule(), gpuClustering::maxNumModules, min(), eostools::move(), nhits, nHits_, convertSQLitetoXML_cfg::output, edmNew::DetSetVector< T >::FastFiller::push_back(), rechitsPutToken_, edmNew::DetSetVector< T >::FastFiller::size(), and store32_.

Member Data Documentation

◆ clusterToken_

const edm::EDGetTokenT<SiPixelClusterCollectionNew> SiPixelRecHitFromCUDA::clusterToken_
private

Definition at line 44 of file SiPixelRecHitFromCUDA.cc.

Referenced by produce().

◆ geomToken_

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SiPixelRecHitFromCUDA::geomToken_
private

Definition at line 42 of file SiPixelRecHitFromCUDA.cc.

Referenced by produce().

◆ hitsModuleStart_

cms::cuda::host::unique_ptr<uint32_t[]> SiPixelRecHitFromCUDA::hitsModuleStart_
private

Definition at line 50 of file SiPixelRecHitFromCUDA.cc.

Referenced by acquire(), and produce().

◆ hitsToken_

const edm::EDGetTokenT<cms::cuda::Product<TrackingRecHit2DCUDA> > SiPixelRecHitFromCUDA::hitsToken_
private

Definition at line 43 of file SiPixelRecHitFromCUDA.cc.

Referenced by acquire().

◆ hostPutToken_

const edm::EDPutTokenT<HMSstorage> SiPixelRecHitFromCUDA::hostPutToken_
private

Definition at line 46 of file SiPixelRecHitFromCUDA.cc.

Referenced by produce().

◆ nHits_

uint32_t SiPixelRecHitFromCUDA::nHits_
private

Definition at line 48 of file SiPixelRecHitFromCUDA.cc.

Referenced by acquire(), and produce().

◆ rechitsPutToken_

const edm::EDPutTokenT<SiPixelRecHitCollection> SiPixelRecHitFromCUDA::rechitsPutToken_
private

Definition at line 45 of file SiPixelRecHitFromCUDA.cc.

Referenced by produce().

◆ store32_

cms::cuda::host::unique_ptr<float[]> SiPixelRecHitFromCUDA::store32_
private

Definition at line 49 of file SiPixelRecHitFromCUDA.cc.

Referenced by acquire(), and produce().

SiPixelRecHitFromCUDA::hostPutToken_
const edm::EDPutTokenT< HMSstorage > hostPutToken_
Definition: SiPixelRecHitFromCUDA.cc:46
SiPixelRecHitFromCUDA::hitsToken_
const edm::EDGetTokenT< cms::cuda::Product< TrackingRecHit2DCUDA > > hitsToken_
Definition: SiPixelRecHitFromCUDA.cc:43
gpuClustering::maxHitsInModule
constexpr uint32_t maxHitsInModule()
Definition: gpuClusteringConstants.h:27
input
static const std::string input
Definition: EdmProvDump.cc:48
GeomDet
Definition: GeomDet.h:27
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
min
T min(T a, T b)
Definition: MathUtil.h:58
SiPixelRecHitFromCUDA::store32_
cms::cuda::host::unique_ptr< float[]> store32_
Definition: SiPixelRecHitFromCUDA.cc:49
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89281
edmNew::makeRefTo
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)
Definition: DetSetVectorNew.h:689
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
cms::cuda::assert
assert(be >=bs)
GeomDet::index
int index() const
Definition: GeomDet.h:83
SiPixelCluster
Pixel cluster – collection of neighboring pixels above threshold.
Definition: SiPixelCluster.h:28
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
SiPixelRecHit
Our base class.
Definition: SiPixelRecHit.h:23
edm::Ref
Definition: AssociativeIterator.h:58
DetId
Definition: DetId.h:17
SiPixelRecHitFromCUDA::hitsModuleStart_
cms::cuda::host::unique_ptr< uint32_t[]> hitsModuleStart_
Definition: SiPixelRecHitFromCUDA.cc:50
SiPixelRecHitQuality::QualWordType
unsigned int QualWordType
Definition: SiPixelRecHitQuality.h:9
PixelGeomDetUnit
Definition: PixelGeomDetUnit.h:15
TrackingRecHit2DSOAView::maxHits
static constexpr uint32_t maxHits()
Definition: TrackingRecHit2DSOAView.h:17
benchmark_cfg.fc
fc
Definition: benchmark_cfg.py:15
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
dqmdumpme.k
k
Definition: dqmdumpme.py:60
Point3DBase< float, LocalTag >
nhits
Definition: HIMultiTrackSelector.h:42
gpuClustering::maxNumModules
constexpr uint16_t maxNumModules
Definition: gpuClusteringConstants.h:29
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
LocalError
Definition: LocalError.h:12
iEvent
int iEvent
Definition: GenABIO.cc:224
SiPixelRecHitFromCUDA::rechitsPutToken_
const edm::EDPutTokenT< SiPixelRecHitCollection > rechitsPutToken_
Definition: SiPixelRecHitFromCUDA.cc:45
SiPixelRecHitFromCUDA::geomToken_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
Definition: SiPixelRecHitFromCUDA.cc:42
SiPixelRecHitFromCUDA::clusterToken_
const edm::EDGetTokenT< SiPixelClusterCollectionNew > clusterToken_
Definition: SiPixelRecHitFromCUDA.cc:44
cms::cuda::ScopedContextAcquire
Definition: ScopedContext.h:101
edmNew::DetSetVector
Definition: DetSetNew.h:13
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
cms::cuda::Product
Definition: Product.h:34
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edmNew::DetSetVector::FastFiller
Definition: DetSetVectorNew.h:202
SiPixelRecHitFromCUDA::nHits_
uint32_t nHits_
Definition: SiPixelRecHitFromCUDA.cc:48
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::InputTag
Definition: InputTag.h:15
hit
Definition: SiStripHitEffFromCalibTree.cc:88
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87
TrackerGeometry
Definition: TrackerGeometry.h:14