LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
evd::details::RawDigitCacheDataClass Class Reference

Cached set of RawDigitInfo_t. More...

Classes

struct  BoolWithUpToDateMetadata
 

Public Member Functions

std::vector< RawDigitInfo_t > const & Digits () const
 Returns the list of digit info. More...
 
RawDigitInfo_t const * FindChannel (raw::ChannelID_t channel) const
 Returns a pointer to the digit info of given channel, nullptr if none. More...
 
size_t MaxSamples () const
 Returns the largest number of samples in the unpacked raw digits. More...
 
bool empty () const
 Returns whether the cache is empty() (STL-like interface) More...
 
void Clear ()
 Empties the cache. More...
 
void Refill (art::Handle< std::vector< raw::RawDigit >> &rdcol)
 Fills the cache from the specified raw digits product handle. More...
 
void Invalidate ()
 Clears the cache and marks it as invalid (use Update() to fill it) More...
 
bool Update (art::Event const &evt, CacheID_t const &new_timestamp)
 
template<typename Stream >
void Dump (Stream &&out) const
 Dump the content of the cache. More...
 

Private Member Functions

BoolWithUpToDateMetadata CheckUpToDate (CacheID_t const &ts, art::Event const *evt=nullptr) const
 Checks whether an update is needed; can load digits in the process. More...
 

Static Private Member Functions

static std::vector< raw::RawDigit > const * ReadProduct (art::Event const &evt, art::InputTag label)
 

Private Attributes

std::vector< RawDigitInfo_tdigits
 vector of raw digit information More...
 
CacheID_t timestamp
 object expressing validity range of cached data More...
 
size_t max_samples = 0
 the largest number of ticks in any digit More...
 

Detailed Description

Cached set of RawDigitInfo_t.

Definition at line 249 of file RawDataDrawer.cxx.

Member Function Documentation

RawDigitCacheDataClass::BoolWithUpToDateMetadata evd::details::RawDigitCacheDataClass::CheckUpToDate ( CacheID_t const &  ts,
art::Event const *  evt = nullptr 
) const
private

Checks whether an update is needed; can load digits in the process.

Definition at line 1712 of file RawDataDrawer.cxx.

References evd::details::RawDigitInfo_t::Digit(), evd::details::RawDigitCacheDataClass::BoolWithUpToDateMetadata::digits, util::DataProductChangeTracker_t::inputLabel(), util::PlaneDataChangeTracker_t::sameProduct(), and Update().

1713  {
1714  BoolWithUpToDateMetadata res{ false, nullptr };
1715 
1716  // normally only if either the event or the product label have changed,
1717  // cache becomes invalid:
1718  if (!ts.sameProduct(timestamp)) return res; // outdated cache
1719 
1720  // But: our cache stores pointers to the original data, and on a new TPC
1721  // the event display may reload the event anew, removing the "old" data
1722  // from memory.
1723  // Since TPC can change with or without the data being invalidated,
1724  // a more accurate verification is needed.
1725 
1726  // if the cache is empty, well, it does not make much difference;
1727  // we invalidate it to be sure
1728  if (empty())
1729  return res; // outdated cache
1730 
1731  if (!evt)
1732  return res; // outdated, since we can't know better without the event
1733 
1734  // here we force reading of the product
1735  res.digits = ReadProduct(*evt, ts.inputLabel());
1736  if (!res.digits)
1737  return res; // outdated cache; this is actually an error
1738 
1739  if (res.digits->empty())
1740  return res; // outdated; no digits (strange!), invalidate just in case
1741 
1742  // use the first digit as test
1743  raw::ChannelID_t channel = res.digits->front().Channel();
1744  RawDigitInfo_t const* pInfo = FindChannel(channel);
1745  if (!pInfo)
1746  return res; // outdated: we don't even have this channel in cache!
1747 
1748  if (&(pInfo->Digit()) != &(res.digits->front()))
1749  return res; // outdated: different memory address for data
1750 
1751  res.bUpToDate = true;
1752  return res; // cache still valid
1753  } // RawDigitCacheDataClass::CheckUpToDate()
CacheID_t timestamp
object expressing validity range of cached data
bool empty() const
Returns whether the cache is empty() (STL-like interface)
RawDigitInfo_t const * FindChannel(raw::ChannelID_t channel) const
Returns a pointer to the digit info of given channel, nullptr if none.
static std::vector< raw::RawDigit > const * ReadProduct(art::Event const &evt, art::InputTag label)
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:27
void evd::details::RawDigitCacheDataClass::Clear ( )

