ChannelData.h
Go to the documentation of this file.
1 // OpticalDetectorData/ChannelData.h
2 // William Seligman <seligman@nevis.columbia.edu>
3 
4 // The ADC counts associated with a particular channel.
5 
6 #ifndef OpticalDetectorData_ChannelData_h
7 #define OpticalDetectorData_ChannelData_h
8 
9 // LArSoft includes
11 
12 // C++ includes
13 #include <vector>
14 #include <functional> // so we can redefine less<> below
15 #include <limits>
16 
17 namespace optdata {
18 
19  class ChannelData : public std::vector< ADC_Count_t >
20  {
21  public:
22 
23  // Simple constructors/destructors.
24  // Just in case the user forgets to supply the default channel, use
25  // a garbage value to indicate that there's a problem.
26  // To save on memory reallocations, offer an option to specify the
27  // the initial memory allocation of the channel vector.
29  size_type len = 0 )
30  : fm_optDetChannel(chan)
31  {
32  this->reserve(len);
33  };
34 
36 
37  // No "setter" for the channel number; you have to assign it when
38  // you create a ChannelData object.
40 
41 
42  private:
43  unsigned int fm_optDetChannel;
44  };
45 
46  // In case we want to sort a collection of ChannelDatas (e.g.,
47  // std::set<ChannelData>), here's the definition of the less-than
48  // operator.
49  bool operator<( const ChannelData& lhs, const ChannelData& rhs )
50  {
51  // Sort by channel.
52  if ( lhs.ChannelNumber() < rhs.ChannelNumber() )
53  return true;
54  return false;
55  }
56 
57 } // namespace optdata
58 
59 // For no extra charge, include how to sort ChannelData*, just in
60 // case we want (for example) a std::set<ChannelData*>.
61 namespace std {
62  template <>
64  {
65  public:
66  bool operator()( const optdata::ChannelData* lhs, const optdata::ChannelData* rhs )
67  {
68  return (*lhs) < (*rhs);
69  }
70  };
71 } // std
72 
73 #endif // OpticalDetectorData_ChannelData_h
struct vector vector
STL namespace.
ChannelData(Channel_t chan=std::numeric_limits< Channel_t >::max(), size_type len=0)
Definition: ChannelData.h:28
bool operator()(const optdata::ChannelData *lhs, const optdata::ChannelData *rhs)
Definition: ChannelData.h:66
unsigned int fm_optDetChannel
Definition: ChannelData.h:43
static int max(int a, int b)
Channel_t ChannelNumber() const
Definition: ChannelData.h:39
unsigned int Channel_t
Definition: OpticalTypes.h:19
bool operator<(const ChannelData &lhs, const ChannelData &rhs)
Definition: ChannelData.h:49