37 #define BOOST_TEST_MODULE ( raw_test ) 38 #include "boost/test/unit_test.hpp" 99 baseline(pedestal), width(RMS * std::sqrt(12.))
105 std::uniform_real_distribution<float> noise
106 (baseline - width, baseline + width);
108 for (
auto& item: data)
132 std::normal_distribution<float> noise(mean, stdev);
134 for (
auto& item: data)
152 period(new_period), amplitude(new_amplitude)
160 constexpr
float two_pi = 2.0F * util::pi<float>();
163 for (
size_t i = 0; i <
size; ++i)
164 data.push_back(amplitude * std::sin(i / period * two_pi));
178 std::uniform_int_distribution<short> uniform(
183 for (
auto& item: data)
217 std::vector<short> buffer(data);
221 std::cout <<
id <<
": compressed data size: " << buffer.size() <<
std::endl;
224 std::vector<short> data_again(data.size());
228 BOOST_TEST(data_again.size() == data.size());
230 BOOST_CHECK_EQUAL_COLLECTIONS
231 (data.begin(), data.end(), data_again.begin(), data_again.end());
249 std::map<raw::Compress_t, std::string> CompressionModes;
250 CompressionModes[
raw::kNone] =
"uncompressed";
257 std::map<size_t, std::string> DataSizes;
258 DataSizes[64] =
"small size";
259 DataSizes[9600] =
"medium size";
260 DataSizes[1048576] =
"large size";
262 for (
const auto size_info: DataSizes) {
264 const std::vector<short>
data(pDataCreator->
create(size_info.first));
267 for (
const auto test_info: CompressionModes) {
270 +
" (" + size_info.second +
" " +
test_info.second +
")";
327 SineWaveCreator InputData(
"Very low frequency pure sine wave", 1024., 50.);
virtual InputData_t create(size_t size)=0
Creates and returns the data sample; pure virtual.
enum raw::_compress Compress_t
float stdev
standard deviation of the noise Gaussian (RMS)
static std::default_random_engine random_engine
Random engine shared by all the data creators.
void RunDataCompressionTests(DataCreatorBase *pDataCreator)
Runs data compression tests with selected compression modes.
Data creator: uniformly random data, full range.
std::string test_name
internal storage for test name
Interface of an object creating data to be tested on.
void RunDataCompressionTest(std::string id, const std::vector< short > &data, raw::Compress_t mode)
Tests a data set with a given compression.
virtual ~DataCreatorBase()
Virtual destructor.
std::string name() const
Returns the name of this set.
virtual InputData_t create(size_t size) override
Creates and returns the data sample.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
DataCreatorBase(std::string new_name)
Constructor: just assigns a name to this data set.
virtual InputData_t create(size_t size) override
Creates and returns the data sample.
Data creator: Gaussian random data.
static int max(int a, int b)
float period
period of the wave [ticks]
virtual InputData_t create(size_t size) override
Creates and returns the data sample.
float amplitude
amplitude of the wave [ADC counts]
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
void Compress(std::vector< short > &adc, raw::Compress_t compress)
Compresses a raw data buffer.
constexpr unsigned int RandomSeed
The seed for the default random engine.
BOOST_AUTO_TEST_CASE(NullData)
Collection of Physical constants used in LArSoft.
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
std::vector< short > InputData_t
Data creator: sine wave data.
float mean
mean of the noise Gaussian (pedestal)
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
QTextStream & endl(QTextStream &s)