All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions
WaveformBaseline_test.cc File Reference

Unit test for WaveformBaseline.h header. More...

#include "sbnobj/ICARUS/PMT/Data/WaveformBaseline.h"
#include "icarusalg/Utilities/WaveformOperations.h"
#include "lardataalg/Utilities/quantities/electronics.h"
#include <boost/test/unit_test.hpp>
#include <sstream>
#include <vector>
#include <cmath>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   ( WaveformBaseline_test )
 

Functions

void WaveformBaseline_value_test ()
 
void WaveformBaseline_documentation1_test ()
 
void WaveformBaseline_documentation2_test ()
 
 BOOST_AUTO_TEST_CASE (WaveformBaseline_documentation_testcase)
 

Detailed Description

Unit test for WaveformBaseline.h header.

Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.slac..nosp@m.stan.nosp@m.ford..nosp@m.edu)
Date
September 11, 2020
See Also
icaruscode/PMT/Data/WaveformBaseline.h

The main purpose of this test is to make sure TriggerGateData code is compiled, since it is just a header.

Definition in file WaveformBaseline_test.cc.

Macro Definition Documentation

#define BOOST_TEST_MODULE   ( WaveformBaseline_test )

Definition at line 20 of file WaveformBaseline_test.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( WaveformBaseline_documentation_testcase  )

Definition at line 117 of file WaveformBaseline_test.cc.

117  {
118 
120 
123 
124 } // BOOST_AUTO_TEST_CASE(WaveformBaseline_documentation_testcase)
void WaveformBaseline_documentation2_test()
void WaveformBaseline_value_test()
void WaveformBaseline_documentation1_test()
void WaveformBaseline_documentation1_test ( )

Definition at line 55 of file WaveformBaseline_test.cc.

55  {
56 
57  std::ostringstream sstr;
58 
59  /*
60  * icarus::WaveformBaseline const baseline { 1.2f };
61  *
62  * std::cout << "Baseline: " << baseline << " ADC" << std::endl;
63  */
64 
65  icarus::WaveformBaseline const baseline { 1.2f };
66 
67  sstr << "Baseline: " << baseline << " ADC";
68 
69 
70  BOOST_TEST((sstr.str() == "Baseline: 1.2 ADC"));
71 
72 } // WaveformBaseline_documentation1_test()
BEGIN_PROLOG baseline
Class containing a waveform baseline value.
void WaveformBaseline_documentation2_test ( )

Definition at line 75 of file WaveformBaseline_test.cc.

75  {
76  /*
77  *
78  */
79 
80  //
81  // initialization
82  //
83  using ADCCount_t = util::quantities::counts;
84  std::vector<ADCCount_t> const data
85  { ADCCount_t{ -6 }, ADCCount_t{ -8 }, ADCCount_t{ -2 } };
86 
87  //
88  // test code
89  //
90  icarus::WaveformBaseline const baseline { -1.8 };
91 
93  waveOps { baseline() };
94 
95  std::vector<ADCCount_t> subtracted;
96  subtracted.reserve(data.size());
97  for (ADCCount_t sample: data) {
98  subtracted.emplace_back
99  (std::round(waveOps.subtractBaseline(sample.value())));
100  }
101 
102  //
103  // checks
104  //
105  BOOST_TEST((subtracted.size() == data.size()));
106 
107  BOOST_TEST((subtracted[0U] == ADCCount_t{ 4 }));
108  BOOST_TEST((subtracted[1U] == ADCCount_t{ 6 }));
109  BOOST_TEST((subtracted[2U] == ADCCount_t{ 0 }));
110 
111 } // WaveformBaseline_documentation2_test()
Operations< Sample,-1 > NegativePolarityOperations
Waveform operations for negative polarity waveforms.
counts_as<> counts
Number of ADC counts, represented by signed short int.
Definition: electronics.h:116
BEGIN_PROLOG baseline
Class containing a waveform baseline value.
void WaveformBaseline_value_test ( )

Definition at line 33 of file WaveformBaseline_test.cc.

33  {
34 
35  constexpr float baselineValue { 6.6f };
36 
37  icarus::WaveformBaseline const baseline { baselineValue };
38 
39  BOOST_TEST((baseline.fBaseline == baselineValue));
40  BOOST_TEST((baseline.baseline() == baselineValue));
41  BOOST_TEST((baseline() == baselineValue));
42 
43  std::ostringstream sstr;
44  sstr << baseline;
45  std::string const baselineStr { sstr.str() };
46  sstr.str("");
47  sstr << baselineValue;
48  std::string const baselineValueStr { sstr.str() };
49 
50  BOOST_TEST((baselineStr == baselineValueStr));
51 
52 } // WaveformBaseline_value_test()
BEGIN_PROLOG baseline
Class containing a waveform baseline value.