Jpp
JDAQKeyHit.hh
Go to the documentation of this file.
1 #ifndef __JDAQKEYHIT__
2 #define __JDAQKEYHIT__
3 
4 #include "JIO/JSerialisable.hh"
5 #include "JDAQ/JDAQRoot.hh"
7 #include "JDAQ/JDAQHit.hh"
9 
10 
11 /**
12  * \author mdejong
13  */
14 
15 namespace KM3NETDAQ {
16 
17  using JIO::JReader;
18  using JIO::JWriter;
19 
20 
21  /**
22  * DAQ key hit
23  */
24  class JDAQKeyHit :
25  public JDAQModuleIdentifier,
26  public JDAQHit
27  {
28  public:
29 
30 
31  /**
32  * Default constructor.
33  */
36  JDAQHit()
37  {}
38 
39 
40  /**
41  * Constructor.
42  *
43  * \param id module identifier
44  * \param hit PMT hit
45  */
47  const JDAQHit& hit) :
49  JDAQHit(hit)
50  {}
51 
52 
53  /**
54  * Virtual destructor.
55  */
56  virtual ~JDAQKeyHit()
57  {}
58 
59 
60  /**
61  * Type conversion operator.
62  *
63  * \return axis
64  */
65  operator JDAQPMTIdentifier () const
66  {
67  return JDAQPMTIdentifier(this->getModuleID(), this->getPMT());
68  }
69 
70 
71  /**
72  * Read JDAQKeyHit from input.
73  *
74  * \param in JReader
75  * \param hit JDAQKeyHit
76  * \return JReader
77  */
78  friend inline JReader& operator>>(JReader& in, JDAQKeyHit& hit)
79  {
80  in >> static_cast<JDAQModuleIdentifier&>(hit);
81  in >> static_cast<JDAQHit&> (hit);
82 
83  return in;
84  }
85 
86 
87  /**
88  * Write JDAQKeyHit to output.
89  *
90  * \param out JWriter
91  * \param hit JDAQKeyHit
92  * \return JWriter
93  */
94  friend inline JWriter& operator<<(JWriter& out, const JDAQKeyHit& hit)
95  {
96  out << static_cast<const JDAQModuleIdentifier&>(hit);
97  out << static_cast<const JDAQHit&> (hit);
98 
99  return out;
100  }
101 
102 
103  /**
104  * Get size of object.
105  *
106  * \return number of bytes
107  */
108  static int sizeOf()
109  {
110  return (JDAQModuleIdentifier::sizeOf() +
111  JDAQHit ::sizeOf());
112  }
113 
114 
115  ClassDef(JDAQKeyHit,1);
116  };
117 
118 
119 
120  /**
121  * Less than operator for DAQ hits.
122  *
123  * The less than operator is applied first to the module idientifier then to the PMT channel and then to the time of the hits.
124  *
125  * \param first hit
126  * \param second hit
127  * \result true if first hit before than second; else false
128  */
129  inline bool operator<(const JDAQKeyHit& first,
130  const JDAQKeyHit& second)
131  {
132  if (first.getModuleID() == second.getModuleID()) {
133  if (first.getPMT() == second.getPMT())
134  return first.getT() < second.getT();
135  else
136  return first.getPMT() < second.getPMT();
137  } else
138  return first.getModuleID() < second.getModuleID();
139  }
140 
141 
142 
143  /**
144  * Equal operator for DAQ hits.
145  *
146  * The equal operator is applied to the module idientifier, to the PMT channel and to the time of the hits.
147  *
148  * \param first hit
149  * \param second hit
150  * \result t rue if first hit equal to second; else false
151  */
152  inline bool operator==(const JDAQKeyHit& first,
153  const JDAQKeyHit& second)
154  {
155  return (first.getModuleID() == second.getModuleID() &&
156  first.getPMT() == second.getPMT() &&
157  first.getT() == second.getT());
158  }
159 
160 
161  /**
162  * Not-equal operator for DAQ hits.
163  *
164  * \param first hit
165  * \param second hit
166  * \result true if first hit not equal to second; else false
167  */
168  inline bool operator!=(const JDAQKeyHit& first,
169  const JDAQKeyHit& second)
170  {
171  return !(first == second);
172  }
173 }
174 
175 #endif
JIO::JReader
Interface for binary input.
Definition: JSerialisable.hh:62
KM3NETDAQ::JDAQModuleIdentifier::sizeOf
static int sizeOf()
Get size of object.
Definition: JDAQModuleIdentifier.hh:143
KM3NETDAQ::operator<
bool operator<(const JDAQHit &first, const JDAQHit &second)
Less than operator for DAQ hits.
Definition: JDAQHit.hh:222
KM3NETDAQ::JDAQHit::getPMT
JPMT_t getPMT() const
Get PMT.
Definition: JDAQHit.hh:78
KM3NETDAQ::JDAQKeyHit::JDAQKeyHit
JDAQKeyHit()
Default constructor.
Definition: JDAQKeyHit.hh:34
KM3NETDAQ::JDAQKeyHit::ClassDef
ClassDef(JDAQKeyHit, 1)
KM3NETDAQ::JDAQKeyHit::operator<<
friend JWriter & operator<<(JWriter &out, const JDAQKeyHit &hit)
Write JDAQKeyHit to output.
Definition: JDAQKeyHit.hh:94
KM3NETDAQ::JDAQKeyHit::JDAQKeyHit
JDAQKeyHit(const JDAQModuleIdentifier &id, const JDAQHit &hit)
Constructor.
Definition: JDAQKeyHit.hh:46
KM3NETDAQ::JDAQModuleIdentifier::getModuleID
int getModuleID() const
Get module identifier.
Definition: JDAQModuleIdentifier.hh:72
KM3NETDAQ::JDAQModuleIdentifier::id
int id
Definition: JDAQModuleIdentifier.hh:153
KM3NETDAQ::JDAQHit::sizeOf
static int sizeOf()
Get size of object.
Definition: JDAQHit.hh:196
KM3NETDAQ::JDAQKeyHit::sizeOf
static int sizeOf()
Get size of object.
Definition: JDAQKeyHit.hh:108
JSerialisable.hh
KM3NETDAQ::JDAQHit::getT
JTDC_t getT() const
Get time.
Definition: JDAQHit.hh:89
KM3NETDAQ::JDAQKeyHit::~JDAQKeyHit
virtual ~JDAQKeyHit()
Virtual destructor.
Definition: JDAQKeyHit.hh:56
KM3NETDAQ::operator!=
bool operator!=(const JDAQChronometer &first, const JDAQChronometer &second)
Not-equal operator for DAQ chronometers.
Definition: JDAQChronometer.hh:303
JIO::JWriter
Interface for binary output.
Definition: JSerialisable.hh:130
KM3NETDAQ::JDAQModuleIdentifier
Module identifier.
Definition: JDAQModuleIdentifier.hh:24
KM3NETDAQ::JDAQKeyHit
DAQ key hit.
Definition: JDAQKeyHit.hh:24
JDAQRoot.hh
KM3NETDAQ::operator==
bool operator==(const JDAQChronometer &first, const JDAQChronometer &second)
Equal operator for DAQ chronometers.
Definition: JDAQChronometer.hh:286
KM3NETDAQ::JDAQPMTIdentifier
PMT identifier.
Definition: JDAQPMTIdentifier.hh:25
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
JDAQPMTIdentifier.hh
KM3NETDAQ::JDAQHit
Hit data structure.
Definition: JDAQHit.hh:40
JDAQModuleIdentifier.hh
JDAQHit.hh
KM3NETDAQ::JDAQKeyHit::operator>>
friend JReader & operator>>(JReader &in, JDAQKeyHit &hit)
Read JDAQKeyHit from input.
Definition: JDAQKeyHit.hh:78