All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lardataobj/lardataobj/RawData/OpDetWaveform.h
Go to the documentation of this file.
1 /**
2  * @file lardataobj/RawData/OpDetWaveform.h
3  *
4  * Raw signals from the photon detectors.
5  * Waveform (adcs in time bins), a channel number, and a time stamp.
6  *
7  */
8 
9 
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 
17 
18 namespace raw {
19 
20  // Define the types used
21  typedef short ADC_Count_t;
22  typedef unsigned int Channel_t;
23  typedef double TimeStamp_t; ///< us since 1970, based on TimeService
24 
25  class OpDetWaveform : public std::vector< ADC_Count_t >
26  {
27  private:
29  TimeStamp_t fTimeStamp; ///< On @ref DetectorClocksElectronicsTime "electronics time scale".
30 
31 
32  public:
33  // Simple constructors/destructors.
34  // Just in case the user forgets to supply the default channel, use
35  // a garbage value to indicate that there's a problem.
36  // To save on memory reallocations, offer an option to specify the
37  // the initial memory allocation of the channel vector.
38  OpDetWaveform( TimeStamp_t time = std::numeric_limits<TimeStamp_t>::max(),
39  Channel_t chan = std::numeric_limits<Channel_t>::max(),
40  size_type len = 0 )
41  : fChannel(chan)
42  , fTimeStamp(time)
43  {
44  this->reserve(len);
45  };
46 
47 
49  Channel_t chan,
50  std::vector< uint16_t > const& rhs )
51  : std::vector< ADC_Count_t >(rhs.begin(), rhs.end())
52  , fChannel(chan)
53  , fTimeStamp(time)
54  {
55  };
56 
57 
58  // Functions included for backwards compatability with previous data types
59  std::vector<ADC_Count_t>& Waveform() { return *this; }
60 
61  // Functions included for backwards compatability with previous data types
62  std::vector<ADC_Count_t>const & Waveform() const { return *this; }
63 
64 
65  Channel_t ChannelNumber() const { return fChannel; }
66  TimeStamp_t TimeStamp() const { return fTimeStamp; }
67  void SetChannelNumber(Channel_t chan) { fChannel = chan; }
68  void SetTimeStamp(TimeStamp_t time) { fTimeStamp = time; }
69 
70  };
71 }
72 
73 
74 
75 
76 namespace raw {
77  inline bool operator<( const OpDetWaveform& lhs, const OpDetWaveform& rhs )
78  {
79  // Sort by channel, then time
80  if ( lhs.ChannelNumber() < rhs.ChannelNumber() ) return true;
81  if ( lhs.ChannelNumber() > rhs.ChannelNumber() ) return false;
82 
83  return ( lhs.TimeStamp() < rhs.TimeStamp() );
84  }
85 } // namespace raw
86 
87 
88 // For no extra charge, include how to sort ChannelData*, just in
89 // case we want (for example) a std::set<ChannelData*>.
90 namespace std {
91  template <>
92  class less<raw::OpDetWaveform*>
93  {
94  public:
95  bool operator()( const raw::OpDetWaveform* lhs, const raw::OpDetWaveform* rhs )
96  {
97  return (*lhs) < (*rhs);
98  }
99  };
100 }
101 
102 
103 #endif
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
bool operator<(const OpDetWaveform &lhs, const OpDetWaveform &rhs)
double TimeStamp_t
us since 1970, based on TimeService
std::vector< ADC_Count_t > & Waveform()
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
OpDetWaveform(TimeStamp_t time, Channel_t chan, std::vector< uint16_t > const &rhs)
std::vector< ADC_Count_t > const & Waveform() const
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
OpDetWaveform(TimeStamp_t time=std::numeric_limits< TimeStamp_t >::max(), Channel_t chan=std::numeric_limits< Channel_t >::max(), size_type len=0)
TimeStamp_t fTimeStamp
On electronics time scale.
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
bool operator()(const raw::OpDetWaveform *lhs, const raw::OpDetWaveform *rhs)