37 #define BOOST_TEST_MODULE ( raw_test )
38 #include "boost/test/unit_test.hpp"
97 (std::string
name,
float RMS,
float pedestal = 0.):
105 std::uniform_real_distribution<float> noise
108 for (
auto& item: data)
124 (std::string name,
float sigma,
float mu = 0.):
132 std::normal_distribution<float> noise(
mean,
stdev);
134 for (
auto& item: data)
150 (std::string name,
float new_period,
float new_amplitude):
160 constexpr
float two_pi = 2.0F * util::pi<float>();
163 for (
size_t i = 0; i <
size; ++i)
178 std::uniform_int_distribution<short> uniform(
179 std::numeric_limits<short>::min(),
180 std::numeric_limits<short>::max()
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) {
269 std::string test_id = pDataCreator->
name()
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.
constexpr unsigned int RandomSeed
The seed for the default random engine.
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.
std::size_t size(FixedBins< T, C > const &) noexcept
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.
Collect all the RawData header files together.
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.
GaussianNoiseCreator(std::string name, float sigma, float mu=0.)
Constructor: assigns data set name and noise parameters.
Data creator: Gaussian random data.
float period
period of the wave [ticks]
SineWaveCreator(std::string name, float new_period, float new_amplitude)
Constructor: assigns data set name and noise parameters.
virtual InputData_t create(size_t size) override
Creates and returns the data sample.
float amplitude
amplitude of the wave [ADC counts]
void Compress(std::vector< short > &adc, raw::Compress_t compress)
Compresses a raw data buffer.
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)
BEGIN_PROLOG could also be cout