1 #ifndef __JTRIGGER__JALGORITHM__
2 #define __JTRIGGER__JALGORITHM__
16 namespace JPP {
using namespace JTRIGGER; }
46 template<
class JHitIterator_t,
class JMatch_t>
47 inline JHitIterator_t operator()(JHitIterator_t __begin,
49 const JMatch_t& match,
50 const int Nmin = 1)
const
52 return (*
this)(__begin,
std::distance(__begin,__end), match, Nmin,
typename std::iterator_traits<JHitIterator_t>::iterator_category());
68 template<
class JHitIterator_t,
class JComparator_t,
class JMatch_t>
69 inline JHitIterator_t operator()(JHitIterator_t __begin,
71 const JComparator_t& comparator,
72 const JMatch_t& match)
const
74 if (__begin != __end) {
76 std::sort(__begin, __end, comparator);
78 JHitIterator_t
root = __begin;
80 return std::partition(++__begin, __end,
JBind2nd(match, *root));
99 template<
class JHitIterator_t,
class JMatch_t>
100 inline JHitIterator_t operator()(JHitIterator_t buffer,
102 const JMatch_t& match,
104 std::random_access_iterator_tag tag)
const
121 for (i = 0; i !=
N; ++i) {
122 for (j = i; ++j !=
N; ) {
123 if (match(buffer[i], buffer[j])) {
137 int M = (
count[0] >= Nmin ? 1 : 0);
141 for (i = 1; i !=
n; ++i) {
145 if (
count[i] >= Nmin) {
166 swap(buffer[j], buffer[n]);
171 for (i = 0; i != n &&
count[
n] != 1; ++i) {
172 if (match(buffer[i], buffer[n])) {
192 static const struct {
214 template<
class JHitIterator_t,
class JMatch_t>
215 inline JHitIterator_t operator()(JHitIterator_t __begin,
216 JHitIterator_t __end,
217 const JMatch_t& match)
const
219 return (*
this)(__begin,
std::distance(__begin,__end), match,
typename std::iterator_traits<JHitIterator_t>::iterator_category());
232 template<
class JHitIterator_t,
class JMatch_t>
233 inline JHitIterator_t operator()(JHitIterator_t buffer,
235 const JMatch_t& match,
236 std::random_access_iterator_tag tag)
const
252 for (i = 0; i !=
N; ++i) {
253 for (j = 0; j != i; ++
j) {
254 if (match(buffer[i], buffer[j])) {
264 for (
int n = 0; ; ++
n) {
268 for (i = j; ++i !=
N; ) {
282 swap(buffer[j], buffer[n]);
287 for (i = n; ++i !=
N; ) {
288 if (match(buffer[i], buffer[n])) {
308 static const struct {
332 template<
class JHitIterator_t,
class JMatch_t>
333 inline JHitIterator_t operator()(JHitIterator_t __begin,
334 JHitIterator_t __end,
335 const JMatch_t& match)
const
337 return (*
this)(__begin,
std::distance(__begin,__end), match,
typename std::iterator_traits<JHitIterator_t>::iterator_category());
350 template<
class JHitIterator_t,
class JMatch_t>
351 inline JHitIterator_t operator()(JHitIterator_t buffer,
353 const JMatch_t& match,
354 std::random_access_iterator_tag tag)
const
366 for (i = 0; i !=
N; ++i) {
367 weight[i] = buffer[i].getW();
370 for (i = 0; i !=
N; ++i) {
371 for (j = i; ++j !=
N; ) {
372 if (match(buffer[i], buffer[j])) {
391 for (i = 1; i !=
n; ++i) {
410 swap(buffer[j], buffer[n]);
415 for (i = 0; i != n &&
weight[
n] > buffer[
n].getW(); ++i) {
416 if (match(buffer[i], buffer[n])) {
443 template<
class JHit_t>
446 return first.getW() > second.getW();
460 template<
class JHit_t>
463 return first.getT() < second.getT();
JBinder2nd< JHit_t > JBind2nd(const JMatch< JHit_t > &match, const JHit_t &second)
Auxiliary method to create JBinder2nd object.
static struct JTRIGGER::@69 clusterize
Anonymous structure for clustering of hits.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
then JPlot1D f $WORKDIR postfit[prefit\] root
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
static struct JTRIGGER::@71 clusterizeWeight
Anonymous struct for weighed clustering of hits.
bool timeSorter(const JHit_t &first, const JHit_t &second)
Compare two hits by weight.
bool weightSorter(const JHit_t &first, const JHit_t &second)
Compare two hits by weight.
static struct JTRIGGER::@70 reverse_clusterize
Anonymous structure for reverse clustering of hits.
alias put_queue eval echo n
then usage $script[input file[working directory[option]]] nWhere option can be N
std::vector< double > weight