32{
34
35 string inputFile;
38 ULong_t seed;
40
41 try {
42
43 JParser<> zap(
"Example program to find smallest distance between two points.");
44
50
51 zap(argc, argv);
52 }
53 catch(const exception &error) {
54 FATAL(error.what() << endl);
55 }
56
57 gRandom->SetSeed(seed);
58
60
61
63
65
66
67 if (inputFile != "") {
68
69 ifstream in(inputFile.c_str());
70
71 for (
double x, y; in >>
x >>
y; ) {
73 }
74
75 in.close();
76
78
80
82
85 }
86
88
90
91 for (const_iterator i = buffer.begin(); i != buffer.end(); ++i)
92 out <<
setw(7) << i->getX() <<
' '
94
95 out.close();
96 }
97 }
98
99 if (buffer.size() < 2) {
101 }
102
103 for (const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
104 DEBUG(i->getX() <<
' ' << i->getY() <<
endl);
105 }
106
107
108 {
110
111 timer.start();
112
114
115 for (const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
116 for (const_iterator j = i; ++
j != buffer.end(); ) {
117
118 const double d = i->getDistance(*j);
119
120 if (d < dmin) {
121 dmin = d;
122 }
123 }
124 }
125
126 timer.stop();
127
130 }
131
132
133 JTimer timer(
"O(n log(n))");
134
135 timer.start();
136
137 const double dmin = getSmallestDistance2D(buffer.begin(), buffer.end());
138
139 timer.stop();
140
143
144
146
151
152
154
155 TCanvas cv(
"cv",
"", 400, 400);
156
157 cv.SetFillStyle(4000);
158 cv.SetFillColor(0);
159
160 cv.Divide(1, 1);
161 cv.cd(1);
162
163
165
168
169 int N = 0;
170
171 for (const_iterator i = buffer.begin(); i != buffer.end(); ++i, ++N) {
174 }
175
176
181
183
185 h2.Draw();
186
187
188 TGraph g(N, x, y);
189
190 g.SetMarkerStyle(20);
192 g.SetMarkerSize(0.7);
193 g.Draw("P");
194
197
200
201 m1.SetMarkerSize(0.7);
202 m2.SetMarkerSize(0.7);
203
206
207 cv.Update();
208
209 tp->Run();
210}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Auxiliary class for CPU timing and usage.
Data structure for vector in two dimensions.
Template definition of a multi-dimensional oscillation probability interpolation table.
Utility class to parse command line options.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Auxiliary data structure for floating point format specification.