Classes | Macros | Functions
SimpleChannelStatus_test.cxx File Reference

Test of SimpleChannelStatus. More...

#include "boost/test/unit_test.hpp"
#include "larevt/Filters/SimpleChannelStatus.h"
#include "larcoreobj/SimpleTypesAndConstants/RawTypes.h"
#include "fhiclcpp/ParameterSet.h"
#include "fhiclcpp/coding.h"
#include <any>
#include <iostream>
#include <ostream>
#include <set>
#include <memory>
#include <algorithm>

Go to the source code of this file.

Classes

class  StatusConfiguration
 

Macros

#define BOOST_TEST_MODULE   ( simple_channel_status_test )
 

Functions

template<typename T >
fhicl::detail::ps_sequence_t std::encode (std::set< T > const &s)
 
template<typename T >
std::ostream & std::operator<< (std::ostream &out, std::set< T > const &s)
 
void test_simple_status ()
 
 BOOST_AUTO_TEST_CASE (SimpleStatusTest)
 

Detailed Description

Test of SimpleChannelStatus.

Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.fnal..nosp@m.gov)
Date
July 17th, 2015

Definition in file SimpleChannelStatus_test.cxx.

Macro Definition Documentation

#define BOOST_TEST_MODULE   ( simple_channel_status_test )

Definition at line 18 of file SimpleChannelStatus_test.cxx.

Function Documentation

BOOST_AUTO_TEST_CASE ( SimpleStatusTest  )

Definition at line 215 of file SimpleChannelStatus_test.cxx.

215  {
217 }
void test_simple_status()
template<typename T >
fhicl::detail::ps_sequence_t std::encode ( std::set< T > const &  s)

Definition at line 41 of file SimpleChannelStatus_test.cxx.

41  {
43  result.reserve(s.size());
44  std::transform(s.begin(), s.end(), std::inserter(result, result.end()),
45  [](T const& value) { return std::any(fhicl::detail::encode(value)); }
46  );
47  return result;
48  } // encode(set<T>)
static QCString result
ps_atom_t encode(std::string const &)
Definition: coding.cc:87
std::vector< std::any > ps_sequence_t
Definition: coding.h:45
template<typename T >
std::ostream& std::operator<< ( std::ostream &  out,
std::set< T > const &  s 
)

Definition at line 52 of file SimpleChannelStatus_test.cxx.

52  {
53  out << "{";
54  typename std::set<T>::const_iterator begin = s.cbegin(), end = s.cend();
55  if (begin != end) {
56  out << " " << *begin;
57  while (++begin != end) out << ", " << *begin;
58  out << " ";
59  } // if not empty
60  out << "}";
61  return out;
62  } // operator<< (ostream, set<T>)
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
intermediate_table::const_iterator const_iterator
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
void test_simple_status ( )

Public interface:

bool isPresent(raw::ChannelID_t channel) const

bool isGood(raw::ChannelID_t channel) const

bool isBad(raw::ChannelID_t channel) const

bool isNoisy(raw::ChannelID_t channel) const

ChannelSet_t GoodChannels() const

ChannelSet_t BadChannels() const

ChannelSet_t NoisyChannels() const

Definition at line 127 of file SimpleChannelStatus_test.cxx.

127  {
128 
129  StatusConfiguration statusCreator(
130  /* MaxChannel */ 20,
131  /* MaxPresentChannel */ 15,
132  /* BadChannels */ { 1, 9, 13 },
133  /* NoisyChannels */ { 6, 8, 10, 11, 12, 13 }
134  );
135 
136  BOOST_TEST_CHECKPOINT("Creating simple status");
137  std::unique_ptr<lariov::SimpleChannelStatus> StatusOwner
138  = statusCreator.CreateStatus();
139 
140  lariov::SimpleChannelStatus const* pSimpleStatus = StatusOwner.get();
141 
142  // check the values of the extremes
143  BOOST_TEST(pSimpleStatus->MaxChannel() == statusCreator.fMaxChannel);
144  BOOST_TEST
145  (pSimpleStatus->MaxChannelPresent() == statusCreator.fMaxPresentChannel);
146 
147  // downcast to the interface to test interface stuff
148  lariov::ChannelStatusProvider const* pStatus = pSimpleStatus;
149 
150  /**
151  *
152  * Public interface:
153  *
154  * bool isPresent(raw::ChannelID_t channel) const
155  *
156  * bool isGood(raw::ChannelID_t channel) const
157  *
158  * bool isBad(raw::ChannelID_t channel) const
159  *
160  * bool isNoisy(raw::ChannelID_t channel) const
161  *
162  * ChannelSet_t GoodChannels() const
163  *
164  * ChannelSet_t BadChannels() const
165  *
166  * ChannelSet_t NoisyChannels() const
167  *
168  */
169 
170  // ChannelStatusBaseInterface::BadChannels()
171  std::set<raw::ChannelID_t> StatusBadChannels = pStatus->BadChannels();
172  BOOST_TEST
173  (StatusBadChannels.size() == statusCreator.fBadChannels.size());
174  BOOST_TEST(StatusBadChannels == statusCreator.fBadChannels);
175 
176  // ChannelStatusBaseInterface::NoisyChannels()
177  std::set<raw::ChannelID_t> StatusNoisyChannels = pStatus->NoisyChannels();
178  BOOST_TEST
179  (StatusNoisyChannels.size() == statusCreator.fNoisyChannels.size());
180  BOOST_TEST(StatusNoisyChannels == statusCreator.fNoisyChannels);
181 
182  std::set<raw::ChannelID_t> GoodChannels;
183 
184  for (raw::ChannelID_t channel = 0; channel <= statusCreator.fMaxChannel;
185  ++channel
186  ) {
187 
188  const bool bPresent = raw::isValidChannelID(channel)
189  && (channel <= statusCreator.fMaxPresentChannel);
190  const bool bBad = (statusCreator.fBadChannels.count(channel) > 0);
191  const bool bNoisy = (statusCreator.fNoisyChannels.count(channel) > 0);
192  const bool bGood = bPresent && !bBad && !bNoisy;
193 
194  if (bGood) GoodChannels.insert(channel);
195 
196  BOOST_TEST(pStatus->IsPresent(channel) == bPresent);
197  BOOST_TEST(pStatus->IsBad(channel) == bBad);
198  BOOST_TEST(pStatus->IsNoisy(channel) == bNoisy);
199 
200  BOOST_TEST(pStatus->IsGood(channel) == bGood);
201 
202  } // for channel
203 
204  // ChannelStatusBaseInterface::GoodChannels()
205  std::set<raw::ChannelID_t> StatusGoodChannels = pStatus->GoodChannels();
206  BOOST_TEST(StatusGoodChannels.size() == GoodChannels.size());
207  BOOST_TEST(StatusGoodChannels == GoodChannels);
208 
209 } // test_simple_status()
raw::ChannelID_t MaxChannelPresent() const
Returns the ID of the largest present channel.
raw::ChannelID_t MaxChannel() const
Returns the ID of the largest known channel.
uint8_t channel
Definition: CRTFragment.hh:201
constexpr bool isValidChannelID(raw::ChannelID_t channel)
Definition: RawTypes.h:37
Class providing information about the quality of channels.
virtual ChannelSet_t BadChannels() const override
Returns a copy of set of bad channel IDs for the current run.
Class providing information about the quality of channels.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28