raw.h
Go to the documentation of this file.
1 /// \file raw.h
2 /// \brief raw data utilities -- compression and decompression
3 /// \author trj@fnal.gov
4 /// many thanks to Brian Rebel and Jonathan Insler
5 
6 #ifndef GAR_RAWDATA_RAW_H
7 #define GAR_RAWDATA_RAW_H
8 
9 #include <vector>
11 
12 namespace gar{
13 
14 namespace raw{
15 
16  /**
17  * @brief Uncompresses a raw data buffer
18  * @param adc compressed buffer
19  * @param uncompressed buffer to be filled with uncompressed data
20  * @param compress type of compression in the adc buffer
21  *
22  * This function dispatches the uncompression to the correct uncompress
23  * function according to compression type in compress.
24  *
25  * The uncompressed buffer *must* be already allocated with enough space
26  * to store the full inflated adc data. Uncompressing raw::RawDigit can
27  * be done as follows:
28  *
29  * ADCvector_t uncompressed(digit.Samples(), 0);
30  * raw::Uncompress(digit.ADC(), uncompressed, digit.ADC());
31  *
32  *
33  */
34 
35  // uncompressing Huffman-encoded data or other compression algs that do not need to backfill
36  // with pedestal
37 
39  gar::raw::ADCvector_t &uncompressed,
40  gar::raw::Compress_t compress);
41 
42  // for filling in zero-suppressed data -- put pedestal in for the missing samples.
43 
45  gar::raw::ADCvector_t &uncompressed,
46  gar::raw::ADC_t pedestal,
47  gar::raw::Compress_t compress);
48 
50  gar::raw::Compress_t compress,
51  gar::raw::ADC_t zerothreshold,
52  size_t ticksbefore,
53  size_t ticksafter);
54 
55 
56  /**
57  * @brief In-place compression of raw data buffer
58  * @param adc buffer with uncompressed data
59  * @param compress type of compression to be applied
60  *
61  * This function dispatches the compression to the function appropriate
62  * for the specified compression type.
63  * The resulting compressed data replaces the input buffer content, which is lost.
64  * Compression is expected to reduce the size of the data, so that there is
65  * in principle no need for reallocation of the input buffer, adc, to store
66  * the result.
67  */
68 
70  gar::raw::Compress_t compress);
71 
72  // duplicate of above?
73  //int Compress(gar::raw::ADCvector_t &adc,
74  // gar::raw::Compress_t compress,
75  // gar::raw::ADC_t zerothreshold,
76  // size_t ticksbefore,
77  // size_t ticksafter);
78 
80 
82  gar::raw::ADC_t zerothreshold,
83  size_t ticksbefore,
84  size_t ticksafter);
85 
87  gar::raw::ADCvector_t &uncompressed);
88 
90  gar::raw::ADCvector_t &uncompressed);
91 
92 } // namespace raw
93 
94 }// namespace gar
95 
96 #endif // GAR_RAWDATA_RAW_H
std::vector< ADC_t > ADCvector_t
Definition: RawTypes.h:13
void CompressHuffman(gar::raw::ADCvector_t &adc)
Definition: raw.cxx:243
void ZeroUnsuppression(const gar::raw::ADCvector_t &adc, gar::raw::ADCvector_t &uncompressed, gar::raw::ADC_t pedestal)
Definition: raw.cxx:152
int ZeroSuppression(gar::raw::ADCvector_t &adc, gar::raw::ADC_t zerothreshold, size_t ticksbefore_in, size_t ticksafter_in)
Definition: raw.cxx:66
void UncompressHuffman(const gar::raw::ADCvector_t &adc, gar::raw::ADCvector_t &uncompressed)
Definition: raw.cxx:453
enum gar::raw::_compress Compress_t
int16_t adc
Definition: CRTFragment.hh:202
Raw data description.
short ADC_t
Definition: RawTypes.h:12
General GArSoft Utilities.
void Uncompress(const gar::raw::ADCvector_t &adc, gar::raw::ADCvector_t &uncompressed, gar::raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:183
void Compress(gar::raw::ADCvector_t &adc, gar::raw::Compress_t compress)
In-place compression of raw data buffer.
Definition: raw.cxx:23