All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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()
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.
virtual ChannelSet_t BadChannels() const override
Returns a copy of set of bad channel IDs for the current run.
raw::ChannelID_t MaxChannel() const
Returns the ID of the largest known channel.
constexpr bool isValidChannelID(raw::ChannelID_t channel)
Definition: RawTypes.h:37
Class providing information about the quality of channels.
Class providing information about the quality of channels.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28