1#ifndef __JTRIGGER__JALGORITHM__
2#define __JTRIGGER__JALGORITHM__
42 template<
class JHitIterator_t,
class JMatch_t>
45 const JMatch_t& match,
46 const int Nmin = 1)
const
48 return (*
this)(__begin, std::distance(__begin,__end), match, Nmin,
typename std::iterator_traits<JHitIterator_t>::iterator_category());
64 template<
class JHitIterator_t,
class JComparator_t,
class JMatch_t>
67 const JComparator_t& comparator,
68 const JMatch_t& match)
const
70 if (__begin != __end) {
72 std::sort(__begin, __end, comparator);
74 JHitIterator_t
root = __begin;
76 return std::partition(++__begin, __end,
JBind2nd(match, *
root));
95 template<
class JHitIterator_t,
class JMatch_t>
98 const JMatch_t& match,
100 std::random_access_iterator_tag tag)
const
117 for (i = 0; i != N; ++i) {
118 for (j = i; ++j != N; ) {
119 if (match(buffer[i], buffer[j])) {
133 int M = (
count[0] >= Nmin ? 1 : 0);
137 for (i = 1; i != n; ++i) {
141 if (
count[i] >= Nmin) {
162 swap(buffer[j], buffer[n]);
167 for (i = 0; i != n &&
count[n] != 1; ++i) {
168 if (match(buffer[i], buffer[n])) {
206 template<
class JHitIterator_t,
class JMatch_t>
208 JHitIterator_t __end,
209 const JMatch_t& match)
const
211 return (*
this)(__begin, std::distance(__begin,__end), match,
typename std::iterator_traits<JHitIterator_t>::iterator_category());
224 template<
class JHitIterator_t,
class JMatch_t>
227 const JMatch_t& match,
228 std::random_access_iterator_tag tag)
const
244 for (i = 0; i != N; ++i) {
245 for (j = 0; j != i; ++j) {
246 if (match(buffer[i], buffer[j])) {
256 for (
int n = 0; ; ++n) {
260 for (i = j; ++i != N; ) {
274 swap(buffer[j], buffer[n]);
279 for (i = n; ++i != N; ) {
280 if (match(buffer[i], buffer[n])) {
321 template<
class JHitIterator_t,
class JMatch_t>
323 JHitIterator_t __end,
324 const JMatch_t& match)
const
326 return (*
this)(__begin, std::distance(__begin,__end), match,
typename std::iterator_traits<JHitIterator_t>::iterator_category());
339 template<
class JHitIterator_t,
class JMatch_t>
342 const JMatch_t& match,
343 std::random_access_iterator_tag tag)
const
355 for (i = 0; i != N; ++i) {
356 weight[i] = buffer[i].getW();
359 for (i = 0; i != N; ++i) {
360 for (j = i; ++j != N; ) {
361 if (match(buffer[i], buffer[j])) {
362 weight[i] += buffer[j].getW();
363 weight[j] += buffer[i].getW();
380 for (i = 1; i != n; ++i) {
399 swap(buffer[j], buffer[n]);
404 for (i = 0; i != n &&
weight[n] > buffer[n].getW(); ++i) {
405 if (match(buffer[i], buffer[n])) {
406 weight[i] -= buffer[n].getW();
407 weight[n] -= buffer[i].getW();
432 template<
class JHit_t>
435 return first.getW() > second.getW();
449 template<
class JHit_t>
450 inline bool timeSorter(
const JHit_t& first,
const JHit_t& second)
452 return first.getT() < second.getT();
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for triggering.
static const struct JTRIGGER::reverse_clusterize reverse_clusterize
static const struct JTRIGGER::clusterize clusterize
JBinder2nd< JHit_t > JBind2nd(const JMatch< JHit_t > &match, const JHit_t &second)
Auxiliary method to create JBinder2nd object.
static const struct JTRIGGER::clusterizeWeight clusterizeWeight
bool weightSorter(const JHit_t &first, const JHit_t &second)
Compare two hits by weight.
bool timeSorter(const JHit_t &first, const JHit_t &second)
Compare two hits by weight.
Anonymous struct for weighed clustering of hits.
std::vector< double > weight
JHitIterator_t operator()(JHitIterator_t buffer, const int N, const JMatch_t &match, std::random_access_iterator_tag tag) const
Implementation of method clusterizeWeight for random access iterators.
JHitIterator_t operator()(JHitIterator_t __begin, JHitIterator_t __end, const JMatch_t &match) const
Partition data according given binary match operator.
Anonymous structure for clustering of hits.
JHitIterator_t operator()(JHitIterator_t __begin, JHitIterator_t __end, const JComparator_t &comparator, const JMatch_t &match) const
Select best root hit according given comparator and partition remaining data according given binary m...
JHitIterator_t operator()(JHitIterator_t __begin, JHitIterator_t __end, const JMatch_t &match, const int Nmin=1) const
Partition data according given binary match operator.
JHitIterator_t operator()(JHitIterator_t buffer, const int N, const JMatch_t &match, const int Nmin, std::random_access_iterator_tag tag) const
Implementation of method clusterize for random access iterators.
Anonymous structure for reverse clustering of hits.
JHitIterator_t operator()(JHitIterator_t buffer, const int N, const JMatch_t &match, std::random_access_iterator_tag tag) const
Implementation of method reverse_clusterize for random access iterators.
JHitIterator_t operator()(JHitIterator_t __begin, JHitIterator_t __end, const JMatch_t &match) const
Partition data according given binary match operator.