All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 875 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 878 of file WebEVDServer.cxx.

879  : fEvt(&evt), fGeom(geom), fArena("dig")
880  {
881  }
const geo::GeometryCore * fGeom
TCEvent evt
Definition: DataStructs.cxx:8

Member Function Documentation

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

Implements evd::ILazy.

Definition at line 889 of file WebEVDServer.cxx.

890  {
891  Init();
892  return fArena;
893  }
template<class T>
void evd::LazyDigits< T >::Init ( )
inlineprotected

Definition at line 896 of file WebEVDServer.cxx.

897  {
898  std::lock_guard guard(fLock);
899 
900  if(!fEvt || !fGeom) return; // already init'd
901 
902  for(art::InputTag tag: fEvt->template getInputTags<std::vector<raw::RawDigit>>()){
903  typename T::template HandleT<std::vector<raw::RawDigit>> digs; // deduce handle type
904  // This can fail in the case of dropped products
905  if(!fEvt->getByLabel(tag, digs)) continue;
906 
907  for(const raw::RawDigit& dig: *digs){
908  for(geo::WireID wire: fGeom->ChannelToWire(dig.Channel())){
909  // const geo::TPCID tpc(wire);
910  const geo::PlaneID plane(wire);
911 
912  const geo::WireID w0 = fGeom->GetBeginWireID(plane);
913 
914  if(fImgs[tag].count(plane) == 0){
915  fImgs[tag].emplace(plane, PNGView(fArena));
916  }
917 
918  PNGView& bytes = fImgs[tag].find(plane)->second;
919 
920  raw::RawDigit::ADCvector_t adcs(dig.Samples());
921  raw::Uncompress(dig.ADCs(), adcs, dig.Compression());
922 
923  for(unsigned int tick = 0; tick < adcs.size(); ++tick){
924  const int adc = adcs[tick] ? int(adcs[tick])-dig.GetPedestal() : 0;
925 
926  if(adc != 0){
927  // alpha
928  bytes(wire.Wire-w0.Wire, tick, 3) = std::min(abs(adc), 255);
929  if(adc > 0){
930  // red
931  bytes(wire.Wire-w0.Wire, tick, 0) = 255;
932  }
933  else{
934  // blue
935  bytes(wire.Wire-w0.Wire, tick, 2) = 255;
936  }
937  }
938  } // end for tick
939  } // end for wire
940  } // end for dig
941  } // end for tag
942 
943  fEvt = 0;
944  fGeom = 0;
945  }
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.
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.
std::mutex fLock
std::size_t count(Cont const &cont)
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 883 of file WebEVDServer.cxx.

884  {
885  Init();
886  json << fImgs;
887  }
std::map< art::InputTag, std::map< geo::PlaneID, PNGView > > fImgs
basic_json<> json
default JSON class
Definition: json.hpp:2445

Member Data Documentation

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

Definition at line 951 of file WebEVDServer.cxx.

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

Definition at line 947 of file WebEVDServer.cxx.

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

Definition at line 948 of file WebEVDServer.cxx.

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

Definition at line 953 of file WebEVDServer.cxx.

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

Definition at line 950 of file WebEVDServer.cxx.


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