Macros | Functions
RawDigit_test.cc File Reference

Simple test on a raw::RawDigit object. More...

#include <algorithm>
#include "boost/test/unit_test.hpp"
#include "larcoreobj/SimpleTypesAndConstants/RawTypes.h"
#include "lardataobj/RawData/raw.h"
#include "lardataobj/RawData/RawDigit.h"

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   ( rawdigit_test )
 

Functions

void CheckRawDigit (raw::RawDigit const &digits, raw::ChannelID_t channel, unsigned short samples, raw::RawDigit::ADCvector_t const &uncompressed_adclist, raw::Compress_t compression)
 
void RawDigitTestDefaultConstructor ()
 
void RawDigitTestCustomConstructors ()
 
void FibonacciCompressionTestCustomConstructor ()
 
 BOOST_AUTO_TEST_CASE (RawDigitDefaultConstructor)
 
 BOOST_AUTO_TEST_CASE (RawDigitCustomConstructors)
 
 BOOST_AUTO_TEST_CASE (FibonacciCompressionConstructor)
 

Detailed Description

Simple test on a raw::RawDigit object.

Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.fnal..nosp@m.gov)
Date
20150114
Version
1.0

This test simply creates raw::RawDigit objects and verifies that the values it can access are the right ones.

See http://www.boost.org/libs/test for the Boost test library home page.

Timing: version 1.0: <1" (debug mode)

Definition in file RawDigit_test.cc.

Macro Definition Documentation

#define BOOST_TEST_MODULE   ( rawdigit_test )

Definition at line 31 of file RawDigit_test.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( RawDigitDefaultConstructor  )

Definition at line 192 of file RawDigit_test.cc.

192  {
194 }
void RawDigitTestDefaultConstructor()
BOOST_AUTO_TEST_CASE ( RawDigitCustomConstructors  )

Definition at line 196 of file RawDigit_test.cc.

196  {
198 }
void RawDigitTestCustomConstructors()
BOOST_AUTO_TEST_CASE ( FibonacciCompressionConstructor  )

Definition at line 200 of file RawDigit_test.cc.

200  {
202 }
void FibonacciCompressionTestCustomConstructor()
void CheckRawDigit ( raw::RawDigit const &  digits,
raw::ChannelID_t  channel,
unsigned short  samples,
raw::RawDigit::ADCvector_t const &  uncompressed_adclist,
raw::Compress_t  compression 
)

Definition at line 46 of file RawDigit_test.cc.

52  {
53 
54  // this is a parameters validation check
55  BOOST_TEST(samples == uncompressed_adclist.size());
56 
57  // verify that the values are as expected
58  // - channel ID
59  BOOST_TEST(digits.Channel() == channel);
60 
61  // - compression mode
62  BOOST_TEST(digits.Compression() == compression);
63 
64  // - uncompressed size
65  BOOST_TEST(digits.Samples() == samples);
66  BOOST_TEST(digits.Samples() == uncompressed_adclist.size());
67 
68  // - digits
69 
70  // decompress (on an already allocated buffer)
71  raw::RawDigit::ADCvector_t ADCs(digits.Samples());
72  raw::Uncompress(digits.ADCs(), ADCs, digits.Compression());
73 
74  BOOST_WARN(digits.NADC() <= samples); // is this always the case?
75  BOOST_TEST
76  (std::equal(ADCs.begin(), ADCs.end(), uncompressed_adclist.begin()));
77 
78  // - others
79  BOOST_TEST(digits.GetPedestal() == 0.);
80  BOOST_TEST(digits.GetSigma() == 0.);
81 
82 } // CheckRawDigit()
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:73
uint8_t channel
Definition: CRTFragment.hh:201
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 FibonacciCompressionTestCustomConstructor ( )

Definition at line 155 of file RawDigit_test.cc.

