Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
JDAQEvaluator.hh
Go to the documentation of this file.
1#ifndef __JDAQEVALUATOR__
2#define __JDAQEVALUATOR__
3
4#include <ostream>
5#include <limits>
6
10
11#include "JLang/JComparable.hh"
12
13
14/**
15 * \author mdejong
16 */
17
18namespace KM3NETDAQ {
19
21
22 /**
23 * Auxiliary class to determine time of DAQ objects.
24 *
25 * The time is relative to the fixed time defined in JDAQUTCExtended.\n
26 * For DAQ events, the time is offset by the product of the event counter and a constant weight.\n
27 * To correlate DAQ events with summary data, the weight should be set to a value such that
28 * this product is strictly less than half of the frame duration.
29 */
31 /**
32 * Type definition of time value.
33 */
34 struct value_type :
35 public JComparable<value_type>
36 {
37
38 static inline JTriggerCounter_t min() { return std::numeric_limits<JTriggerCounter_t>::min(); } //!< minimal counter value
39 static inline JTriggerCounter_t max() { return std::numeric_limits<JTriggerCounter_t>::max(); } //!< maximal counter value
40
41 /**
42 * Default constructor.
43 */
45 {}
46
47 /**
48 * Constructor.
49 */
55
56 /**
57 * Less-than method.
58 *
59 * \param value value
60 * \return true if this value less than given value; else false
61 */
62 bool less(const value_type& value) const
63 {
64 if (this->utc == value.utc && this->counter != max() && value.counter != max())
65 return this->counter < value.counter;
66 else
67 return this->utc < value.utc;
68 }
69
70 /**
71 * Subtraction operator.
72 *
73 * \param first first value
74 * \param second second value
75 * \return difference
76 */
77 friend inline double operator-(const value_type& first, const value_type& second)
78 {
79 if (first.utc == second.utc && first.counter != max() && second.counter != max())
80 return ((double) first.counter - (double) second.counter) / ((double) JDAQEvaluator::value_type::max());
81 else
82 return getTimeDifference(second.utc, first.utc);
83 }
84
85
86 /**
87 * Write value to output stream.
88 */
89 friend inline std::ostream& operator<<(std::ostream& out, const value_type& value)
90 {
91 return out << value.utc << ' ' << value.counter;
92 }
93
96 };
97
98
99 /**
100 * Default constructor.
101 */
104
105
106 /**
107 * Get time of object.
108 *
109 * \param object UTC time
110 * \return time
111 */
112 inline value_type operator()(const JDAQUTCExtended& object) const
113 {
115 }
116
117
118 /**
119 * Get time of object.
120 *
121 * \param object DAQ header
122 * \return time
123 */
124 inline value_type operator()(const JDAQHeader& object) const
125 {
126 return (*this)(object.getTimesliceStart());
127 }
128
129
130 /**
131 * Get time of event.
132 *
133 * \param object event header
134 * \return time
135 */
136 inline value_type operator()(const JDAQEventHeader& object) const
137 {
138 return value_type(object.getTimesliceStart(), object.getCounter());
139 }
140 };
141
142
143 /**
144 * Function object for evaluation of DAQ objects.
145 */
147}
148
149#endif
Data structure for UTC time.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
double getTimeDifference(const JDAQChronometer &first, const JDAQChronometer &second)
Get time difference between two chronometers.
unsigned long long int JTriggerCounter_t
Type definition of trigger counter.
static const JDAQEvaluator getDAQValue
Function object for evaluation of DAQ objects.
Template definition of auxiliary base class for comparison of data structures.
Type definition of time value.
static JTriggerCounter_t min()
minimal counter value
value_type(const JDAQUTCExtended &utc, const JTriggerCounter_t counter)
Constructor.
friend double operator-(const value_type &first, const value_type &second)
Subtraction operator.
static JTriggerCounter_t max()
maximal counter value
friend std::ostream & operator<<(std::ostream &out, const value_type &value)
Write value to output stream.
bool less(const value_type &value) const
Less-than method.
Auxiliary class to determine time of DAQ objects.
value_type operator()(const JDAQHeader &object) const
Get time of object.
JDAQEvaluator()
Default constructor.
value_type operator()(const JDAQUTCExtended &object) const
Get time of object.
value_type operator()(const JDAQEventHeader &object) const
Get time of event.