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:
28  Channel_t fChannel;
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.
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 
48  OpDetWaveform( TimeStamp_t time,
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 ( rhs.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 <>
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
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
Channel_t ChannelNumber() const
Definition: OpDetWaveform.h:65
TimeStamp_t TimeStamp() const
Definition: OpDetWaveform.h:66
bool operator<(const OpDetWaveform &lhs, const OpDetWaveform &rhs)
Definition: OpDetWaveform.h:77
struct vector vector
STL namespace.
double TimeStamp_t
us since 1970, based on TimeService
Definition: OpDetWaveform.h:23
Raw data description.
std::vector< ADC_Count_t > & Waveform()
Definition: OpDetWaveform.h:59
void SetTimeStamp(TimeStamp_t time)
Definition: OpDetWaveform.h:68
OpDetWaveform(TimeStamp_t time, Channel_t chan, std::vector< uint16_t > const &rhs)
Definition: OpDetWaveform.h:48
std::vector< ADC_Count_t > const & Waveform() const
Definition: OpDetWaveform.h:62
void SetChannelNumber(Channel_t chan)
Definition: OpDetWaveform.h:67
static int max(int a, int b)
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:38
TimeStamp_t fTimeStamp
On electronics time scale.
Definition: OpDetWaveform.h:29
bool operator()(const raw::OpDetWaveform *lhs, const raw::OpDetWaveform *rhs)
Definition: OpDetWaveform.h:95
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
short ADC_Count_t
Definition: OpDetWaveform.h:21
unsigned int Channel_t
Definition: OpDetWaveform.h:22