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 DROP_CGAL // in case we do not have the code for CGAL
00033 #ifndef __FASTJET_DNN2PICYLINDER_HH__
00034 #define __FASTJET_DNN2PICYLINDER_HH__
00035
00036 #include "fastjet/internal/DynamicNearestNeighbours.hh"
00037 #include "fastjet/internal/DnnPlane.hh"
00038 #include "fastjet/internal/numconsts.hh"
00039
00040 FASTJET_BEGIN_NAMESPACE
00041
00042
00046 class Dnn2piCylinder : public DynamicNearestNeighbours {
00047 public:
00049 Dnn2piCylinder() {}
00050
00065 Dnn2piCylinder(const std::vector<EtaPhi> &,
00066 const bool & ignore_nearest_is_mirror = false,
00067 const bool & verbose = false );
00068
00071 int NearestNeighbourIndex(const int & ii) const ;
00072
00075 double NearestNeighbourDistance(const int & ii) const ;
00076
00080 bool Valid(const int & index) const;
00081
00082 void RemoveAndAddPoints(const std::vector<int> & indices_to_remove,
00083 const std::vector<EtaPhi> & points_to_add,
00084 std::vector<int> & indices_added,
00085 std::vector<int> & indices_of_updated_neighbours);
00086
00087 ~Dnn2piCylinder();
00088
00089 private:
00090
00091
00092 const static int INEXISTENT_VERTEX=-3;
00093
00094 bool _verbose;
00095
00096 bool _ignore_nearest_is_mirror;
00097
00134
00136 struct MirrorVertexInfo {
00141 int main_index;
00144 int mirror_index;
00145 };
00146
00147
00148
00149 std::vector<MirrorVertexInfo> _mirror_info;
00150
00151
00152
00153 std::vector<int> _cylinder_index_of_plane_vertex;
00154
00155
00156
00157
00158
00159 DnnPlane * _DNN;
00160
00164 inline EtaPhi _remap_phi(const EtaPhi & point) {
00165 double phi = point.second;
00166 if (phi < pi) { phi += twopi ;} else {phi -= twopi;}
00167 return EtaPhi(point.first, phi);}
00168
00169
00170
00177 void _RegisterCylinderPoint (const EtaPhi & cylinder_point,
00178 std::vector<EtaPhi> & plane_points);
00179
00195 void _CreateNecessaryMirrorPoints(
00196 const std::vector<int> & plane_indices,
00197 std::vector<int> & updated_plane_points);
00198
00199 };
00200
00201
00202
00203
00204
00205
00214 inline int Dnn2piCylinder::NearestNeighbourIndex(const int & current) const {
00215 int main_index = _mirror_info[current].main_index;
00216 int mirror_index = _mirror_info[current].mirror_index;
00217 int plane_index;
00218 if (mirror_index == INEXISTENT_VERTEX ) {
00219 plane_index = _DNN->NearestNeighbourIndex(main_index);
00220 } else {
00221 plane_index = (
00222 _DNN->NearestNeighbourDistance(main_index) <
00223 _DNN->NearestNeighbourDistance(mirror_index)) ?
00224 _DNN->NearestNeighbourIndex(main_index) :
00225 _DNN->NearestNeighbourIndex(mirror_index) ;
00226 }
00227 int this_cylinder_index = _cylinder_index_of_plane_vertex[plane_index];
00228
00229
00230
00231 assert(_ignore_nearest_is_mirror || this_cylinder_index != current);
00232
00233
00234
00235
00236 return this_cylinder_index;
00237 }
00238
00239 inline double Dnn2piCylinder::NearestNeighbourDistance(const int & current) const {
00240 int main_index = _mirror_info[current].main_index;
00241 int mirror_index = _mirror_info[current].mirror_index;
00242 if (mirror_index == INEXISTENT_VERTEX ) {
00243 return _DNN->NearestNeighbourDistance(main_index);
00244 } else {
00245 return (
00246 _DNN->NearestNeighbourDistance(main_index) <
00247 _DNN->NearestNeighbourDistance(mirror_index)) ?
00248 _DNN->NearestNeighbourDistance(main_index) :
00249 _DNN->NearestNeighbourDistance(mirror_index) ;
00250 }
00251
00252 }
00253
00254 inline bool Dnn2piCylinder::Valid(const int & index) const {
00255 return (_DNN->Valid(_mirror_info[index].main_index));
00256 }
00257
00258
00259 inline Dnn2piCylinder::~Dnn2piCylinder() {
00260 delete _DNN;
00261 }
00262
00263
00264 FASTJET_END_NAMESPACE
00265
00266 #endif // __FASTJET_DNN2PICYLINDER_HH__
00267 #endif //DROP_CGAL