Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
evd::LazyDigits< T > Class Template Reference
Inheritance diagram for evd::LazyDigits< T >:
evd::ILazy

Public Member Functions

 LazyDigits (const T &evt, const geo::GeometryCore *geom)
 
virtual void Serialize (JSONFormatter &json) override
 
virtual PNGArenaGetArena () override
 

Protected Member Functions

void Init ()
 

Protected Attributes

const T * fEvt
 
const geo::GeometryCorefGeom
 
std::mutex fLock
 
PNGArena fArena
 
std::map< art::InputTag, std::map< geo::PlaneID, PNGView > > fImgs
 

Detailed Description

template<class T>
class evd::LazyDigits< T >

Definition at line 856 of file WebEVDServer.cxx.

Constructor & Destructor Documentation

template<class T>
evd::LazyDigits< T >::LazyDigits ( const T &  evt,
const geo::GeometryCore geom 
)
inline

Definition at line 859 of file WebEVDServer.cxx.

860  : fEvt(&evt), fGeom(geom), fArena("dig")
861  {
862  }
const geo::GeometryCore * fGeom
TCEvent evt
Definition: DataStructs.cxx:7

Member Function Documentation

template<class T>
virtual PNGArena& evd::LazyDigits< T >::GetArena ( )
inlineoverridevirtual

Implements evd::ILazy.

Definition at line 870 of file WebEVDServer.cxx.

871  {
872  Init();
873  return fArena;
874  }
template<class T>
void evd::LazyDigits< T >::Init ( void  )
inlineprotected

Definition at line 877 of file WebEVDServer.cxx.

878  {
879  std::lock_guard guard(fLock);
880 
881  if(!fEvt || !fGeom) return; // already init'd
882 
883  for(art::InputTag tag: fEvt->template getInputTags<std::vector<raw::RawDigit>>()){
884  typename T::template HandleT<std::vector<raw::RawDigit>> digs; // deduce handle type
885  // This can fail in the case of dropped products
886  if(!fEvt->getByLabel(tag, digs)) continue;
887 
888  for(const raw::RawDigit& dig: *digs){
889  for(geo::WireID wire: fGeom->ChannelToWire(dig.Channel())){
890  // const geo::TPCID tpc(wire);
891  const geo::PlaneID plane(wire);
892 
893  const geo::WireID w0 = fGeom->GetBeginWireID(plane);
894 
895  if(fImgs[tag].count(plane) == 0){
896  fImgs[tag].emplace(plane, PNGView(fArena));
897  }
898 
899  PNGView& bytes = fImgs[tag].find(plane)->second;
900 
901  raw::RawDigit::ADCvector_t adcs(dig.Samples());
902  raw::Uncompress(dig.ADCs(), adcs, dig.Compression());
903 
904  for(unsigned int tick = 0; tick < adcs.size(); ++tick){
905  const int adc = adcs[tick] ? int(adcs[tick])-dig.GetPedestal() : 0;
906 
907  if(adc != 0){
908  // alpha
909  bytes(wire.Wire-w0.Wire, tick, 3) = std::min(abs(adc), 255);
910  if(adc > 0){
911  // red
912  bytes(wire.Wire-w0.Wire, tick, 0) = 255;
913  }
914  else{
915  // blue
916  bytes(wire.Wire-w0.Wire, tick, 2) = 255;
917  }
918  }
919  } // end for tick
920  } // end for wire
921  } // end for dig
922  } // end for tag
923 
924  fEvt = 0;
925  fGeom = 0;
926  }
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
std::map< art::InputTag, std::map< geo::PlaneID, PNGView > > fImgs
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:73
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
int16_t adc
Definition: CRTFragment.hh:202
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
T abs(T value)
const geo::GeometryCore * fGeom
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
geo::WireID GetBeginWireID(geo::CryostatID const &id) const
Returns the ID of the first wire in the specified cryostat.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
std::mutex fLock
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:776
byte bytes
Alias for common language habits.
Definition: datasize.h:101
template<class T>
virtual void evd::LazyDigits< T >::Serialize ( JSONFormatter json)
inlineoverridevirtual

Implements evd::ILazy.

Definition at line 864 of file WebEVDServer.cxx.

865  {
866  Init();
867  json << fImgs;
868  }
std::map< art::InputTag, std::map< geo::PlaneID, PNGView > > fImgs

Member Data Documentation

template<class T>
PNGArena evd::LazyDigits< T >::fArena
protected

Definition at line 932 of file WebEVDServer.cxx.

template<class T>
const T* evd::LazyDigits< T >::fEvt
protected

Definition at line 928 of file WebEVDServer.cxx.

template<class T>
const geo::GeometryCore* evd::LazyDigits< T >::fGeom
protected

Definition at line 929 of file WebEVDServer.cxx.

template<class T>
std::map<art::InputTag, std::map<geo::PlaneID, PNGView> > evd::LazyDigits< T >::fImgs
protected

Definition at line 934 of file WebEVDServer.cxx.

template<class T>
std::mutex evd::LazyDigits< T >::fLock
protected

Definition at line 931 of file WebEVDServer.cxx.


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