LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
FIFOChannel.h
Go to the documentation of this file.
1 
6 #ifndef optdata_FIFOChannel_h
7 #define optdata_FIFOChannel_h
8 
9 // LArSoft includes
12 
13 // C++ includes
14 #include <functional> // so we can redefine less<> below
15 #include <limits>
16 #include <vector>
17 
18 namespace optdata {
19 
20  class FIFOChannel : public ChannelData {
21  public:
22  // Simple constructor/destructor.
24  TimeSlice_t time = 0,
25  Frame_t frame = 0,
26  Channel_t channel = std::numeric_limits<Channel_t>::max(),
27  size_type len = 0)
28  : ChannelData(channel, len), fm_category(category), fm_timeSlice(time), fm_frame(frame){};
29 
31 
32  // Here we have getters and setters for the time information.
33 
35 
36  // A time slice associated with the first bin in the channel
37  // data. For example, the first bin of the ADC channel may refer
38  // to clock value 8595824 (in some arbitrary units).
39  TimeSlice_t TimeSlice() const { return fm_timeSlice; }
41 
42  // The frame number associated with the first frame in the channel.
43  Frame_t Frame() const { return fm_frame; }
44  void SetFrame(Frame_t f) { fm_frame = f; }
45 
46  private:
47  Optical_Category_t fm_category; // A channel category from Types.h
48  TimeSlice_t fm_timeSlice; // The time of the first slice in the channel data
49  Frame_t fm_frame; // The frame number corresponding to the above time
50  };
51 
52  // In case we want to sort a collection of FIFOChannels (e.g.,
53  // std::set<FIFOChannel>), here's the definition of the less-than
54  // operator.
55  bool operator<(const FIFOChannel& lhs, const FIFOChannel& rhs)
56  {
57  // Sort by channel, frame number, and time associated with the first bin.
58  if (lhs.ChannelNumber() < rhs.ChannelNumber() && lhs.Frame() < rhs.Frame() &&
59  lhs.TimeSlice() < rhs.TimeSlice())
60  return true;
61  return false;
62  }
63 
64 } // namespace optdata
65 
66 // For no extra charge, include how to sort FIFOChannel*, just in
67 // case we want (for example) a std::set<FIFOChannel*>.
68 namespace std {
69  template <>
71  public:
73  {
74  return (*lhs) < (*rhs);
75  }
76  };
77 } // std
78 
79 #endif // optdata_FIFOChannel_h
Frame_t Frame() const
Definition: FIFOChannel.h:43
enum optdata::_optical_category_t Optical_Category_t
STL namespace.
TimeSlice_t TimeSlice() const
Definition: FIFOChannel.h:39
TFile f
Definition: plotHisto.C:6
Optical_Category_t fm_category
Definition: FIFOChannel.h:47
Channel_t ChannelNumber() const
Definition: ChannelData.h:36
void SetFrame(Frame_t f)
Definition: FIFOChannel.h:44
unsigned int TimeSlice_t
Definition: OpticalTypes.h:20
unsigned int Frame_t
Definition: OpticalTypes.h:21
bool operator()(const optdata::FIFOChannel *lhs, const optdata::FIFOChannel *rhs)
Definition: FIFOChannel.h:72
FIFOChannel(Optical_Category_t category=kUndefined, TimeSlice_t time=0, Frame_t frame=0, Channel_t channel=std::numeric_limits< Channel_t >::max(), size_type len=0)
Definition: FIFOChannel.h:23
void SetTimeSlice(TimeSlice_t t)
Definition: FIFOChannel.h:40
unsigned int Channel_t
Definition: OpticalTypes.h:19
bool operator<(const ChannelData &lhs, const ChannelData &rhs)
Definition: ChannelData.h:45
Optical_Category_t Category() const
Definition: FIFOChannel.h:34
TimeSlice_t fm_timeSlice
Definition: FIFOChannel.h:48