32 #ifndef DROP_CGAL // in case we do not have the code for CGAL
34 #include "fastjet/internal/Dnn2piCylinder.hh"
37 FASTJET_BEGIN_NAMESPACE
41 Dnn2piCylinder::Dnn2piCylinder(
42 const vector<EtaPhi> & input_points,
43 const bool & ignore_nearest_is_mirror,
44 const bool & verbose) {
47 _ignore_nearest_is_mirror = ignore_nearest_is_mirror;
48 vector<EtaPhi> plane_points;
49 vector<int> plane_point_indices(input_points.size());
52 for (
unsigned int i=0; i < input_points.size(); i++) {
53 _RegisterCylinderPoint(input_points[i], plane_points);
54 plane_point_indices[i] = i;
57 if (_verbose) cout <<
"============== Preparing _DNN" << endl;
58 _DNN =
new DnnPlane(plane_points, verbose);
61 vector<int> updated_point_indices;
62 _CreateNecessaryMirrorPoints(plane_point_indices,updated_point_indices);
73 void Dnn2piCylinder::_RegisterCylinderPoint (
const EtaPhi & cylinder_point,
74 vector<EtaPhi> & plane_points) {
75 double phi = cylinder_point.second;
76 assert(phi >= 0.0 && phi < 2*pi);
80 mvi.main_index = _cylinder_index_of_plane_vertex.size();
81 _cylinder_index_of_plane_vertex.push_back(_mirror_info.size());
82 plane_points.push_back(cylinder_point);
83 mvi.mirror_index = INEXISTENT_VERTEX;
86 _mirror_info.push_back(mvi);
107 void Dnn2piCylinder::_CreateNecessaryMirrorPoints(
108 const vector<int> & plane_indices,
109 vector<int> & updated_plane_points) {
111 vector<EtaPhi> new_plane_points;
113 for (
size_t i = 0; i < plane_indices.size(); i++) {
115 int ip = plane_indices[i];
116 EtaPhi position = _DNN->etaphi(ip);
117 double phi = position.second;
123 int ic = _cylinder_index_of_plane_vertex[ip];
124 if (_mirror_info[ic].mirror_index != INEXISTENT_VERTEX) {
continue;}
135 double nndist = _DNN->NearestNeighbourDistance(ip);
136 if (phi*phi >= nndist && (twopi-phi)*(twopi-phi) >= nndist) {
continue;}
139 new_plane_points.push_back(_remap_phi(position));
140 _mirror_info[ic].mirror_index = _cylinder_index_of_plane_vertex.size();
141 _cylinder_index_of_plane_vertex.push_back(ic);
144 vector<int> indices_to_remove;
145 vector<int> indices_added;
146 _DNN->RemoveAndAddPoints(indices_to_remove,new_plane_points,indices_added,
147 updated_plane_points);
183 void Dnn2piCylinder::RemoveAndAddPoints(
const vector<int> & indices_to_remove,
184 const vector<EtaPhi> & points_to_add,
185 vector<int> & indices_added,
186 vector<int> & indices_of_updated_neighbours) {
191 vector<int> plane_indices_to_remove;
192 for (
unsigned int i=0; i < indices_to_remove.size(); i++) {
193 MirrorVertexInfo * mvi;
194 mvi = & _mirror_info[indices_to_remove[i]];
195 plane_indices_to_remove.push_back(mvi->main_index);
196 if (mvi->mirror_index != INEXISTENT_VERTEX) {
197 plane_indices_to_remove.push_back(mvi->mirror_index);
203 vector<EtaPhi> plane_points_to_add;
204 indices_added.clear();
205 for (
unsigned int i=0; i < points_to_add.size(); i++) {
206 indices_added.push_back(_mirror_info.size());
207 _RegisterCylinderPoint(points_to_add[i], plane_points_to_add);
214 vector<int> updated_plane_neighbours, plane_indices_added;
215 _DNN->RemoveAndAddPoints(plane_indices_to_remove, plane_points_to_add,
216 plane_indices_added, updated_plane_neighbours);
218 vector<int> extra_updated_plane_neighbours;
219 _CreateNecessaryMirrorPoints(updated_plane_neighbours,
220 extra_updated_plane_neighbours);
227 for (i=0; i < updated_plane_neighbours.size(); i++) {
229 _cylinder_index_of_plane_vertex[updated_plane_neighbours[i]]);}
230 for (i=0; i < extra_updated_plane_neighbours.size(); i++) {
232 _cylinder_index_of_plane_vertex[extra_updated_plane_neighbours[i]]);}
235 indices_of_updated_neighbours.clear();
236 for (set<int>::iterator iter = index_set.begin();
237 iter != index_set.end(); iter++) {
238 indices_of_updated_neighbours.push_back(*iter);
242 FASTJET_END_NAMESPACE