LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PMTTrigger.h
Go to the documentation of this file.
1 
6 #ifndef optdata_PMTTrigger_h
7 #define optdata_PMTTrigger_h
8 
9 // LArSoft includes
11 
12 // C++ includes
13 #include <functional> // so we can redefine less<> below
14 #include <limits>
15 
16 namespace optdata {
17 
18  class PMTTrigger {
19  public:
20  // Simple constructor/destructor.
21  PMTTrigger(Optical_Category_t category = kUndefined, TimeSlice_t time = 0, Frame_t frame = 0)
22  : fm_category(category), fm_timeSlice(time), fm_frame(frame){};
23 
25 
26  // Here we have getters and setters for the time information.
27 
29 
30  // A time slice associated with the first bin in the channel
31  // data. For example, the first bin of the ADC channel may refer
32  // to clock value 8595824 (in some arbitrary units).
33  TimeSlice_t TimeSlice() const { return fm_timeSlice; }
35 
36  // The frame number associated with the first frame in the channel.
37  Frame_t Frame() const { return fm_frame; }
38  void SetFrame(Frame_t f) { fm_frame = f; }
39 
40  private:
41  Optical_Category_t fm_category; // A channel category from Types.h
42  TimeSlice_t fm_timeSlice; // The time of the first slice in the channel data
43  Frame_t fm_frame; // The frame number corresponding to the above time
44  };
45 
46  // In case we want to sort a collection of PMTTriggers (e.g.,
47  // std::set<PMTTrigger>), here's the definition of the less-than
48  // operator.
49  bool operator<(const PMTTrigger& lhs, const PMTTrigger& rhs)
50  {
51  // Sort by channel, frame number, and time associated with the first bin.
52  if (lhs.Frame() < rhs.Frame() && lhs.TimeSlice() < rhs.TimeSlice() &&
53  lhs.Category() < rhs.Category())
54  return true;
55  return false;
56  }
57 
58 } // namespace optdata
59 
60 // For no extra charge, include how to sort PMTTrigger*, just in
61 // case we want (for example) a std::set<PMTTrigger*>.
62 namespace std {
63  template <>
64  class less<optdata::PMTTrigger*> {
65  public:
66  bool operator()(const optdata::PMTTrigger* lhs, const optdata::PMTTrigger* rhs)
67  {
68  return (*lhs) < (*rhs);
69  }
70  };
71 } // std
72 
73 #endif // optdata_PMTTrigger_h
bool operator()(const optdata::PMTTrigger *lhs, const optdata::PMTTrigger *rhs)
Definition: PMTTrigger.h:66
Optical_Category_t Category() const
Definition: PMTTrigger.h:28
PMTTrigger(Optical_Category_t category=kUndefined, TimeSlice_t time=0, Frame_t frame=0)
Definition: PMTTrigger.h:21
void SetTimeSlice(TimeSlice_t t)
Definition: PMTTrigger.h:34
enum optdata::_optical_category_t Optical_Category_t
STL namespace.
TFile f
Definition: plotHisto.C:6
void SetFrame(Frame_t f)
Definition: PMTTrigger.h:38
TimeSlice_t fm_timeSlice
Definition: PMTTrigger.h:42
Optical_Category_t fm_category
Definition: PMTTrigger.h:41
Frame_t Frame() const
Definition: PMTTrigger.h:37
unsigned int TimeSlice_t
Definition: OpticalTypes.h:20
unsigned int Frame_t
Definition: OpticalTypes.h:21
bool operator<(const ChannelData &lhs, const ChannelData &rhs)
Definition: ChannelData.h:45
TimeSlice_t TimeSlice() const
Definition: PMTTrigger.h:33