1 #ifndef __JTRIGGER__JALGORITHM__
2 #define __JTRIGGER__JALGORITHM__
16 namespace JPP {
using namespace JTRIGGER; }
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) {
381 if (weight[i] < weight[j])
383 else if (weight[i] > W)
389 if (weight[j] == W) {
399 swap(buffer[j], buffer[n]);
400 swap(weight[j], weight[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>
452 return first.getT() < second.getT();
static struct JTRIGGER::clusterizeWeight clusterizeWeight
JBinder2nd< JHit_t > JBind2nd(const JMatch< JHit_t > &match, const JHit_t &second)
Auxiliary method to create JBinder2nd object.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
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 int Nmin=1) const
Partition data according given binary match operator.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
std::vector< double > weight
JHitIterator_t operator()(JHitIterator_t __begin, JHitIterator_t __end, const JMatch_t &match) const
Partition data according given binary match operator.
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...
bool timeSorter(const JHit_t &first, const JHit_t &second)
Compare two hits by weight.
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.
Anonymous struct for weighed clustering of hits.
bool weightSorter(const JHit_t &first, const JHit_t &second)
Compare two hits by weight.
JHitIterator_t operator()(JHitIterator_t __begin, JHitIterator_t __end, const JMatch_t &match) 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.
do JPlot2D f $WORKDIR detector root
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
static struct JTRIGGER::reverse_clusterize reverse_clusterize
Anonymous structure for clustering of hits.
static struct JTRIGGER::clusterize clusterize