LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
OpDetWaveform.h
Go to the documentation of this file.
1 
10 #ifndef OpDetWaveform_h
11 #define OpDetWaveform_h
12 
13 #include <vector>
14 #include <functional> // so we can redefine less<> below
15 #include <limits>
16 #include <iosfwd>
17 
18 
19 namespace raw {
20 
21  // Define the types used
22  typedef short ADC_Count_t;
23  typedef unsigned int Channel_t;
24  typedef double TimeStamp_t;
25 
26  class OpDetWaveform : public std::vector< ADC_Count_t >
27  {
28  private:
29  Channel_t fChannel;
30  TimeStamp_t fTimeStamp;
31 
32 
33  public:
34  // Simple constructors/destructors.
35  // Just in case the user forgets to supply the default channel, use
36  // a garbage value to indicate that there's a problem.
37  // To save on memory reallocations, offer an option to specify the
38  // the initial memory allocation of the channel vector.
40  Channel_t chan = std::numeric_limits<Channel_t>::max(),
41  size_type len = 0 )
42  : fChannel(chan)
43  , fTimeStamp(time)
44  {
45  this->reserve(len);
46  };
47 
48 
49  OpDetWaveform( TimeStamp_t time,
50  Channel_t chan,
51  std::vector< uint16_t > rhs )
52  : fChannel(chan)
53  , fTimeStamp(time)
54  {
55  this->reserve(rhs.size());
56  for (unsigned int i =0; i < rhs.size(); i++)
57  this->push_back(rhs[i]);
58  };
59 
60 
62 
63  // Functions included for backwards compatability with previous data types
64  std::vector<ADC_Count_t>& Waveform() { return *this; }
65 
66 
67  static_assert(sizeof(unsigned long long)==8,"unsigned long long is not 8 bytes");
68 
69  // The sections bracketed with GCCXML tests handle a problem ART
70  // with generating its data dictionaries.
71 
72  Channel_t ChannelNumber() const { return fChannel; }
73  TimeStamp_t TimeStamp() const { return fTimeStamp; }
74  void SetChannelNumber(Channel_t chan) { fChannel = chan; }
75  void SetTimeStamp(TimeStamp_t time) { fTimeStamp = time; }
76 
77  };
78 }
79 
80 
81 
82 
83 namespace raw {
84  inline bool operator<( const OpDetWaveform& lhs, const OpDetWaveform& rhs )
85  {
86  // Sort by channel, then time
87  if ( lhs.ChannelNumber() < rhs.ChannelNumber() ) return true;
88  if ( rhs.ChannelNumber() > rhs.ChannelNumber() ) return false;
89 
90  return ( lhs.TimeStamp() < rhs.TimeStamp() );
91  }
92 } // namespace raw
93 
94 
95 // For no extra charge, include how to sort ChannelData*, just in
96 // case we want (for example) a std::set<ChannelData*>.
97 namespace std {
98  template <>
100  {
101  public:
102  bool operator()( const raw::OpDetWaveform* lhs, const raw::OpDetWaveform* rhs )
103  {
104  return (*lhs) < (*rhs);
105  }
106  };
107 }
108 
109 
110 #endif
Channel_t ChannelNumber() const
Definition: OpDetWaveform.h:72
TimeStamp_t TimeStamp() const
Definition: OpDetWaveform.h:73
bool operator<(const OpDetWaveform &lhs, const OpDetWaveform &rhs)
Definition: OpDetWaveform.h:84
STL namespace.
double TimeStamp_t
us since 1970, based on TimeService
Definition: OpDetWaveform.h:24
Raw data description.
Definition: RawTypes.h:6
std::vector< ADC_Count_t > & Waveform()
Definition: OpDetWaveform.h:64
void SetTimeStamp(TimeStamp_t time)
Definition: OpDetWaveform.h:75
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
Int_t max
Definition: plot.C:27
void SetChannelNumber(Channel_t chan)
Definition: OpDetWaveform.h:74
OpDetWaveform(TimeStamp_t time=std::numeric_limits< TimeStamp_t >::max(), Channel_t chan=std::numeric_limits< Channel_t >::max(), size_type len=0)
Definition: OpDetWaveform.h:39
TimeStamp_t fTimeStamp
Definition: OpDetWaveform.h:30
bool operator()(const raw::OpDetWaveform *lhs, const raw::OpDetWaveform *rhs)
OpDetWaveform(TimeStamp_t time, Channel_t chan, std::vector< uint16_t > rhs)
Definition: OpDetWaveform.h:49
short ADC_Count_t
Definition: OpDetWaveform.h:22
unsigned int Channel_t
Definition: OpDetWaveform.h:23