Jpp 19.3.0-rc.1
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 <limits>
5
9
10#include "JLang/JComparable.hh"
11
12
13/**
14 * \author mdejong
15 */
16
17namespace KM3NETDAQ {
18
20
21 /**
22 * Auxiliary class to determine time of DAQ objects.
23 *
24 * The time is relative to the fixed time defined in JDAQUTCExtended.\n
25 * For DAQ events, the time is offset by the product of the event counter and a constant weight.\n
26 * To correlate DAQ events with summary data, the weight should be set to a value such that
27 * this product is strictly less than half of the frame duration.
28 */
30 /**
31 * Type definition of time value.
32 */
33 struct value_type :
34 public JComparable<value_type>
35 {
36
37 static inline JTriggerCounter_t min() { return std::numeric_limits<JTriggerCounter_t>::min(); } //!< minimal counter value
38 static inline JTriggerCounter_t max() { return std::numeric_limits<JTriggerCounter_t>::max(); } //!< maximal counter value
39
40 /**
41 * Default constructor.
42 */
44 {}
45
46 /**
47 * Constructor.
48 */
54
55 /**
56 * Less-than method.
57 *
58 * \param value value
59 * \return true if this value less than given value; else false
60 */
61 bool less(const value_type& value) const
62 {
63 if (this->utc == value.utc && this->counter != max() && value.counter != max())
64 return this->counter < value.counter;
65 else
66 return this->utc < value.utc;
67 }
68
69 /**
70 * Subtraction operator.
71 *
72 * \param first first value
73 * \param second second value
74 * \return difference
75 */
76 friend inline double operator-(const value_type& first, const value_type& second)
77 {
78 if (first.utc == second.utc && first.counter != max() && second.counter != max())
79 return ((double) first.counter - (double) second.counter) / ((double) JDAQEvaluator::value_type::max());
80 else
81 return getTimeDifference(second.utc, first.utc);
82 }
83
86 };
87
88
89 /**
90 * Default constructor.
91 */
94
95
96 /**
97 * Get time of object.
98 *
99 * \param object UTC time
100 * \return time
101 */
102 inline value_type operator()(const JDAQUTCExtended& object) const
103 {
105 }
106
107
108 /**
109 * Get time of object.
110 *
111 * \param object DAQ header
112 * \return time
113 */
114 inline value_type operator()(const JDAQHeader& object) const
115 {
116 return (*this)(object.getTimesliceStart());
117 }
118
119
120 /**
121 * Get time of event.
122 *
123 * \param object event header
124 * \return time
125 */
126 inline value_type operator()(const JDAQEventHeader& object) const
127 {
128 return value_type(object.getTimesliceStart(), object.getCounter());
129 }
130 };
131
132
133 /**
134 * Function object for evaluation of DAQ objects.
135 */
137}
138
139#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
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.