All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FIFOChannel.h
Go to the documentation of this file.
1 /// FIFOChannel.h
2 /// William Seligman <seligman@nevis.columbia.edu>
3 ///
4 /// The information associated with a given FEM channel as stored in its FIFO memory.
5 
6 #ifndef optdata_FIFOChannel_h
7 #define optdata_FIFOChannel_h
8 
9 // LArSoft includes
12 
13 // C++ includes
14 #include <vector>
15 #include <functional> // so we can redefine less<> below
16 #include <limits>
17 
18 namespace optdata {
19 
20  class FIFOChannel : public ChannelData
21  {
22  public:
23 
24  // Simple constructor/destructor.
26  TimeSlice_t time = 0,
27  Frame_t frame = 0,
28  Channel_t channel = std::numeric_limits<Channel_t>::max(),
29  size_type len = 0 )
30  : ChannelData(channel,len)
31  , fm_category(category)
32  , fm_timeSlice(time)
33  , fm_frame(frame)
34  {};
35 
37 
38  // Here we have getters and setters for the time information.
39 
40 
42 
43  // A time slice associated with the first bin in the channel
44  // data. For example, the first bin of the ADC channel may refer
45  // to clock value 8595824 (in some arbitrary units).
46  TimeSlice_t TimeSlice() const { return fm_timeSlice; }
48 
49  // The frame number associated with the first frame in the channel.
50  Frame_t Frame() const { return fm_frame; }
51  void SetFrame( Frame_t f ) { fm_frame = f; }
52 
53 
54  private:
55  Optical_Category_t fm_category; // A channel category from Types.h
56  TimeSlice_t fm_timeSlice; // The time of the first slice in the channel data
57  Frame_t fm_frame; // The frame number corresponding to the above time
58  };
59 
60  // In case we want to sort a collection of FIFOChannels (e.g.,
61  // std::set<FIFOChannel>), here's the definition of the less-than
62  // operator.
63  bool operator<( const FIFOChannel& lhs, const FIFOChannel& rhs )
64  {
65  // Sort by channel, frame number, and time associated with the first bin.
66  if ( lhs.ChannelNumber() < rhs.ChannelNumber() &&
67  lhs.Frame() < rhs.Frame() &&
68  lhs.TimeSlice() < rhs.TimeSlice() )
69  return true;
70  return false;
71  }
72 
73 } // namespace optdata
74 
75 // For no extra charge, include how to sort FIFOChannel*, just in
76 // case we want (for example) a std::set<FIFOChannel*>.
77 namespace std {
78  template <>
79  class less<optdata::FIFOChannel*>
80  {
81  public:
82  bool operator()( const optdata::FIFOChannel* lhs, const optdata::FIFOChannel* rhs )
83  {
84  return (*lhs) < (*rhs);
85  }
86  };
87 } // std
88 
89 #endif // optdata_FIFOChannel_h
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
Frame_t Frame() const
Definition: FIFOChannel.h:50
enum optdata::_optical_category_t Optical_Category_t
TimeSlice_t TimeSlice() const
Definition: FIFOChannel.h:46
Optical_Category_t fm_category
Definition: FIFOChannel.h:55
Channel_t ChannelNumber() const
Definition: ChannelData.h:39
void SetFrame(Frame_t f)
Definition: FIFOChannel.h:51
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:82
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:25
void SetTimeSlice(TimeSlice_t t)
Definition: FIFOChannel.h:47
unsigned int Channel_t
Definition: OpticalTypes.h:19
bool operator<(const ChannelData &lhs, const ChannelData &rhs)
Definition: ChannelData.h:49
Optical_Category_t Category() const
Definition: FIFOChannel.h:41
TimeSlice_t fm_timeSlice
Definition: FIFOChannel.h:56