All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
raw.h
Go to the documentation of this file.
1 /// \file raw.h
2 /// \brief Collect all the RawData header files together
3 /// \author brebel@fnal.gov
4 /// modified by jti3@fnal.gov
5 
6 #ifndef RAWDATA_RAW_H
7 #define RAWDATA_RAW_H
8 
9 #include <vector>
10 #include <map>
11 #include <functional>
12 #include <boost/circular_buffer.hpp>
14 
15 namespace raw{
16 
17  /**
18  * @brief Uncompresses a raw data buffer
19  * @param adc compressed buffer
20  * @param uncompressed buffer to be filled with uncompressed data
21  * @param compress type of compression in the adc buffer
22  *
23  * This function dispatches the uncompression to the correct uncompress
24  * function according to compression type in compress.
25  *
26  * The uncompressed buffer *must* be already allocated with enough space
27  * to store the full inflated adc data. Uncompressing raw::RawDigit can
28  * be done as follows:
29  *
30  * std::vector<ADC_t> uncompressed(digit.Samples(), 0);
31  * raw::Uncompress(digit.ADC(), uncompressed, digit.ADC());
32  *
33  *
34  */
35  void Uncompress(const std::vector<short>& adc,
36  std::vector<short> &uncompressed,
37  raw::Compress_t compress);
38 
39  void Uncompress(const std::vector<short>& adc,
40  std::vector<short> &uncompressed,
41  int pedestal,
42  raw::Compress_t compress);
43 
44  void Compress(std::vector<short> &adc,
45  raw::Compress_t compress,
46  int &nearestneighbor);
47  void Compress(std::vector<short> &adc,
48  raw::Compress_t compress,
49  unsigned int &zerothreshold,
50  int &nearestneighbor);
51  void Compress(std::vector<short> &adc,
52  raw::Compress_t compress,
53  unsigned int &zerothreshold,
54  int pedestal,
55  int &nearestneighbor,
56  bool fADCStickyCodeFeature=false);
57 
58  /**
59  * @brief Compresses a raw data buffer
60  * @param adc buffer with uncompressed data
61  * @param compress type of compression to be applied
62  *
63  * This function dispatches the compression to the function appropriate
64  * for the specified compression type.
65  * The resulting compressed data replaces the input buffer content, which is lost.
66  * Compression is expected to reduce the size of the data, so that there is
67  * in principle no need for reallocation of the input buffer, adc, to store
68  * the result.
69  */
70  void Compress(std::vector<short> &adc,
71  raw::Compress_t compress);
72  void Compress(std::vector<short> &adc,
73  raw::Compress_t compress,
74  unsigned int &zerothreshold);
75 
76  void Compress(const boost::circular_buffer<std::vector<short>> &adcvec_neighbors,
77  std::vector<short> &adc,
78  raw::Compress_t compress,
79  unsigned int &zerothreshold,
80  int &nearestneighbor);
81 
82  void Compress(const boost::circular_buffer<std::vector<short>> &adcvec_neighbors,
83  std::vector<short> &adc,
84  raw::Compress_t compress,
85  unsigned int &zerothreshold,
86  int pedestal,
87  int &nearestneighbor,
88  bool fADCStickyCodeFeature=false);
89 
90  void CompressHuffman(std::vector<short> &adc);
91 
92  void UncompressHuffman(const std::vector<short>& adc,
93  std::vector<short> &uncompressed);
94 
95  short fibonacci_decode(std::vector<bool>& chunk);
96  void fibonacci_encode_table(int end, std::vector<std::vector<bool>>& table);
97 
98  void CompressFibonacci(std::vector<short> &wf,
99  std::function<void(int, std::vector<std::vector<bool>>&)> add_to_table=fibonacci_encode_table);
100 
101  void UncompressFibonacci(const std::vector<short> &adc,
102  std::vector<short> &uncompressed,
103  std::function<int(std::vector<bool>&)> decode_table_chunk=fibonacci_decode);
104 
105 
106  void ZeroSuppression(std::vector<short> &adc,
107  unsigned int &zerothreshold,
108  int &nearestneighbor);
109 
110  void ZeroSuppression(std::vector<short> &adc,
111  unsigned int &zerothreshold,
112  int pedestal,
113  int &nearestneighbor,
114  bool fADCStickyCodeFeature=false);
115 
116 
117  void ZeroSuppression(std::vector<short> &adc,
118  unsigned int &zerothreshold);
119 
120  void ZeroSuppression(const boost::circular_buffer<std::vector<short>> &adcvec_neighbors,
121  std::vector<short> &adc,
122  unsigned int &zerothreshold,
123  int &nearestneighbor);
124 
125  void ZeroSuppression(const boost::circular_buffer<std::vector<short>> &adcvec_neighbors,
126  std::vector<short> &adc,
127  unsigned int &zerothreshold,
128  int pedestal,
129  int &nearestneighbor,
130  bool fADCStickyCodeFeature=false);
131 
132  void ZeroUnsuppression(const std::vector<short>& adc,
133  std::vector<short> &uncompressed);
134 
135  void ZeroUnsuppression(const std::vector<short>& adc,
136  std::vector<short> &uncompressed,
137  int pedestal);
138 
139  const unsigned int onemask = 0x003f; // Unsigned int ending in 111111 used to select 6 LSBs with bitwise AND
140 
141  int ADCStickyCodeCheck(const short adc_current_value, // Function to check if ADC value may be ADC sticky code in DUNE35t data
142  const int pedestal,
143  bool fADCStickyCodeFeature);
144 
145 } // namespace raw
146 
147 #endif // RAWDATA_RAW_H
void CompressHuffman(std::vector< short > &adc)
Definition: raw.cxx:849
enum raw::_compress Compress_t
void UncompressHuffman(const std::vector< short > &adc, std::vector< short > &uncompressed)
Definition: raw.cxx:1059
const unsigned int onemask
Definition: raw.h:139
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
int ADCStickyCodeCheck(const short adc_value, const int pedestal, bool fADCStickyCodeFeature)
Definition: raw.cxx:1185
void fibonacci_encode_table(int end, std::vector< std::vector< bool >> &table)
Definition: raw.cxx:1346
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
void ZeroUnsuppression(const std::vector< short > &adc, std::vector< short > &uncompressed)
Definition: raw.cxx:716
void UncompressFibonacci(const std::vector< short > &adc, std::vector< short > &uncompressed, std::function< int(std::vector< bool > &)> decode_table_chunk)
Definition: raw.cxx:1301
void CompressFibonacci(std::vector< short > &wf, std::function< void(int, std::vector< std::vector< bool >> &)> add_to_table)
Definition: raw.cxx:1208
void Compress(std::vector< short > &adc, raw::Compress_t compress)
Compresses a raw data buffer.
Definition: raw.cxx:19
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:776
void ZeroSuppression(std::vector< short > &adc, unsigned int &zerothreshold)
Definition: raw.cxx:173
short fibonacci_decode(std::vector< bool > &chunk)
Definition: raw.cxx:1394