Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lariov::SimpleChannelStatus Class Reference

Class providing information about the quality of channels. More...

#include <SimpleChannelStatus.h>

Inheritance diagram for lariov::SimpleChannelStatus:
lariov::ChannelStatusProvider lar::UncopiableAndUnmovableClass

Public Types

using ChannelSet_t = lariov::ChannelStatusProvider::ChannelSet_t
 
- Public Types inherited from lariov::ChannelStatusProvider
using Status_t = unsigned short
 type representing channel status More...
 
using ChannelSet_t = std::set< raw::ChannelID_t >
 Type of set of channel IDs. More...
 

Public Member Functions

 SimpleChannelStatus (fhicl::ParameterSet const &pset)
 Configuration. More...
 
raw::ChannelID_t MaxChannel () const
 Returns the ID of the largest known channel. More...
 
raw::ChannelID_t MaxChannelPresent () const
 Returns the ID of the largest present channel. More...
 
Single channel queries

Returns whether the specified channel is physical and connected to wire

virtual bool IsPresent (raw::ChannelID_t channel) const override
 Returns whether the specified channel is physical and connected to wire. More...
 
virtual bool IsGood (raw::ChannelID_t channel) const override
 Returns whether the specified channel is physical and good. More...
 
virtual bool IsBad (raw::ChannelID_t channel) const override
 Returns whether the specified channel is bad in the current run. More...
 
virtual bool IsNoisy (raw::ChannelID_t channel) const override
 Returns whether the specified channel is noisy in the current run. More...
 
Global channel queries

Returns a copy of set of good channel IDs for the current run

virtual ChannelSet_t GoodChannels () const override
 Returns a copy of set of good channel IDs for the current run. More...
 
virtual ChannelSet_t BadChannels () const override
 Returns a copy of set of bad channel IDs for the current run. More...
 
virtual ChannelSet_t NoisyChannels () const override
 Returns a copy of set of noisy channel IDs for the current run. More...
 
Configuration functions
void Setup (raw::ChannelID_t MaxChannel, raw::ChannelID_t MaxGoodChannel)
 Sets the service provider up. More...
 
void Setup (raw::ChannelID_t MaxChannel)
 Sets the service provider up. More...
 
- Public Member Functions inherited from lariov::ChannelStatusProvider
 ChannelStatusProvider ()=default
 Default constructor. More...
 
 ChannelStatusProvider (ChannelStatusProvider const &)=delete
 
 ChannelStatusProvider (ChannelStatusProvider &&)=delete
 
ChannelStatusProvideroperator= (ChannelStatusProvider const &)=delete
 
ChannelStatusProvideroperator= (ChannelStatusProvider &&)=delete
 
virtual ~ChannelStatusProvider ()=default
 Virtual destructor; destructs nothing. More...
 
virtual Status_t Status (raw::ChannelID_t channel) const
 Returns a status integer with arbitrary meaning. More...
 
virtual bool HasStatus (raw::ChannelID_t channel) const
 Returns whether the specified status is a valid one. More...
 

Protected Member Functions

void FillGoodChannels () const
 Fills the collection of good channels. More...
 

Protected Attributes

ChannelSet_t fBadChannels
 set of bad channels More...
 
ChannelSet_t fNoisyChannels
 set of noisy channels More...
 
raw::ChannelID_t fMaxChannel
 largest ID among existing channels More...
 
raw::ChannelID_t fMaxPresentChannel
 largest ID among present channels More...
 
std::unique_ptr< ChannelSet_tfGoodChannels
 cached set of good channels (lazy evaluation) More...
 

Additional Inherited Members

- Static Public Member Functions inherited from lariov::ChannelStatusProvider
static bool IsValidStatus (Status_t status)
 Returns whether the specified status is a valid one. More...
 
- Static Public Attributes inherited from lariov::ChannelStatusProvider
static constexpr Status_t InvalidStatus = std::numeric_limits<Status_t>::max()
 Value or invalid status. More...
 

Detailed Description

