Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JModuleCounter.hh
Go to the documentation of this file.
1#ifndef __JTRIGGER__JMODULECOUNTER__
2#define __JTRIGGER__JMODULECOUNTER__
3
4#include <vector>
5#include <algorithm>
6
7
8/**
9 * \author mdejong
10 */
11
12namespace JTRIGGER {}
13namespace JPP { using namespace JTRIGGER; }
14
15namespace JTRIGGER {
16
17 /**
18 * Auxiliary class for counting unique modules.
19 */
21 /**
22 * Default constructor.
23 */
26
27
28 /**
29 * Count unique modules.
30 *
31 * The template parameter should correspond to a data type which provides for the following method:
32 * <pre>
33 * int getModuleID();
34 * </pre>
35 * Note that the input data are not changed.
36 *
37 * \param __begin begin of data
38 * \param __end end of data
39 * \return number of unique modules
40 */
41 template<class T>
42 int operator()(T __begin, T __end) const
43 {
44 using namespace std;
45
46 buffer.resize(distance(__begin, __end));
47
48 vector<int>::iterator out = buffer.begin();
49
50 for (T i = __begin; i != __end; ++i, ++out) {
51 *out = i->getModuleID();
52 }
53
54 sort(buffer.begin(), buffer.end());
55
56 return distance(buffer.begin(), unique(buffer.begin(), buffer.end()));
57 }
58
59 private:
61 };
62
63
64 /**
65 * Function object to count unique modules.
66 */
68}
69
70#endif
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for triggering.
static const JModuleCounter getNumberOfModules
Function object to count unique modules.
Auxiliary class for counting unique modules.
std::vector< int > buffer
int operator()(T __begin, T __end) const
Count unique modules.
JModuleCounter()
Default constructor.