LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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 234 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 1699 of file RawDataDrawer.cxx.

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

1702  {
1703  BoolWithUpToDateMetadata res{false, nullptr};
1704 
1705  // normally only if either the event or the product label have changed,
1706  // cache becomes invalid:
1707  if (!ts.sameProduct(timestamp)) return res; // outdated cache
1708 
1709  // But: our cache stores pointers to the original data, and on a new TPC
1710  // the event display may reload the event anew, removing the "old" data
1711  // from memory.
1712  // Since TPC can change with or without the data being invalidated,
1713  // a more accurate verification is needed.
1714 
1715  // if the cache is empty, well, it does not make much difference;
1716  // we invalidate it to be sure
1717  if (empty()) return res; // outdated cache
1718 
1719  if (!evt) return res; // outdated, since we can't know better without the event
1720 
1721  // here we force reading of the product
1722  res.digits = ReadProduct(*evt, ts.inputLabel());
1723  if (!res.digits) return res; // outdated cache; this is actually an error
1724 
1725  if (res.digits->empty())
1726  return res; // outdated; no digits (strange!), invalidate just in case
1727 
1728  // use the first digit as test
1729  raw::ChannelID_t channel = res.digits->front().Channel();
1730  RawDigitInfo_t const* pInfo = FindChannel(channel);
1731  if (!pInfo) return res; // outdated: we don't even have this channel in cache!
1732 
1733  if (&(pInfo->Digit()) != &(res.digits->front()))
1734  return res; // outdated: different memory address for data
1735 
1736  res.bUpToDate = true;
1737  return res; // cache still valid
1738  } // 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)
TCEvent evt
Definition: DataStructs.cxx:8
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void evd::details::RawDigitCacheDataClass::Clear ( )

Empties the cache.

Definition at line 1692 of file RawDataDrawer.cxx.

1693  {
1694  Invalidate();
1695  digits.clear();
1696  max_samples = 0;
1697  } // 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 237 of file RawDataDrawer.cxx.

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

237 { 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 1765 of file RawDataDrawer.cxx.

1766  {
1767  out << "Cache at " << ((void*)this) << " with time stamp " << std::string(timestamp)
1768  << " and " << digits.size() << " entries (maximum sample: " << max_samples << ");"
1769  << " data at " << ((void*)digits.data());
1770  for (RawDigitInfo_t const& digitInfo : digits) {
1771  out << "\n ";
1772  digitInfo.Dump(out);
1773  } // for
1774  out << "\n";
1775  } // 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 246 of file RawDataDrawer.cxx.

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

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

246 { 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 1659 of file RawDataDrawer.cxx.

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

1660  {
1661  auto iDigit = std::find_if(
1662  digits.cbegin(), digits.cend(), [channel](evd::details::RawDigitInfo_t const& digit) {
1663  return digit.Channel() == channel;
1664  });
1665  return (iDigit == digits.cend()) ? nullptr : &*iDigit;
1666  } // 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 1687 of file RawDataDrawer.cxx.

1688  {
1689  timestamp.clear();
1690  } // 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 243 of file RawDataDrawer.cxx.

243 { 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 1668 of file RawDataDrawer.cxx.

References art::ProductRetriever::getByLabel().

1670  {
1672  if (!evt.getByLabel(label, rdcol)) return nullptr;
1673  return &*rdcol;
1674  } // RawDigitCacheDataClass::ReadProduct()
TCEvent evt
Definition: DataStructs.cxx:8
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 1676 of file RawDataDrawer.cxx.

References raw::RawDigit::Samples().

1677  {
1678  digits.resize(rdcol->size());
1679  for (size_t iDigit = 0; iDigit < rdcol->size(); ++iDigit) {
1680  art::Ptr<raw::RawDigit> pDigit(rdcol, iDigit);
1681  digits[iDigit].Fill(pDigit);
1682  size_t samples = pDigit->Samples();
1683  if (samples > max_samples) max_samples = samples;
1684  } // for
1685  } // 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 1740 of file RawDataDrawer.cxx.

References art::ProductRetriever::getByLabel(), util::DataProductChangeTracker_t::inputLabel(), and MF_LOG_DEBUG.

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

1741  {
1742  BoolWithUpToDateMetadata update_info = CheckUpToDate(new_timestamp, &evt);
1743 
1744  if (update_info) return false; // already up to date: move on!
1745 
1746  MF_LOG_DEBUG("RawDataDrawer") << "Refilling raw digit cache RawDigitCacheDataClass["
1747  << ((void*)this) << "] for " << new_timestamp;
1748 
1749  Clear();
1750 
1752  if (!evt.getByLabel(new_timestamp.inputLabel(), rdcol)) {
1753  mf::LogWarning("RawDataDrawer")
1754  << "no RawDigit collection '" << new_timestamp.inputLabel() << "' found";
1755  return true;
1756  }
1757 
1758  Refill(rdcol);
1759 
1760  timestamp = new_timestamp;
1761  return true;
1762  } // 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 MF_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.
TCEvent evt
Definition: DataStructs.cxx:8

Member Data Documentation

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

vector of raw digit information

Definition at line 279 of file RawDataDrawer.cxx.

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

the largest number of ticks in any digit

Definition at line 283 of file RawDataDrawer.cxx.

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

object expressing validity range of cached data

Definition at line 281 of file RawDataDrawer.cxx.


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