SimpleChannelStatus.h
Go to the documentation of this file.
1 /**
2  * @file SimpleChannelStatus.h
3  * @brief Channel quality provider with information from configuration file
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date November 25th, 2014
6  * @see ChannelStatusService.h SimpleChannelStatus.cpp
7  */
8 
9 
10 #ifndef SIMPLECHANNELFILTER_H
11 #define SIMPLECHANNELFILTER_H 1
12 
13 // LArSoft libraries
14 #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t
16 
17 // Utility libraries
18 namespace fhicl { class ParameterSet; }
19 
20 // C/C++ standard library
21 #include <memory> // std::unique_ptr<>
22 
23 
24 namespace lariov {
25 
26 
27  /** **************************************************************************
28  * @brief Class providing information about the quality of channels
29  *
30  * This class serves information read from a FHiCL configuration file.
31  * Time-dependent (or, run-dependent) information is not supported.
32  *
33  * All and only the channels up to the one specified in the Setup() call (that
34  * one included) are considered present. If no valid ID is specified, all
35  * channels are supposed present.
36  *
37  * LArSoft interface to this class is through the service
38  * SimpleChannelStatusService.
39  *
40  * Configuration parameters
41  * =========================
42  *
43  * - *BadChannels* (list of integers, default: empty) list of ID of bad
44  * channels
45  * - *NoisyChannels* (list of integers, default: empty) list of ID of noisy
46  * channels
47  *
48  */
50  public:
52 
53  /// Configuration
54  explicit SimpleChannelStatus(fhicl::ParameterSet const& pset);
55 
56  //
57  // interface methods
58  //
59 
60  /// @name Single channel queries
61  /// @{
62  /// Returns whether the specified channel is physical and connected to wire
63  virtual bool IsPresent(raw::ChannelID_t channel) const override;
64 
65  /// Returns whether the specified channel is physical and good
66  virtual bool IsGood(raw::ChannelID_t channel) const override
67  { return IsPresent(channel) && !IsBad(channel) && !IsNoisy(channel); }
68 
69  /// Returns whether the specified channel is bad in the current run
70  virtual bool IsBad(raw::ChannelID_t channel) const override
71  { return fBadChannels.count(channel) > 0; }
72 
73  /// Returns whether the specified channel is noisy in the current run
74  virtual bool IsNoisy(raw::ChannelID_t channel) const override
75  { return fNoisyChannels.count(channel) > 0; }
76  /// @}
77 
78 
79  /// @name Global channel queries
80  /// @{
81  /// Returns a copy of set of good channel IDs for the current run
82  virtual ChannelSet_t GoodChannels() const override;
83 
84  /// Returns a copy of set of bad channel IDs for the current run
85  virtual ChannelSet_t BadChannels() const override
86  { return fBadChannels; }
87 
88  /// Returns a copy of set of noisy channel IDs for the current run
89  virtual ChannelSet_t NoisyChannels() const override
90  { return fNoisyChannels; }
91  /// @}
92 
93 
94  //
95  // non-interface methods and configuration methods
96  //
97 
98  /// Returns the ID of the largest known channel
99  raw::ChannelID_t MaxChannel() const { return fMaxChannel; }
100 
101  /// Returns the ID of the largest present channel
102  raw::ChannelID_t MaxChannelPresent() const { return fMaxPresentChannel; }
103 
104 
105 
106  /// @name Configuration functions
107  /// @{
108 
109  /**
110  * @brief Sets the service provider up
111  * @param MaxChannel ID of the last channel
112  * @param MaxGoodChannel ID of the last good channel
113  *
114  * Sets the largest ID of a physically present channel.
115  * All valid IDs smaller than this one are also considered present.
116  * If MaxGoodChannel is invalid, all channels are considered present.
117  */
118  void Setup(raw::ChannelID_t MaxChannel, raw::ChannelID_t MaxGoodChannel);
119 
120  /**
121  * @brief Sets the service provider up
122  * @param MaxChannel ID of the last channel
123  *
124  * As Setup(raw::ChannelID_t, raw::ChannelID_t), but assumes all channels
125  * to be present.
126  */
127  void Setup(raw::ChannelID_t MaxChannel) { Setup(MaxChannel, MaxChannel); }
128 
129  /* TODO DELME
130  /// Prepares the object to provide information about the specified time
131  /// @return always true
132  virtual bool Update(std::uint64_t) override { return true; }
133  */
134 
135  ///@}
136 
137  protected:
138 
139  ChannelSet_t fBadChannels; ///< set of bad channels
140  ChannelSet_t fNoisyChannels; ///< set of noisy channels
141 
142  raw::ChannelID_t fMaxChannel; ///< largest ID among existing channels
143  raw::ChannelID_t fMaxPresentChannel; ///< largest ID among present channels
144 
145  /// cached set of good channels (lazy evaluation)
146  mutable std::unique_ptr<ChannelSet_t> fGoodChannels;
147 
148  /// Fills the collection of good channels
149  void FillGoodChannels() const;
150 
151  }; // class SimpleChannelStatus
152 
153 
154 } // namespace lariov
155 
156 
157 #endif // SIMPLECHANNELFILTER_H
raw::ChannelID_t MaxChannelPresent() const
Returns the ID of the largest present channel.
ChannelSet_t fNoisyChannels
set of noisy channels
std::set< raw::ChannelID_t > ChannelSet_t
Type of set of channel IDs.
virtual bool IsBad(raw::ChannelID_t channel) const override
Returns whether the specified channel is bad in the current run.
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.
uint8_t channel
Definition: CRTFragment.hh:201
raw::ChannelID_t fMaxPresentChannel
largest ID among present channels
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.
Class providing information about the quality of channels.
Filters for channels, events, etc.
Interface for experiment-specific channel quality info provider.
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.
virtual bool IsNoisy(raw::ChannelID_t channel) const override
Returns whether the specified channel is noisy in the current run.
void Setup(raw::ChannelID_t MaxChannel)
Sets the service provider up.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
virtual bool IsGood(raw::ChannelID_t channel) const override
Returns whether the specified channel is physical and good.
raw::ChannelID_t fMaxChannel
largest ID among existing channels