Empties the cache.

Definition at line 1703 of file RawDataDrawer.cxx.

1703  {
1704  Invalidate();
1705  digits.clear();
1706  max_samples = 0;
1707  } // RawDigitCacheDataClass::Clear()
size_t max_samples
the largest number of ticks in any digit
void Invalidate()
Clears the cache and marks it as invalid (use Update() to fill it)
std::vector< RawDigitInfo_t > digits
vector of raw digit information
std::vector<RawDigitInfo_t> const& evd::details::RawDigitCacheDataClass::Digits ( ) const
inline

Returns the list of digit info.

Definition at line 253 of file RawDataDrawer.cxx.

Referenced by evd::details::begin(), and evd::details::end().

253 { return digits; }
std::vector< RawDigitInfo_t > digits
vector of raw digit information
template<typename Stream >
void evd::details::RawDigitCacheDataClass::Dump ( Stream &&  out) const

Dump the content of the cache.

Definition at line 1784 of file RawDataDrawer.cxx.

1784  {
1785  out << "Cache at " << ((void*) this)
1786  << " with time stamp " << std::string(timestamp)
1787  << " and " << digits.size()
1788  << " entries (maximum sample: " << max_samples << ");"
1789  << " data at " << ((void*) digits.data());
1790  for (RawDigitInfo_t const& digitInfo: digits) {
1791  out << "\n ";
1792  digitInfo.Dump(out);
1793  } // for
1794  out << "\n";
1795  } // RawDigitCacheDataClass::Dump()
size_t max_samples
the largest number of ticks in any digit
CacheID_t timestamp
object expressing validity range of cached data
std::vector< RawDigitInfo_t > digits
vector of raw digit information
bool evd::details::RawDigitCacheDataClass::empty ( ) const
inline

Returns whether the cache is empty() (STL-like interface)

Definition at line 262 of file RawDataDrawer.cxx.

References details::PointerToData_t< T >::Clear(), and Update().

Referenced by evd::RawDataDrawer::FillTQHisto(), and evd::RawDataDrawer::RunOperation().

262 { return digits.empty(); }
std::vector< RawDigitInfo_t > digits
vector of raw digit information
RawDigitInfo_t const * evd::details::RawDigitCacheDataClass::FindChannel ( raw::ChannelID_t  channel) const

Returns a pointer to the digit info of given channel, nullptr if none.

Definition at line 1666 of file RawDataDrawer.cxx.

Referenced by evd::RawDataDrawer::FillTQHisto().

1667  {
1668  auto iDigit = std::find_if(
1669  digits.cbegin(), digits.cend(),
1670  [channel](evd::details::RawDigitInfo_t const& digit)
1671  { return digit.Channel() == channel; }
1672  );
1673  return (iDigit == digits.cend())? nullptr: &*iDigit;
1674  } // RawDigitCacheDataClass::FindChannel()
Information about a RawDigit; may contain uncompressed duplicate of data.
std::vector< RawDigitInfo_t > digits
vector of raw digit information
void evd::details::RawDigitCacheDataClass::Invalidate ( )

Clears the cache and marks it as invalid (use Update() to fill it)

Definition at line 1698 of file RawDataDrawer.cxx.

1698  {
1699  timestamp.clear();
1700  } // RawDigitCacheDataClass::Invalidate()
CacheID_t timestamp
object expressing validity range of cached data
void clear()
Set a new event and data product label as current.
size_t evd::details::RawDigitCacheDataClass::MaxSamples ( ) const
inline