Class providing information about the quality of channels.


This class serves information read from a FHiCL configuration file. Time-dependent (or, run-dependent) information is not supported.

All and only the channels up to the one specified in the Setup() call (that one included) are considered present. If no valid ID is specified, all channels are supposed present.

LArSoft interface to this class is through the service SimpleChannelStatusService.

Configuration parameters

Definition at line 49 of file SimpleChannelStatus.h.

Member Typedef Documentation

Definition at line 51 of file SimpleChannelStatus.h.

Constructor & Destructor Documentation

lariov::SimpleChannelStatus::SimpleChannelStatus ( fhicl::ParameterSet const &  pset)
explicit

Configuration.

Definition at line 29 of file SimpleChannelStatus.cpp.

32  {
33  using chan_vect_t = std::vector<raw::ChannelID_t>;
34 
35  // Read the bad channels as a vector, then convert it into a set
36  auto BadChannels = pset.get<chan_vect_t>("BadChannels", {});
38  std::inserter(fBadChannels, fBadChannels.begin()));
39 
40  // Read the noise channels as a vector, then convert it into a set
41  auto NoisyChannels = pset.get<chan_vect_t>("NoisyChannels", {});
43  std::inserter(fNoisyChannels, fNoisyChannels.begin()));
44 
45  } // SimpleChannelStatus::SimpleChannelStatus()
ChannelSet_t fNoisyChannels
set of noisy channels
raw::ChannelID_t fMaxPresentChannel
largest ID among present channels
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
Definition: RawTypes.h:32
ChannelSet_t fBadChannels
set of bad channels
virtual ChannelSet_t NoisyChannels() const override
Returns a copy of set of noisy channel IDs for the current run.
auto copy_all(FwdCont &, FwdIter)
virtual ChannelSet_t BadChannels() const override
Returns a copy of set of bad channel IDs for the current run.
raw::ChannelID_t fMaxChannel
largest ID among existing channels

Member Function Documentation

virtual ChannelSet_t lariov::SimpleChannelStatus::BadChannels ( ) const
inlineoverridevirtual

Returns a copy of set of bad channel IDs for the current run.

Implements lariov::ChannelStatusProvider.

Definition at line 85 of file SimpleChannelStatus.h.

86  { return fBadChannels; }
ChannelSet_t fBadChannels
set of bad channels
void lariov::SimpleChannelStatus::FillGoodChannels ( ) const
protected

Fills the collection of good channels.

Definition at line 80 of file SimpleChannelStatus.cpp.

