88int main(
int argc,
char**argv)
101 JParser<> zap(
"Example program to test watershed algorithm.");
111 catch(
const exception &error) {
112 FATAL(error.what() << endl);
116 gRandom->SetSeed(seed);
120 const int N = numeric_limits<int>::max();
122 for (
int count = 0; count != numberOfEvents; ++count) {
127 data.push_back(gRandom->Uniform(0.0, M * PI));
130 if (
debug >= debug_t) {
132 cout << ps(i) << endl;
138 DEBUG(
"number of soultions " <<
distance(data.begin(),__end) << endl);
142 if (
debug >= debug_t) {
150 cout << ps(*i) <<
" | ";
154 return getDistance(*i,first) < getDistance(*i,second);
157 sort(
p1, buffer.end(), compare);
159 double y = getValue(*
p1);
163 if (
p1 != buffer.end()) {
166 (getValue(*
p1) <= y + Y ||
170 cout <<
' ' << ps(*
p1) <<
' ' <<
FIXED(6,3) << getDistance(*i,*
p1);
180 if (
distance(data.begin(), __end) > 1) {
185 return getValue(first) > getValue(second);
188 ASSERT(is_sorted(data.begin(), __end, compare),
"test if maxima are sorted");
197 if (
p1.l == p2.l) {
ASSERT(p2.y <=
p1.y,
"test if maxima " <<
p1 <<
" and " << p2 <<
" are not compatible"); }
206 m1[ps(*i).l].push_back(*i);
210 m2[ps(*i).l].push_back(*i);
215 return getValue(first) > getValue(second);
219 ASSERT(is_sorted(i.second.begin(), i.second.end(), compare),
"test if maxima are sorted in bin " << i.first);
222 sort(i.second.begin(), i.second.end(), compare);
225 for (
const auto& i : m1) {
227 const ps
p1(i.second[0]);
229 if (m2.count(
p1.l)) {
231 const ps p2(m2[
p1.l][0]);
233 ASSERT(
p1.y >= p2.y,
"test maximum in " <<
p1.l <<
" " <<
p1 <<
" " << p2);