All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SingleChannelOpticalTriggerGate.h
Go to the documentation of this file.
1 /**
2  * @file sbnobj/ICARUS/PMT/Trigger/Data/SingleChannelOpticalTriggerGate.h
3  * @brief Logical multi-level gate associated to a optical detector channel.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date April 1, 2019
6  * @see `sbnobj/ICARUS/PMT/Trigger/Data/SingleChannelOpticalTriggerGate.cxx`
7  *
8  */
9 
10 #ifndef SBNOBJ_ICARUS_PMT_TRIGGER_DATA_SINGLECHANNELOPTICALTRIGGERGATE_H
11 #define SBNOBJ_ICARUS_PMT_TRIGGER_DATA_SINGLECHANNELOPTICALTRIGGERGATE_H
12 
13 
14 // ICARUS libraries
16 
17 // LArSoft libraries
19 
20 // C/C++ standard libraries
21 #include <iosfwd> // std::ostream
22 
23 
24 //------------------------------------------------------------------------------
25 // TODO move this into `lardataobj/RawData/OpDetWaveform.h`
26 namespace raw {
27 
28  /// Mnemonics for an invalid channel number.
29  constexpr Channel_t InvalidChannel = std::numeric_limits<Channel_t>::max();
30 
31  /// Returns whether the specified one is a valid `channel` number.
32  constexpr bool isValidChannel(Channel_t channel)
33  { return channel != InvalidChannel; }
34 
35 } // namespace raw
36 
37 
38 //------------------------------------------------------------------------------
39 namespace icarus::trigger { class SingleChannelOpticalTriggerGate; }
40 /**
41  * @brief Logical multi-level gate associated to a optical detector channel.
42  *
43  * This object is a trigger gate associated with one readout channel.
44  */
47 {
48  //
49  // NOTE while there is some infrastructure allowing for the presence of more
50  // than one waveform, this class is designed with a single channel in
51  // mind.
52  //
53 
55 
56  public:
57 
58  /// Constructor: a closed gate for the channel in `waveform`.
60  : Base_t(waveform)
61  {}
62 
63  /// Constructor: a closed gate for the specified channel.
65 
67  (SingleChannelOpticalTriggerGate const&) = default;
69  (SingleChannelOpticalTriggerGate&&) = default;
71  (SingleChannelOpticalTriggerGate const&) = default;
73  (SingleChannelOpticalTriggerGate&&) = default;
74 
75  /// Adds another waveform to the channel (unless it has just been added).
76  bool add(raw::OpDetWaveform const& waveform);
77 
78  //@{
79  /// Copies/steals all the levels from the specified data.
81  { Base_t::operator=(data); return *this; }
83  { Base_t::operator=(std::move(data)); return *this; }
84  //@}
85 
86 
87  /// Do not support multi-channel interface.
88  decltype(auto) channels() const = delete;
89 
90  /// Comparison operator: sorts by increasing channel number.
92  { return channel() < other.channel(); }
93 
94  private:
95 
96  /// Returns the "reference" waveform, used when a single waveform is needed.
97  bool hasRefWaveform() const { return !waveforms().empty(); }
98 
99  /// Returns the "reference" waveform, used when a single waveform is needed.
101  { return *(waveforms().front()); }
102 
103  /// Returns the "reference" waveform, used when a single waveform is needed.
105  { return hasRefWaveform()? nullptr: &(refWaveform()); }
106 
107 
108 }; // class icarus::trigger::SingleChannelOpticalTriggerGate
109 
110 
111 #endif // SBNOBJ_ICARUS_PMT_TRIGGER_DATA_SINGLECHANNELOPTICALTRIGGERGATE_H
std::vector< raw::OpDetWaveform const * > waveforms() const
ChannelID_t channel() const
Returns the channel associated to the gate data.
bool hasRefWaveform() const
Returns the &quot;reference&quot; waveform, used when a single waveform is needed.
constexpr bool isValidChannel(Channel_t channel)
Returns whether the specified one is a valid channel number.
SingleChannelOpticalTriggerGate(ChannelID_t channel)
Constructor: a closed gate for the specified channel.
bool add(raw::OpDetWaveform const &waveform)
Adds another waveform to the channel (unless it has just been added).
raw::OpDetWaveform const & refWaveform() const
Returns the &quot;reference&quot; waveform, used when a single waveform is needed.
SingleChannelOpticalTriggerGate(raw::OpDetWaveform const &waveform)
Constructor: a closed gate for the channel in waveform.
decltype(auto) channels() const =delete
Do not support multi-channel interface.
constexpr Channel_t InvalidChannel
Mnemonics for an invalid channel number.
Logical multi-level gate associated to one or more readout channels.
raw::OpDetWaveform const * refWaveformPtr() const
Returns the &quot;reference&quot; waveform, used when a single waveform is needed.
SingleChannelOpticalTriggerGate & operator=(SingleChannelOpticalTriggerGate const &)=default
A trigger gate data object for optical detector electronics.
OpticalTriggerGate & operator=(OpticalTriggerGate const &)=default
Logical multi-level gate associated to one or more waveforms.
GateData_t::ChannelID_t ChannelID_t
Type of channel identifier.
Logical multi-level gate.
friend std::ostream & operator(std::ostream &, triggergatedata_t const &)
Logical multi-level gate associated to a optical detector channel.