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
00050 class Dnn2piCylinder : public DynamicNearestNeighbours {
00051 public:
00053 Dnn2piCylinder() {}
00054
00071 Dnn2piCylinder(const std::vector<EtaPhi> &,
00072 const bool & ignore_nearest_is_mirror = false,
00073 const bool & verbose = false );
00074
00077 int NearestNeighbourIndex(const int & ii) const ;
00078
00081 double NearestNeighbourDistance(const int & ii) const ;
00082
00086 bool Valid(const int & index) const;
00087
00088 void RemoveAndAddPoints(const std::vector<int> & indices_to_remove,
00089 const std::vector<EtaPhi> & points_to_add,
00090 std::vector<int> & indices_added,
00091 std::vector<int> & indices_of_updated_neighbours);
00092
00093 ~Dnn2piCylinder();
00094
00095 private:
00096
00097
00098 const static int INEXISTENT_VERTEX=-3;
00099
00100 bool _verbose;
00101
00102 bool _ignore_nearest_is_mirror;
00103
00140
00142 struct MirrorVertexInfo {
00147 int main_index;
00150 int mirror_index;
00151 };
00152
00153
00154
00155 std::vector<MirrorVertexInfo> _mirror_info;
00156
00157
00158
00159 std::vector<int> _cylinder_index_of_plane_vertex;
00160
00161
00162
00163
00164
00165 DnnPlane * _DNN;
00166
00170 inline EtaPhi _remap_phi(const EtaPhi & point) {
00171 double phi = point.second;
00172 if (phi < pi) { phi += twopi ;} else {phi -= twopi;}
00173 return EtaPhi(point.first, phi);}
00174
00175
00176
00183 void _RegisterCylinderPoint (const EtaPhi & cylinder_point,
00184 std::vector<EtaPhi> & plane_points);
00185
00201 void _CreateNecessaryMirrorPoints(
00202 const std::vector<int> & plane_indices,
00203 std::vector<int> & updated_plane_points);
00204
00205 };
00206
00207
00208
00209
00210
00211
00220 inline int Dnn2piCylinder::NearestNeighbourIndex(const int & current) const {
00221 int main_index = _mirror_info[current].main_index;
00222 int mirror_index = _mirror_info[current].mirror_index;
00223 int plane_index;
00224 if (mirror_index == INEXISTENT_VERTEX ) {
00225 plane_index = _DNN->NearestNeighbourIndex(main_index);
00226 } else {
00227 plane_index = (
00228 _DNN->NearestNeighbourDistance(main_index) <
00229 _DNN->NearestNeighbourDistance(mirror_index)) ?
00230 _DNN->NearestNeighbourIndex(main_index) :
00231 _DNN->NearestNeighbourIndex(mirror_index) ;
00232 }
00233 int this_cylinder_index = _cylinder_index_of_plane_vertex[plane_index];
00234
00235
00236
00237 assert(_ignore_nearest_is_mirror || this_cylinder_index != current);
00238
00239
00240
00241
00242 return this_cylinder_index;
00243 }
00244
00245 inline double Dnn2piCylinder::NearestNeighbourDistance(const int & current) const {
00246 int main_index = _mirror_info[current].main_index;
00247 int mirror_index = _mirror_info[current].mirror_index;
00248 if (mirror_index == INEXISTENT_VERTEX ) {
00249 return _DNN->NearestNeighbourDistance(main_index);
00250 } else {
00251 return (
00252 _DNN->NearestNeighbourDistance(main_index) <
00253 _DNN->NearestNeighbourDistance(mirror_index)) ?
00254 _DNN->NearestNeighbourDistance(main_index) :
00255 _DNN->NearestNeighbourDistance(mirror_index) ;
00256 }
00257
00258 }
00259
00260 inline bool Dnn2piCylinder::Valid(const int & index) const {
00261 return (_DNN->Valid(_mirror_info[index].main_index));
00262 }
00263
00264
00265 inline Dnn2piCylinder::~Dnn2piCylinder() {
00266 delete _DNN;
00267 }
00268
00269
00270 FASTJET_END_NAMESPACE
00271
00272 #endif // __FASTJET_DNN2PICYLINDER_HH__
00273 #endif //DROP_CGAL