Returns the largest number of samples in the unpacked raw digits.

Definition at line 259 of file RawDataDrawer.cxx.

259 { return max_samples; }
size_t max_samples
the largest number of ticks in any digit
std::vector< raw::RawDigit > const * evd::details::RawDigitCacheDataClass::ReadProduct ( art::Event const &  evt,
art::InputTag  label 
)
staticprivate

Definition at line 1677 of file RawDataDrawer.cxx.

References art::DataViewImpl::getByLabel().

1678  {
1680  if (!evt.getByLabel(label, rdcol)) return nullptr;
1681  return &*rdcol;
1682  } // RawDigitCacheDataClass::ReadProduct()
void evd::details::RawDigitCacheDataClass::Refill ( art::Handle< std::vector< raw::RawDigit >> &  rdcol)

Fills the cache from the specified raw digits product handle.

Definition at line 1686 of file RawDataDrawer.cxx.

References raw::RawDigit::Samples().

1687  {
1688  digits.resize(rdcol->size());
1689  for(size_t iDigit = 0; iDigit < rdcol->size(); ++iDigit) {
1690  art::Ptr<raw::RawDigit> pDigit(rdcol, iDigit);
1691  digits[iDigit].Fill(pDigit);
1692  size_t samples = pDigit->Samples();
1693  if (samples > max_samples) max_samples = samples;
1694  } // for
1695  } // RawDigitCacheDataClass::Refill()
size_t max_samples
the largest number of ticks in any digit
std::vector< RawDigitInfo_t > digits
vector of raw digit information
bool evd::details::RawDigitCacheDataClass::Update ( art::Event const &  evt,
CacheID_t const &  new_timestamp 
)

Updates the cache for new_timestamp using the specified event

Returns
true if it needed to update (that might have failed)

Definition at line 1757 of file RawDataDrawer.cxx.

References art::DataViewImpl::getByLabel(), util::DataProductChangeTracker_t::inputLabel(), and LOG_DEBUG.

Referenced by evd::RawDataDrawer::GetRawDigits().

1758  {
1759  BoolWithUpToDateMetadata update_info = CheckUpToDate(new_timestamp, &evt);
1760 
1761  if (update_info) return false; // already up to date: move on!
1762 
1763  LOG_DEBUG("RawDataDrawer")
1764  << "Refilling raw digit cache RawDigitCacheDataClass["
1765  << ((void*) this ) << "] for " << new_timestamp;
1766 
1767  Clear();
1768 
1770  if (!evt.getByLabel(new_timestamp.inputLabel(), rdcol)) {
1771  mf::LogWarning("RawDataDrawer") << "no RawDigit collection '"
1772  << new_timestamp.inputLabel() << "' found";
1773  return true;
1774  }
1775 
1776  Refill(rdcol);
1777 
1778  timestamp = new_timestamp;
1779  return true;
1780  } // RawDigitCacheDataClass::Update()
CacheID_t timestamp
object expressing validity range of cached data
void Refill(art::Handle< std::vector< raw::RawDigit >> &rdcol)
Fills the cache from the specified raw digits product handle.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
#define LOG_DEBUG(id)
BoolWithUpToDateMetadata CheckUpToDate(CacheID_t const &ts, art::Event const *evt=nullptr) const
Checks whether an update is needed; can load digits in the process.

Member Data Documentation

std::vector<RawDigitInfo_t> evd::details::RawDigitCacheDataClass::digits
private

vector of raw digit information

Definition at line 297 of file RawDataDrawer.cxx.

size_t evd::details::RawDigitCacheDataClass::max_samples = 0
private

the largest number of ticks in any digit

Definition at line 301 of file RawDataDrawer.cxx.

CacheID_t evd::details::RawDigitCacheDataClass::timestamp
private

object expressing validity range of cached data

Definition at line 299 of file RawDataDrawer.cxx.


The documentation for this class was generated from the following file: