Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
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 286 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 1936 of file RawDataDrawer.cxx.

1938  {
1939  BoolWithUpToDateMetadata res{false, nullptr};
1940 
1941  // normally only if either the event or the product label have changed,
1942  // cache becomes invalid:
1943  if (!ts.sameProduct(timestamp)) return res; // outdated cache
1944 
1945  // But: our cache stores pointers to the original data, and on a new TPC
1946  // the event display may reload the event anew, removing the "old" data
1947  // from memory.
1948  // Since TPC can change with or without the data being invalidated,
1949  // a more accurate verification is needed.
1950 
1951  // if the cache is empty, well, it does not make much difference;
1952  // we invalidate it to be sure
1953  if (empty()) return res; // outdated cache
1954 
1955  if (!evt) return res; // outdated, since we can't know better without the event
1956 
1957  // here we force reading of the product
1958  res.digits = ReadProduct(*evt, ts.inputLabel());
1959  if (!res.digits) return res; // outdated cache; this is actually an error
1960 
1961  if (res.digits->empty())
1962  return res; // outdated; no digits (strange!), invalidate just in case
1963 
1964  // use the first digit as test
1965  raw::ChannelID_t channel = res.digits->front().Channel();
1966  RawDigitInfo_t const* pInfo = FindChannel(channel);
1967  if (!pInfo) return res; // outdated: we don't even have this channel in cache!
1968 
1969  if (&(pInfo->Digit()) != &(res.digits->front()))
1970  return res; // outdated: different memory address for data
1971 
1972  res.bUpToDate = true;
1973  return res; // cache still valid
1974  } // RawDigitCacheDataClass::CheckUpToDate()
CacheID_t timestamp
object expressing validity range of cached data
uint8_t channel
Definition: CRTFragment.hh:201
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:7
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void evd::details::RawDigitCacheDataClass::Clear ( void  )

Empties the cache.

Definition at line 1928 of file RawDataDrawer.cxx.

1929  {
1930  Invalidate();
1931  digits.clear();
1932  max_samples = 0;
1933  } // 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 290 of file RawDataDrawer.cxx.

291  {
292  return digits;
293  }
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 2003 of file RawDataDrawer.cxx.

2004  {
2005  out << "Cache at " << ((void*)this) << " with time stamp " << std::string(timestamp)
2006  << " and " << digits.size() << " entries (maximum sample: " << max_samples << ");"
2007  << " data at " << ((void*)digits.data());
2008  for (RawDigitInfo_t const& digitInfo : digits) {
2009  out << "\n ";
2010  digitInfo.Dump(out);
2011  } // for
2012  out << "\n";
2013  } // RawDigitCacheDataClass::Dump()
size_t max_samples
the largest number of ticks in any digit
std::string string
Definition: nybbler.cc:12
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 307 of file RawDataDrawer.cxx.

308  {
309  return digits.empty();
310  }
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 1892 of file RawDataDrawer.cxx.

1893  {
1894  auto iDigit = std::find_if(
1895  digits.cbegin(), digits.cend(), [channel](evd::details::RawDigitInfo_t const& digit) {
1896  return digit.Channel() == channel;
1897  });
1898  return (iDigit == digits.cend()) ? nullptr : &*iDigit;
1899  } // RawDigitCacheDataClass::FindChannel()
uint8_t channel
Definition: CRTFragment.hh:201
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 1922 of file RawDataDrawer.cxx.

1923  {
1924  timestamp.clear();
1925  } // RawDigitCacheDataClass::Invalidate()
CacheID_t timestamp
object expressing validity range of cached data
size_t evd::details::RawDigitCacheDataClass::MaxSamples ( ) const
inline

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

Definition at line 300 of file RawDataDrawer.cxx.

301  {
302  return max_samples;
303  }
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 1902 of file RawDataDrawer.cxx.

1903  {
1905  if (!evt.getByLabel(label, rdcol)) return nullptr;
1906  return &*rdcol;
1907  } // RawDigitCacheDataClass::ReadProduct()
TCEvent evt
Definition: DataStructs.cxx:7
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 1910 of file RawDataDrawer.cxx.

1911  {
1912  digits.resize(rdcol->size());
1913  for (size_t iDigit = 0; iDigit < rdcol->size(); ++iDigit) {
1914  art::Ptr<raw::RawDigit> pDigit(rdcol, iDigit);
1915  digits[iDigit].Fill(pDigit);
1916  size_t samples = pDigit->Samples();
1917  if (samples > max_samples) max_samples = samples;
1918  } // for
1919  } // 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 1977 of file RawDataDrawer.cxx.

1978  {
1979  BoolWithUpToDateMetadata update_info = CheckUpToDate(new_timestamp, &evt);
1980 
1981  if (update_info) return false; // already up to date: move on!
1982 
1983  MF_LOG_DEBUG("RawDataDrawer") << "Refilling raw digit cache RawDigitCacheDataClass["
1984  << ((void*)this) << "] for " << new_timestamp;
1985 
1986  Clear();
1987 
1989  if (!evt.getByLabel(new_timestamp.inputLabel(), rdcol)) {
1990  mf::LogWarning("RawDataDrawer")
1991  << "no RawDigit collection '" << new_timestamp.inputLabel() << "' found";
1992  return true;
1993  }
1994 
1995  Refill(rdcol);
1996 
1997  timestamp = new_timestamp;
1998  return true;
1999  } // RawDigitCacheDataClass::Update()
CacheID_t timestamp
object expressing validity range of cached data
def update_info(flist, md)
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:7

Member Data Documentation

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

vector of raw digit information

Definition at line 343 of file RawDataDrawer.cxx.

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

the largest number of ticks in any digit

Definition at line 347 of file RawDataDrawer.cxx.

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

object expressing validity range of cached data

Definition at line 345 of file RawDataDrawer.cxx.


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