LArSoft  v10_04_05
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 235 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 1599 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().

1602  {
1603  BoolWithUpToDateMetadata res{false, nullptr};
1604 
1605  // normally only if either the event or the product label have changed,
1606  // cache becomes invalid:
1607  if (!ts.sameProduct(timestamp)) return res; // outdated cache
1608 
1609  // But: our cache stores pointers to the original data, and on a new TPC
1610  // the event display may reload the event anew, removing the "old" data
1611  // from memory.
1612  // Since TPC can change with or without the data being invalidated,
1613  // a more accurate verification is needed.
1614 
1615  // if the cache is empty, well, it does not make much difference;
1616  // we invalidate it to be sure
1617  if (empty()) return res; // outdated cache
1618 
1619  if (!evt) return res; // outdated, since we can't know better without the event
1620 
1621  // here we force reading of the product
1622  res.digits = ReadProduct(*evt, ts.inputLabel());
1623  if (!res.digits) return res; // outdated cache; this is actually an error
1624 
1625  if (res.digits->empty())
1626  return res; // outdated; no digits (strange!), invalidate just in case
1627 
1628  // use the first digit as test
1629  raw::ChannelID_t channel = res.digits->front().Channel();
1630  RawDigitInfo_t const* pInfo = FindChannel(channel);
1631  if (!pInfo) return res; // outdated: we don't even have this channel in cache!
1632 
1633  if (&(pInfo->Digit()) != &(res.digits->front()))
1634  return res; // outdated: different memory address for data
1635 
1636  res.bUpToDate = true;
1637  return res; // cache still valid
1638  } // 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 1592 of file RawDataDrawer.cxx.

1593  {
1594  Invalidate();
1595  digits.clear();
1596  max_samples = 0;
1597  } // 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 238 of file RawDataDrawer.cxx.

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

238 { 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 1665 of file RawDataDrawer.cxx.

1666  {
1667  out << "Cache at " << ((void*)this) << " with time stamp " << std::string(timestamp)
1668  << " and " << digits.size() << " entries (maximum sample: " << max_samples << ");"
1669  << " data at " << ((void*)digits.data());
1670  for (RawDigitInfo_t const& digitInfo : digits) {
1671  out << "\n ";
1672  digitInfo.Dump(out);
1673  } // for
1674  out << "\n";
1675  } // 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 247 of file RawDataDrawer.cxx.

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

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

247 { 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 1559 of file RawDataDrawer.cxx.

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

1560  {
1561  auto iDigit = std::find_if(
1562  digits.cbegin(), digits.cend(), [channel](evd::details::RawDigitInfo_t const& digit) {
1563  return digit.Channel() == channel;
1564  });
1565  return (iDigit == digits.cend()) ? nullptr : &*iDigit;
1566  } // 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 1587 of file RawDataDrawer.cxx.

1588  {
1589  timestamp.clear();
1590  } // 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 244 of file RawDataDrawer.cxx.

244 { 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 1568 of file RawDataDrawer.cxx.

References art::ProductRetriever::getByLabel().

1570  {
1572  if (!evt.getByLabel(label, rdcol)) return nullptr;
1573  return &*rdcol;
1574  } // 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 1576 of file RawDataDrawer.cxx.

References raw::RawDigit::Samples().

1577  {
1578  digits.resize(rdcol->size());
1579  for (size_t iDigit = 0; iDigit < rdcol->size(); ++iDigit) {
1580  art::Ptr<raw::RawDigit> pDigit(rdcol, iDigit);
1581  digits[iDigit].Fill(pDigit);
1582  size_t samples = pDigit->Samples();
1583  if (samples > max_samples) max_samples = samples;
1584  } // for
1585  } // 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 1640 of file RawDataDrawer.cxx.

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

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

1641  {
1642  BoolWithUpToDateMetadata update_info = CheckUpToDate(new_timestamp, &evt);
1643 
1644  if (update_info) return false; // already up to date: move on!
1645 
1646  MF_LOG_DEBUG("RawDataDrawer") << "Refilling raw digit cache RawDigitCacheDataClass["
1647  << ((void*)this) << "] for " << new_timestamp;
1648 
1649  Clear();
1650 
1652  if (!evt.getByLabel(new_timestamp.inputLabel(), rdcol)) {
1653  mf::LogWarning("RawDataDrawer")
1654  << "no RawDigit collection '" << new_timestamp.inputLabel() << "' found";
1655  return true;
1656  }
1657 
1658  Refill(rdcol);
1659 
1660  timestamp = new_timestamp;
1661  return true;
1662  } // 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 280 of file RawDataDrawer.cxx.

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

the largest number of ticks in any digit

Definition at line 284 of file RawDataDrawer.cxx.

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

object expressing validity range of cached data

Definition at line 282 of file RawDataDrawer.cxx.


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