30 #ifndef DROP_CGAL // in case we do not have the code for CGAL 32 #include "fastjet/internal/Dnn2piCylinder.hh" 35 FASTJET_BEGIN_NAMESPACE
39 Dnn2piCylinder::Dnn2piCylinder(
40 const vector<EtaPhi> & input_points,
41 const bool & ignore_nearest_is_mirror,
42 const bool & verbose) {
45 _ignore_nearest_is_mirror = ignore_nearest_is_mirror;
46 vector<EtaPhi> plane_points;
47 vector<int> plane_point_indices(input_points.size());
50 for (
unsigned int i=0; i < input_points.size(); i++) {
51 _RegisterCylinderPoint(input_points[i], plane_points);
52 plane_point_indices[i] = i;
55 if (_verbose) cout <<
"============== Preparing _DNN" << endl;
56 _DNN =
new DnnPlane(plane_points, verbose);
59 vector<int> updated_point_indices;
60 _CreateNecessaryMirrorPoints(plane_point_indices,updated_point_indices);
71 void Dnn2piCylinder::_RegisterCylinderPoint (
const EtaPhi & cylinder_point,
72 vector<EtaPhi> & plane_points) {
73 double phi = cylinder_point.second;
74 assert(phi >= 0.0 && phi < 2*pi);
78 mvi.main_index = _cylinder_index_of_plane_vertex.size();
79 _cylinder_index_of_plane_vertex.push_back(_mirror_info.size());
80 plane_points.push_back(cylinder_point);
81 mvi.mirror_index = INEXISTENT_VERTEX;
84 _mirror_info.push_back(mvi);
105 void Dnn2piCylinder::_CreateNecessaryMirrorPoints(
106 const vector<int> & plane_indices,
107 vector<int> & updated_plane_points) {
109 vector<EtaPhi> new_plane_points;
111 for (
size_t i = 0; i < plane_indices.size(); i++) {
113 int ip = plane_indices[i];
114 EtaPhi position = _DNN->etaphi(ip);
115 double phi = position.second;
121 int ic = _cylinder_index_of_plane_vertex[ip];
122 if (_mirror_info[ic].mirror_index != INEXISTENT_VERTEX) {
continue;}
133 double nndist = _DNN->NearestNeighbourDistance(ip);
134 if (phi*phi >= nndist && (twopi-phi)*(twopi-phi) >= nndist) {
continue;}
137 new_plane_points.push_back(_remap_phi(position));
138 _mirror_info[ic].mirror_index = _cylinder_index_of_plane_vertex.size();
139 _cylinder_index_of_plane_vertex.push_back(ic);
142 vector<int> indices_to_remove;
143 vector<int> indices_added;
144 _DNN->RemoveAndAddPoints(indices_to_remove,new_plane_points,indices_added,
145 updated_plane_points);
181 void Dnn2piCylinder::RemoveAndAddPoints(
const vector<int> & indices_to_remove,
182 const vector<EtaPhi> & points_to_add,
183 vector<int> & indices_added,
184 vector<int> & indices_of_updated_neighbours) {
189 vector<int> plane_indices_to_remove;
190 for (
unsigned int i=0; i < indices_to_remove.size(); i++) {
191 MirrorVertexInfo * mvi;
192 mvi = & _mirror_info[indices_to_remove[i]];
193 plane_indices_to_remove.push_back(mvi->main_index);
194 if (mvi->mirror_index != INEXISTENT_VERTEX) {
195 plane_indices_to_remove.push_back(mvi->mirror_index);
201 vector<EtaPhi> plane_points_to_add;
202 indices_added.clear();
203 for (
unsigned int i=0; i < points_to_add.size(); i++) {
204 indices_added.push_back(_mirror_info.size());
205 _RegisterCylinderPoint(points_to_add[i], plane_points_to_add);
212 vector<int> updated_plane_neighbours, plane_indices_added;
213 _DNN->RemoveAndAddPoints(plane_indices_to_remove, plane_points_to_add,
214 plane_indices_added, updated_plane_neighbours);
216 vector<int> extra_updated_plane_neighbours;
217 _CreateNecessaryMirrorPoints(updated_plane_neighbours,
218 extra_updated_plane_neighbours);
225 for (i=0; i < updated_plane_neighbours.size(); i++) {
227 _cylinder_index_of_plane_vertex[updated_plane_neighbours[i]]);}
228 for (i=0; i < extra_updated_plane_neighbours.size(); i++) {
230 _cylinder_index_of_plane_vertex[extra_updated_plane_neighbours[i]]);}
233 indices_of_updated_neighbours.clear();
234 for (set<int>::iterator iter = index_set.begin();
235 iter != index_set.end(); iter++) {
236 indices_of_updated_neighbours.push_back(*iter);
240 FASTJET_END_NAMESPACE