Public Member Functions | Private Member Functions | Private Attributes | List of all members
LarsoftHuffmanCompressService Class Reference

#include <LarsoftHuffmanCompressService.h>

Inheritance diagram for LarsoftHuffmanCompressService:
AdcCompressService

Public Member Functions

 LarsoftHuffmanCompressService (bool useBlock, bool useHuffman, int logLevel)
 
 LarsoftHuffmanCompressService (fhicl::ParameterSet const &pset, art::ActivityRegistry &)
 
int compress (AdcCountVector &sigs, const AdcFilterVector &keep, AdcCount offset, raw::Compress_t &comp) const
 
std::ostream & print (std::ostream &out=std::cout, std::string prefix=" ") const
 
- Public Member Functions inherited from AdcCompressService
virtual ~AdcCompressService ()=default
 

Private Member Functions

void block (const AdcCountVector &oldsigs, const AdcFilterVector &keep, AdcCountVector &newsigs) const
 

Private Attributes

bool m_UseBlock
 
bool m_UseHuffman
 
int m_LogLevel
 

Detailed Description

Definition at line 34 of file LarsoftHuffmanCompressService.h.

Constructor & Destructor Documentation

LarsoftHuffmanCompressService::LarsoftHuffmanCompressService ( bool  useBlock,
bool  useHuffman,
int  logLevel 
)
LarsoftHuffmanCompressService::LarsoftHuffmanCompressService ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry  
)

Member Function Documentation

void LarsoftHuffmanCompressService::block ( const AdcCountVector oldsigs,
const AdcFilterVector keep,
AdcCountVector newsigs 
) const
private

Definition at line 112 of file LarsoftHuffmanCompressService_service.cc.

112  {
113  const unsigned int adcsize = sigsin.size();
114  std::vector<short> zerosuppressed(sigsin.size());
115  unsigned int maxblocks = adcsize/2 + 1;
116  std::vector<short> blockbegin(maxblocks);
117  std::vector<short> blocksize(maxblocks);
118  unsigned int nblocks = 0;
119  unsigned int zerosuppressedsize = 0;
120  bool inblock = false;
121  for ( unsigned int i=0; i<adcsize; ++i ) {
122  if ( keep[i] ) {
123  if ( ! inblock ) {
124  blockbegin[nblocks] = i;
125  blocksize[nblocks] = 0;
126  inblock = true;
127  }
128  zerosuppressed[zerosuppressedsize] = sigsin[i];
129  ++zerosuppressedsize;
130  ++blocksize[nblocks];
131  if ( i == adcsize-1 ) ++nblocks;
132  } else if ( inblock ) {
133  //zerosuppressed[zerosuppressedsize] = sigsin[i];
134  //++zerosuppressedsize;
135  //++blocksize[nblocks];
136  ++nblocks;
137  inblock = false;
138  }
139  }
140  sigsout.resize(2+nblocks+nblocks+zerosuppressedsize);
141  sigsout[0] = adcsize; //fill first entry in adc with length of uncompressed vector
142  sigsout[1] = nblocks;
143  for ( unsigned int i=0; i<nblocks; ++i ) sigsout[i+2] = blockbegin[i];
144  for ( unsigned int i=0; i<nblocks; ++i ) sigsout[i+nblocks+2] = blocksize[i];
145  for ( unsigned int i=0; i<zerosuppressedsize; ++i ) sigsout[i+nblocks+nblocks+2] = zerosuppressed[i];
146 }
int LarsoftHuffmanCompressService::compress ( AdcCountVector sigs,
const AdcFilterVector keep,
AdcCount  offset,
raw::Compress_t comp 
) const
virtual

Implements AdcCompressService.

Definition at line 62 of file LarsoftHuffmanCompressService_service.cc.

63  {
64  const string myname = "LarsoftHuffmanCompressService::compress: ";
65  if ( keep.size() != sigs.size() ) {
66  cout << "ERROR: Filter and ADC have different sizes: " << keep.size()
67  << " != " << sigs.size() << endl;
68  return 1;
69  }
70  AdcCountVector newsigs;
71  comp = raw::kNone;
72  logsigs(sigs, m_LogLevel, 6, myname + "Before compression");
73  logsigs(keep, m_LogLevel, 6, myname + "Filter");
74  if ( m_LogLevel > 1 ) {
75  int nkeep = 0;
76  for ( bool val : keep ) if ( val ) ++nkeep;
77  cout << myname << "Keeping " << nkeep << "/" << keep.size() << " ticks" << endl;
78  }
79  if ( m_UseBlock ) {
80  block(sigs, keep, newsigs);
81  sigs = newsigs;
82  comp = raw::kZeroSuppression;
83  } else {
85  repsvc.compress(sigs, keep, offset, comp);
86  }
87  if ( m_UseHuffman ) {
89  if ( m_UseBlock ) comp = raw::kZeroHuffman;
90  else comp = raw::kHuffman;
91  }
92  logsigs(sigs, m_LogLevel, 5, myname + "After compression");
93  return 0;
94 }
void CompressHuffman(std::vector< short > &adc)
Definition: raw.cxx:849
Huffman Encoding.
Definition: RawTypes.h:10
std::vector< AdcCount > AdcCountVector
Definition: AdcTypes.h:19
void block(const AdcCountVector &oldsigs, const AdcFilterVector &keep, AdcCountVector &newsigs) const
Zero Suppression followed by Huffman Encoding.
Definition: RawTypes.h:12
no compression
Definition: RawTypes.h:9
Zero Suppression algorithm.
Definition: RawTypes.h:11
int compress(AdcCountVector &sigs, const AdcFilterVector &keep, AdcCount offset, raw::Compress_t &comp) const
QTextStream & endl(QTextStream &s)
ostream & LarsoftHuffmanCompressService::print ( std::ostream &  out = std::cout,
std::string  prefix = "  " 
) const
virtual

Implements AdcCompressService.

Definition at line 98 of file LarsoftHuffmanCompressService_service.cc.

98  {
99  out << prefix << "LarsoftHuffmanCompressService";
100  return out;
101 }

Member Data Documentation

int LarsoftHuffmanCompressService::m_LogLevel
private

Definition at line 63 of file LarsoftHuffmanCompressService.h.

bool LarsoftHuffmanCompressService::m_UseBlock
private

Definition at line 61 of file LarsoftHuffmanCompressService.h.

bool LarsoftHuffmanCompressService::m_UseHuffman
private

Definition at line 62 of file LarsoftHuffmanCompressService.h.


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