80  {
81 
82  if (!fGoodChannels) fGoodChannels.reset(new ChannelSet_t);
83 
85  GoodChannels.clear();
86 
88  <std::pair<ChannelSet_t::const_iterator, ChannelSet_t::const_iterator>>
89  VetoedIDs;
90 
91  VetoedIDs.emplace_back(fBadChannels.cbegin(), fBadChannels.cend());
92  VetoedIDs.emplace_back(fNoisyChannels.cbegin(), fNoisyChannels.cend());
93 
94  // go for the first (lowest) channel ID...
96  while (!raw::isValidChannelID(channel)) ++channel;
97 
98  // ... to the last present one
99  raw::ChannelID_t last_channel = fMaxChannel;
101  && (fMaxPresentChannel < last_channel))
102  last_channel = fMaxPresentChannel;
103 
104  // if we don't know how many channels
105  if (!raw::isValidChannelID(last_channel)) {
106  // this exception means that the Setup() function was not called
107  // or it was called with an invalid value
108  throw cet::exception("SimpleChannelStatus")
109  << "Can't fill good channel list since no largest channel was set up\n";
110  } // if
111 
112  // add the channels to the set one by one
113  while (channel <= last_channel) {
114  bool bGood = true;
115 
116  // check if this channel is in any of the vetoed lists
117  for (auto iter: VetoedIDs) {
118 
119  // check all the remaining vetoed channels in this list
120  while (iter.first != iter.second) {
121  // if the first vetoed channel is larger than the tested channel,
122  // we are done with this list
123  if (*(iter.first) > channel) break;
124 
125  if (*(iter.first) == channel) { // vetoed!
126  bGood = false;
127  ++(iter.first); // we have found this already
128  break;
129  }
130 
131  // the last vetoed channel is smaller than the tested channel;
132  // maybe the next vetoed channel will be it!
133  ++(iter.first);
134  } // while
135 
136  if (!bGood) break; // already known bad, we are done
137  } // for
138 
139  // add the channel
140  if (bGood) GoodChannels.insert(channel);
141  ++channel;
142  } // while
143 
144  } // SimpleChannelStatus::GoodChannels()
ChannelSet_t fNoisyChannels
set of noisy channels
std::unique_ptr< ChannelSet_t > fGoodChannels
cached set of good channels (lazy evaluation)
struct vector vector
uint8_t channel
Definition: CRTFragment.hh:201
raw::ChannelID_t fMaxPresentChannel
largest ID among present channels
ChannelSet_t fBadChannels
set of bad channels
constexpr bool isValidChannelID(raw::ChannelID_t channel)
Definition: RawTypes.h:37
lariov::ChannelStatusProvider::ChannelSet_t ChannelSet_t
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
virtual ChannelSet_t GoodChannels() const override
Returns a copy of set of good channel IDs for the current run.
raw::ChannelID_t fMaxChannel
largest ID among existing channels
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
SimpleChannelStatus::ChannelSet_t lariov::SimpleChannelStatus::GoodChannels ( ) const
overridevirtual

Returns a copy of set of good channel IDs for the current run.

Implements lariov::ChannelStatusProvider.

Definition at line 71 of file SimpleChannelStatus.cpp.

71  {
72 
74  return *fGoodChannels;
75 
76  } // SimpleChannelStatus::GoodChannels()
std::unique_ptr< ChannelSet_t > fGoodChannels
cached set of good channels (lazy evaluation)
void FillGoodChannels() const
Fills the collection of good channels.
virtual bool lariov::SimpleChannelStatus::IsBad ( raw::ChannelID_t  channel) const
inlineoverridevirtual

Returns whether the specified channel is bad in the current run.

Implements lariov::ChannelStatusProvider.

Definition at line 70 of file SimpleChannelStatus.h.

71  { return fBadChannels.count(channel) > 0; }
uint8_t channel
Definition: CRTFragment.hh:201
ChannelSet_t fBadChannels
set of bad channels
virtual bool lariov::SimpleChannelStatus::IsGood ( raw::ChannelID_t  channel) const
inlineoverridevirtual

Returns whether the specified channel is physical and good.

Reimplemented from lariov::ChannelStatusProvider.

Definition at line 66 of file SimpleChannelStatus.h.

67  { return IsPresent(channel) && !IsBad(channel) && !IsNoisy(channel); }
virtual bool IsBad(raw::ChannelID_t channel) const override
Returns whether the specified channel is bad in the current run.
uint8_t channel
Definition: CRTFragment.hh:201
virtual bool IsPresent(raw::ChannelID_t channel) const override
Returns whether the specified channel is physical and connected to wire.
virtual bool IsNoisy(raw::ChannelID_t channel) const override
Returns whether the specified channel is noisy in the current run.
virtual bool lariov::SimpleChannelStatus::IsNoisy ( raw::ChannelID_t  channel) const
inlineoverridevirtual

Returns whether the specified channel is noisy in the current run.

Implements lariov::ChannelStatusProvider.

Definition at line 74 of file SimpleChannelStatus.h.

75  { return fNoisyChannels.count(channel) > 0; }
ChannelSet_t fNoisyChannels
set of noisy channels
uint8_t channel
Definition: CRTFragment.hh:201
bool lariov::SimpleChannelStatus::IsPresent ( raw::ChannelID_t  channel) const
overridevirtual

Returns whether the specified channel is physical and connected to wire.

Implements lariov::ChannelStatusProvider.

