Jpp master_rocky-44-g75b7c4f75
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
11/**
12 * \author mdejong
13 */
14
15namespace KM3NETDAQ {
16
17 /**
18 * Auxiliary class to determine time of DAQ objects.
19 *
20 * The time is relative to the fixed time defined in JDAQUTCExtended.\n
21 * For DAQ events, the time is offset by the product of the event counter and a constant weight.\n
22 * To correlate DAQ events with summary data, the weight should be set to a value such that
23 * this product is strictly less than half of the frame duration.
24 */
26 /**
27 * Type definition of time value.
28 */
29 struct value_type {
30
33
34 static inline JTriggerCounter_t min() { return std::numeric_limits<JTriggerCounter_t>::min(); } //!< minimal counter value
35 static inline JTriggerCounter_t max() { return std::numeric_limits<JTriggerCounter_t>::max(); } //!< maximal counter value
36
37 /**
38 * Less-than operator.
39 *
40 * \param first first value
41 * \param second second value
42 * \return true if first value less than second value; else false
43 */
44 friend inline bool operator<(const value_type& first, const value_type& second)
45 {
46 if (first.utc == second.utc && first.counter != max() && second.counter != max())
47 return first.counter < second.counter;
48 else
49 return first.utc < second.utc;
50 }
51
52 /**
53 * Subtraction operator.
54 *
55 * \param first first value
56 * \param second second value
57 * \return difference
58 */
59 friend inline double operator-(const value_type& first, const value_type& second)
60 {
61 if (first.utc == second.utc && first.counter != max() && second.counter != max())
62 return (double) first.counter - (double) second.counter;
63 else
64 return getTimeDifference(second.utc, first.utc);
65 }
66 };
67
68
69 /**
70 * Default constructor.
71 */
74
75
76 /**
77 * Get time of object.
78 *
79 * \param object UTC time
80 * \return time
81 */
82 inline value_type operator()(const JDAQUTCExtended& object) const
83 {
84 return { object, JDAQEvaluator::value_type::max() };
85 }
86
87
88 /**
89 * Get time of object.
90 *
91 * \param object DAQ header
92 * \return time
93 */
94 inline value_type operator()(const JDAQHeader& object) const
95 {
96 return(*this)(object.getTimesliceStart());
97 }
98
99
100 /**
101 * Get time of event.
102 *
103 * \param object event header
104 * \return time
105 */
106 inline value_type operator()(const JDAQEventHeader& object) const
107 {
108 return { object.getTimesliceStart(), object.getCounter() };
109 }
110 };
111
112
113 /**
114 * Function object for evaluation of DAQ objects.
115 */
117}
118
119#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.
Type definition of time value.
static JTriggerCounter_t min()
minimal counter value
friend double operator-(const value_type &first, const value_type &second)
Subtraction operator.
static JTriggerCounter_t max()
maximal counter value
friend bool operator<(const value_type &first, const value_type &second)
Less-than operator.
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.