Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JTRIGGER::JModuleCounter Struct Reference

Auxiliary class for counting unique modules. More...

#include <JModuleCounter.hh>

Public Member Functions

 JModuleCounter ()
 Default constructor.
 
template<class T >
int operator() (T __begin, T __end) const
 Count unique modules.
 

Private Attributes

std::vector< int > buffer
 

Detailed Description

Auxiliary class for counting unique modules.

Definition at line 20 of file JModuleCounter.hh.

Constructor & Destructor Documentation

◆ JModuleCounter()

JTRIGGER::JModuleCounter::JModuleCounter ( )
inline

Default constructor.

Definition at line 24 of file JModuleCounter.hh.

25 {}

Member Function Documentation

◆ operator()()

template<class T >
int JTRIGGER::JModuleCounter::operator() ( T __begin,
T __end ) const
inline

Count unique modules.

The template parameter should correspond to a data type which provides for the following method:

       int getModuleID();

Note that the input data are not changed.

Parameters
__beginbegin of data
__endend of data
Returns
number of unique modules

Definition at line 42 of file JModuleCounter.hh.

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 }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
std::vector< int > buffer

Member Data Documentation

◆ buffer

std::vector<int> JTRIGGER::JModuleCounter::buffer
mutableprivate

Definition at line 60 of file JModuleCounter.hh.


The documentation for this struct was generated from the following file: