89{
92
93 int numberOfEvents;
95 UInt_t seed;
96 double Y;
98
99 try {
100
101 JParser<> zap(
"Example program to test watershed algorithm.");
102
108
109 zap(argc, argv);
110 }
111 catch(const exception &error) {
112 FATAL(error.what() << endl);
113 }
114
115
116 gRandom->SetSeed(seed);
117
118
119 const int M = 10;
120 const int N = numeric_limits<int>::max();
121
122 for (int count = 0; count != numberOfEvents; ++count) {
123
125
127 data.push_back(gRandom->Uniform(0.0, M * PI));
128 }
129
130 if (
debug >= debug_t) {
132 cout << ps(i) << endl;
133 }
134 }
135
137
139
141
142 if (
debug >= debug_t) {
143
145
147
149
150 cout << ps(*i) << " | ";
151
153 {
154 return getDistance(*i,first) < getDistance(*i,second);
155 };
156
157 sort(
p1, buffer.end(), compare);
158
160
162
163 if (
p1 != buffer.end()) {
164
169
170 cout <<
' ' << ps(*
p1) <<
' ' <<
FIXED(6,3) << getDistance(*i,*
p1);
171
173 }
174 }
175
176 cout << endl;
177 }
178 }
179
181
182 {
184 {
186 };
187
188 ASSERT(is_sorted(
data.begin(), __end, compare),
"test if maxima are sorted");
189 }
190 {
193
195 const ps p2(*q);
196
197 if (
p1.l == p2.l) {
ASSERT(p2.y <=
p1.y,
"test if maxima " <<
p1 <<
" and " << p2 <<
" are not compatible"); }
198 }
199 }
200 }
201 {
204
206 m1[ps(*i).l].push_back(*i);
207 }
208
210 m2[ps(*i).l].push_back(*i);
211 }
212
214 {
216 };
217
218 for (auto& i : m1) {
219 ASSERT(is_sorted(i.second.begin(), i.second.end(), compare),
"test if maxima are sorted in bin " << i.first);
220 }
221 for (auto& i : m2) {
222 sort(i.second.begin(), i.second.end(), compare);
223 }
224
225 for (const auto& i : m1) {
226
227 const ps
p1(i.second[0]);
228
229 if (m2.count(
p1.l)) {
230
231 const ps p2(m2[
p1.l][0]);
232
233 ASSERT(
p1.y >= p2.y,
"test maximum in " <<
p1.l <<
" " <<
p1 <<
" " << p2);
234 }
235 }
236 }
237 }
238 }
239
240 return 0;
241}
#define DEBUG(A)
Message macros.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
double getValue(const JScale_t scale)
Get numerical value corresponding to scale.
T watershed(T __begin, T __end, const JFunction_t &getValue, const JDistance_t &getDistance, double Y, int N=std::numeric_limits< int >::max())
Watershed algorithm.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Data structure for measured coincidence rates of all pairs of PMTs in optical module.