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
00049 class EtaPhi {
00050 public:
00051 double first, second;
00052 EtaPhi() {}
00053 EtaPhi(double a, double b) {first = a; second = b;}
00055 void sanitize() {
00056 if (second < 0) second += twopi;
00057 if (second >= twopi) second -= twopi;
00058 }
00059
00060 };
00061
00064 class DnnError {
00065 public:
00066
00067 DnnError() {;};
00068 DnnError(const std::string & message) {
00069 _message = message; std::cerr << message << std::endl;};
00070
00071 std::string message() const {return _message;};
00072
00073 private:
00074 std::string _message;
00075 };
00076
00077
00089 class DynamicNearestNeighbours {
00090
00091 public:
00093
00094
00097
00098
00099
00102 virtual int NearestNeighbourIndex(const int & ii) const = 0;
00103
00106 virtual double NearestNeighbourDistance(const int & ii) const = 0;
00107
00111 virtual bool Valid(const int & index) const = 0;
00112
00123 virtual void RemoveAndAddPoints(const std::vector<int> & indices_to_remove,
00124 const std::vector<EtaPhi> & points_to_add,
00125 std::vector<int> & indices_added,
00126 std::vector<int> & indices_of_updated_neighbours) = 0;
00127
00128
00131 inline void RemovePoint (const int & index,
00132 std::vector<int> & indices_of_updated_neighbours) {
00133 std::vector<int> indices_added;
00134 std::vector<EtaPhi> points_to_add;
00135 std::vector<int> indices_to_remove(1);
00136 indices_to_remove[0] = index;
00137 RemoveAndAddPoints(indices_to_remove, points_to_add, indices_added,
00138 indices_of_updated_neighbours
00139 );};
00140
00141
00147 inline void RemoveCombinedAddCombination(
00148 const int & index1, const int & index2,
00149 const EtaPhi & newpoint,
00150 int & index3,
00151 std::vector<int> & indices_of_updated_neighbours) {
00152 std::vector<int> indices_added(1);
00153 std::vector<EtaPhi> points_to_add(1);
00154 std::vector<int> indices_to_remove(2);
00155 indices_to_remove[0] = index1;
00156 indices_to_remove[1] = index2;
00157 points_to_add[0] = newpoint;
00158 RemoveAndAddPoints(indices_to_remove, points_to_add, indices_added,
00159 indices_of_updated_neighbours
00160 );
00161 index3 = indices_added[0];
00162 };
00163
00165 virtual ~DynamicNearestNeighbours () {}
00166 };
00167
00168
00169 FASTJET_END_NAMESPACE
00170
00171 #endif // __FASTJET_DYNAMICNEARESTNEIGHBOURS_HH__