00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __FASTJET_DYNAMICNEARESTNEIGHBOURS_HH__
00033 #define __FASTJET_DYNAMICNEARESTNEIGHBOURS_HH__
00034
00035 #include<vector>
00036 #include<string>
00037 #include<iostream>
00038 #include<sstream>
00039 #include<cassert>
00040 #include "fastjet/internal/numconsts.hh"
00041
00042 FASTJET_BEGIN_NAMESPACE
00043
00045
00046
00053 class EtaPhi {
00054 public:
00055 double first, second;
00056 EtaPhi() {}
00057 EtaPhi(double a, double b) {first = a; second = b;}
00059 void sanitize() {
00060 if (second < 0) second += twopi;
00061 if (second >= twopi) second -= twopi;
00062 }
00063
00064 };
00065
00072 class DnnError {
00073 public:
00074
00075 DnnError() {;};
00076 DnnError(const std::string & message) {
00077 _message = message; std::cerr << message << std::endl;};
00078
00079 std::string message() const {return _message;};
00080
00081 private:
00082 std::string _message;
00083 };
00084
00085
00103 class DynamicNearestNeighbours {
00104
00105 public:
00107
00108
00111
00112
00113
00116 virtual int NearestNeighbourIndex(const int & ii) const = 0;
00117
00120 virtual double NearestNeighbourDistance(const int & ii) const = 0;
00121
00125 virtual bool Valid(const int & index) const = 0;
00126
00137 virtual void RemoveAndAddPoints(const std::vector<int> & indices_to_remove,
00138 const std::vector<EtaPhi> & points_to_add,
00139 std::vector<int> & indices_added,
00140 std::vector<int> & indices_of_updated_neighbours) = 0;
00141
00142
00145 inline void RemovePoint (const int & index,
00146 std::vector<int> & indices_of_updated_neighbours) {
00147 std::vector<int> indices_added;
00148 std::vector<EtaPhi> points_to_add;
00149 std::vector<int> indices_to_remove(1);
00150 indices_to_remove[0] = index;
00151 RemoveAndAddPoints(indices_to_remove, points_to_add, indices_added,
00152 indices_of_updated_neighbours
00153 );};
00154
00155
00161 inline void RemoveCombinedAddCombination(
00162 const int & index1, const int & index2,
00163 const EtaPhi & newpoint,
00164 int & index3,
00165 std::vector<int> & indices_of_updated_neighbours) {
00166 std::vector<int> indices_added(1);
00167 std::vector<EtaPhi> points_to_add(1);
00168 std::vector<int> indices_to_remove(2);
00169 indices_to_remove[0] = index1;
00170 indices_to_remove[1] = index2;
00171 points_to_add[0] = newpoint;
00172 RemoveAndAddPoints(indices_to_remove, points_to_add, indices_added,
00173 indices_of_updated_neighbours
00174 );
00175 index3 = indices_added[0];
00176 };
00177
00179 virtual ~DynamicNearestNeighbours () {}
00180 };
00181
00182
00183 FASTJET_END_NAMESPACE
00184
00185 #endif // __FASTJET_DYNAMICNEARESTNEIGHBOURS_HH__