CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
HFShowerLibrary::BranchCache Struct Reference

Public Member Functions

 BranchCache (BranchReader &, size_t maxRecordsToCache)
 
HFShowerPhotonCollection getRecord (int) const
 

Private Attributes

std::vector< std::size_t > offsets_
 
HFShowerPhotonCollection photons_
 

Detailed Description

Definition at line 124 of file HFShowerLibrary.h.

Constructor & Destructor Documentation

◆ BranchCache()

HFShowerLibrary::BranchCache::BranchCache ( HFShowerLibrary::BranchReader iReader,
size_t  maxRecordsToCache 
)
explicit

Definition at line 413 of file HFShowerLibrary.cc.

References filterCSVwithJSON::copy, HFShowerLibrary::BranchReader::getRecord(), run3scouting_cff::nPhotons, HFShowerLibrary::BranchReader::numberOfRecords(), hltrates_dqm_sourceclient-live_cfg::offset, offsets_, photons_, and alignCSCRings::r.

413  {
414  auto nRecords = iReader.numberOfRecords();
415  if (nRecords > maxRecordsToCache) {
416  nRecords = maxRecordsToCache;
417  }
418  offsets_.reserve(nRecords + 1);
419 
420  //first pass is to figure out how much space will be needed
421  size_t nPhotons = 0;
422  for (size_t r = 0; r < nRecords; ++r) {
423  auto shower = iReader.getRecord(r + 1);
424  nPhotons += shower.size();
425  }
426 
427  photons_.reserve(nPhotons);
428 
429  size_t offset = 0;
430  for (size_t r = 0; r < nRecords; ++r) {
431  offsets_.emplace_back(offset);
432  auto shower = iReader.getRecord(r + 1);
433  offset += shower.size();
434  std::copy(shower.begin(), shower.end(), std::back_inserter(photons_));
435  }
436  offsets_.emplace_back(offset);
437  photons_.shrink_to_fit();
438 }
std::size_t numberOfRecords() const
std::vector< std::size_t > offsets_
HFShowerPhotonCollection photons_
HFShowerPhotonCollection getRecord(int) const

Member Function Documentation

◆ getRecord()

HFShowerPhotonCollection HFShowerLibrary::BranchCache::getRecord ( int  iRecord) const

Definition at line 459 of file HFShowerLibrary.cc.

References cms::cuda::assert(), mps_fire::end, and command_line::start.

459  {
460  assert(iRecord > 0);
461  assert(static_cast<size_t>(iRecord + 1) < offsets_.size());
462 
463  auto start = offsets_[iRecord - 1];
464  auto end = offsets_[iRecord];
465 
466  return HFShowerPhotonCollection(photons_.begin() + start, photons_.begin() + end);
467 }
Definition: start.py:1
assert(be >=bs)
std::vector< HFShowerPhoton > HFShowerPhotonCollection
std::vector< std::size_t > offsets_
HFShowerPhotonCollection photons_

Member Data Documentation

◆ offsets_

std::vector<std::size_t> HFShowerLibrary::BranchCache::offsets_
private

Definition at line 130 of file HFShowerLibrary.h.

Referenced by BranchCache().

◆ photons_

HFShowerPhotonCollection HFShowerLibrary::BranchCache::photons_
private

Definition at line 129 of file HFShowerLibrary.h.

Referenced by BranchCache().