Macros | Functions
Wire_test.cc File Reference

Simple test on a recob::Wire object. More...

#include <algorithm>
#include "boost/test/unit_test.hpp"
#include "larcoreobj/SimpleTypesAndConstants/RawTypes.h"
#include "larcoreobj/SimpleTypesAndConstants/geo_types.h"
#include "lardataobj/Utilities/sparse_vector.h"
#include "lardataobj/RecoBase/Wire.h"

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   ( wire_test )
 

Functions

void CheckWire (recob::Wire const &wire, recob::Wire::RegionsOfInterest_t const &sigROIlist, raw::ChannelID_t channel, geo::View_t view)
 
void WireTestDefaultConstructor ()
 
void WireTestCustomConstructors ()
 
 BOOST_AUTO_TEST_CASE (WireDefaultConstructor)
 
 BOOST_AUTO_TEST_CASE (WireCustomConstructors)
 

Detailed Description

Simple test on a recob::Wire object.

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

This test simply creates recob::Wire 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.5" (debug mode)

Definition in file Wire_test.cc.

Macro Definition Documentation

#define BOOST_TEST_MODULE   ( wire_test )

Definition at line 31 of file Wire_test.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( WireDefaultConstructor  )

Definition at line 163 of file Wire_test.cc.

163  {
165 }
void WireTestDefaultConstructor()
Definition: Wire_test.cc:80
BOOST_AUTO_TEST_CASE ( WireCustomConstructors  )

Definition at line 167 of file Wire_test.cc.

167  {
169 }
void WireTestCustomConstructors()
Definition: Wire_test.cc:103
void CheckWire ( recob::Wire const &  wire,
recob::Wire::RegionsOfInterest_t const &  sigROIlist,
raw::ChannelID_t  channel,
geo::View_t  view 
)

Definition at line 47 of file Wire_test.cc.

52  {
53 
54  // verify that the values are as expected
55  // - channel ID
56  BOOST_TEST(wire.Channel() == channel);
57 
58  // - view
59  BOOST_TEST(wire.View() == view);
60 
61  // - region of interest
62  BOOST_TEST(wire.NSignal() == sigROIlist.size());
63 
64  recob::Wire::RegionsOfInterest_t const& wireROI = wire.SignalROI();
65  BOOST_TEST(wireROI.n_ranges() == sigROIlist.n_ranges());
66 
67  unsigned int index = 0;
68  for (auto sample: wireROI) {
69  BOOST_TEST(sample == sigROIlist[index++]);
70  }
71 
72  // - other elements of interface
73  auto const& wire_signal = wire.Signal();
74  BOOST_TEST
75  (std::equal(wire_signal.begin(), wire_signal.end(), sigROIlist.cbegin()));
76 
77 } // CheckWire()
uint8_t channel
Definition: CRTFragment.hh:201
void WireTestCustomConstructors ( )

Definition at line 103 of file Wire_test.cc.

103  {
104 
105  //
106  // Part I: initialization of wire inputs
107  //
109  geo::View_t view = geo::kV;
110 
111  recob::Wire::RegionsOfInterest_t sigROIlist(20);
112  sigROIlist.add_range
113  (5, recob::Wire::RegionsOfInterest_t::vector_t({ 5., 6., 7. }));
114  sigROIlist.add_range
115  (11, recob::Wire::RegionsOfInterest_t::vector_t({ 11., 12., 13., 14. }));
116 
117  // this is not a recob::Wire test, but I want to make sure anyway...
118  BOOST_TEST(sigROIlist.size() == 20U);
119  BOOST_TEST(sigROIlist.n_ranges() == 2U);
120  size_t index = 0;
121  for (auto sample: sigROIlist) {
122  BOOST_TEST(((sample == (float) index) || (sample == 0.)));
123  ++index;
124  } // for
125 
126 
127  //
128  // Part II: constructor with signal copy
129  //
130  // step II.1: create a wire with the signal-copying constructor
131  recob::Wire wire1(sigROIlist, channel, view);
132 
133 
134  // step II.2: verify that the values are as expected
135  CheckWire(wire1, sigROIlist, channel, view);
136 
137 
138  //
139  // Part III: constructor with signal move
140  //
141  // step III.1: create a wire with the signal-copying constructor
142  recob::Wire::RegionsOfInterest_t sigROIlistCopy(sigROIlist); // need a copy for check
143  recob::Wire wire2(std::move(sigROIlistCopy), channel, view);
144 
145  // step III.2: verify that the values are as expected
146  CheckWire(wire2, sigROIlist, channel, view);
147 
148  // step III.3: verify that the values were actually moved
149  BOOST_TEST(sigROIlistCopy.empty());
150 
151 } // WireTestCustomConstructors()
std::vector< value_type > vector_t
type of STL vector holding this data
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Planes which measure V.
Definition: geo_types.h:130
void CheckWire(recob::Wire const &wire, recob::Wire::RegionsOfInterest_t const &sigROIlist, raw::ChannelID_t channel, geo::View_t view)
Definition: Wire_test.cc:47
uint8_t channel
Definition: CRTFragment.hh:201
def move(depos, offset)
Definition: depos.py:107
Class holding the regions of interest of signal from a channel.
Definition: Wire.h:118
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void WireTestDefaultConstructor ( )

Definition at line 80 of file Wire_test.cc.

80  {
81 
82  //
83  // Part I: initialization of wire inputs
84  //
85  // these are the values expected for a default-constructed wire
89 
90  //
91  // Part II: default constructor
92  //
93  // step II.1: create a wire with the default constructor
94  recob::Wire wire;
95 
96 
97  // step II.2: verify that the values are as expected
98  CheckWire(wire, sigROIlist, channel, view);
99 
100 } // WireTestDefaultConstructor()
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Unknown view.
Definition: geo_types.h:136
void CheckWire(recob::Wire const &wire, recob::Wire::RegionsOfInterest_t const &sigROIlist, raw::ChannelID_t channel, geo::View_t view)
Definition: Wire_test.cc:47
uint8_t channel
Definition: CRTFragment.hh:201
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
Definition: RawTypes.h:32
Class holding the regions of interest of signal from a channel.
Definition: Wire.h:118
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28