All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
V1730channelConfiguration.h
Go to the documentation of this file.
1 /**
2  * @file sbnobj/Common/PMT/Data/V1730channelConfiguration.h
3  * @brief Information from the configuration of a V1730 PMT readout board.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date February 18, 2021
6  * @see sbnobj/Common/PMT/Data/V1730channelConfiguration.cxx
7  */
8 
9 #ifndef SBNOBJ_COMMON_PMT_DATA_V1730CHANNELCONFIGURATION_H
10 #define SBNOBJ_COMMON_PMT_DATA_V1730CHANNELCONFIGURATION_H
11 
12 // LArSoft libraries
13 #include "lardataobj/RawData/OpDetWaveform.h" // raw::Channel_t
14 
15 // C/C++ standard libraries
16 #include <iosfwd> // std::ostream
17 #include <string>
18 #include <limits>
19 
20 
21 //------------------------------------------------------------------------------
22 namespace sbn {
23 
24  struct V1730channelConfiguration;
25 
26  /// Prints the configuration into a stream with default verbosity.
27  std::ostream& operator<<
28  (std::ostream& out, sbn::V1730channelConfiguration const& config);
29 
30 } // namespace sbn
31 
32 /**
33  * @brief Class containing configuration for a V1730 channel.
34  *
35  * This is an informative class containing configuration of a V1730 channel
36  * extracted from some other source (typically, DAQ) made readily available
37  * to the users.
38  *
39  * This class does not include any configuration extraction code.
40  *
41  * The class is default-constructible only, and its content needs to be added
42  * element by element.
43  *
44  */
46 
47  /// Special value for unassigned channel ID.
48  static constexpr auto NoChannelID
49  = std::numeric_limits<raw::Channel_t>::max();
50 
51  // --- BEGIN -- Data members -------------------------------------------------
52 
53  // NOTE when adding data members, remember to add an element to the comparison
54 
55  /// Number of the channel on the board (0-15).
56  short unsigned int channelNo = std::numeric_limits<short unsigned int>::max();
57 
58  /// Offline channel ID.
60 
61  /// Baseline (`BaselineCh<N+1>`).
62  short signed int baseline = 0;
63 
64  /// Threshold (`triggerThreshold<N>`).
65  short signed int threshold = 0;
66 
67  /// Channel is enabled (`enable`).
68  bool enabled = false;
69 
70  // --- END ---- Data members -------------------------------------------------
71 
72 
73  // --- BEGIN -- Derived quantities -------------------------------------------
74 
75  /// Returns whether the channel ID is set.
76  bool hasChannelID() const;
77 
78  /// Threshold relative to the baseline (ticks).
79  short signed int relativeThreshold() const;
80 
81  // --- END ---- Derived quantities -------------------------------------------
82 
83 
84 #if __cplusplus < 202004L
85  //@{
86  /// Comparison: all fields need to have the same values.
87  bool operator== (V1730channelConfiguration const& other) const;
88  bool operator!= (V1730channelConfiguration const& other) const
89  { return ! this->operator== (other); }
90  //@}
91 #else
92 # error "With C++20 support, enable the default comparison operators"
93  // probably the compiler will be generating these anyway, so don't bother
94 // bool operator== (V1730channelConfiguration const& other) const = default;
95 // bool operator!= (V1730channelConfiguration const& other) const = default;
96 #endif
97 
98  // -- BEGIN -- Dump facility -------------------------------------------------
99  /// Maximum supported verbosity level supported by `dump()`.
100  static constexpr unsigned int MaxDumpVerbosity = 1U;
101 
102  /// Default verbosity level for `dump()`.
103  static constexpr unsigned int DefaultDumpVerbosity = MaxDumpVerbosity;
104 
105 
106  /**
107  * @brief Dumps the content of the configuration into `out` stream.
108  * @param out stream to dump the information into
109  * @param indent indentation string
110  * @param firstIndent special indentation string for the first line
111  * @param verbosity (default: `DefaultDumpVerbosity`) level of verbosity
112  *
113  * The indentation string is prepended to each new line of the dump.
114  * The first line indentation string is prepended before the first line of
115  * the dump. The dump ends on a new empty line.
116  *
117  * The amount of information printed depends on the `verbosity` level:
118  *
119  * * `0`: channel number and whether it is enabled or not (also off-line
120  * channel ID if available)
121  * * `1`: also baseline and threshold
122  *
123  */
124  void dump(std::ostream& out,
125  std::string const& indent, std::string const& firstIndent,
126  unsigned int verbosity = MaxDumpVerbosity
127  ) const;
128 
129  /**
130  * @brief Dumps the content of the configuration into `out` stream.
131  * @param out stream to dump the information into
132  * @param indent indentation level
133  * @see `dump(std::ostream&, std::string const&, std::string const&, unsigned int) const`
134  *
135  * Version of `dump()` with same first indentation level as the rest, and
136  * default verbosity.
137  */
138  void dump(std::ostream& out, std::string const& indent = "") const
139  { dump(out, indent, indent); }
140 
141  /**
142  * @brief Dumps the content of the configuration into `out` stream.
143  * @param out stream to dump the information into
144  * @param indent (default: none) indentation string
145  * @see `dump(std::ostream&, std::string const&, std::string const&, unsigned int) const`
146  *
147  * Version of `dump()` with the specified `verbosity` level and same first
148  * indentation level as the rest.
149  */
150  void dump(std::ostream& out,
151  unsigned int verbosity,
152  std::string const& indent = ""
153  ) const
154  { dump(out, indent, indent, verbosity); }
155 
156  // -- END ---- Dump facility -------------------------------------------------
157 
158 }; // sbn::V1730channelConfiguration
159 
160 
161 
162 //------------------------------------------------------------------------------
163 //--- Inline implementation
164 //------------------------------------------------------------------------------
166  { return channelID != NoChannelID; }
167 
168 
169 //------------------------------------------------------------------------------
171  () const
172  { return baseline - threshold; }
173 
174 
175 //------------------------------------------------------------------------------
176 inline bool sbn::V1730channelConfiguration::operator==
177  (sbn::V1730channelConfiguration const& other) const
178 {
179  if (channelNo != other.channelNo) return false;
180  if (channelID != other.channelID) return false;
181  if (baseline != other.baseline ) return false;
182  if (threshold != other.threshold) return false;
183  if (enabled != other.enabled ) return false;
184 
185  return true;
186 } // sbn::V1730channelConfiguration::operator==()
187 
188 
189 //------------------------------------------------------------------------------
190 inline std::ostream& sbn::operator<<
191  (std::ostream& out, sbn::V1730channelConfiguration const& config)
192  { config.dump(out); return out; }
193 
194 
195 //------------------------------------------------------------------------------
196 
197 #endif // SBNOBJ_COMMON_PMT_DATA_V1730CHANNELCONFIGURATION_H
short signed int threshold
Threshold (triggerThreshold&lt;N&gt;).
bool operator==(V1730channelConfiguration const &other) const
Comparison: all fields need to have the same values.
bool operator!=(V1730channelConfiguration const &other) const
void dump(std::ostream &out, unsigned int verbosity, std::string const &indent="") const
Dumps the content of the configuration into out stream.
static constexpr unsigned int DefaultDumpVerbosity
Default verbosity level for dump().
BEGIN_PROLOG baseline
short unsigned int channelNo
Number of the channel on the board (0-15).
void dump(std::ostream &out, std::string const &indent, std::string const &firstIndent, unsigned int verbosity=MaxDumpVerbosity) const
Dumps the content of the configuration into out stream.
short signed int relativeThreshold() const
Threshold relative to the baseline (ticks).
void dump(std::ostream &out, std::string const &indent="") const
Dumps the content of the configuration into out stream.
static constexpr unsigned int MaxDumpVerbosity
Maximum supported verbosity level supported by dump().
short signed int baseline
Baseline (BaselineCh&lt;N+1&gt;).
bool enabled
Channel is enabled (enable).
static constexpr auto NoChannelID
Special value for unassigned channel ID.
raw::Channel_t channelID
Offline channel ID.
bool hasChannelID() const
Returns whether the channel ID is set.
Class containing configuration for a V1730 channel.