All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PMTconfiguration.h
Go to the documentation of this file.
1 /**
2  * @file sbnobj/Common/PMT/Data/PMTconfiguration.h
3  * @brief Information from the configuration of PMT readout.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date February 18, 2021
6  * @see sbnobj/Common/PMT/Data/PMTconfiguration.cxx
7  */
8 
9 #ifndef SBNOBJ_COMMON_PMT_DATA_PMTCONFIGURATION_H
10 #define SBNOBJ_COMMON_PMT_DATA_PMTCONFIGURATION_H
11 
12 // SBN libraries
14 
15 // C/C++ standard libraries
16 #include <iosfwd> // std::ostream
17 #include <string>
18 #include <vector>
19 
20 
21 //------------------------------------------------------------------------------
22 namespace sbn {
23 
24  struct PMTconfiguration;
25 
26  /// Prints the configuration into a stream with default verbosity.
27  std::ostream& operator<<
28  (std::ostream& out, sbn::PMTconfiguration const& config);
29 
30 } // namespace sbn
31 
32 /**
33  * @brief Class containing configuration for PMT readout.
34  *
35  * This is an informative class containing configuration of all V1730 boards
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  // --- BEGIN -- Data members -------------------------------------------------
48 
49  // NOTE when adding data members, remember to add an element to the comparison
50 
51  /// Configuration of all PMT readout boards.
52  std::vector<sbn::V1730Configuration> boards;
53 
54  // --- END ---- Data members -------------------------------------------------
55 
56 #if __cplusplus < 202004L
57  //@{
58  /// Comparison: all fields need to have the same values.
59  bool operator== (PMTconfiguration const& other) const;
60  bool operator!= (PMTconfiguration const& other) const
61  { return ! this->operator== (other); }
62  //@}
63 #else
64 # error "With C++20 support, enable the default comparison operators"
65  // probably the compiler will be generating these anyway, so don't bother
66 // bool operator== (PMTconfiguration const& other) const = default;
67 // bool operator!= (PMTconfiguration const& other) const = default;
68 #endif
69 
70  // -- BEGIN -- Dump facility -------------------------------------------------
71  /// Maximum supported verbosity level supported by `dump()`.
72  static constexpr unsigned int MaxDumpVerbosity
74 
75  /// Default verbosity level for `dump()`.
76  static constexpr unsigned int DefaultDumpVerbosity = MaxDumpVerbosity;
77 
78 
79  /**
80  * @brief Dumps the content of the configuration into `out` stream.
81  * @param out stream to dump the information into
82  * @param indent indentation string
83  * @param firstIndent special indentation string for the first line
84  * @param verbosity (default: `DefaultDumpVerbosity`) level of verbosity
85  *
86  * The indentation string is prepended to each new line of the dump.
87  * The first line indentation string is prepended before the first line of
88  * the dump. The dump ends on a new empty line.
89  *
90  * The amount of information printed depends on the `verbosity` level:
91  *
92  * * `0`: only the number of boards in the configuration
93  * * `1`: information on each board, as in `V1730Configuration::dump()` with
94  * verbosity one level smaller than the value of `verbosity` argument
95  *
96  */
97  void dump(std::ostream& out,
98  std::string const& indent, std::string const& firstIndent,
99  unsigned int verbosity = MaxDumpVerbosity
100  ) const;
101 
102  /**
103  * @brief Dumps the content of the configuration into `out` stream.
104  * @param out stream to dump the information into
105  * @param indent indentation level
106  * @see `dump(std::ostream&, std::string const&, std::string const&, unsigned int) const`
107  *
108  * Version of `dump()` with same first indentation level as the rest, and
109  * default verbosity.
110  */
111  void dump(std::ostream& out, std::string const& indent = "") const
112  { dump(out, indent, indent); }
113 
114  /**
115  * @brief Dumps the content of the configuration into `out` stream.
116  * @param out stream to dump the information into
117  * @param indent (default: none) indentation string
118  * @see `dump(std::ostream&, std::string const&, std::string const&, unsigned int) const`
119  *
120  * Version of `dump()` with the specified `verbosity` level and same first
121  * indentation level as the rest.
122  */
123  void dump(std::ostream& out,
124  unsigned int verbosity,
125  std::string const& indent = ""
126  ) const
127  { dump(out, indent, indent, verbosity); }
128 
129  // -- END ---- Dump facility -------------------------------------------------
130 
131 }; // sbn::PMTconfiguration
132 
133 
134 
135 //------------------------------------------------------------------------------
136 //--- Inline implementation
137 //------------------------------------------------------------------------------
138 inline bool sbn::PMTconfiguration::operator==
139  (sbn::PMTconfiguration const& other) const
140 {
141 
142  if (boards != other.boards) return false;
143 
144  return true;
145 } // sbn::PMTconfiguration::operator==()
146 
147 
148 //------------------------------------------------------------------------------
149 inline std::ostream& sbn::operator<<
150  (std::ostream& out, sbn::PMTconfiguration const& config)
151  { config.dump(out); return out; }
152 
153 
154 //------------------------------------------------------------------------------
155 
156 #endif // SBNOBJ_COMMON_PMT_DATA_PMTCONFIGURATION_H
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 MaxDumpVerbosity
Maximum supported verbosity level supported by dump().
Information from the configuration of a V1730 PMT readout board.
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.
void dump(std::ostream &out, std::string const &indent="") const
Dumps the content of the configuration into out stream.
static constexpr unsigned int DefaultDumpVerbosity
Default verbosity level for dump().
bool operator!=(PMTconfiguration const &other) const
static constexpr unsigned int MaxDumpVerbosity
Maximum supported verbosity level supported by dump().
bool operator==(PMTconfiguration const &other) const
Comparison: all fields need to have the same values.
Class containing configuration for PMT readout.
std::vector< sbn::V1730Configuration > boards
Configuration of all PMT readout boards.