155  {
156 
157  //
158  // Part I: initialization of wire inputs
159  //
160  const raw::ChannelID_t channel = 12;
161  const unsigned short samples = 1000;
162  raw::RawDigit::ADCvector_t adclist(samples);
163  for (size_t i = 0; i < samples; ++i)
164  adclist[i] = (i % 3)? 0: i;
165  const raw::Compress_t compression = raw::kHuffman;
166 
167 // working a copy of the original data:
168  std::vector<short> buffer(adclist);
169  raw::Compress(buffer, compression); // compression happens in place
170 
171  //
172  // Part II: constructor with signal copy
173  //
174  // step II.1: create a wire with the signal-copying constructor
175  raw::RawDigit digits1(channel, samples, buffer, compression /*, flags */);
176 
177  // step II.2: verify that the values are as expected
178  CheckRawDigit(digits1, channel, samples, adclist, compression);
179 
180 } // FibonacciCompressionTestCustomConstructors()
Huffman Encoding.
Definition: RawTypes.h:10
enum raw::_compress Compress_t
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:73
void CheckRawDigit(raw::RawDigit const &digits, raw::ChannelID_t channel, unsigned short samples, raw::RawDigit::ADCvector_t const &uncompressed_adclist, raw::Compress_t compression)
uint8_t channel
Definition: CRTFragment.hh:201
void Compress(std::vector< short > &adc, raw::Compress_t compress)
Compresses a raw data buffer.
Definition: raw.cxx:19
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void RawDigitTestCustomConstructors ( )

Definition at line 110 of file RawDigit_test.cc.

110  {
111 
112  //
113  // Part I: initialization of wire inputs
114  //
115  const raw::ChannelID_t channel = 12;
116  const unsigned short samples = 1000;
117  raw::RawDigit::ADCvector_t adclist(samples);
118  for (size_t i = 0; i < samples; ++i)
119  adclist[i] = (i % 3)? 0: i;
120  const raw::Compress_t compression = raw::kHuffman;
121 // raw::RawDigit::Flags_t flags;
122 
123  // working a copy of the original data:
124  std::vector<short> buffer(adclist);
125  raw::Compress(buffer, compression); // compression happens in place
126 
127 
128  //
129  // Part II: constructor with signal copy
130  //
131  // step II.1: create a wire with the signal-copying constructor
132  raw::RawDigit digits1(channel, samples, buffer, compression /*, flags */);
133 
134  // step II.2: verify that the values are as expected
135  CheckRawDigit(digits1, channel, samples, adclist, compression);
136 
137 
138  //
139  // Part III: constructor with signal move
140  //
141  // step III.1: create a wire with the signal-moving constructor
142  std::vector<short> buffer_copy(buffer);
143  raw::RawDigit digits2
144  (channel, samples, std::move(buffer_copy), compression /*, flags */);
145 
146  // step III.2: verify that the values are as expected
147  CheckRawDigit(digits2, channel, samples, adclist, compression);
148 
149  // step III.3: verify that the data was actually moved
150  BOOST_TEST(buffer_copy.empty());
151 
152 } // RawDigitTestCustomConstructors()
Huffman Encoding.
Definition: RawTypes.h:10
enum raw::_compress Compress_t
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:73
void CheckRawDigit(raw::RawDigit const &digits, raw::ChannelID_t channel, unsigned short samples, raw::RawDigit::ADCvector_t const &uncompressed_adclist, raw::Compress_t compression)
uint8_t channel
Definition: CRTFragment.hh:201
def move(depos, offset)
Definition: depos.py:107
void Compress(std::vector< short > &adc, raw::Compress_t compress)
Compresses a raw data buffer.
Definition: raw.cxx:19
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void RawDigitTestDefaultConstructor ( )

Definition at line 85 of file RawDigit_test.cc.

85  {
86 
87  //
88  // Part I: initialization of wire inputs
89  //
90  // these are the values expected for a default-constructed wire
92  const unsigned short samples = 0;
94  const raw::Compress_t compression = raw::kNone;
95 // raw::RawDigit::Flags_t flags;
96 
97  //
98  // Part II: default constructor
99  //
100  // step II.1: create a wire with the signal-copying constructor
101  raw::RawDigit digits;
102 
103 
104  // step II.2: verify that the values are as expected
105  CheckRawDigit(digits, channel, samples, adclist, compression);
106 
107 } // RawDigitTestDefaultConstructor()
enum raw::_compress Compress_t
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:73
void CheckRawDigit(raw::RawDigit const &digits, raw::ChannelID_t channel, unsigned short samples, raw::RawDigit::ADCvector_t const &uncompressed_adclist, raw::Compress_t compression)
uint8_t channel
Definition: CRTFragment.hh:201
no compression
Definition: RawTypes.h:9
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
Definition: RawTypes.h:32
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28