CompareDAQHit.h
Go to the documentation of this file.
1 #ifndef DDT_COMPARE_DAQHIT_H
2 #define DDT_COMPARE_DAQHIT_H
3 
4 
6 
7 
8 // This file contains the various structs that can be used to compare
9 // two DAQHit objects.
10 
11 
12 namespace novaddt
13 {
14  //
15  // General Template
16  //
17  template<class T> struct CompareDAQHit;
18 
19  //
20  // Specializations of the General Template
21  //
22  // 1. Compare DAQ Hits based on their ADC value:
23  template<> struct CompareDAQHit<ADC>
24  {
25  bool operator() (DAQHit const & lhs, DAQHit const & rhs) const
26  { return lhs.ADC() < rhs.ADC(); }
27 
28  bool operator() (DAQHit const & lhs, ADC const & rhs) const
29  { return lhs.ADC() < rhs; }
30  };
31 
32 
33  // 2. Compare DAQ Hits based on their TDC value:
34  template<> struct CompareDAQHit<TDC>
35  {
36  bool operator() (DAQHit const & lhs, DAQHit const & rhs) const
37  {
38  if (!(lhs.TDC() ==rhs.TDC())) {
39  return lhs.TDC() < rhs.TDC();
40  }
41  else if (!(lhs.Plane() == rhs.Plane()) ){
42  return lhs.Plane() < rhs.Plane();
43  }
44  else {
45  return lhs.Cell() < rhs.Cell();
46  }
47  }
48 
49  bool operator() (DAQHit const & lhs, TDC const & rhs) const
50  {
51  return lhs.TDC() < rhs;
52  }
53  };
54 
55 
56  // 3. Compare DAQ Hits based on their Plane:
57  template<> struct CompareDAQHit<Plane>
58  {
59  bool operator() (DAQHit const & lhs, DAQHit const & rhs) const
60  { return lhs.Plane() < rhs.Plane(); }
61 
62  bool operator() (DAQHit const & lhs, Plane const & rhs) const
63  { return lhs.Plane() < rhs; }
64  };
65 
66 
67  // 4. Compare DAQ Hits based on their Cell:
68  template<> struct CompareDAQHit<Cell>
69  {
70  bool operator() (DAQHit const & lhs, DAQHit const & rhs) const
71  { return lhs.Cell() < rhs.Cell(); }
72 
73  bool operator() (DAQHit const & lhs, Cell const & rhs) const
74  { return lhs.Cell() < rhs; }
75  };
76 
77 
78  // 5. Compare DAQ Hits based on their View
79  template<> struct CompareDAQHit<View>
80  {
81  bool operator() (DAQHit const & lhs, DAQHit const & rhs) const
82  { return lhs.View() < rhs.View(); }
83 
84  bool operator() (DAQHit const & lhs, View const & rhs) const
85  { return lhs.View() < rhs; }
86 
87  bool operator() (const DAQHit& lhs) const
88  { return lhs.View().val==daqchannelmap::X_VIEW; }
89  };
90 
91 
92  // 6. Compare DAQ Hits based on their DCM
93  template<> struct CompareDAQHit<DCM>
94  {
95  bool operator() (DAQHit const & lhs, DAQHit const & rhs) const
96  { return lhs.getDCM() < rhs.getDCM(); }
97 
98  bool operator() (DAQHit const & lhs, DCM const & rhs) const
99  { return lhs.getDCM() < rhs; }
100  };
101 }
102 
103 
104 #endif
novaddt::Plane const & Plane() const
Definition: DAQHit.h:70
novaddt::TDC const & TDC() const
Definition: DAQHit.h:74
novaddt::ADC const & ADC() const
Definition: DAQHit.h:73
novaddt::View const & View() const
Definition: DAQHit.h:72
Identifier for the X measuring view of the detector (top)
novaddt::DCM getDCM() const
Definition: DAQHit.cxx:134
Definition: View.py:1
value_type val
Definition: BaseProducts.h:137
novaddt::Cell const & Cell() const
Definition: DAQHit.h:71