LArSoft  v07_13_02
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 1767 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().

1768  {
1769  BoolWithUpToDateMetadata res{ false, nullptr };
1770 
1771  // normally only if either the event or the product label have changed,
1772  // cache becomes invalid:
1773  if (!ts.sameProduct(timestamp)) return res; // outdated cache
1774 
1775  // But: our cache stores pointers to the original data, and on a new TPC
1776  // the event display may reload the event anew, removing the "old" data
1777  // from memory.
1778  // Since TPC can change with or without the data being invalidated,
1779  // a more accurate verification is needed.
1780 
1781  // if the cache is empty, well, it does not make much difference;
1782  // we invalidate it to be sure
1783  if (empty())
1784  return res; // outdated cache
1785 
1786  if (!evt)
1787  return res; // outdated, since we can't know better without the event
1788 
1789  // here we force reading of the product
1790  res.digits = ReadProduct(*evt, ts.inputLabel());
1791  if (!res.digits)
1792  return res; // outdated cache; this is actually an error
1793 
1794  if (res.digits->empty())
1795  return res; // outdated; no digits (strange!), invalidate just in case
1796 
1797  // use the first digit as test
1798  raw::ChannelID_t channel = res.digits->front().Channel();
1799  RawDigitInfo_t const* pInfo = FindChannel(channel);
1800  if (!pInfo)
1801  return res; // outdated: we don't even have this channel in cache!
1802 
1803  if (&(pInfo->Digit()) != &(res.digits->front()))
1804  return res; // outdated: different memory address for data
1805 
1806  res.bUpToDate = true;
1807  return res; // cache still valid
1808  } // 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:5
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 1758 of file RawDataDrawer.cxx.

1758  {
1759  Invalidate();
1760  digits.clear();
1761  max_samples = 0;
1762  } // 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 1839 of file RawDataDrawer.cxx.

1839  {
1840  out << "Cache at " << ((void*) this)
1841  << " with time stamp " << std::string(timestamp)
1842  << " and " << digits.size()
1843  << " entries (maximum sample: " << max_samples << ");"
1844  << " data at " << ((void*) digits.data());
1845  for (RawDigitInfo_t const& digitInfo: digits) {
1846  out << "\n ";
1847  digitInfo.Dump(out);
1848  } // for
1849  out << "\n";
1850  } // 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(), tca::evt, 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 1721 of file RawDataDrawer.cxx.

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

1722  {
1723  auto iDigit = std::find_if(
1724  digits.cbegin(), digits.cend(),
1725  [channel](evd::details::RawDigitInfo_t const& digit)
1726  { return digit.Channel() == channel; }
1727  );
1728  return (iDigit == digits.cend())? nullptr: &*iDigit;
1729  } // 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 1753 of file RawDataDrawer.cxx.

1753  {
1754  timestamp.clear();
1755  } // 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 1732 of file RawDataDrawer.cxx.

References art::DataViewImpl::getByLabel().

1733  {
1735  if (!evt.getByLabel(label, rdcol)) return nullptr;
1736  return &*rdcol;
1737  } // RawDigitCacheDataClass::ReadProduct()
TCEvent evt
Definition: DataStructs.cxx:5
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 1741 of file RawDataDrawer.cxx.

References raw::RawDigit::Samples().

1742  {
1743  digits.resize(rdcol->size());
1744  for(size_t iDigit = 0; iDigit < rdcol->size(); ++iDigit) {
1745  art::Ptr<raw::RawDigit> pDigit(rdcol, iDigit);
1746  digits[iDigit].Fill(pDigit);
1747  size_t samples = pDigit->Samples();
1748  if (samples > max_samples) max_samples = samples;
1749  } // for
1750  } // 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 1812 of file RawDataDrawer.cxx.

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

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

1813  {
1814  BoolWithUpToDateMetadata update_info = CheckUpToDate(new_timestamp, &evt);
1815 
1816  if (update_info) return false; // already up to date: move on!
1817 
1818  LOG_DEBUG("RawDataDrawer")
1819  << "Refilling raw digit cache RawDigitCacheDataClass["
1820  << ((void*) this ) << "] for " << new_timestamp;
1821 
1822  Clear();
1823 
1825  if (!evt.getByLabel(new_timestamp.inputLabel(), rdcol)) {
1826  mf::LogWarning("RawDataDrawer") << "no RawDigit collection '"
1827  << new_timestamp.inputLabel() << "' found";
1828  return true;
1829  }
1830 
1831  Refill(rdcol);
1832 
1833  timestamp = new_timestamp;
1834  return true;
1835  } // 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.
TCEvent evt
Definition: DataStructs.cxx:5

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: