Jpp  17.3.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Timestamp.hh
Go to the documentation of this file.
1 #ifndef __ANTARESDAQ__TIMESTAMP__
2 #define __ANTARESDAQ__TIMESTAMP__
3 
4 #include <utility>
5 #include <iterator>
6 
7 
8 /**
9  * Auxiliary class to remove bit-flipped ARS data.
10  *
11  * The input data are reshuffeld such that the pair container contains:
12  * - begin of correct output data
13  * - end of correct output data
14  *
15  * This class provides for the usual STL interface methods.
16  */
17 template<class T>
18 class Timestamp :
19  public std::pair<T,T> {
20 public:
21 
22  typedef T const_iterator;
23 
24 
25  /**
26  * Constructor.
27  *
28  * \param __begin begin of input data
29  * \param __end end of input data
30  */
31  Timestamp(T __begin, T __end) :
32  std::pair<T,T>(__begin, __end)
33  {
34  if (__begin != __end) {
35 
36  const_iterator p0 = __begin;
37  const_iterator p1 = p0;
38 
39  ++p1;
40 
41  /*
42  * assure following start conditions
43  *
44  * 1. p0 /= 0
45  * 2. p1 > p0
46  */
47  while (p1 != __end && (p0->timestamp == 0 || p1->timestamp < p0->timestamp)) {
48  ++p0;
49  ++p1;
50  }
51 
52  if (p1 != __end) {
53 
54  this->first = p0;
55  /*
56  * assume following start conditions
57  *
58  * 1. p0 /= 0
59  * 2. p1 > p0
60  */
61  for (const_iterator p2 = p1; ++p2 != __end; ) {
62 
63 
64  if (p2->timestamp > p1->timestamp) {
65  /*
66  * p2
67  * /
68  * p1
69  * /
70  * p0
71  */
72  *(++p0) = *p1;
73  *(++p1) = *p2;
74 
75  } else {
76 
77  if (p2->timestamp < p0->timestamp) {
78  /*
79  * p1
80  * / \
81  * / \
82  * p0 \
83  * p2
84  *
85  */
86  } else {
87  /*
88  * p1
89  * / \
90  * / p2
91  * /
92  * p0
93  */
94  *p1 = *p2;
95  }
96  }
97  }
98 
99  this->second = ++p1;
100 
101  } else {
102 
103  this->first = p0;
104  this->second = p1;
105  }
106  }
107  }
108 
109  const_iterator begin() const { return this->first; }
110  const_iterator end() const { return this->second; }
111 
112  size_t size() const { return std::distance(this->begin(), this->end()); }
113  bool empty() const { return this->begin() == this->end(); }
114 };
115 
116 #endif
TPaveText * p1
size_t size() const
Definition: Timestamp.hh:112
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Timestamp(T __begin, T __end)
Constructor.
Definition: Timestamp.hh:31
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
const_iterator end() const
Definition: Timestamp.hh:110
do set_variable OUTPUT_DIRECTORY $WORKDIR T
const_iterator begin() const
Definition: Timestamp.hh:109
p2
Definition: module-Z:fit.sh:74
T const_iterator
Definition: Timestamp.hh:22
bool empty() const
Definition: Timestamp.hh:113
Auxiliary class to remove bit-flipped ARS data.
Definition: Timestamp.hh:18