LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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 <functional> // so we can redefine less<> below
14 #include <limits>
15 #include <vector>
16 
17 namespace optdata {
18 
19  class ChannelData : public std::vector<ADC_Count_t> {
20  public:
21  // Simple constructors/destructors.
22  // Just in case the user forgets to supply the default channel, use
23  // a garbage value to indicate that there's a problem.
24  // To save on memory reallocations, offer an option to specify the
25  // the initial memory allocation of the channel vector.
26  ChannelData(Channel_t chan = std::numeric_limits<Channel_t>::max(), size_type len = 0)
27  : fm_optDetChannel(chan)
28  {
29  this->reserve(len);
30  };
31 
33 
34  // No "setter" for the channel number; you have to assign it when
35  // you create a ChannelData object.
37 
38  private:
39  unsigned int fm_optDetChannel;
40  };
41 
42  // In case we want to sort a collection of ChannelDatas (e.g.,
43  // std::set<ChannelData>), here's the definition of the less-than
44  // operator.
45  bool operator<(const ChannelData& lhs, const ChannelData& rhs)
46  {
47  // Sort by channel.
48  if (lhs.ChannelNumber() < rhs.ChannelNumber()) return true;
49  return false;
50  }
51 
52 } // namespace optdata
53 
54 // For no extra charge, include how to sort ChannelData*, just in
55 // case we want (for example) a std::set<ChannelData*>.
56 namespace std {
57  template <>
59  public:
61  {
62  return (*lhs) < (*rhs);
63  }
64  };
65 } // std
66 
67 #endif // OpticalDetectorData_ChannelData_h
STL namespace.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
ChannelData(Channel_t chan=std::numeric_limits< Channel_t >::max(), size_type len=0)
Definition: ChannelData.h:26
bool operator()(const optdata::ChannelData *lhs, const optdata::ChannelData *rhs)
Definition: ChannelData.h:60
unsigned int fm_optDetChannel
Definition: ChannelData.h:39
Channel_t ChannelNumber() const
Definition: ChannelData.h:36
unsigned int Channel_t
Definition: OpticalTypes.h:19
bool operator<(const ChannelData &lhs, const ChannelData &rhs)
Definition: ChannelData.h:45