Definition at line 63 of file SimpleChannelStatus.cpp.

63  {
66  : true;
67  } // SimpleChannelStatus::isPresent()
uint8_t channel
Definition: CRTFragment.hh:201
raw::ChannelID_t fMaxPresentChannel
largest ID among present channels
constexpr bool isValidChannelID(raw::ChannelID_t channel)
Definition: RawTypes.h:37
raw::ChannelID_t lariov::SimpleChannelStatus::MaxChannel ( ) const
inline

Returns the ID of the largest known channel.

Definition at line 99 of file SimpleChannelStatus.h.

99 { return fMaxChannel; }
raw::ChannelID_t fMaxChannel
largest ID among existing channels
raw::ChannelID_t lariov::SimpleChannelStatus::MaxChannelPresent ( ) const
inline

Returns the ID of the largest present channel.

Definition at line 102 of file SimpleChannelStatus.h.

102 { return fMaxPresentChannel; }
raw::ChannelID_t fMaxPresentChannel
largest ID among present channels
virtual ChannelSet_t lariov::SimpleChannelStatus::NoisyChannels ( ) const
inlineoverridevirtual

Returns a copy of set of noisy channel IDs for the current run.

Implements lariov::ChannelStatusProvider.

Definition at line 89 of file SimpleChannelStatus.h.

90  { return fNoisyChannels; }
ChannelSet_t fNoisyChannels
set of noisy channels
void lariov::SimpleChannelStatus::Setup ( raw::ChannelID_t  MaxChannel,
raw::ChannelID_t  MaxGoodChannel 
)

Sets the service provider up.

Parameters
MaxChannelID of the last channel
MaxGoodChannelID of the last good channel

Sets the largest ID of a physically present channel. All valid IDs smaller than this one are also considered present. If MaxGoodChannel is invalid, all channels are considered present.

Definition at line 50 of file SimpleChannelStatus.cpp.

51  {
52 
54  fMaxPresentChannel = MaxGoodChannel;
55 
56  // clear the caches, if any
57  fGoodChannels.reset();
58 
59  } // SimpleChannelStatus::Setup()
std::unique_ptr< ChannelSet_t > fGoodChannels
cached set of good channels (lazy evaluation)
raw::ChannelID_t MaxChannel() const
Returns the ID of the largest known channel.
raw::ChannelID_t fMaxPresentChannel
largest ID among present channels
raw::ChannelID_t fMaxChannel
largest ID among existing channels
void lariov::SimpleChannelStatus::Setup ( raw::ChannelID_t  MaxChannel)
inline

Sets the service provider up.

Parameters
MaxChannelID of the last channel

As Setup(raw::ChannelID_t, raw::ChannelID_t), but assumes all channels to be present.

Definition at line 127 of file SimpleChannelStatus.h.

void Setup(raw::ChannelID_t MaxChannel, raw::ChannelID_t MaxGoodChannel)
Sets the service provider up.
raw::ChannelID_t MaxChannel() const
Returns the ID of the largest known channel.

Member Data Documentation

ChannelSet_t lariov::SimpleChannelStatus::fBadChannels
protected

set of bad channels

Definition at line 139 of file SimpleChannelStatus.h.

std::unique_ptr<ChannelSet_t> lariov::SimpleChannelStatus::fGoodChannels
mutableprotected

cached set of good channels (lazy evaluation)

Definition at line 146 of file SimpleChannelStatus.h.

raw::ChannelID_t lariov::SimpleChannelStatus::fMaxChannel
protected

largest ID among existing channels

Definition at line 142 of file SimpleChannelStatus.h.

raw::ChannelID_t lariov::SimpleChannelStatus::fMaxPresentChannel
protected

largest ID among present channels

Definition at line 143 of file SimpleChannelStatus.h.

ChannelSet_t lariov::SimpleChannelStatus::fNoisyChannels
protected

set of noisy channels

Definition at line 140 of file SimpleChannelStatus.h.


The documentation for this class was generated from the following files: