fastjet 2.4.5
Dnn3piCylinder.cc
Go to the documentation of this file.
00001 //STARTHEADER
00002 // $Id: Dnn3piCylinder.cc 431 2007-01-20 10:44:55Z salam $
00003 //
00004 // Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam
00005 //
00006 //----------------------------------------------------------------------
00007 // This file is part of FastJet.
00008 //
00009 //  FastJet is free software; you can redistribute it and/or modify
00010 //  it under the terms of the GNU General Public License as published by
00011 //  the Free Software Foundation; either version 2 of the License, or
00012 //  (at your option) any later version.
00013 //
00014 //  The algorithms that underlie FastJet have required considerable
00015 //  development and are described in hep-ph/0512210. If you use
00016 //  FastJet as part of work towards a scientific publication, please
00017 //  include a citation to the FastJet paper.
00018 //
00019 //  FastJet is distributed in the hope that it will be useful,
00020 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022 //  GNU General Public License for more details.
00023 //
00024 //  You should have received a copy of the GNU General Public License
00025 //  along with FastJet; if not, write to the Free Software
00026 //  Foundation, Inc.:
00027 //      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 //----------------------------------------------------------------------
00029 //ENDHEADER
00030 
00031 
00032 #ifndef DROP_CGAL // in case we do not have the code for CGAL
00033 #include <set>
00034 #include "fastjet/internal/Dnn3piCylinder.hh"
00035 using namespace std;
00036 
00037 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00038 
00039 //----------------------------------------------------------------------
00041 Dnn3piCylinder::Dnn3piCylinder(
00042         const vector<EtaPhi> & input_points, 
00043         const bool & ignore_nearest_is_mirror,
00044         const bool & verbose) {
00045   
00046   _verbose = verbose;
00047   _ignore_nearest_is_mirror = ignore_nearest_is_mirror;
00048   vector<EtaPhi> plane_points;
00049   //plane_points.reserve(2*input_points.size());
00050 
00051   for (unsigned int i=0; i < input_points.size(); i++) {
00052     _RegisterCylinderPoint(input_points[i], plane_points);
00053   }
00054 
00055   if (_verbose) cout << "============== Preparing _DNN" << endl;
00056   _DNN = new DnnPlane(plane_points, verbose);
00057 }
00058 
00059 
00060 //----------------------------------------------------------------------
00079 void Dnn3piCylinder::_RegisterCylinderPoint (const EtaPhi & cylinder_point,
00080                                              vector<EtaPhi> & plane_points) {
00081   double phi = cylinder_point.second;
00082   assert(phi >= 0.0 && phi < 2*pi);
00083   
00084   // do main point
00085   MirrorVertexInfo mvi;
00086   mvi.main_index = _cylinder_index_of_plane_vertex.size();
00087   _cylinder_index_of_plane_vertex.push_back(_mirror_info.size());
00088   plane_points.push_back(cylinder_point);
00089   
00090   // do mirror point if need be
00091   if (phi < pi) {
00092     mvi.mirror_index = _cylinder_index_of_plane_vertex.size();
00093     _cylinder_index_of_plane_vertex.push_back(_mirror_info.size());
00094     plane_points.push_back(_remap_phi(cylinder_point));
00095   } else {
00096     mvi.mirror_index = INEXISTENT_VERTEX;
00097   }
00098   
00099   // 
00100   _mirror_info.push_back(mvi);
00101 }
00102 
00103 
00104 //----------------------------------------------------------------------
00106 void Dnn3piCylinder::RemoveAndAddPoints(const vector<int> & indices_to_remove,
00107                                 const vector<EtaPhi> & points_to_add,
00108                                 vector<int> & indices_added,
00109                                 vector<int> & indices_of_updated_neighbours) {
00110 
00111   // translate from "cylinder" indices of points to remove to the
00112   // plane indices of points to remove, bearing in mind that sometimes
00113   // there are multple plane points to remove.
00114   vector<int> plane_indices_to_remove;
00115   for (unsigned int i=0; i < indices_to_remove.size(); i++) {
00116     MirrorVertexInfo * mvi;
00117     mvi = & _mirror_info[indices_to_remove[i]];
00118     plane_indices_to_remove.push_back(mvi->main_index);
00119     if (mvi->mirror_index != INEXISTENT_VERTEX) {
00120       plane_indices_to_remove.push_back(mvi->mirror_index);
00121     }
00122   }
00123 
00124   // given "cylinder" points to add get hold of the list of
00125   // plane-points to add.
00126   vector<EtaPhi> plane_points_to_add;
00127   indices_added.clear();
00128   for (unsigned int i=0; i < points_to_add.size(); i++) {
00129     indices_added.push_back(_mirror_info.size());
00130     _RegisterCylinderPoint(points_to_add[i], plane_points_to_add);
00131   }
00132 
00133   // now get the hard work done (note that we need to supply the
00134   // plane_indices_added vector but that we will not actually check
00135   // its contents in any way -- the indices_added that is actually
00136   // returned has been calculated above).
00137   vector<int> updated_plane_neighbours, plane_indices_added;
00138   _DNN->RemoveAndAddPoints(plane_indices_to_remove, plane_points_to_add,
00139                              plane_indices_added, updated_plane_neighbours);
00140 
00141   // extract, from the updated_plane_neighbours, the set of cylinder
00142   // neighbours that have changed
00143   set<int> index_set;
00144   unsigned int i;
00145   for (i=0; i < updated_plane_neighbours.size(); i++) {
00146     index_set.insert(
00147        _cylinder_index_of_plane_vertex[updated_plane_neighbours[i]]);}
00148 
00149   // decant the set into the vector that needs to be returned
00150   indices_of_updated_neighbours.clear();
00151   for (set<int>::iterator iter = index_set.begin(); 
00152        iter != index_set.end(); iter++) {
00153     indices_of_updated_neighbours.push_back(*iter);
00154   }
00155 }
00156 
00157 
00158 FASTJET_END_NAMESPACE
00159 
00160 #endif //  DROP_CGAL 
00161 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines